Skip to content

Commit

Permalink
improve commit batch, handles and log batch which items were already …
Browse files Browse the repository at this point in the history
…updated
  • Loading branch information
patrick borowy committed Apr 2, 2024
1 parent bac3c75 commit d76cbaf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/commit_analyzed_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ async def commit_analyzed_batch(processed_batch, app):
app["web3_configuration"]["contracts"],
app["web3_configuration"]["read_web3"],
app["web3_configuration"]["write_web3"],
app["web3_configuration"],
app["web3_configuration"]
)
receipt = await get_transaction_receipt(
transaction_hash, previous_nonce, app["web3_configuration"]
)
logging.info("COMMIT OK")
return transaction_hash, cid
return (transaction_hash, cid)
return (None, None)
except Exception as e:
logging.exception("An error occured while commiting a batch")
raise e
27 changes: 15 additions & 12 deletions src/transactioneer.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,22 @@ async def create_task(items, app):
logging.info("===")
with tracer.start_as_current_span("commit_analyzed_batch") as commit_analyzed_batch_span:
try:
transaction_hash, cid = await commit_analyzed_batch(
(transaction_hash, cid) = await commit_analyzed_batch(
{"items": items, "kind": "SPOTTING"}, app
)
commit_analyzed_batch_span.set_status(StatusCode.OK)
commit_analyzed_batch_span.set_attribute("CID", cid)
commit_analyzed_batch_span.set_attribute(
"TX", transaction_hash.hex()
)
receipt_count.inc({})
receipt_count_populated.inc(
{ "CID": cid, "TX": transaction_hash.hex() }
)
logging.info("COMMIT OK")
if cid and transaction_hash:
commit_analyzed_batch_span.set_status(StatusCode.OK)
commit_analyzed_batch_span.set_attribute("CID", cid)
commit_analyzed_batch_span.set_attribute(
"TX", transaction_hash.hex()
)
receipt_count.inc({})
receipt_count_populated.inc(
{ "CID": cid, "TX": transaction_hash.hex() }
)
logging.info("COMMIT OK")
else:
logging.info("Every item of this batch are already collected")
except Exception as e:
logging.info("COMMIT FAILED")
logging.exception("An Error occured commiting analyzed batch")
Expand Down Expand Up @@ -231,7 +234,7 @@ async def do_claim_master(app):


def start_transactioneer():
if os.getenv('TRACE'):
if os.getenv("TRACE", False):
setup_tracing()
logging.basicConfig(
level=logging.DEBUG,
Expand Down

0 comments on commit d76cbaf

Please sign in to comment.