@@ -97,6 +97,7 @@ struct COrphanTx {
97
97
map<uint256, COrphanTx> mapOrphanTransactions;
98
98
map<uint256, set<uint256> > mapOrphanTransactionsByPrev;
99
99
map<uint256, int64_t > mapRejectedBlocks;
100
+ map<uint256, int64_t > mapZerocoinspends; // txid, time received
100
101
101
102
102
103
void EraseOrphansFor (NodeId peer);
@@ -1822,6 +1823,10 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState& state, const CTransa
1822
1823
1823
1824
SyncWithWallets (tx, NULL );
1824
1825
1826
+ // Track zerocoinspends and ensure that they are given priority to make it into the blockchain
1827
+ if (tx.IsZerocoinSpend ())
1828
+ mapZerocoinspends[tx.GetHash ()] = GetAdjustedTime ();
1829
+
1825
1830
return true ;
1826
1831
}
1827
1832
@@ -3340,6 +3345,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
3340
3345
CAmount nValueOut = 0 ;
3341
3346
CAmount nValueIn = 0 ;
3342
3347
unsigned int nMaxBlockSigOps = MAX_BLOCK_SIGOPS_CURRENT;
3348
+ vector<uint256> vSpendsInBlock;
3343
3349
for (unsigned int i = 0 ; i < block.vtx .size (); i++) {
3344
3350
const CTransaction& tx = block.vtx [i];
3345
3351
@@ -3355,7 +3361,9 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
3355
3361
}
3356
3362
if (tx.IsZerocoinSpend ()) {
3357
3363
int nHeightTx = 0 ;
3358
- if (IsTransactionInChain (tx.GetHash (), nHeightTx)) {
3364
+ uint256 txid = tx.GetHash ();
3365
+ vSpendsInBlock.emplace_back (txid);
3366
+ if (IsTransactionInChain (txid, nHeightTx)) {
3359
3367
// when verifying blocks on init, the blocks are scanned without being disconnected - prevent that from causing an error
3360
3368
if (!fVerifyingBlocks || (fVerifyingBlocks && pindex->nHeight > nHeightTx))
3361
3369
return state.DoS (100 , error (" %s : txid %s already exists in block %d , trying to include it again in block %d" , __func__,
@@ -3600,6 +3608,13 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
3600
3608
if (pindex->nHeight >= Params ().Zerocoin_Block_FirstFraudulent () && pindex->nHeight <= Params ().Zerocoin_Block_RecalculateAccumulators () + 1 )
3601
3609
AddInvalidSpendsToMap (block);
3602
3610
3611
+ // Remove zerocoinspends from the pending map
3612
+ for (const uint256& txid : vSpendsInBlock) {
3613
+ auto it = mapZerocoinspends.find (txid);
3614
+ if (it != mapZerocoinspends.end ())
3615
+ mapZerocoinspends.erase (it);
3616
+ }
3617
+
3603
3618
return true ;
3604
3619
}
3605
3620
0 commit comments