rust-web3 icon indicating copy to clipboard operation
rust-web3 copied to clipboard

Generic approach to confirmations

Open tomusdrw opened this issue 7 years ago • 1 comments

More generic support for confirmations would be nice.

Currently we have a bunch of methods like "send_transaction_with_confirmations" instead it would be good to have a trait that can be implemented for some return types (e.g. futures resolving to transaction hashes) that allows you to (optionally) wait for confirmations.

Related: #86, #102, #89

tomusdrw avatar Mar 08 '18 08:03 tomusdrw

agree. the API should be more like send_transaction().wait_for_confirmations(n).

Maybe for any type that implements a

trait Confirm {
    // whether the value was confirmed in this block.
    // TODO: extend to receipts for log events?
    fn confirmed(&self, block: &Block) -> bool;
}

then the machinery just keeps track of the depth of blocks where x.confirmed(block) is true.

initially impl Confirm for TransactionHash { ... } but allow implementation for user types

rphmeier avatar Mar 12 '18 15:03 rphmeier