@@ -24,14 +24,14 @@ struct DBVal {
24
24
uint64_t bogo_size;
25
25
CAmount total_amount;
26
26
CAmount total_subsidy;
27
- CAmount block_unspendable_amount ;
28
- CAmount block_prevout_spent_amount ;
29
- CAmount block_new_outputs_ex_coinbase_amount ;
30
- CAmount block_coinbase_amount ;
31
- CAmount unspendables_genesis_block ;
32
- CAmount unspendables_bip30 ;
33
- CAmount unspendables_scripts ;
34
- CAmount unspendables_unclaimed_rewards ;
27
+ CAmount total_unspendable_amount ;
28
+ CAmount total_prevout_spent_amount ;
29
+ CAmount total_new_outputs_ex_coinbase_amount ;
30
+ CAmount total_coinbase_amount ;
31
+ CAmount total_unspendables_genesis_block ;
32
+ CAmount total_unspendables_bip30 ;
33
+ CAmount total_unspendables_scripts ;
34
+ CAmount total_unspendables_unclaimed_rewards ;
35
35
36
36
SERIALIZE_METHODS (DBVal, obj)
37
37
{
@@ -40,14 +40,14 @@ struct DBVal {
40
40
READWRITE (obj.bogo_size );
41
41
READWRITE (obj.total_amount );
42
42
READWRITE (obj.total_subsidy );
43
- READWRITE (obj.block_unspendable_amount );
44
- READWRITE (obj.block_prevout_spent_amount );
45
- READWRITE (obj.block_new_outputs_ex_coinbase_amount );
46
- READWRITE (obj.block_coinbase_amount );
47
- READWRITE (obj.unspendables_genesis_block );
48
- READWRITE (obj.unspendables_bip30 );
49
- READWRITE (obj.unspendables_scripts );
50
- READWRITE (obj.unspendables_unclaimed_rewards );
43
+ READWRITE (obj.total_unspendable_amount );
44
+ READWRITE (obj.total_prevout_spent_amount );
45
+ READWRITE (obj.total_new_outputs_ex_coinbase_amount );
46
+ READWRITE (obj.total_coinbase_amount );
47
+ READWRITE (obj.total_unspendables_genesis_block );
48
+ READWRITE (obj.total_unspendables_bip30 );
49
+ READWRITE (obj.total_unspendables_scripts );
50
+ READWRITE (obj.total_unspendables_unclaimed_rewards );
51
51
}
52
52
};
53
53
@@ -138,8 +138,8 @@ bool CoinStatsIndex::WriteBlock(const CBlock& block, const CBlockIndex* pindex)
138
138
139
139
// Skip duplicate txid coinbase transactions (BIP30).
140
140
if (is_bip30_block && tx->IsCoinBase ()) {
141
- m_block_unspendable_amount += block_subsidy;
142
- m_unspendables_bip30 += block_subsidy;
141
+ m_total_unspendable_amount += block_subsidy;
142
+ m_total_unspendables_bip30 += block_subsidy;
143
143
continue ;
144
144
}
145
145
@@ -150,17 +150,17 @@ bool CoinStatsIndex::WriteBlock(const CBlock& block, const CBlockIndex* pindex)
150
150
151
151
// Skip unspendable coins
152
152
if (coin.out .scriptPubKey .IsUnspendable ()) {
153
- m_block_unspendable_amount += coin.out .nValue ;
154
- m_unspendables_scripts += coin.out .nValue ;
153
+ m_total_unspendable_amount += coin.out .nValue ;
154
+ m_total_unspendables_scripts += coin.out .nValue ;
155
155
continue ;
156
156
}
157
157
158
158
m_muhash.Insert (MakeUCharSpan (TxOutSer (outpoint, coin)));
159
159
160
160
if (tx->IsCoinBase ()) {
161
- m_block_coinbase_amount += coin.out .nValue ;
161
+ m_total_coinbase_amount += coin.out .nValue ;
162
162
} else {
163
- m_block_new_outputs_ex_coinbase_amount += coin.out .nValue ;
163
+ m_total_new_outputs_ex_coinbase_amount += coin.out .nValue ;
164
164
}
165
165
166
166
++m_transaction_output_count;
@@ -178,7 +178,7 @@ bool CoinStatsIndex::WriteBlock(const CBlock& block, const CBlockIndex* pindex)
178
178
179
179
m_muhash.Remove (MakeUCharSpan (TxOutSer (outpoint, coin)));
180
180
181
- m_block_prevout_spent_amount += coin.out .nValue ;
181
+ m_total_prevout_spent_amount += coin.out .nValue ;
182
182
183
183
--m_transaction_output_count;
184
184
m_total_amount -= coin.out .nValue ;
@@ -188,32 +188,32 @@ bool CoinStatsIndex::WriteBlock(const CBlock& block, const CBlockIndex* pindex)
188
188
}
189
189
} else {
190
190
// genesis block
191
- m_block_unspendable_amount += block_subsidy;
192
- m_unspendables_genesis_block += block_subsidy;
191
+ m_total_unspendable_amount += block_subsidy;
192
+ m_total_unspendables_genesis_block += block_subsidy;
193
193
}
194
194
195
195
// If spent prevouts + block subsidy are still a higher amount than
196
196
// new outputs + coinbase + current unspendable amount this means
197
197
// the miner did not claim the full block reward. Unclaimed block
198
198
// rewards are also unspendable.
199
- const CAmount unclaimed_rewards{(m_block_prevout_spent_amount + m_total_subsidy) - (m_block_new_outputs_ex_coinbase_amount + m_block_coinbase_amount + m_block_unspendable_amount )};
200
- m_block_unspendable_amount += unclaimed_rewards;
201
- m_unspendables_unclaimed_rewards += unclaimed_rewards;
199
+ const CAmount unclaimed_rewards{(m_total_prevout_spent_amount + m_total_subsidy) - (m_total_new_outputs_ex_coinbase_amount + m_total_coinbase_amount + m_total_unspendable_amount )};
200
+ m_total_unspendable_amount += unclaimed_rewards;
201
+ m_total_unspendables_unclaimed_rewards += unclaimed_rewards;
202
202
203
203
std::pair<uint256, DBVal> value;
204
204
value.first = pindex->GetBlockHash ();
205
205
value.second .transaction_output_count = m_transaction_output_count;
206
206
value.second .bogo_size = m_bogo_size;
207
207
value.second .total_amount = m_total_amount;
208
208
value.second .total_subsidy = m_total_subsidy;
209
- value.second .block_unspendable_amount = m_block_unspendable_amount ;
210
- value.second .block_prevout_spent_amount = m_block_prevout_spent_amount ;
211
- value.second .block_new_outputs_ex_coinbase_amount = m_block_new_outputs_ex_coinbase_amount ;
212
- value.second .block_coinbase_amount = m_block_coinbase_amount ;
213
- value.second .unspendables_genesis_block = m_unspendables_genesis_block ;
214
- value.second .unspendables_bip30 = m_unspendables_bip30 ;
215
- value.second .unspendables_scripts = m_unspendables_scripts ;
216
- value.second .unspendables_unclaimed_rewards = m_unspendables_unclaimed_rewards ;
209
+ value.second .total_unspendable_amount = m_total_unspendable_amount ;
210
+ value.second .total_prevout_spent_amount = m_total_prevout_spent_amount ;
211
+ value.second .total_new_outputs_ex_coinbase_amount = m_total_new_outputs_ex_coinbase_amount ;
212
+ value.second .total_coinbase_amount = m_total_coinbase_amount ;
213
+ value.second .total_unspendables_genesis_block = m_total_unspendables_genesis_block ;
214
+ value.second .total_unspendables_bip30 = m_total_unspendables_bip30 ;
215
+ value.second .total_unspendables_scripts = m_total_unspendables_scripts ;
216
+ value.second .total_unspendables_unclaimed_rewards = m_total_unspendables_unclaimed_rewards ;
217
217
218
218
uint256 out;
219
219
m_muhash.Finalize (out);
@@ -317,14 +317,14 @@ bool CoinStatsIndex::LookUpStats(const CBlockIndex* block_index, CCoinsStats& co
317
317
coins_stats.nBogoSize = entry.bogo_size ;
318
318
coins_stats.nTotalAmount = entry.total_amount ;
319
319
coins_stats.total_subsidy = entry.total_subsidy ;
320
- coins_stats.block_unspendable_amount = entry.block_unspendable_amount ;
321
- coins_stats.block_prevout_spent_amount = entry.block_prevout_spent_amount ;
322
- coins_stats.block_new_outputs_ex_coinbase_amount = entry.block_new_outputs_ex_coinbase_amount ;
323
- coins_stats.block_coinbase_amount = entry.block_coinbase_amount ;
324
- coins_stats.unspendables_genesis_block = entry.unspendables_genesis_block ;
325
- coins_stats.unspendables_bip30 = entry.unspendables_bip30 ;
326
- coins_stats.unspendables_scripts = entry.unspendables_scripts ;
327
- coins_stats.unspendables_unclaimed_rewards = entry.unspendables_unclaimed_rewards ;
320
+ coins_stats.total_unspendable_amount = entry.total_unspendable_amount ;
321
+ coins_stats.total_prevout_spent_amount = entry.total_prevout_spent_amount ;
322
+ coins_stats.total_new_outputs_ex_coinbase_amount = entry.total_new_outputs_ex_coinbase_amount ;
323
+ coins_stats.total_coinbase_amount = entry.total_coinbase_amount ;
324
+ coins_stats.total_unspendables_genesis_block = entry.total_unspendables_genesis_block ;
325
+ coins_stats.total_unspendables_bip30 = entry.total_unspendables_bip30 ;
326
+ coins_stats.total_unspendables_scripts = entry.total_unspendables_scripts ;
327
+ coins_stats.total_unspendables_unclaimed_rewards = entry.total_unspendables_unclaimed_rewards ;
328
328
329
329
return true ;
330
330
}
@@ -354,14 +354,14 @@ bool CoinStatsIndex::Init()
354
354
m_bogo_size = entry.bogo_size ;
355
355
m_total_amount = entry.total_amount ;
356
356
m_total_subsidy = entry.total_subsidy ;
357
- m_block_unspendable_amount = entry.block_unspendable_amount ;
358
- m_block_prevout_spent_amount = entry.block_prevout_spent_amount ;
359
- m_block_new_outputs_ex_coinbase_amount = entry.block_new_outputs_ex_coinbase_amount ;
360
- m_block_coinbase_amount = entry.block_coinbase_amount ;
361
- m_unspendables_genesis_block = entry.unspendables_genesis_block ;
362
- m_unspendables_bip30 = entry.unspendables_bip30 ;
363
- m_unspendables_scripts = entry.unspendables_scripts ;
364
- m_unspendables_unclaimed_rewards = entry.unspendables_unclaimed_rewards ;
357
+ m_total_unspendable_amount = entry.total_unspendable_amount ;
358
+ m_total_prevout_spent_amount = entry.total_prevout_spent_amount ;
359
+ m_total_new_outputs_ex_coinbase_amount = entry.total_new_outputs_ex_coinbase_amount ;
360
+ m_total_coinbase_amount = entry.total_coinbase_amount ;
361
+ m_total_unspendables_genesis_block = entry.total_unspendables_genesis_block ;
362
+ m_total_unspendables_bip30 = entry.total_unspendables_bip30 ;
363
+ m_total_unspendables_scripts = entry.total_unspendables_scripts ;
364
+ m_total_unspendables_unclaimed_rewards = entry.total_unspendables_unclaimed_rewards ;
365
365
}
366
366
367
367
return true ;
@@ -409,17 +409,17 @@ bool CoinStatsIndex::ReverseBlock(const CBlock& block, const CBlockIndex* pindex
409
409
410
410
// Skip unspendable coins
411
411
if (coin.out .scriptPubKey .IsUnspendable ()) {
412
- m_block_unspendable_amount -= coin.out .nValue ;
413
- m_unspendables_scripts -= coin.out .nValue ;
412
+ m_total_unspendable_amount -= coin.out .nValue ;
413
+ m_total_unspendables_scripts -= coin.out .nValue ;
414
414
continue ;
415
415
}
416
416
417
417
m_muhash.Remove (MakeUCharSpan (TxOutSer (outpoint, coin)));
418
418
419
419
if (tx->IsCoinBase ()) {
420
- m_block_coinbase_amount -= coin.out .nValue ;
420
+ m_total_coinbase_amount -= coin.out .nValue ;
421
421
} else {
422
- m_block_new_outputs_ex_coinbase_amount -= coin.out .nValue ;
422
+ m_total_new_outputs_ex_coinbase_amount -= coin.out .nValue ;
423
423
}
424
424
425
425
--m_transaction_output_count;
@@ -437,7 +437,7 @@ bool CoinStatsIndex::ReverseBlock(const CBlock& block, const CBlockIndex* pindex
437
437
438
438
m_muhash.Insert (MakeUCharSpan (TxOutSer (outpoint, coin)));
439
439
440
- m_block_prevout_spent_amount -= coin.out .nValue ;
440
+ m_total_prevout_spent_amount -= coin.out .nValue ;
441
441
442
442
m_transaction_output_count++;
443
443
m_total_amount += coin.out .nValue ;
@@ -446,9 +446,9 @@ bool CoinStatsIndex::ReverseBlock(const CBlock& block, const CBlockIndex* pindex
446
446
}
447
447
}
448
448
449
- const CAmount unclaimed_rewards{(m_block_new_outputs_ex_coinbase_amount + m_block_coinbase_amount + m_block_unspendable_amount ) - (m_block_prevout_spent_amount + m_total_subsidy)};
450
- m_block_unspendable_amount -= unclaimed_rewards;
451
- m_unspendables_unclaimed_rewards -= unclaimed_rewards;
449
+ const CAmount unclaimed_rewards{(m_total_new_outputs_ex_coinbase_amount + m_total_coinbase_amount + m_total_unspendable_amount ) - (m_total_prevout_spent_amount + m_total_subsidy)};
450
+ m_total_unspendable_amount -= unclaimed_rewards;
451
+ m_total_unspendables_unclaimed_rewards -= unclaimed_rewards;
452
452
453
453
// Check that the rolled back internal values are consistent with the DB read out
454
454
uint256 out;
@@ -459,14 +459,14 @@ bool CoinStatsIndex::ReverseBlock(const CBlock& block, const CBlockIndex* pindex
459
459
Assert (m_total_amount == read_out.second .total_amount );
460
460
Assert (m_bogo_size == read_out.second .bogo_size );
461
461
Assert (m_total_subsidy == read_out.second .total_subsidy );
462
- Assert (m_block_unspendable_amount == read_out.second .block_unspendable_amount );
463
- Assert (m_block_prevout_spent_amount == read_out.second .block_prevout_spent_amount );
464
- Assert (m_block_new_outputs_ex_coinbase_amount == read_out.second .block_new_outputs_ex_coinbase_amount );
465
- Assert (m_block_coinbase_amount == read_out.second .block_coinbase_amount );
466
- Assert (m_unspendables_genesis_block == read_out.second .unspendables_genesis_block );
467
- Assert (m_unspendables_bip30 == read_out.second .unspendables_bip30 );
468
- Assert (m_unspendables_scripts == read_out.second .unspendables_scripts );
469
- Assert (m_unspendables_unclaimed_rewards == read_out.second .unspendables_unclaimed_rewards );
462
+ Assert (m_total_unspendable_amount == read_out.second .total_unspendable_amount );
463
+ Assert (m_total_prevout_spent_amount == read_out.second .total_prevout_spent_amount );
464
+ Assert (m_total_new_outputs_ex_coinbase_amount == read_out.second .total_new_outputs_ex_coinbase_amount );
465
+ Assert (m_total_coinbase_amount == read_out.second .total_coinbase_amount );
466
+ Assert (m_total_unspendables_genesis_block == read_out.second .total_unspendables_genesis_block );
467
+ Assert (m_total_unspendables_bip30 == read_out.second .total_unspendables_bip30 );
468
+ Assert (m_total_unspendables_scripts == read_out.second .total_unspendables_scripts );
469
+ Assert (m_total_unspendables_unclaimed_rewards == read_out.second .total_unspendables_unclaimed_rewards );
470
470
471
471
return m_db->Write (DB_MUHASH, m_muhash);
472
472
}
0 commit comments