fix block_txs iterator stop condition
This commit is contained in:
parent
68a97b0e61
commit
c03b1b5a93
2 changed files with 3 additions and 2 deletions
|
@ -280,6 +280,7 @@ def tx_merkle(tx_num, tx_height):
|
|||
return ctx.merkle_tx_cache[(tx_num, tx_height)]
|
||||
if tx_height not in ctx.block_txs_cache:
|
||||
block_txs = list(db.iterator(
|
||||
prefix=TX_HASH_PREFIX,
|
||||
start=TX_HASH_PREFIX + util.pack_be_uint64(tx_counts[tx_height - 1]),
|
||||
stop=None if tx_height + 1 == len(tx_counts) else
|
||||
TX_HASH_PREFIX + util.pack_be_uint64(tx_counts[tx_height]), include_key=False
|
||||
|
@ -288,6 +289,7 @@ def tx_merkle(tx_num, tx_height):
|
|||
ctx.block_txs_cache[tx_height] = block_txs
|
||||
else:
|
||||
block_txs = ctx.block_txs_cache.get(tx_height, uncached)
|
||||
|
||||
branch, root = ctx.merkle.branch_and_root(block_txs, tx_pos)
|
||||
merkle = {
|
||||
'block_height': tx_height,
|
||||
|
|
|
@ -153,12 +153,11 @@ class RocksDBIterator:
|
|||
]
|
||||
|
||||
def __init__(self, db, prefix=None, start=None, stop=None, include_key=True, include_value=True, reverse=False):
|
||||
assert (start is None and stop is None) or (prefix is None), 'cannot use start/stop and prefix'
|
||||
self.start = start
|
||||
self.prefix = prefix
|
||||
self.stop = stop
|
||||
self.iterator = db.iteritems() if not reverse else reversed(db.iteritems())
|
||||
if prefix is not None:
|
||||
if prefix is not None and start is None:
|
||||
self.iterator.seek(prefix)
|
||||
elif start is not None:
|
||||
self.iterator.seek(start)
|
||||
|
|
Loading…
Add table
Reference in a new issue