changeset 23:32061555853c

refactor code
author Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com>
date Sun, 14 Nov 2021 17:35:18 +0100
parents 650b11261b2c
children 139c77ea99b7
files Dockerfile src/bitcaviar_plus/block.py src/bitcaviar_plus/search.py tests/implementation_testing.py tests/test_app.py
diffstat 5 files changed, 33 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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):
     """
--- /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
--- /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()
--- 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()