Browse Source

Replace bytes_serialized with bogosize

0.15
Pieter Wuille 8 years ago
parent
commit
8b22af3ee5
  1. 6
      doc/release-notes.md
  2. 9
      src/rpc/blockchain.cpp
  3. 3
      test/functional/blockchain.py

6
doc/release-notes.md

@ -42,9 +42,15 @@ Low-level RPC changes
- The `gettxoutsetinfo` RPC reports `hash_serialized_2` instead of `hash_serialized`, - The `gettxoutsetinfo` RPC reports `hash_serialized_2` instead of `hash_serialized`,
which does not commit to the transaction versions of unspent outputs, but does which does not commit to the transaction versions of unspent outputs, but does
commit to the height and coinbase information. commit to the height and coinbase information.
- The `gettxoutsetinfo` response now contains `disk_size` and `bogosize` instead of
`bytes_serialized`. The first is a more accurate estimate of actual disk usage, but
is not deterministic. The second is unrelated to disk usage, but is a
database-independent metric of UTXO set size: it counts every UTXO entry as 50 + the
length of its scriptPubKey.
- The `getutxos` REST path no longer reports the `txvers` field in JSON format, - The `getutxos` REST path no longer reports the `txvers` field in JSON format,
and always reports 0 for transaction versions in the binary format and always reports 0 for transaction versions in the binary format
- Error codes have been updated to be more accurate for the following error cases: - Error codes have been updated to be more accurate for the following error cases:
- `getblock` now returns RPC_MISC_ERROR if the block can't be found on disk (for - `getblock` now returns RPC_MISC_ERROR if the block can't be found on disk (for
example if the block has been pruned). Previously returned RPC_INTERNAL_ERROR. example if the block has been pruned). Previously returned RPC_INTERNAL_ERROR.

9
src/rpc/blockchain.cpp

@ -781,11 +781,12 @@ struct CCoinsStats
uint256 hashBlock; uint256 hashBlock;
uint64_t nTransactions; uint64_t nTransactions;
uint64_t nTransactionOutputs; uint64_t nTransactionOutputs;
uint64_t nBogoSize;
uint256 hashSerialized; uint256 hashSerialized;
uint64_t nDiskSize; uint64_t nDiskSize;
CAmount nTotalAmount; CAmount nTotalAmount;
CCoinsStats() : nHeight(0), nTransactions(0), nTransactionOutputs(0), nTotalAmount(0) {} CCoinsStats() : nHeight(0), nTransactions(0), nTransactionOutputs(0), nBogoSize(0), nDiskSize(0), nTotalAmount(0) {}
}; };
static void ApplyStats(CCoinsStats &stats, CHashWriter& ss, const uint256& hash, const std::map<uint32_t, Coin>& outputs) static void ApplyStats(CCoinsStats &stats, CHashWriter& ss, const uint256& hash, const std::map<uint32_t, Coin>& outputs)
@ -800,6 +801,8 @@ static void ApplyStats(CCoinsStats &stats, CHashWriter& ss, const uint256& hash,
ss << VARINT(output.second.out.nValue); ss << VARINT(output.second.out.nValue);
stats.nTransactionOutputs++; stats.nTransactionOutputs++;
stats.nTotalAmount += output.second.out.nValue; stats.nTotalAmount += output.second.out.nValue;
stats.nBogoSize += 32 /* txid */ + 4 /* vout index */ + 4 /* height + coinbase */ + 8 /* amount */ +
2 /* scriptPubKey len */ + output.second.out.scriptPubKey.size() /* scriptPubKey */;
} }
ss << VARINT(0); ss << VARINT(0);
} }
@ -904,7 +907,8 @@ UniValue gettxoutsetinfo(const JSONRPCRequest& request)
" \"bestblock\": \"hex\", (string) the best block hash hex\n" " \"bestblock\": \"hex\", (string) the best block hash hex\n"
" \"transactions\": n, (numeric) The number of transactions\n" " \"transactions\": n, (numeric) The number of transactions\n"
" \"txouts\": n, (numeric) The number of output transactions\n" " \"txouts\": n, (numeric) The number of output transactions\n"
" \"hash_serialized\": \"hash\", (string) The serialized hash\n" " \"bogosize\": n, (numeric) A meaningless metric for UTXO set size\n"
" \"hash_serialized_2\": \"hash\", (string) The serialized hash\n"
" \"disk_size\": n, (numeric) The estimated size of the chainstate on disk\n" " \"disk_size\": n, (numeric) The estimated size of the chainstate on disk\n"
" \"total_amount\": x.xxx (numeric) The total amount\n" " \"total_amount\": x.xxx (numeric) The total amount\n"
"}\n" "}\n"
@ -922,6 +926,7 @@ UniValue gettxoutsetinfo(const JSONRPCRequest& request)
ret.push_back(Pair("bestblock", stats.hashBlock.GetHex())); ret.push_back(Pair("bestblock", stats.hashBlock.GetHex()));
ret.push_back(Pair("transactions", (int64_t)stats.nTransactions)); ret.push_back(Pair("transactions", (int64_t)stats.nTransactions));
ret.push_back(Pair("txouts", (int64_t)stats.nTransactionOutputs)); ret.push_back(Pair("txouts", (int64_t)stats.nTransactionOutputs));
ret.push_back(Pair("bogosize", (int64_t)stats.nBogoSize));
ret.push_back(Pair("hash_serialized_2", stats.hashSerialized.GetHex())); ret.push_back(Pair("hash_serialized_2", stats.hashSerialized.GetHex()));
ret.push_back(Pair("disk_size", stats.nDiskSize)); ret.push_back(Pair("disk_size", stats.nDiskSize));
ret.push_back(Pair("total_amount", ValueFromAmount(stats.nTotalAmount))); ret.push_back(Pair("total_amount", ValueFromAmount(stats.nTotalAmount)));

