Skip to content

Commit 92fafb3

Browse files
committed
coinstats: add coins_count
Also changes existing CCoinsStats attributes to be C++11 initialized.
1 parent 707fde7 commit 92fafb3

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/node/coinstats.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ static void ApplyStats(CCoinsStats &stats, CHashWriter& ss, const uint256& hash,
3838
//! Calculate statistics about the unspent transaction output set
3939
bool GetUTXOStats(CCoinsView *view, CCoinsStats &stats)
4040
{
41+
stats = CCoinsStats();
4142
std::unique_ptr<CCoinsViewCursor> pcursor(view->Cursor());
4243
assert(pcursor);
4344

@@ -61,6 +62,7 @@ bool GetUTXOStats(CCoinsView *view, CCoinsStats &stats)
6162
}
6263
prevkey = key.hash;
6364
outputs[key.n] = std::move(coin);
65+
stats.coins_count++;
6466
} else {
6567
return error("%s: unable to read value", __func__);
6668
}

src/node/coinstats.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@ class CCoinsView;
1515

1616
struct CCoinsStats
1717
{
18-
int nHeight;
19-
uint256 hashBlock;
20-
uint64_t nTransactions;
21-
uint64_t nTransactionOutputs;
22-
uint64_t nBogoSize;
23-
uint256 hashSerialized;
24-
uint64_t nDiskSize;
25-
CAmount nTotalAmount;
26-
27-
CCoinsStats() : nHeight(0), nTransactions(0), nTransactionOutputs(0), nBogoSize(0), nDiskSize(0), nTotalAmount(0) {}
18+
int nHeight{0};
19+
uint256 hashBlock{};
20+
uint64_t nTransactions{0};
21+
uint64_t nTransactionOutputs{0};
22+
uint64_t nBogoSize{0};
23+
uint256 hashSerialized{};
24+
uint64_t nDiskSize{0};
25+
CAmount nTotalAmount{0};
26+
27+
//! The number of coins contained.
28+
uint64_t coins_count{0};
2829
};
2930

3031
//! Calculate statistics about the unspent transaction output set

0 commit comments

Comments
 (0)