Mercurial > public > bitcaviar-plus
comparison 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 |
comparison
equal
deleted
inserted
replaced
22:650b11261b2c | 23:32061555853c |
---|---|
1 import os | |
2 from bitcaviar_plus.block import deserialize_block | |
3 from bitcaviar_plus.errors import InvalidMagicBytes | |
4 import plyvel | |
5 | |
6 | |
7 # noinspection PyUnresolvedReferences | |
8 def parse_genesis_block(): | |
9 blk_path = '/bitcoin-node/.bitcoin/blocks/blk00355.dat' | |
10 db = plyvel.DB('/bitcoin-node/.bitcoin/blocks/index/', create_if_missing=False) | |
11 | |
12 with open(blk_path, 'rb') as f: | |
13 file_size = os.path.getsize(blk_path) | |
14 while f.tell() < file_size: | |
15 try: | |
16 block = deserialize_block(f) | |
17 except InvalidMagicBytes as e: | |
18 print(e) | |
19 | |
20 | |
21 if __name__ == '__main__': | |
22 parse_genesis_block() |