mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-11-29 12:06:35 -05:00
Type timelock and block height
To ensure no mistake is made (and none were!)
This commit is contained in:
parent
81cbc24c46
commit
bcbc54b569
8 changed files with 125 additions and 70 deletions
|
|
@ -133,24 +133,26 @@ impl GetRawTransaction for Wallet {
|
|||
|
||||
#[async_trait]
|
||||
impl GetBlockHeight for Wallet {
|
||||
async fn get_block_height(&self) -> u32 {
|
||||
(|| async { Ok(self.inner.client.getblockcount().await?) })
|
||||
async fn get_block_height(&self) -> BlockHeight {
|
||||
let height = (|| async { Ok(self.inner.client.getblockcount().await?) })
|
||||
.retry(ConstantBackoff::new(Duration::from_secs(1)))
|
||||
.await
|
||||
.expect("transient errors to be retried")
|
||||
.expect("transient errors to be retried");
|
||||
|
||||
BlockHeight::new(height)
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl TransactionBlockHeight for Wallet {
|
||||
async fn transaction_block_height(&self, txid: Txid) -> u32 {
|
||||
async fn transaction_block_height(&self, txid: Txid) -> BlockHeight {
|
||||
#[derive(Debug)]
|
||||
enum Error {
|
||||
Io,
|
||||
NotYetMined,
|
||||
}
|
||||
|
||||
(|| async {
|
||||
let height = (|| async {
|
||||
let block_height = self
|
||||
.inner
|
||||
.transaction_block_height(txid)
|
||||
|
|
@ -164,7 +166,9 @@ impl TransactionBlockHeight for Wallet {
|
|||
})
|
||||
.retry(ConstantBackoff::new(Duration::from_secs(1)))
|
||||
.await
|
||||
.expect("transient errors to be retried")
|
||||
.expect("transient errors to be retried");
|
||||
|
||||
BlockHeight::new(height)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue