Skip to content

Commit 6cc0d44

Browse files
committed
squash: use activation state for utxo hasher
1 parent baaf905 commit 6cc0d44

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

divi/src/UtxoCheckingAndUpdating.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ extern BlockMap mapBlockIndex;
1616

1717
uint256 TransactionUtxoHasher::GetUtxoHash(const CTransaction& tx) const
1818
{
19+
if (as.IsActive(Fork::SegwitLight))
20+
return tx.GetBareTxid();
1921
return tx.GetHash();
2022
}
2123

divi/src/UtxoCheckingAndUpdating.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,16 @@ class uint256;
2222
class TransactionUtxoHasher
2323
{
2424

25+
private:
26+
27+
const ActivationState& as;
28+
2529
public:
2630

27-
TransactionUtxoHasher() = default;
31+
explicit TransactionUtxoHasher(const ActivationState& a)
32+
: as(a)
33+
{}
34+
2835
virtual ~TransactionUtxoHasher() = default;
2936

3037
TransactionUtxoHasher(const TransactionUtxoHasher&) = delete;

divi/src/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,7 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex
13731373
std::vector<std::pair<CSpentIndexKey, CSpentIndexValue> > spentIndex;
13741374

13751375
const ActivationState as(pindex);
1376-
const TransactionUtxoHasher utxoHasher;
1376+
const TransactionUtxoHasher utxoHasher(as);
13771377

13781378
// undo transactions in reverse order
13791379
for (int i = block.vtx.size() - 1; i >= 0; i--) {
@@ -1619,7 +1619,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
16191619
unsigned int nMaxBlockSigOps = MAX_BLOCK_SIGOPS_CURRENT;
16201620

16211621
const ActivationState as(pindex);
1622-
const TransactionUtxoHasher utxoHasher;
1622+
const TransactionUtxoHasher utxoHasher(as);
16231623
static const CChainParams& chainParameters = Params();
16241624
static const SuperblockSubsidyContainer subsidiesContainer(chainParameters);
16251625
static const BlockIncentivesPopulator incentives(
@@ -3275,7 +3275,7 @@ bool static LoadBlockIndexDB(string& strError)
32753275
return false;
32763276
}
32773277
const ActivationState as(block);
3278-
const TransactionUtxoHasher utxoHasher;
3278+
const TransactionUtxoHasher utxoHasher(as);
32793279

32803280
std::vector<CTxUndo> vtxundo;
32813281
vtxundo.reserve(block.vtx.size() - 1);

divi/src/txmempool.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ void CTxMemPool::remove(const CTransaction& origTx, std::list<CTransaction>& rem
572572
{
573573
LOCK(cs);
574574
const ActivationState as(chainActive.Tip());
575-
const TransactionUtxoHasher utxoHasher;
575+
const TransactionUtxoHasher utxoHasher(as);
576576
std::deque<uint256> txToRemove;
577577
txToRemove.push_back(origTx.GetHash());
578578
if (fRecursive && !mapTx.count(origTx.GetHash())) {
@@ -698,7 +698,7 @@ void CTxMemPool::check(const CCoinsViewCache* pcoins) const
698698
CCoinsViewCache mempoolDuplicate(const_cast<CCoinsViewCache*>(pcoins));
699699

700700
const ActivationState as(chainActive.Tip());
701-
const TransactionUtxoHasher utxoHasher;
701+
const TransactionUtxoHasher utxoHasher(as);
702702

703703
LOCK(cs);
704704
list<const CTxMemPoolEntry*> waitingOnDependants;
@@ -797,7 +797,7 @@ bool CTxMemPool::lookupOutpoint(const uint256& hash, CTransaction& result) const
797797
mempool is not allowed in a time window "around" the fork, so that
798798
this should be good enough. */
799799
const ActivationState as(chainActive.Tip());
800-
const TransactionUtxoHasher utxoHasher;
800+
const TransactionUtxoHasher utxoHasher(as);
801801

802802
/* The TransactionUtxoHasher can only tell us the txid to use once we
803803
know the transaction already. Thus we check both txid and bare txid

0 commit comments

Comments
 (0)