Skip to content

Commit 687119b

Browse files
committed
fix(types): use f64 for GetChainTxStats tx_rate field
Bitcoin Core has always returned txrate as a double since the RPC was added in v0.15 (PR #9733).
1 parent 87c72e7 commit 687119b

File tree

5 files changed

+5
-7
lines changed

5 files changed

+5
-7
lines changed

types/src/model/blockchain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ pub struct GetChainTxStats {
417417
/// The elapsed time in the window in seconds. Only returned if "window_block_count" is > 0.
418418
pub window_interval: Option<u32>,
419419
/// The average rate of transactions per second in the window. Only returned if "window_interval" is > 0.
420-
pub tx_rate: Option<u32>,
420+
pub tx_rate: Option<f64>,
421421
}
422422

423423
/// Models the result of JSON-RPC method `getdeploymentinfo`.

types/src/v17/blockchain/into.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ impl GetChainTxStats {
315315
self.window_tx_count.map(|h| crate::to_u32(h, "window_tx_count")).transpose()?;
316316
let window_interval =
317317
self.window_interval.map(|h| crate::to_u32(h, "window_interval")).transpose()?;
318-
let tx_rate = self.tx_rate.map(|h| crate::to_u32(h, "tx_rate")).transpose()?;
319318

320319
Ok(model::GetChainTxStats {
321320
time: crate::to_u32(self.time, "time")?,
@@ -325,7 +324,7 @@ impl GetChainTxStats {
325324
window_block_count: crate::to_u32(self.window_block_count, "window_block_count")?,
326325
window_tx_count,
327326
window_interval,
328-
tx_rate,
327+
tx_rate: self.tx_rate,
329328
})
330329
}
331330
}

types/src/v17/blockchain/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ pub struct GetChainTxStats {
438438
pub window_interval: Option<i64>,
439439
/// The average rate of transactions per second in the window. Only returned if "window_interval" is > 0.
440440
#[serde(rename = "txrate")]
441-
pub tx_rate: Option<i64>,
441+
pub tx_rate: Option<f64>,
442442
}
443443

444444
/// Result of JSON-RPC method `getdifficulty`.

types/src/v19/blockchain/into.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ impl GetChainTxStats {
8181
self.window_tx_count.map(|h| crate::to_u32(h, "window_tx_count")).transpose()?;
8282
let window_interval =
8383
self.window_interval.map(|h| crate::to_u32(h, "window_interval")).transpose()?;
84-
let tx_rate = self.tx_rate.map(|h| crate::to_u32(h, "tx_rate")).transpose()?;
8584

8685
Ok(model::GetChainTxStats {
8786
time: crate::to_u32(self.time, "time")?,
@@ -91,7 +90,7 @@ impl GetChainTxStats {
9190
window_block_count: crate::to_u32(self.window_block_count, "window_block_count")?,
9291
window_tx_count,
9392
window_interval,
94-
tx_rate,
93+
tx_rate: self.tx_rate,
9594
})
9695
}
9796
}

types/src/v19/blockchain/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ pub struct GetChainTxStats {
186186
pub window_interval: Option<i64>,
187187
/// The average rate of transactions per second in the window. Only returned if "window_interval" is > 0.
188188
#[serde(rename = "txrate")]
189-
pub tx_rate: Option<i64>,
189+
pub tx_rate: Option<f64>,
190190
}
191191

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

0 commit comments

Comments
 (0)