-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change(rpc): Adds
getmininginfo
, getnetworksolps
and `getnetworkh…
…ashps` methods (#5808) * adds type and stub * adds: - SolutionRate state request - getnetworksolps, getnetworkhashps, & getmininginfo RPCs - vectors tests * adds snapshot tests updates ReadRequest::SolutionRate doc link * removes random slash in doc comment moves snapshot tests up where it can use the populated state service * adds snapshots * updates doc comments * applies `num_blocks` default in RPC instead of `solution_rate` * adds # Correctness comment * Add testnet field to getmininginfo response * use PartialCumulativeWork instead of u128 * document why `solution_rate` takes an extra block * add comment explaining why the work for the last block in the iterator is not added to `total_work` * use `as_u128` method instead of deref for PartialCumulativeWork * Updates `chain` field of getmininginfo response * Updates snapshots Adds "arbitrary_precision" feature to serde_json in zebra-rpc
- Loading branch information
Showing
15 changed files
with
404 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
zebra-rpc/src/methods/get_block_template_rpcs/types/get_mining_info.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//! Response type for the `getmininginfo` RPC. | ||
use zebra_chain::parameters::Network; | ||
|
||
/// Response to a `getmininginfo` RPC request. | ||
#[derive(Debug, PartialEq, Eq, serde::Serialize)] | ||
pub struct Response { | ||
/// The estimated network solution rate in Sol/s. | ||
networksolps: u128, | ||
|
||
/// The estimated network solution rate in Sol/s. | ||
networkhashps: u128, | ||
|
||
/// Current network name as defined in BIP70 (main, test, regtest) | ||
chain: String, | ||
|
||
/// If using testnet or not | ||
testnet: bool, | ||
} | ||
|
||
impl Response { | ||
/// Creates a new `getmininginfo` response | ||
pub fn new(network: Network, networksolps: u128) -> Self { | ||
Self { | ||
networksolps, | ||
networkhashps: networksolps, | ||
chain: network.bip70_network_name(), | ||
testnet: network == Network::Testnet, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
zebra-rpc/src/methods/tests/snapshot/snapshots/get_mining_info@mainnet_10.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
source: zebra-rpc/src/methods/tests/snapshot/get_block_template_rpcs.rs | ||
expression: get_mining_info | ||
--- | ||
{ | ||
"networksolps": 2, | ||
"networkhashps": 2, | ||
"chain": "main", | ||
"testnet": false | ||
} |
10 changes: 10 additions & 0 deletions
10
zebra-rpc/src/methods/tests/snapshot/snapshots/get_mining_info@testnet_10.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
source: zebra-rpc/src/methods/tests/snapshot/get_block_template_rpcs.rs | ||
expression: get_mining_info | ||
--- | ||
{ | ||
"networksolps": 0, | ||
"networkhashps": 0, | ||
"chain": "test", | ||
"testnet": true | ||
} |
5 changes: 5 additions & 0 deletions
5
zebra-rpc/src/methods/tests/snapshot/snapshots/get_network_sol_ps@mainnet_10.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
source: zebra-rpc/src/methods/tests/snapshot/get_block_template_rpcs.rs | ||
expression: get_network_sol_ps | ||
--- | ||
2 |
5 changes: 5 additions & 0 deletions
5
zebra-rpc/src/methods/tests/snapshot/snapshots/get_network_sol_ps@testnet_10.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
source: zebra-rpc/src/methods/tests/snapshot/get_block_template_rpcs.rs | ||
expression: get_network_sol_ps | ||
--- | ||
0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.