Skip to main content

Module onchain_tx

Module onchain_tx 

Source
Expand description

Shared driver for the node’s on-chain PaymentPool write ladders.

Every state-changing call the node makes against PaymentPool (today only the redeemer’s redeemMany) follows the same micro-sequence: issue the transaction with .send(), await its receipt (optionally under a timeout), and inspect receipt.status() to tell a mined-and-succeeded transaction from a mined-and-reverted one. A receipt wait that fails or lapses is not an outcome yet: the transaction was issued and often mines, and a load-balanced RPC can fail the wait on a backend that has not seen the block. The driver then fetches the receipt by hash a few times before it settles on an unconfirmed outcome. What each caller then does with that result — which metric it ticks, whether it re-reads the pool to resolve a revert, what it returns — is domain state that stays at the call site.

send_and_await_receipt folds only that common plumbing into one place and hands back a TxOutcome. It deliberately does not take the call builder (each redeem/redeemMany/… builder is a distinct type, which would force a generic or a closure hook); it takes the already issued .send() result, so the concrete method call stays a visible call at every site.

send_and_await_receipt is fixed to the Ethereum network — the whole crate is Ethereum-only — which keeps its signature free of a Provider type parameter and its where clause. The private by-hash helpers stay generic over Provider so tests can drive them against a mocked client.