chainsyncer

Blockchain syncer driver
Log | Files | Refs | LICENSE

commit 43249a9ec0468ae7acc0ed28965d08dda341ad82
parent 41e00449f88eb56fd55b30db25b61b7ac0e8f095
Author: lash <dev@holbrook.no>
Date:   Sat, 19 Mar 2022 01:04:43 +0000

Move serialize code block

Diffstat:
Mchainsyncer/store/fs.py | 27++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/chainsyncer/store/fs.py b/chainsyncer/store/fs.py @@ -20,6 +20,20 @@ from chainsyncer.error import ( logg = logging.getLogger(__name__) +def sync_state_serialize(block_height, tx_index, block_target): + b = block_height.to_bytes(4, 'big') + b += tx_index.to_bytes(4, 'big') + b += block_target.to_bytes(4, 'big', signed=True) + return b + + +def sync_state_deserialize(b): + block_height = int.from_bytes(b[:4], 'big') + tx_index = int.from_bytes(b[4:8], 'big') + block_target = int.from_bytes(b[8:], 'big', signed=True) + return (block_height, tx_index, block_target,) + + # NOT thread safe class SyncFsItem: @@ -293,16 +307,3 @@ class SyncFsStore: def disconnect(self): self.filter_state.disconnect() - -def sync_state_serialize(block_height, tx_index, block_target): - b = block_height.to_bytes(4, 'big') - b += tx_index.to_bytes(4, 'big') - b += block_target.to_bytes(4, 'big', signed=True) - return b - - -def sync_state_deserialize(b): - block_height = int.from_bytes(b[:4], 'big') - tx_index = int.from_bytes(b[4:8], 'big') - block_target = int.from_bytes(b[8:], 'big', signed=True) - return (block_height, tx_index, block_target,)