Skip to content
Merged
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
5 changes: 4 additions & 1 deletion blockchain_parser/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from .block import Block
from .index import DBBlockIndex
from .utils import format_hash
from .block_header import BlockHeader


# Constant separating blocks in the .blk files
Expand Down Expand Up @@ -243,13 +244,15 @@ def get_transaction(self, txid, db):
offset = tx_idx.block_offset

transaction_data = raw_hex[80:]
block_header_data = raw_hex[:80]
# Try from 1024 (1KiB) -> 1073741824 (1GiB) slice widths
for j in range(0, 20):
try:
block_header = BlockHeader.from_hex(block_header_data)
offset_e = offset + (1024 * 2 ** j)
transaction = Transaction.from_hex(
transaction_data[offset:offset_e])
return transaction
return [block_header, transaction]
except Exception:
continue

Expand Down