forked from LBRYCommunity/lbry-sdk
faster read_claim_txos
This commit is contained in:
parent
b66adfdf78
commit
de9159d83c
2 changed files with 7 additions and 5 deletions
|
@ -44,6 +44,8 @@ class PrefixRow(metaclass=PrefixRowType):
|
|||
|
||||
def iterate(self, prefix=None, start=None, stop=None,
|
||||
reverse: bool = False, include_key: bool = True, include_value: bool = True):
|
||||
if not prefix and not start and not stop:
|
||||
prefix = ()
|
||||
if prefix is not None:
|
||||
prefix = self.pack_partial_key(*prefix)
|
||||
if start is not None:
|
||||
|
|
|
@ -851,11 +851,11 @@ class LevelDB:
|
|||
|
||||
async def _read_claim_txos(self):
|
||||
def read_claim_txos():
|
||||
for _k, _v in self.db.iterator(prefix=Prefixes.claim_to_txo.prefix):
|
||||
k = Prefixes.claim_to_txo.unpack_key(_k)
|
||||
v = Prefixes.claim_to_txo.unpack_value(_v)
|
||||
self.claim_to_txo[k.claim_hash] = v
|
||||
self.txo_to_claim[(v.tx_num, v.position)] = k.claim_hash
|
||||
set_txo_to_claim = self.txo_to_claim.__setitem__
|
||||
set_claim_to_txo = self.claim_to_txo.__setitem__
|
||||
for k, v in self.prefix_db.claim_to_txo.iterate():
|
||||
set_claim_to_txo(k.claim_hash, v)
|
||||
set_txo_to_claim((v.tx_num, v.position), k.claim_hash)
|
||||
|
||||
self.claim_to_txo.clear()
|
||||
self.txo_to_claim.clear()
|
||||
|
|
Loading…
Reference in a new issue