mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
rpc: Improve getblockstats
- Fix getblockstats for block height 0 which previously returned an error. - Introduce alternative utxo_*_actual statistics which exclude unspendables: Genesis block, BIP30, unspendable outputs - Update test data - Explicitly test Genesis block results
This commit is contained in:
@@ -142,7 +142,9 @@
|
||||
"totalfee": 0,
|
||||
"txs": 1,
|
||||
"utxo_increase": 2,
|
||||
"utxo_size_inc": 163
|
||||
"utxo_increase_actual": 1,
|
||||
"utxo_size_inc": 163,
|
||||
"utxo_size_inc_actual": 75
|
||||
},
|
||||
{
|
||||
"avgfee": 4460,
|
||||
@@ -179,7 +181,9 @@
|
||||
"totalfee": 4460,
|
||||
"txs": 2,
|
||||
"utxo_increase": 3,
|
||||
"utxo_size_inc": 236
|
||||
"utxo_increase_actual": 2,
|
||||
"utxo_size_inc": 236,
|
||||
"utxo_size_inc_actual": 148
|
||||
},
|
||||
{
|
||||
"avgfee": 24906,
|
||||
@@ -216,7 +220,9 @@
|
||||
"totalfee": 74720,
|
||||
"txs": 4,
|
||||
"utxo_increase": 5,
|
||||
"utxo_size_inc": 384
|
||||
"utxo_size_inc": 384,
|
||||
"utxo_increase_actual": 4,
|
||||
"utxo_size_inc_actual": 296
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,6 +161,14 @@ class GetblockstatsTest(BitcoinTestFramework):
|
||||
assert_raises_rpc_error(-1, 'getblockstats hash_or_height ( stats )', self.nodes[0].getblockstats, '00', 1, 2)
|
||||
assert_raises_rpc_error(-1, 'getblockstats hash_or_height ( stats )', self.nodes[0].getblockstats)
|
||||
|
||||
self.log.info('Test block height 0')
|
||||
genesis_stats = self.nodes[0].getblockstats(0)
|
||||
assert_equal(genesis_stats["blockhash"], "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206")
|
||||
assert_equal(genesis_stats["utxo_increase"], 1)
|
||||
assert_equal(genesis_stats["utxo_size_inc"], 117)
|
||||
assert_equal(genesis_stats["utxo_increase_actual"], 0)
|
||||
assert_equal(genesis_stats["utxo_size_inc_actual"], 0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
GetblockstatsTest().main()
|
||||
|
||||
Reference in New Issue
Block a user