Skip to content

Commit d763ca6

Browse files
authored
Merge pull request #90 from cirosantilli/master
Add the blk*.data file path basename to Block.blk_file
2 parents e3a9750 + b1ca91e commit d763ca6

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

blockchain_parser/block.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,15 @@ class Block(object):
4646
Represents a Bitcoin block, contains its header and its transactions.
4747
"""
4848

49-
def __init__(self, raw_hex, height=None):
49+
def __init__(self, raw_hex, height=None, blk_file=None):
5050
self.hex = raw_hex
5151
self._hash = None
5252
self._transactions = None
5353
self._header = None
5454
self._n_transactions = None
5555
self.size = len(raw_hex)
5656
self.height = height
57+
self.blk_file = blk_file
5758

5859
def __repr__(self):
5960
return "Block(%s)" % self.hash

blockchain_parser/blockchain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def get_unordered_blocks(self):
9494
"""
9595
for blk_file in get_files(self.path):
9696
for raw_block in get_blocks(blk_file):
97-
yield Block(raw_block)
97+
yield Block(raw_block, None, os.path.split(blk_file)[1])
9898

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

0 commit comments

Comments
 (0)