Mercurial > public > bitcaviar-plus
diff tests/implementation_testing.py @ 23:32061555853c
refactor code
author | Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com> |
---|---|
date | Sun, 14 Nov 2021 17:35:18 +0100 |
parents | tests/test_app.py@905b6fdc5e1b |
children | 139c77ea99b7 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/implementation_testing.py Sun Nov 14 17:35:18 2021 +0100 @@ -0,0 +1,22 @@ +import os +from bitcaviar_plus.block import deserialize_block +from bitcaviar_plus.errors import InvalidMagicBytes +import plyvel + + +# noinspection PyUnresolvedReferences +def parse_genesis_block(): + blk_path = '/bitcoin-node/.bitcoin/blocks/blk00355.dat' + db = plyvel.DB('/bitcoin-node/.bitcoin/blocks/index/', create_if_missing=False) + + with open(blk_path, 'rb') as f: + file_size = os.path.getsize(blk_path) + while f.tell() < file_size: + try: + block = deserialize_block(f) + except InvalidMagicBytes as e: + print(e) + + +if __name__ == '__main__': + parse_genesis_block()