@@ -415,46 +415,8 @@ void CTxMemPool::addUnchecked(const CTxMemPoolEntry &entry, setEntries &setAnces
415
415
// Invalid ProTxes should never get this far because transactions should be
416
416
// fully checked by AcceptToMemoryPool() at this point, so we just assume that
417
417
// everything is fine here.
418
- if (tx.nType == TRANSACTION_PROVIDER_REGISTER) {
419
- auto proTx = *Assert (GetTxPayload<CProRegTx>(tx));
420
- if (!proTx.collateralOutpoint .hash .IsNull ()) {
421
- mapProTxRefs.emplace (tx.GetHash (), proTx.collateralOutpoint .hash );
422
- }
423
- mapProTxAddresses.emplace (proTx.addr , tx.GetHash ());
424
- mapProTxPubKeyIDs.emplace (proTx.keyIDOwner , tx.GetHash ());
425
- mapProTxBlsPubKeyHashes.emplace (proTx.pubKeyOperator .GetHash (), tx.GetHash ());
426
- if (!proTx.collateralOutpoint .hash .IsNull ()) {
427
- mapProTxCollaterals.emplace (proTx.collateralOutpoint , tx.GetHash ());
428
- } else {
429
- mapProTxCollaterals.emplace (COutPoint (tx.GetHash (), proTx.collateralOutpoint .n ), tx.GetHash ());
430
- }
431
- } else if (tx.nType == TRANSACTION_PROVIDER_UPDATE_SERVICE) {
432
- auto proTx = *Assert (GetTxPayload<CProUpServTx>(tx));
433
- mapProTxRefs.emplace (proTx.proTxHash , tx.GetHash ());
434
- mapProTxAddresses.emplace (proTx.addr , tx.GetHash ());
435
- } else if (tx.nType == TRANSACTION_PROVIDER_UPDATE_REGISTRAR) {
436
- auto proTx = *Assert (GetTxPayload<CProUpRegTx>(tx));
437
- mapProTxRefs.emplace (proTx.proTxHash , tx.GetHash ());
438
- mapProTxBlsPubKeyHashes.emplace (proTx.pubKeyOperator .GetHash (), tx.GetHash ());
439
- auto dmn = Assert (deterministicMNManager->GetListAtChainTip ().GetMN (proTx.proTxHash ));
440
- newit->validForProTxKey = ::SerializeHash (dmn->pdmnState ->pubKeyOperator );
441
- if (dmn->pdmnState ->pubKeyOperator != proTx.pubKeyOperator ) {
442
- newit->isKeyChangeProTx = true ;
443
- }
444
- } else if (tx.nType == TRANSACTION_PROVIDER_UPDATE_REVOKE) {
445
- auto proTx = *Assert (GetTxPayload<CProUpRevTx>(tx));
446
- mapProTxRefs.emplace (proTx.proTxHash , tx.GetHash ());
447
- auto dmn = deterministicMNManager->GetListAtChainTip ().GetMN (proTx.proTxHash );
448
- assert (dmn);
449
- newit->validForProTxKey = ::SerializeHash (dmn->pdmnState ->pubKeyOperator );
450
- if (dmn->pdmnState ->pubKeyOperator .Get () != CBLSPublicKey ()) {
451
- newit->isKeyChangeProTx = true ;
452
- }
453
- } else if (tx.nType == TRANSACTION_ASSET_UNLOCK) {
454
- auto assetUnlockTx = *Assert (GetTxPayload<CAssetUnlockPayload>(tx));
455
- mapAssetUnlockExpiry.insert ({tx.GetHash (), assetUnlockTx.getHeightToExpiry ()});
456
- } else if (tx.nType == TRANSACTION_MNHF_SIGNAL) {
457
- PrioritiseTransaction (tx.GetHash (), 0.1 * COIN);
418
+ if (::deterministicMNManager) {
419
+ addUncheckedProTx (newit, tx);
458
420
}
459
421
}
460
422
@@ -590,6 +552,52 @@ bool CTxMemPool::removeSpentIndex(const uint256 txhash)
590
552
return true ;
591
553
}
592
554
555
+ void CTxMemPool::addUncheckedProTx (indexed_transaction_set::iterator& newit, const CTransaction& tx)
556
+ {
557
+ assert (::deterministicMNManager);
558
+
559
+ if (tx.nType == TRANSACTION_PROVIDER_REGISTER) {
560
+ auto proTx = *Assert (GetTxPayload<CProRegTx>(tx));
561
+ if (!proTx.collateralOutpoint .hash .IsNull ()) {
562
+ mapProTxRefs.emplace (tx.GetHash (), proTx.collateralOutpoint .hash );
563
+ }
564
+ mapProTxAddresses.emplace (proTx.addr , tx.GetHash ());
565
+ mapProTxPubKeyIDs.emplace (proTx.keyIDOwner , tx.GetHash ());
566
+ mapProTxBlsPubKeyHashes.emplace (proTx.pubKeyOperator .GetHash (), tx.GetHash ());
567
+ if (!proTx.collateralOutpoint .hash .IsNull ()) {
568
+ mapProTxCollaterals.emplace (proTx.collateralOutpoint , tx.GetHash ());
569
+ } else {
570
+ mapProTxCollaterals.emplace (COutPoint (tx.GetHash (), proTx.collateralOutpoint .n ), tx.GetHash ());
571
+ }
572
+ } else if (tx.nType == TRANSACTION_PROVIDER_UPDATE_SERVICE) {
573
+ auto proTx = *Assert (GetTxPayload<CProUpServTx>(tx));
574
+ mapProTxRefs.emplace (proTx.proTxHash , tx.GetHash ());
575
+ mapProTxAddresses.emplace (proTx.addr , tx.GetHash ());
576
+ } else if (tx.nType == TRANSACTION_PROVIDER_UPDATE_REGISTRAR) {
577
+ auto proTx = *Assert (GetTxPayload<CProUpRegTx>(tx));
578
+ mapProTxRefs.emplace (proTx.proTxHash , tx.GetHash ());
579
+ mapProTxBlsPubKeyHashes.emplace (proTx.pubKeyOperator .GetHash (), tx.GetHash ());
580
+ auto dmn = Assert (deterministicMNManager->GetListAtChainTip ().GetMN (proTx.proTxHash ));
581
+ newit->validForProTxKey = ::SerializeHash (dmn->pdmnState ->pubKeyOperator );
582
+ if (dmn->pdmnState ->pubKeyOperator != proTx.pubKeyOperator ) {
583
+ newit->isKeyChangeProTx = true ;
584
+ }
585
+ } else if (tx.nType == TRANSACTION_PROVIDER_UPDATE_REVOKE) {
586
+ auto proTx = *Assert (GetTxPayload<CProUpRevTx>(tx));
587
+ mapProTxRefs.emplace (proTx.proTxHash , tx.GetHash ());
588
+ auto dmn = Assert (deterministicMNManager->GetListAtChainTip ().GetMN (proTx.proTxHash ));
589
+ newit->validForProTxKey = ::SerializeHash (dmn->pdmnState ->pubKeyOperator );
590
+ if (dmn->pdmnState ->pubKeyOperator .Get () != CBLSPublicKey ()) {
591
+ newit->isKeyChangeProTx = true ;
592
+ }
593
+ } else if (tx.nType == TRANSACTION_ASSET_UNLOCK) {
594
+ auto assetUnlockTx = *Assert (GetTxPayload<CAssetUnlockPayload>(tx));
595
+ mapAssetUnlockExpiry.insert ({tx.GetHash (), assetUnlockTx.getHeightToExpiry ()});
596
+ } else if (tx.nType == TRANSACTION_MNHF_SIGNAL) {
597
+ PrioritiseTransaction (tx.GetHash (), 0.1 * COIN);
598
+ }
599
+ }
600
+
593
601
void CTxMemPool::removeUnchecked (txiter it, MemPoolRemovalReason reason)
594
602
{
595
603
if (reason != MemPoolRemovalReason::BLOCK) {
@@ -615,6 +623,23 @@ void CTxMemPool::removeUnchecked(txiter it, MemPoolRemovalReason reason)
615
623
} else
616
624
vTxHashes.clear ();
617
625
626
+ if (::deterministicMNManager) {
627
+ removeUncheckedProTx (it->GetTx ());
628
+ }
629
+
630
+ totalTxSize -= it->GetTxSize ();
631
+ m_total_fee -= it->GetFee ();
632
+ cachedInnerUsage -= it->DynamicMemoryUsage ();
633
+ cachedInnerUsage -= memusage::DynamicUsage (it->GetMemPoolParentsConst ()) + memusage::DynamicUsage (it->GetMemPoolChildrenConst ());
634
+ mapTx.erase (it);
635
+ nTransactionsUpdated++;
636
+ if (minerPolicyEstimator) {minerPolicyEstimator->removeTx (hash, false );}
637
+ removeAddressIndex (hash);
638
+ removeSpentIndex (hash);
639
+ }
640
+
641
+ void CTxMemPool::removeUncheckedProTx (const CTransaction& tx)
642
+ {
618
643
auto eraseProTxRef = [&](const uint256& proTxHash, const uint256& txHash) {
619
644
auto its = mapProTxRefs.equal_range (proTxHash);
620
645
for (auto it = its.first ; it != its.second ;) {
@@ -626,40 +651,30 @@ void CTxMemPool::removeUnchecked(txiter it, MemPoolRemovalReason reason)
626
651
}
627
652
};
628
653
629
- if (it-> GetTx () .nType == TRANSACTION_PROVIDER_REGISTER) {
630
- auto proTx = *Assert (GetTxPayload<CProRegTx>(it-> GetTx () ));
654
+ if (tx .nType == TRANSACTION_PROVIDER_REGISTER) {
655
+ auto proTx = *Assert (GetTxPayload<CProRegTx>(tx ));
631
656
if (!proTx.collateralOutpoint .IsNull ()) {
632
- eraseProTxRef (it-> GetTx () .GetHash (), proTx.collateralOutpoint .hash );
657
+ eraseProTxRef (tx .GetHash (), proTx.collateralOutpoint .hash );
633
658
}
634
659
mapProTxAddresses.erase (proTx.addr );
635
660
mapProTxPubKeyIDs.erase (proTx.keyIDOwner );
636
661
mapProTxBlsPubKeyHashes.erase (proTx.pubKeyOperator .GetHash ());
637
662
mapProTxCollaterals.erase (proTx.collateralOutpoint );
638
- mapProTxCollaterals.erase (COutPoint (it-> GetTx () .GetHash (), proTx.collateralOutpoint .n ));
639
- } else if (it-> GetTx () .nType == TRANSACTION_PROVIDER_UPDATE_SERVICE) {
640
- auto proTx = *Assert (GetTxPayload<CProUpServTx>(it-> GetTx () ));
641
- eraseProTxRef (proTx.proTxHash , it-> GetTx () .GetHash ());
663
+ mapProTxCollaterals.erase (COutPoint (tx .GetHash (), proTx.collateralOutpoint .n ));
664
+ } else if (tx .nType == TRANSACTION_PROVIDER_UPDATE_SERVICE) {
665
+ auto proTx = *Assert (GetTxPayload<CProUpServTx>(tx ));
666
+ eraseProTxRef (proTx.proTxHash , tx .GetHash ());
642
667
mapProTxAddresses.erase (proTx.addr );
643
- } else if (it-> GetTx () .nType == TRANSACTION_PROVIDER_UPDATE_REGISTRAR) {
644
- auto proTx = *Assert (GetTxPayload<CProUpRegTx>(it-> GetTx () ));
645
- eraseProTxRef (proTx.proTxHash , it-> GetTx () .GetHash ());
668
+ } else if (tx .nType == TRANSACTION_PROVIDER_UPDATE_REGISTRAR) {
669
+ auto proTx = *Assert (GetTxPayload<CProUpRegTx>(tx ));
670
+ eraseProTxRef (proTx.proTxHash , tx .GetHash ());
646
671
mapProTxBlsPubKeyHashes.erase (proTx.pubKeyOperator .GetHash ());
647
- } else if (it-> GetTx () .nType == TRANSACTION_PROVIDER_UPDATE_REVOKE) {
648
- auto proTx = *Assert (GetTxPayload<CProUpRevTx>(it-> GetTx () ));
649
- eraseProTxRef (proTx.proTxHash , it-> GetTx () .GetHash ());
650
- } else if (it-> GetTx () .nType == TRANSACTION_ASSET_UNLOCK) {
651
- mapAssetUnlockExpiry.erase (it-> GetTx () .GetHash ());
672
+ } else if (tx .nType == TRANSACTION_PROVIDER_UPDATE_REVOKE) {
673
+ auto proTx = *Assert (GetTxPayload<CProUpRevTx>(tx ));
674
+ eraseProTxRef (proTx.proTxHash , tx .GetHash ());
675
+ } else if (tx .nType == TRANSACTION_ASSET_UNLOCK) {
676
+ mapAssetUnlockExpiry.erase (tx .GetHash ());
652
677
}
653
-
654
- totalTxSize -= it->GetTxSize ();
655
- m_total_fee -= it->GetFee ();
656
- cachedInnerUsage -= it->DynamicMemoryUsage ();
657
- cachedInnerUsage -= memusage::DynamicUsage (it->GetMemPoolParentsConst ()) + memusage::DynamicUsage (it->GetMemPoolChildrenConst ());
658
- mapTx.erase (it);
659
- nTransactionsUpdated++;
660
- if (minerPolicyEstimator) {minerPolicyEstimator->removeTx (hash, false );}
661
- removeAddressIndex (hash);
662
- removeSpentIndex (hash);
663
678
}
664
679
665
680
// Calculates descendants of entry that are not already in setDescendants, and adds to
@@ -829,6 +844,8 @@ void CTxMemPool::removeProTxCollateralConflicts(const CTransaction &tx, const CO
829
844
830
845
void CTxMemPool::removeProTxSpentCollateralConflicts (const CTransaction &tx)
831
846
{
847
+ assert (::deterministicMNManager);
848
+
832
849
// Remove TXs that refer to a MN for which the collateral was spent
833
850
auto removeSpentCollateralConflict = [&](const uint256& proTxHash) {
834
851
// Can't use equal_range here as every call to removeRecursive might invalidate iterators
@@ -966,7 +983,9 @@ void CTxMemPool::removeForBlock(const std::vector<CTransactionRef>& vtx, unsigne
966
983
RemoveStaged (stage, true , MemPoolRemovalReason::BLOCK);
967
984
}
968
985
removeConflicts (*tx);
969
- removeProTxConflicts (*tx);
986
+ if (::deterministicMNManager) {
987
+ removeProTxConflicts (*tx);
988
+ }
970
989
ClearPrioritisation (tx->GetHash ());
971
990
}
972
991
lastRollingFeeUpdate = GetTime ();
@@ -1240,6 +1259,8 @@ TxMempoolInfo CTxMemPool::info(const uint256& hash) const
1240
1259
}
1241
1260
1242
1261
bool CTxMemPool::existsProviderTxConflict (const CTransaction &tx) const {
1262
+ assert (::deterministicMNManager);
1263
+
1243
1264
LOCK (cs);
1244
1265
1245
1266
auto hasKeyChangeInMempool = [&](const uint256& proTxHash) {
0 commit comments