rust-web3
rust-web3 copied to clipboard
Generic approach to confirmations
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
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