GetBlockResponse struct
This commit is contained in:
parent
6304a40ab7
commit
e4fc56f119
|
@ -18,7 +18,7 @@ build_rpc_trait! {
|
||||||
fn block_hash(&self, u32) -> Result<H256, Error>;
|
fn block_hash(&self, u32) -> Result<H256, Error>;
|
||||||
/// Get proof-of-work difficulty as a multiple of the minimum difficulty
|
/// Get proof-of-work difficulty as a multiple of the minimum difficulty
|
||||||
#[rpc(name = "getdifficulty")]
|
#[rpc(name = "getdifficulty")]
|
||||||
fn difficulty(&self) -> Result<u32, Error>;
|
fn difficulty(&self) -> Result<f64, Error>;
|
||||||
/// Get information on given block.
|
/// Get information on given block.
|
||||||
#[rpc(name = "getblock")]
|
#[rpc(name = "getblock")]
|
||||||
fn block(&self, H256, Option<bool>) -> Result<GetBlockResponse, Error>;
|
fn block(&self, H256, Option<bool>) -> Result<GetBlockResponse, Error>;
|
||||||
|
|
|
@ -1,3 +1,62 @@
|
||||||
|
use super::bytes::Bytes;
|
||||||
|
use super::hash::H256;
|
||||||
|
use super::raw_block::RawBlock;
|
||||||
|
|
||||||
|
/// Response to getblock RPC request
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub enum GetBlockResponse {
|
pub enum GetBlockResponse {
|
||||||
|
/// When asking for short response
|
||||||
|
Short(RawBlock),
|
||||||
|
/// When asking for verbose response
|
||||||
|
Verbose(Block),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Verbose block information
|
||||||
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
pub struct Block {
|
||||||
|
/// Block hash
|
||||||
|
pub hash: H256,
|
||||||
|
/// Number of confirmations. -1 if block is on the side chain
|
||||||
|
pub confirmations: i64,
|
||||||
|
/// Block size
|
||||||
|
pub size: u32,
|
||||||
|
/// Block size, excluding witness data
|
||||||
|
pub strippedsize: u32,
|
||||||
|
/// Block weight
|
||||||
|
pub weight: u32,
|
||||||
|
/// Block height
|
||||||
|
pub height: u32,
|
||||||
|
/// Block version
|
||||||
|
pub version: u32,
|
||||||
|
/// Block version as hex
|
||||||
|
#[serde(rename = "versionHex")]
|
||||||
|
pub version_hex: Bytes,
|
||||||
|
/// Merkle root of this block
|
||||||
|
pub merkleroot: H256,
|
||||||
|
/// Transactions ids
|
||||||
|
pub tx: Vec<H256>,
|
||||||
|
/// Block time in seconds since epoch (Jan 1 1970 GMT)
|
||||||
|
pub time: u32,
|
||||||
|
/// Median block time in seconds since epoch (Jan 1 1970 GMT)
|
||||||
|
pub mediantime: u32,
|
||||||
|
/// Block nonce
|
||||||
|
pub nonce: u32,
|
||||||
|
/// Block nbits
|
||||||
|
pub bits: u32,
|
||||||
|
/// Block difficulty
|
||||||
|
pub difficulty: f64,
|
||||||
|
/// Expected number of hashes required to produce the chain up to this block (in hex)
|
||||||
|
pub chainwork: H256,
|
||||||
|
/// Hash of previous block
|
||||||
|
pub previousblockhash: Option<H256>,
|
||||||
|
/// Hash of next block
|
||||||
|
pub nextblockhash: Option<H256>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
#[test]
|
||||||
|
fn block_serialize() {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -6,6 +6,7 @@ mod get_transaction_response;
|
||||||
mod get_tx_out_response;
|
mod get_tx_out_response;
|
||||||
mod get_tx_out_set_info_response;
|
mod get_tx_out_set_info_response;
|
||||||
mod hash;
|
mod hash;
|
||||||
|
mod raw_block;
|
||||||
mod raw_transaction;
|
mod raw_transaction;
|
||||||
|
|
||||||
pub use self::block_template::{BlockTemplate, BlockTemplateTransaction};
|
pub use self::block_template::{BlockTemplate, BlockTemplateTransaction};
|
||||||
|
@ -16,4 +17,5 @@ pub use self::get_transaction_response::GetTransactionResponse;
|
||||||
pub use self::get_tx_out_response::GetTxOutResponse;
|
pub use self::get_tx_out_response::GetTxOutResponse;
|
||||||
pub use self::get_tx_out_set_info_response::GetTxOutSetInfoResponse;
|
pub use self::get_tx_out_set_info_response::GetTxOutSetInfoResponse;
|
||||||
pub use self::hash::H256;
|
pub use self::hash::H256;
|
||||||
|
pub use self::raw_block::RawBlock;
|
||||||
pub use self::raw_transaction::RawTransaction;
|
pub use self::raw_transaction::RawTransaction;
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
use super::bytes::Bytes;
|
||||||
|
|
||||||
|
pub type RawBlock = Bytes;
|
Loading…
Reference in New Issue