Skip to content

Commit

Permalink
Merge pull request #90 from cirosantilli/master
Browse files Browse the repository at this point in the history
Add the blk*.data file path basename to Block.blk_file
  • Loading branch information
alecalve committed Jan 14, 2021
2 parents e3a9750 + b1ca91e commit d763ca6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion blockchain_parser/block.py
Expand Up @@ -46,14 +46,15 @@ class Block(object):
Represents a Bitcoin block, contains its header and its transactions.
"""

def __init__(self, raw_hex, height=None):
def __init__(self, raw_hex, height=None, blk_file=None):
self.hex = raw_hex
self._hash = None
self._transactions = None
self._header = None
self._n_transactions = None
self.size = len(raw_hex)
self.height = height
self.blk_file = blk_file

def __repr__(self):
return "Block(%s)" % self.hash
Expand Down
2 changes: 1 addition & 1 deletion blockchain_parser/blockchain.py
Expand Up @@ -94,7 +94,7 @@ def get_unordered_blocks(self):
"""
for blk_file in get_files(self.path):
for raw_block in get_blocks(blk_file):
yield Block(raw_block)
yield Block(raw_block, None, os.path.split(blk_file)[1])

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

0 comments on commit d763ca6

Please sign in to comment.