faster get_future_activated
This commit is contained in:
parent
6330424bcd
commit
b0cf25bf5c
1 changed files with 7 additions and 6 deletions
|
@ -436,12 +436,13 @@ class LevelDB:
|
||||||
|
|
||||||
def get_future_activated(self, height: int) -> DefaultDict[PendingActivationValue, List[PendingActivationKey]]:
|
def get_future_activated(self, height: int) -> DefaultDict[PendingActivationValue, List[PendingActivationKey]]:
|
||||||
activated = defaultdict(list)
|
activated = defaultdict(list)
|
||||||
for i in range(self.coin.maxTakeoverDelay):
|
start_prefix = Prefixes.pending_activation.pack_partial_key(height + 1)
|
||||||
prefix = Prefixes.pending_activation.pack_partial_key(height+1+i)
|
stop_prefix = Prefixes.pending_activation.pack_partial_key(height + 1 + self.coin.maxTakeoverDelay)
|
||||||
for _k, _v in self.db.iterator(prefix=prefix):
|
for _k, _v in self.db.iterator(start=start_prefix, stop=stop_prefix):
|
||||||
k = Prefixes.pending_activation.unpack_key(_k)
|
k = Prefixes.pending_activation.unpack_key(_k)
|
||||||
v = Prefixes.pending_activation.unpack_value(_v)
|
v = Prefixes.pending_activation.unpack_value(_v)
|
||||||
activated[v].append(k)
|
activated[v].append(k)
|
||||||
|
|
||||||
return activated
|
return activated
|
||||||
|
|
||||||
async def _read_tx_counts(self):
|
async def _read_tx_counts(self):
|
||||||
|
|
Loading…
Reference in a new issue