Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions integration_test/tests/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,15 @@ fn blockchain__get_chain_tips__modelled() {

#[test]
fn blockchain__get_chain_tx_stats__modelled() {
let node = Node::with_wallet(Wallet::None, &[]);
let node = Node::with_wallet(Wallet::Default, &[]);
node.fund_wallet();
let (_address, _tx) = node.create_mined_transaction();

let json: GetChainTxStats = node.client.get_chain_tx_stats().expect("getchaintxstats");
let model: Result<mtype::GetChainTxStats, GetChainTxStatsError> = json.into_model();
model.unwrap();
let chain_tx_stats = model.unwrap();

assert!(chain_tx_stats.tx_rate.unwrap() > 0.0);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion types/src/model/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ pub struct GetChainTxStats {
/// The elapsed time in the window in seconds. Only returned if "window_block_count" is > 0.
pub window_interval: Option<u32>,
/// The average rate of transactions per second in the window. Only returned if "window_interval" is > 0.
pub tx_rate: Option<u32>,
pub tx_rate: Option<f64>,
}

/// Models the result of JSON-RPC method `getdeploymentinfo`.
Expand Down
3 changes: 1 addition & 2 deletions types/src/v17/blockchain/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@ impl GetChainTxStats {
self.window_tx_count.map(|h| crate::to_u32(h, "window_tx_count")).transpose()?;
let window_interval =
self.window_interval.map(|h| crate::to_u32(h, "window_interval")).transpose()?;
let tx_rate = self.tx_rate.map(|h| crate::to_u32(h, "tx_rate")).transpose()?;

Ok(model::GetChainTxStats {
time: crate::to_u32(self.time, "time")?,
Expand All @@ -325,7 +324,7 @@ impl GetChainTxStats {
window_block_count: crate::to_u32(self.window_block_count, "window_block_count")?,
window_tx_count,
window_interval,
tx_rate,
tx_rate: self.tx_rate,
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion types/src/v17/blockchain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ pub struct GetChainTxStats {
pub window_interval: Option<i64>,
/// The average rate of transactions per second in the window. Only returned if "window_interval" is > 0.
#[serde(rename = "txrate")]
pub tx_rate: Option<i64>,
pub tx_rate: Option<f64>,
}

/// Result of JSON-RPC method `getdifficulty`.
Expand Down
3 changes: 1 addition & 2 deletions types/src/v19/blockchain/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ impl GetChainTxStats {
self.window_tx_count.map(|h| crate::to_u32(h, "window_tx_count")).transpose()?;
let window_interval =
self.window_interval.map(|h| crate::to_u32(h, "window_interval")).transpose()?;
let tx_rate = self.tx_rate.map(|h| crate::to_u32(h, "tx_rate")).transpose()?;

Ok(model::GetChainTxStats {
time: crate::to_u32(self.time, "time")?,
Expand All @@ -91,7 +90,7 @@ impl GetChainTxStats {
window_block_count: crate::to_u32(self.window_block_count, "window_block_count")?,
window_tx_count,
window_interval,
tx_rate,
tx_rate: self.tx_rate,
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion types/src/v19/blockchain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ pub struct GetChainTxStats {
pub window_interval: Option<i64>,
/// The average rate of transactions per second in the window. Only returned if "window_interval" is > 0.
#[serde(rename = "txrate")]
pub tx_rate: Option<i64>,
pub tx_rate: Option<f64>,
}

/// Result of JSON-RPC method `getmempoolancestors` with verbose set to `false`.
Expand Down