Ejemplo n.º 1
0
def test_poschain_digest(benchmark):
    global NB
    loop = asyncio.new_event_loop()
    try:
        asyncio.set_event_loop(loop)
        logger = logging.getLogger('foo')
        test_helpers.remove_pc()
        poscrypto.load_keys('./bench_wallet.json')
        test_poschain = poschain.SqlitePosChain(app_log=logger, db_path='./')
        test_poschain.check()
        n = 100
        # Generate random tx for the block
        txs = test_helpers.create_txs(n, sign=True, block_height=1)
        block = posblock.PosBlock()
        block.height = 1
        block.round = 1
        block.sir = 1
        block.txs = txs
        # temp = block.to_dict(as_hex=True)
        # logger.warning(json.dumps(temp))
        if benchmark:
            benchmark(sync_digest_txs, loop, test_poschain, block)
        else:
            start = time.time()
            sync_digest_txs(loop, test_poschain, block)
            print("{} txs digested in {} sec".format(n, time.time() - start))
            sync_poschain_count(loop, test_poschain)

        test_helpers.remove_pc()
        NB += 1
    finally:
        loop.close()
Ejemplo n.º 2
0
                        default=False,
                        help='Be verbose.')
    args = parser.parse_args()
    distinct = True
    verbose = True if args.verbose else False
    config.load('../main/')
    config.COMPUTING_REWARD = True

    datadir = '../main/data/'
    app_log = logging.getLogger('foo')  # FakeLog()

    print("Rewards from round {} to {}, Rewards (estimate only)={}".format(
        START_ROUND, END_ROUND, REWARDS))

    poschain = poschain.SqlitePosChain(verbose=verbose,
                                       app_log=app_log,
                                       db_path=datadir,
                                       mempool=None)
    hn_db = hn_db.SqliteHNDB(verbose=verbose, app_log=app_log, db_path=datadir)

    loop = asyncio.get_event_loop()

    # height = loop.run_until_complete(poschain.async_height())

    all_hns = {}
    all_round = {}

    loop.run_until_complete(
        hn_db.async_execute("DELETE FROM reward_stats WHERE 1", commit=True))
    loop.run_until_complete(hn_db.async_execute("VACUUM", commit=True))

    for round in range(START_ROUND, END_ROUND + 1):