Make poll_time configurable
@@ -48,6 +48,7 @@ pub struct EthereumProvider<S: EthereumSigner> {
eth_client: ETHDirectClient<S>,
erc20_abi: ethabi::Contract,
confirmation_timeout: Duration,
+ poll_time: Duration,
}
impl<S: EthereumSigner> EthereumProvider<S> {
@@ -90,6 +91,7 @@ impl<S: EthereumSigner> EthereumProvider<S> {
erc20_abi,
tokens_cache,
confirmation_timeout: Duration::from_secs(30),
+ poll_time: Duration::from_millis(1000),
})
}
@@ -350,9 +352,15 @@ impl<S: EthereumSigner> EthereumProvider<S> {
self.confirmation_timeout = timeout;
}
+ /// Sets the time to poll for transactions to appear in the Ethereum network.
+ /// By default it is set to 1 second.
+ pub fn set_poll_time(&mut self, time: Duration) {
+ self.poll_time = time;
+ }
+
/// Waits until the transaction is confirmed by the Ethereum blockchain.
pub async fn wait_for_tx(&self, tx_hash: H256) -> Result<TransactionReceipt, ClientError> {
- let mut poller = tokio::time::interval(Duration::from_millis(1000));
+ let mut poller = tokio::time::interval(self.poll_time);
let start = Instant::now();
loop {
