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:
Fabian Jahr
2020-09-06 00:22:19 +02:00
parent cb94db119f
commit 2ca5a496c2
3 changed files with 45 additions and 8 deletions

View File

@@ -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
}
]
}
}

View File

@@ -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()