3
test/functional/blockchain.py

@ -49,6 +49,7 @@ class BlockchainTest(BitcoinTestFramework):
assert_equal(res['transactions'], 200) assert_equal(res['transactions'], 200)
assert_equal(res['height'], 200) assert_equal(res['height'], 200)
assert_equal(res['txouts'], 200) assert_equal(res['txouts'], 200)
assert_equal(res['bogosize'], 17000),
assert_equal(res['bestblock'], node.getblockhash(200)) assert_equal(res['bestblock'], node.getblockhash(200))
size = res['disk_size'] size = res['disk_size']
assert size > 6400 assert size > 6400
@ -65,6 +66,7 @@ class BlockchainTest(BitcoinTestFramework):
assert_equal(res2['total_amount'], Decimal('0')) assert_equal(res2['total_amount'], Decimal('0'))
assert_equal(res2['height'], 0) assert_equal(res2['height'], 0)
assert_equal(res2['txouts'], 0) assert_equal(res2['txouts'], 0)
assert_equal(res2['bogosize'], 0),
assert_equal(res2['bestblock'], node.getblockhash(0)) assert_equal(res2['bestblock'], node.getblockhash(0))
assert_equal(len(res2['hash_serialized_2']), 64) assert_equal(len(res2['hash_serialized_2']), 64)
@ -76,6 +78,7 @@ class BlockchainTest(BitcoinTestFramework):
assert_equal(res['transactions'], res3['transactions']) assert_equal(res['transactions'], res3['transactions'])
assert_equal(res['height'], res3['height']) assert_equal(res['height'], res3['height'])
assert_equal(res['txouts'], res3['txouts']) assert_equal(res['txouts'], res3['txouts'])
assert_equal(res['bogosize'], res3['bogosize'])
assert_equal(res['bestblock'], res3['bestblock']) assert_equal(res['bestblock'], res3['bestblock'])
assert_equal(res['hash_serialized_2'], res3['hash_serialized_2']) assert_equal(res['hash_serialized_2'], res3['hash_serialized_2'])

Loading…
Cancel
Save