@@ -347,6 +347,13 @@ CTxMemPool::CTxMemPool(CBlockPolicyEstimator* estimator, int check_ratio)
347
347
_clear (); // lock free clear
348
348
}
349
349
350
+ void CTxMemPool::ConnectManagers (CDeterministicMNManager* dmnman)
351
+ {
352
+ // Do not allow double-initialization
353
+ assert (m_dmnman == nullptr );
354
+ m_dmnman = Assert (dmnman);
355
+ }
356
+
350
357
bool CTxMemPool::isSpent (const COutPoint& outpoint) const
351
358
{
352
359
LOCK (cs);
@@ -415,7 +422,7 @@ void CTxMemPool::addUnchecked(const CTxMemPoolEntry &entry, setEntries &setAnces
415
422
// Invalid ProTxes should never get this far because transactions should be
416
423
// fully checked by AcceptToMemoryPool() at this point, so we just assume that
417
424
// everything is fine here.
418
- if (::deterministicMNManager ) {
425
+ if (m_dmnman ) {
419
426
addUncheckedProTx (newit, tx);
420
427
}
421
428
}
@@ -554,7 +561,7 @@ bool CTxMemPool::removeSpentIndex(const uint256 txhash)
554
561
555
562
void CTxMemPool::addUncheckedProTx (indexed_transaction_set::iterator& newit, const CTransaction& tx)
556
563
{
557
- assert (::deterministicMNManager );
564
+ assert (m_dmnman );
558
565
559
566
if (tx.nType == TRANSACTION_PROVIDER_REGISTER) {
560
567
auto proTx = *Assert (GetTxPayload<CProRegTx>(tx));
@@ -577,15 +584,15 @@ void CTxMemPool::addUncheckedProTx(indexed_transaction_set::iterator& newit, con
577
584
auto proTx = *Assert (GetTxPayload<CProUpRegTx>(tx));
578
585
mapProTxRefs.emplace (proTx.proTxHash , tx.GetHash ());
579
586
mapProTxBlsPubKeyHashes.emplace (proTx.pubKeyOperator .GetHash (), tx.GetHash ());
580
- auto dmn = Assert (deterministicMNManager ->GetListAtChainTip ().GetMN (proTx.proTxHash ));
587
+ auto dmn = Assert (m_dmnman ->GetListAtChainTip ().GetMN (proTx.proTxHash ));
581
588
newit->validForProTxKey = ::SerializeHash (dmn->pdmnState ->pubKeyOperator );
582
589
if (dmn->pdmnState ->pubKeyOperator != proTx.pubKeyOperator ) {
583
590
newit->isKeyChangeProTx = true ;
584
591
}
585
592
} else if (tx.nType == TRANSACTION_PROVIDER_UPDATE_REVOKE) {
586
593
auto proTx = *Assert (GetTxPayload<CProUpRevTx>(tx));
587
594
mapProTxRefs.emplace (proTx.proTxHash , tx.GetHash ());
588
- auto dmn = Assert (deterministicMNManager ->GetListAtChainTip ().GetMN (proTx.proTxHash ));
595
+ auto dmn = Assert (m_dmnman ->GetListAtChainTip ().GetMN (proTx.proTxHash ));
589
596
newit->validForProTxKey = ::SerializeHash (dmn->pdmnState ->pubKeyOperator );
590
597
if (dmn->pdmnState ->pubKeyOperator .Get () != CBLSPublicKey ()) {
591
598
newit->isKeyChangeProTx = true ;
@@ -623,7 +630,7 @@ void CTxMemPool::removeUnchecked(txiter it, MemPoolRemovalReason reason)
623
630
} else
624
631
vTxHashes.clear ();
625
632
626
- if (::deterministicMNManager ) {
633
+ if (m_dmnman ) {
627
634
removeUncheckedProTx (it->GetTx ());
628
635
}
629
636
@@ -844,7 +851,7 @@ void CTxMemPool::removeProTxCollateralConflicts(const CTransaction &tx, const CO
844
851
845
852
void CTxMemPool::removeProTxSpentCollateralConflicts (const CTransaction &tx)
846
853
{
847
- assert (::deterministicMNManager );
854
+ assert (m_dmnman );
848
855
849
856
// Remove TXs that refer to a MN for which the collateral was spent
850
857
auto removeSpentCollateralConflict = [&](const uint256& proTxHash) {
@@ -866,7 +873,7 @@ void CTxMemPool::removeProTxSpentCollateralConflicts(const CTransaction &tx)
866
873
}
867
874
}
868
875
};
869
- auto mnList = deterministicMNManager ->GetListAtChainTip ();
876
+ auto mnList = m_dmnman ->GetListAtChainTip ();
870
877
for (const auto & in : tx.vin ) {
871
878
auto collateralIt = mapProTxCollaterals.find (in.prevout );
872
879
if (collateralIt != mapProTxCollaterals.end ()) {
@@ -983,7 +990,7 @@ void CTxMemPool::removeForBlock(const std::vector<CTransactionRef>& vtx, unsigne
983
990
RemoveStaged (stage, true , MemPoolRemovalReason::BLOCK);
984
991
}
985
992
removeConflicts (*tx);
986
- if (::deterministicMNManager ) {
993
+ if (m_dmnman ) {
987
994
removeProTxConflicts (*tx);
988
995
}
989
996
ClearPrioritisation (tx->GetHash ());
@@ -1259,7 +1266,7 @@ TxMempoolInfo CTxMemPool::info(const uint256& hash) const
1259
1266
}
1260
1267
1261
1268
bool CTxMemPool::existsProviderTxConflict (const CTransaction &tx) const {
1262
- assert (::deterministicMNManager );
1269
+ assert (m_dmnman );
1263
1270
1264
1271
LOCK (cs);
1265
1272
@@ -1314,7 +1321,7 @@ bool CTxMemPool::existsProviderTxConflict(const CTransaction &tx) const {
1314
1321
auto & proTx = *opt_proTx;
1315
1322
1316
1323
// this method should only be called with validated ProTxs
1317
- auto dmn = deterministicMNManager ->GetListAtChainTip ().GetMN (proTx.proTxHash );
1324
+ auto dmn = m_dmnman ->GetListAtChainTip ().GetMN (proTx.proTxHash );
1318
1325
if (!dmn) {
1319
1326
LogPrint (BCLog::MEMPOOL, " %s: ERROR: Masternode is not in the list, proTxHash: %s\n " , __func__, proTx.proTxHash .ToString ());
1320
1327
return true ; // i.e. failed to find validated ProTx == conflict
@@ -1336,7 +1343,7 @@ bool CTxMemPool::existsProviderTxConflict(const CTransaction &tx) const {
1336
1343
}
1337
1344
auto & proTx = *opt_proTx;
1338
1345
// this method should only be called with validated ProTxs
1339
- auto dmn = deterministicMNManager ->GetListAtChainTip ().GetMN (proTx.proTxHash );
1346
+ auto dmn = m_dmnman ->GetListAtChainTip ().GetMN (proTx.proTxHash );
1340
1347
if (!dmn) {
1341
1348
LogPrint (BCLog::MEMPOOL, " %s: ERROR: Masternode is not in the list, proTxHash: %s\n " , __func__, proTx.proTxHash .ToString ());
1342
1349
return true ; // i.e. failed to find validated ProTx == conflict
0 commit comments