This commit is contained in:
Jack Robison 2021-10-20 11:40:15 -04:00 committed by Victor Shyba
parent aa1b20cf7b
commit 9aafb7a743
2 changed files with 7 additions and 25 deletions

View file

@ -47,8 +47,8 @@ async def get_recent_claims(blocks: int, index_name='claims', db=None):
else:
logging.warning("could not sync claim %s", touched.hex())
if cnt % 10000 == 0:
print(f"{cnt} claims sent")
print("sent %i claims, deleted %i" % (len(touched_claims), len(deleted_claims)))
logging.info("%i claims sent to ES", cnt)
logging.info("finished sending %i claims to ES, deleted %i", cnt, len(touched_claims), len(deleted_claims))
finally:
if need_open:
db.close()
@ -60,6 +60,7 @@ async def get_all_claims(index_name='claims', db=None):
db = db or LevelDB(env)
if need_open:
await db.open_dbs()
logging.info("Fetching claims to send ES from leveldb")
try:
cnt = 0
async for claim in db.all_claims_producer():
@ -72,7 +73,7 @@ async def get_all_claims(index_name='claims', db=None):
}
cnt += 1
if cnt % 10000 == 0:
print(f"{cnt} claims sent")
logging.info("sent %i claims to ES", cnt)
finally:
if need_open:
db.close()

View file

@ -498,19 +498,9 @@ class LevelDB:
script.parse()
return Claim.from_bytes(script.values['claim'])
except:
self.logger.error(
"tx parsing for ES went boom %s %s", tx_hash[::-1].hex(),
(raw or b'').hex()
)
self.logger.error("claim parsing for ES failed with tx: %s", tx_hash[::-1].hex())
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):
metadata = self.get_claim_metadata(claim.tx_hash, claim.position)
if not metadata:
@ -552,19 +542,10 @@ class LevelDB:
).outputs[reposted_claim.position]
reposted_script = OutputScript(reposted_claim_txo.pk_script)
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'])
except:
self.logger.error(
"reposted claim parsing for ES went boom %s %s", reposted_tx_hash[::-1].hex(),
raw_reposted_claim_tx.hex()
)
self.logger.error("failed to parse reposted claim in tx %s that was reposted by %s",
reposted_tx_hash[::-1].hex(), claim_hash.hex())
return
if reposted_metadata:
if reposted_metadata.is_stream: