# HG changeset patch # User Dennis Concepcion Martin # Date 1636907718 -3600 # Node ID 32061555853ceee19d9eb8b82cff0eca50ae183b # Parent 650b11261b2c6bb8f98ab2da4e57cd83f2154996 refactor code diff -r 650b11261b2c -r 32061555853c Dockerfile --- a/Dockerfile Wed Nov 10 11:48:26 2021 +0100 +++ b/Dockerfile Sun Nov 14 17:35:18 2021 +0100 @@ -10,7 +10,7 @@ # Copy files COPY src/bitcaviar_plus bitcaviar_plus/ -COPY tests/test_app.py . +COPY tests/implementation_testing.py . # Run script -CMD ["python3", "-u", "test_app.py"] \ No newline at end of file +CMD ["python3", "-u", "implementation_testing.py"] \ No newline at end of file diff -r 650b11261b2c -r 32061555853c src/bitcaviar_plus/block.py --- a/src/bitcaviar_plus/block.py Wed Nov 10 11:48:26 2021 +0100 +++ b/src/bitcaviar_plus/block.py Sun Nov 14 17:35:18 2021 +0100 @@ -1,12 +1,13 @@ + +""" +Deserialize methods for blocks +""" + from bitcaviar_plus.block_structure import * from bitcaviar_plus.helpers import __get_var_int from bitcaviar_plus.helpers import __compute_hash from bitcaviar_plus.errors import InvalidMagicBytes -""" -Deserialize methods -""" - def deserialize_block(f): """ diff -r 650b11261b2c -r 32061555853c src/bitcaviar_plus/search.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/bitcaviar_plus/search.py Sun Nov 14 17:35:18 2021 +0100 @@ -0,0 +1,4 @@ + +""" +Search methods for LEVELDB database +""" \ No newline at end of file diff -r 650b11261b2c -r 32061555853c tests/implementation_testing.py --- /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() diff -r 650b11261b2c -r 32061555853c tests/test_app.py --- a/tests/test_app.py Wed Nov 10 11:48:26 2021 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -import os -from bitcaviar_plus.block import deserialize_block -from bitcaviar_plus.errors import InvalidMagicBytes - - -def parse_genesis_block(): - blk_path = '/bitcoin-node/.bitcoin/blocks/blk00355.dat' - - 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()