Beispiel #1
0
def get_chainmanager(genesis=None):
    cm = chainmanager.ChainManager()
    cm.configure(config=create_default_config(), genesis=genesis)
    return cm
Beispiel #2
0
    data can be created with blockfetcherpatch.py
    """
    import sys

    raw_blocks_fn = sys.argv[1]
    test_db_path = sys.argv[2]
    skip = int(sys.argv[3])
    if len(sys.argv) == 4 or sys.argv[4] != 'silent':
        logging.basicConfig(level=logging.DEBUG)
        global logger
        logger = logging.getLogger()

    print utils
    utils.data_dir.set(test_db_path)

    chain_manager = chainmanager.ChainManager()
    chain_manager.configure(config=eth.create_default_config(), genesis=None)

    fh = open(raw_blocks_fn)
    for i in range(skip):
        fh.readline()

    for hex_rlp_encoded_data in fh:
        hexdata = hex_rlp_encoded_data.strip().decode('hex')
        data = rlp.decode(hexdata)
        # print repr(data)
        blk = blocks.TransientBlock(hexdata)
        print blk.number, blk.hash.encode('hex')
        chain_manager.receive_chain([blk])
        assert blk.hash in chain_manager
Beispiel #3
0
def get_chainmanager(genesis=None):
    cm = chainmanager.ChainManager()
    cm.configure(config=create_default_config(), genesis=genesis)
    return cm
    data can be created with blockfetcherpatch.py
    """
    import sys

    raw_blocks_fn = sys.argv[1]
    test_db_path = sys.argv[2]
    skip = int(sys.argv[3])
    if len(sys.argv) == 4 or sys.argv[4] != "silent":
        logging.basicConfig(level=logging.DEBUG)
        global logger
        logger = logging.getLogger()

    print utils
    utils.data_dir.set(test_db_path)

    chain_manager = chainmanager.ChainManager()
    chain_manager.configure(config=eth.create_default_config(), genesis=None)

    fh = open(raw_blocks_fn)
    for i in range(skip):
        fh.readline()

    for hex_rlp_encoded_data in fh:
        hexdata = hex_rlp_encoded_data.strip().decode("hex")
        data = rlp.decode(hexdata)
        # print repr(data)
        blk = blocks.TransientBlock(hexdata)
        print blk.number, blk.hash.encode("hex")
        chain_manager.receive_chain([blk])
        assert blk.hash in chain_manager