Mercurial > public > bitcaviar-plus
comparison tests/test_app.py @ 19:905b6fdc5e1b
handle invalid magic bytes
author | Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com> |
---|---|
date | Wed, 10 Nov 2021 11:37:44 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
18:d1f527020d54 | 19:905b6fdc5e1b |
---|---|
1 import os | |
2 from bitcaviar_plus.block import deserialize_block | |
3 from bitcaviar_plus.errors import InvalidMagicBytes | |
4 | |
5 | |
6 def parse_genesis_block(): | |
7 blk_path = '/bitcoin-node/.bitcoin/blocks/blk00355.dat' | |
8 | |
9 with open(blk_path, 'rb') as f: | |
10 file_size = os.path.getsize(blk_path) | |
11 while f.tell() < file_size: | |
12 try: | |
13 block = deserialize_block(f) | |
14 except InvalidMagicBytes as e: | |
15 print(e) | |
16 | |
17 | |
18 if __name__ == '__main__': | |
19 parse_genesis_block() |