From 515f270c3aaaaf3eec4555ca430976c6fae11ed4 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Sun, 6 Jun 2021 13:01:06 -0400 Subject: [PATCH] faster get_future_activated --- lbry/wallet/server/leveldb.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lbry/wallet/server/leveldb.py b/lbry/wallet/server/leveldb.py index 9c9c7b910..b844e78dc 100644 --- a/lbry/wallet/server/leveldb.py +++ b/lbry/wallet/server/leveldb.py @@ -436,12 +436,13 @@ class LevelDB: def get_future_activated(self, height: int) -> DefaultDict[PendingActivationValue, List[PendingActivationKey]]: activated = defaultdict(list) - for i in range(self.coin.maxTakeoverDelay): - prefix = Prefixes.pending_activation.pack_partial_key(height+1+i) - for _k, _v in self.db.iterator(prefix=prefix): - k = Prefixes.pending_activation.unpack_key(_k) - v = Prefixes.pending_activation.unpack_value(_v) - activated[v].append(k) + start_prefix = Prefixes.pending_activation.pack_partial_key(height + 1) + stop_prefix = Prefixes.pending_activation.pack_partial_key(height + 1 + self.coin.maxTakeoverDelay) + for _k, _v in self.db.iterator(start=start_prefix, stop=stop_prefix): + k = Prefixes.pending_activation.unpack_key(_k) + v = Prefixes.pending_activation.unpack_value(_v) + activated[v].append(k) + return activated async def _read_tx_counts(self):