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,
|
def iterate(self, prefix=None, start=None, stop=None,
|
||||||
reverse: bool = False, include_key: bool = True, include_value: bool = True):
|
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:
|
if prefix is not None:
|
||||||
prefix = self.pack_partial_key(*prefix)
|
prefix = self.pack_partial_key(*prefix)
|
||||||
if start is not None:
|
if start is not None:
|
||||||
|
|
|
@ -851,11 +851,11 @@ class LevelDB:
|
||||||
|
|
||||||
async def _read_claim_txos(self):
|
async def _read_claim_txos(self):
|
||||||
def read_claim_txos():
|
def read_claim_txos():
|
||||||
for _k, _v in self.db.iterator(prefix=Prefixes.claim_to_txo.prefix):
|
set_txo_to_claim = self.txo_to_claim.__setitem__
|
||||||
k = Prefixes.claim_to_txo.unpack_key(_k)
|
set_claim_to_txo = self.claim_to_txo.__setitem__
|
||||||
v = Prefixes.claim_to_txo.unpack_value(_v)
|
for k, v in self.prefix_db.claim_to_txo.iterate():
|
||||||
self.claim_to_txo[k.claim_hash] = v
|
set_claim_to_txo(k.claim_hash, v)
|
||||||
self.txo_to_claim[(v.tx_num, v.position)] = k.claim_hash
|
set_txo_to_claim((v.tx_num, v.position), k.claim_hash)
|
||||||
|
|
||||||
self.claim_to_txo.clear()
|
self.claim_to_txo.clear()
|
||||||
self.txo_to_claim.clear()
|
self.txo_to_claim.clear()
|
||||||
|
|
Loading…
Reference in a new issue