forked from LBRYCommunity/lbry-sdk
logging
This commit is contained in:
parent
aa1b20cf7b
commit
9aafb7a743
2 changed files with 7 additions and 25 deletions
|
@ -47,8 +47,8 @@ async def get_recent_claims(blocks: int, index_name='claims', db=None):
|
||||||
else:
|
else:
|
||||||
logging.warning("could not sync claim %s", touched.hex())
|
logging.warning("could not sync claim %s", touched.hex())
|
||||||
if cnt % 10000 == 0:
|
if cnt % 10000 == 0:
|
||||||
print(f"{cnt} claims sent")
|
logging.info("%i claims sent to ES", cnt)
|
||||||
print("sent %i claims, deleted %i" % (len(touched_claims), len(deleted_claims)))
|
logging.info("finished sending %i claims to ES, deleted %i", cnt, len(touched_claims), len(deleted_claims))
|
||||||
finally:
|
finally:
|
||||||
if need_open:
|
if need_open:
|
||||||
db.close()
|
db.close()
|
||||||
|
@ -60,6 +60,7 @@ async def get_all_claims(index_name='claims', db=None):
|
||||||
db = db or LevelDB(env)
|
db = db or LevelDB(env)
|
||||||
if need_open:
|
if need_open:
|
||||||
await db.open_dbs()
|
await db.open_dbs()
|
||||||
|
logging.info("Fetching claims to send ES from leveldb")
|
||||||
try:
|
try:
|
||||||
cnt = 0
|
cnt = 0
|
||||||
async for claim in db.all_claims_producer():
|
async for claim in db.all_claims_producer():
|
||||||
|
@ -72,7 +73,7 @@ async def get_all_claims(index_name='claims', db=None):
|
||||||
}
|
}
|
||||||
cnt += 1
|
cnt += 1
|
||||||
if cnt % 10000 == 0:
|
if cnt % 10000 == 0:
|
||||||
print(f"{cnt} claims sent")
|
logging.info("sent %i claims to ES", cnt)
|
||||||
finally:
|
finally:
|
||||||
if need_open:
|
if need_open:
|
||||||
db.close()
|
db.close()
|
||||||
|
|
|
@ -498,19 +498,9 @@ class LevelDB:
|
||||||
script.parse()
|
script.parse()
|
||||||
return Claim.from_bytes(script.values['claim'])
|
return Claim.from_bytes(script.values['claim'])
|
||||||
except:
|
except:
|
||||||
self.logger.error(
|
self.logger.error("claim parsing for ES failed with tx: %s", tx_hash[::-1].hex())
|
||||||
"tx parsing for ES went boom %s %s", tx_hash[::-1].hex(),
|
|
||||||
(raw or b'').hex()
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def _prepare_claim_for_sync(self, claim_hash: bytes):
|
|
||||||
claim = self._fs_get_claim_by_hash(claim_hash)
|
|
||||||
if not claim:
|
|
||||||
print("wat")
|
|
||||||
return
|
|
||||||
return self._prepare_claim_metadata(claim_hash, claim)
|
|
||||||
|
|
||||||
def _prepare_claim_metadata(self, claim_hash: bytes, claim: ResolveResult):
|
def _prepare_claim_metadata(self, claim_hash: bytes, claim: ResolveResult):
|
||||||
metadata = self.get_claim_metadata(claim.tx_hash, claim.position)
|
metadata = self.get_claim_metadata(claim.tx_hash, claim.position)
|
||||||
if not metadata:
|
if not metadata:
|
||||||
|
@ -552,19 +542,10 @@ class LevelDB:
|
||||||
).outputs[reposted_claim.position]
|
).outputs[reposted_claim.position]
|
||||||
reposted_script = OutputScript(reposted_claim_txo.pk_script)
|
reposted_script = OutputScript(reposted_claim_txo.pk_script)
|
||||||
reposted_script.parse()
|
reposted_script.parse()
|
||||||
except:
|
|
||||||
self.logger.error(
|
|
||||||
"repost tx parsing for ES went boom %s %s", reposted_tx_hash[::-1].hex(),
|
|
||||||
raw_reposted_claim_tx.hex()
|
|
||||||
)
|
|
||||||
return
|
|
||||||
try:
|
|
||||||
reposted_metadata = Claim.from_bytes(reposted_script.values['claim'])
|
reposted_metadata = Claim.from_bytes(reposted_script.values['claim'])
|
||||||
except:
|
except:
|
||||||
self.logger.error(
|
self.logger.error("failed to parse reposted claim in tx %s that was reposted by %s",
|
||||||
"reposted claim parsing for ES went boom %s %s", reposted_tx_hash[::-1].hex(),
|
reposted_tx_hash[::-1].hex(), claim_hash.hex())
|
||||||
raw_reposted_claim_tx.hex()
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
if reposted_metadata:
|
if reposted_metadata:
|
||||||
if reposted_metadata.is_stream:
|
if reposted_metadata.is_stream:
|
||||||
|
|
Loading…
Reference in a new issue