Skip to content

Commit 8914b76

Browse files
committed
feat(utxo_block_header): add a box dyn for block header storage to utxo common fields
1 parent 2368209 commit 8914b76

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

mm2src/coins/utxo.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ use super::{BalanceError, BalanceFut, BalanceResult, CoinTransportMetrics, Coins
9797
RpcTransportEventHandler, RpcTransportEventHandlerShared, TradeFee, TradePreimageError, TradePreimageFut,
9898
TradePreimageResult, Transaction, TransactionDetails, TransactionEnum, TransactionFut, WithdrawError,
9999
WithdrawRequest};
100+
use crate::utxo::utxo_block_header_storage::{BlockHeaderStorage, BlockHeaderStorageError};
100101
use std::array::TryFromSliceError;
101102

102103
#[cfg(test)] pub mod utxo_tests;
@@ -553,6 +554,7 @@ pub struct UtxoCoinFields {
553554
pub tx_fee: TxFee,
554555
/// Minimum transaction value at which the value is not less than fee
555556
pub dust_amount: u64,
557+
pub block_header_storage: Option<Box<dyn BlockHeaderStorage<Error = dyn BlockHeaderStorageError>>>,
556558
/// RPC client
557559
pub rpc_client: UtxoRpcClientEnum,
558560
/// Either ECDSA key pair or a Hardware Wallet info.
@@ -1475,6 +1477,7 @@ pub trait UtxoCoinBuilder {
14751477
conf,
14761478
decimals,
14771479
dust_amount,
1480+
block_header_storage: None,
14781481
rpc_client,
14791482
priv_key_policy,
14801483
derivation_method,
@@ -1508,6 +1511,7 @@ pub trait UtxoCoinBuilder {
15081511
conf,
15091512
decimals,
15101513
dust_amount,
1514+
block_header_storage: None,
15111515
rpc_client,
15121516
priv_key_policy: PrivKeyPolicy::HardwareWallet,
15131517
derivation_method: DerivationMethod::HDWallet(HDWalletInfo::new(addr_format)),

mm2src/coins/utxo/utxo_block_header_storage.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use async_trait::async_trait;
33
use chain::BlockHeader;
44
use common::{mm_error::MmError, mm_error::NotMmError, NotSame};
55
use std::collections::HashMap;
6+
use std::fmt::{Debug, Formatter};
67

78
pub trait BlockHeaderStorageError: std::fmt::Debug + NotMmError + NotSame + Send {}
89

@@ -39,3 +40,7 @@ pub trait BlockHeaderStorage: Send + Sync + 'static {
3940
/// Gets the block header by height from the selected coin's storage as hex
4041
async fn get_block_header_raw(&self, for_coin: &str, height: u64) -> Result<Option<String>, MmError<Self::Error>>;
4142
}
43+
44+
impl Debug for dyn BlockHeaderStorage<Error = dyn BlockHeaderStorageError> {
45+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "") }
46+
}

mm2src/coins/utxo/utxo_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ fn utxo_coin_fields_for_test(
131131
tx_cache_directory: None,
132132
recently_spent_outpoints: AsyncMutex::new(RecentlySpentOutPoints::new(my_script_pubkey)),
133133
tx_hash_algo: TxHashAlgo::DSHA256,
134+
block_header_storage: None,
134135
}
135136
}
136137

0 commit comments

Comments
 (0)