File tree 3 files changed +18
-11
lines changed
3 files changed +18
-11
lines changed Original file line number Diff line number Diff line change 31
31
#include < util/signalinterrupt.h>
32
32
#include < util/task_runner.h>
33
33
#include < util/translation.h>
34
+ #include < undo.h>
34
35
#include < validation.h>
35
36
#include < validationinterface.h>
36
37
@@ -171,16 +172,19 @@ int main(int argc, char* argv[])
171
172
LOCK (chainman.GetMutex ());
172
173
current_block = chainman.ActiveChain ()[block_height];
173
174
}
174
- CCoinsViewCache &view = chainman.ActiveChainstate ().CoinsTip ();
175
175
std::cout << " AFTER VIEW" << std::endl;
176
176
std::cout << " BEFORE LOOP" << std::endl;
177
177
178
178
while (current_block) {
179
179
std::cout << " TEST" << std::endl;
180
180
181
181
CBlock block;
182
- chainman.m_blockman .ReadBlockFromDisk (block, *current_block);
183
- CFeeRate fee_rate = GetMedianFeeRateFromBlock (block, view);
182
+ CBlockUndo undo;
183
+ bool read_success = false ;
184
+ read_success = chainman.m_blockman .ReadBlockFromDisk (block, *current_block);
185
+ read_success &= chainman.m_blockman .UndoReadFromDisk (undo, *current_block);
186
+ assert (read_success);
187
+ CFeeRate fee_rate = GetMedianFeeRateFromBlock (block, undo);
184
188
// the get feerate function
185
189
186
190
for (const CTransactionRef& tx : block.vtx ) {
Original file line number Diff line number Diff line change 6
6
#include < coins.h>
7
7
#include < consensus/validation.h>
8
8
#include < util/coinjoins.h>
9
+ #include < undo.h>
9
10
10
11
bool WhirlpoolTransactions::isWhirlpool (const CTransactionRef& tx) {
11
12
if (tx->vin .size () == 5 && tx->vout .size () == 5 ) {
@@ -29,15 +30,17 @@ bool WhirlpoolTransactions::isWhirlpool(const CTransactionRef& tx) {
29
30
return false ;
30
31
}
31
32
32
- CFeeRate GetMedianFeeRateFromBlock (const CBlock& block, CCoinsViewCache &view ) {
33
+ CFeeRate GetMedianFeeRateFromBlock (const CBlock& block, const CBlockUndo &undo ) {
33
34
// calculate median fee rate
34
35
std::vector<CFeeRate> feeRates;
35
- for (const auto & tx : block.vtx ) {
36
+ // Skip coinbase
37
+ for (size_t txindex = 1 ; txindex < block.vtx .size (); txindex++) {
38
+ const auto & tx = block.vtx [txindex];
39
+ // vtxundo is offset by 1 because the coinbase tx is not present.
40
+ const auto & undotx = undo.vtxundo [txindex - 1 ];
36
41
CAmount value_in = 0 ;
37
- for (auto &v : tx->vin ) {
38
- const COutPoint &prevout = v.prevout ;
39
- const Coin& coin = view.AccessCoin (prevout);
40
- value_in += coin.out .nValue ;
42
+ for (const auto & prevout : undotx.vprevout ) {
43
+ value_in += prevout.out .nValue ;
41
44
}
42
45
CAmount value_out = tx->GetValueOut ();
43
46
size_t txSize = GetTransactionWeight (*tx);
Original file line number Diff line number Diff line change @@ -55,8 +55,8 @@ class Tx0s {
55
55
return tx0_set.size ();
56
56
}
57
57
};
58
-
59
- CFeeRate GetMedianFeeRateFromBlock (const CBlock& block, CCoinsViewCache &view );
58
+ class CBlockUndo ;
59
+ CFeeRate GetMedianFeeRateFromBlock (const CBlock& block, const CBlockUndo& undo );
60
60
61
61
class WhirlpoolTransactions {
62
62
Tx0s tx0s;
You can’t perform that action at this time.
0 commit comments