Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to start from specific blkfile to get_unordered_blocks() #66

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions blockchain_parser/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,21 @@ def get_unordered_blocks(self):
for raw_block in get_blocks(blk_file):
yield Block(raw_block)

def get_unordered_blocks_from(self, blk_file_idx=0, unordered_block_position=0):
"""Yields a tuple containing the blk files index, blocks postion in the file,
and the block from the .blk file as is, without ordering them according to height.
"""
for index, blk_file in enumerate(get_files(self.path)):
if index < blk_file_idx:
continue
else:
for block_position, raw_block in enumerate(get_blocks(blk_file)):
if block_position < unordered_block_position:
continue
else:
yield index, block_position, Block(raw_block)
unordered_block_position = 0

def __getBlockIndexes(self, index):
"""There is no method of leveldb to close the db (and release the lock).
This creates problem during concurrent operations.
Expand Down