1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//! Blockchain related RPC result types.

use strason::Json;

/// Models the result of "waitfornewblock", and "waitforblock"
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct BlockRef {
    // TODO: Use Sha256dHash
    pub hash: String,
    pub height: u64,
}

/// Models the result of "getblockchaininfo"
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct BlockchainInfo {
    // TODO: Use Network from rust-bitcoin
    /// Current network name as defined in BIP70 (main, test, regtest)
    pub chain: String, 
    /// The current number of blocks processed in the server
    pub blocks: u64,
    /// The current number of headers we have validated
    pub headers: u64,
    // TODO: Use Sha256dHash from rust-bitcoin
    /// The hash of the currently best block
    pub bestblockhash: String, 
    /// The current difficulty
    pub difficulty: u64, 
    /// Median time for the current best block
    pub mediantime: u64, 
    /// Estimate of verification progress [0..1]
    pub verificationprogress: f64, 
    /// Estimate of whether this node is in Initial Block Download mode
    pub initialblockdownload: bool, 
    /// Total amount of work in active chain, in hexadecimal
    pub chainwork: String,
    /// The estimated size of the block and undo files on disk
    pub size_on_disk: u64,
    /// If the blocks are subject to pruning
    pub pruned: bool,
    /// Lowest-height complete block stored (only present if pruning is enabled)
    pub pruneheight: u64,
    /// Whether automatic pruning is enabled (only present if pruning is enabled)
    pub automatic_pruning: bool, 
    /// The target size used by pruning (only present if automatic pruning is enabled)
    pub prune_target_size: u64, 
    /// Status of softforks in progress
    pub softforks: Vec<Softfork>,
    // TODO: add a type?
    /// Status of BIP9 softforks in progress
    pub bip9_softforks: Json,
    /// Any network and blockchain warnings.
    pub warnings: String,
}

/// Status of a softfork
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Softfork {
    /// Name of softfork
    pub id: String,
    /// Block version
    pub version: u64,
    /// Progress toward rejecting pre-softfork blocks
    pub reject: RejectStatus,
}

/// Progress toward rejecting pre-softfork blocks
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct RejectStatus {
    /// `true` if threshold reached
    pub status: bool,
}