Skip to content

Commit

Permalink
Masternode cache fix (#1010)
Browse files Browse the repository at this point in the history
* Optimize MN lists cache (#3506)
  • Loading branch information
a-bezrukov committed Mar 24, 2021
1 parent 362d499 commit b39fa5f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/evo/deterministicmns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ bool CDeterministicMNManager::IsDIP3Enforced(int nHeight)

void CDeterministicMNManager::CleanupCache(int nHeight)
{
AssertLockHeld(cs);
LOCK(cs);

std::vector<uint256> toDelete;
for (const auto& p : mnListsCache) {
Expand Down
2 changes: 1 addition & 1 deletion src/evo/deterministicmns.h
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ class CDeterministicMNManager
void UpgradeDBIfNeeded();
static bool IsDIP3Active(int height);

private:
public:
void CleanupCache(int nHeight);
};

Expand Down
8 changes: 8 additions & 0 deletions src/masternode-payments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,14 @@ bool CMasternodePayments::GetBlockTxOuts(int nBlockHeight, CAmount blockReward,
return true;
}

bool CMasternodePayments::GetBlockTxOutsWipeCache(int nBlockHeight, CAmount blockReward, std::vector<CTxOut>& voutMasternodePaymentsRet) const
{
bool result = GetBlockTxOuts(nBlockHeight, blockReward, voutMasternodePaymentsRet);
AssertLockHeld(cs_main);
deterministicMNManager->CleanupCache(chainActive.Height());
return result;
}

// Is this masternode scheduled to get paid soon?
// -- Only look ahead up to 8 blocks to allow for propagation of the latest 2 blocks of votes
bool CMasternodePayments::IsScheduled(const CDeterministicMNCPtr& dmnIn, int nNotBlockHeight) const
Expand Down
1 change: 1 addition & 0 deletions src/masternode-payments.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class CMasternodePayments
{
public:
bool GetBlockTxOuts(int nBlockHeight, CAmount blockReward, std::vector<CTxOut>& voutMasternodePaymentsRet) const;
bool GetBlockTxOutsWipeCache(int nBlockHeight, CAmount blockReward, std::vector<CTxOut>& voutMasternodePaymentsRet) const;
bool IsTransactionValid(const CTransaction& txNew, int nBlockHeight, CAmount blockReward) const;
bool IsScheduled(const CDeterministicMNCPtr& dmn, int nNotBlockHeight) const;

Expand Down
2 changes: 1 addition & 1 deletion src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1553,7 +1553,7 @@ void ListTransactions(CWallet * const pwallet, const CWalletTx& wtx, const strin
int txHeight = chainActive.Height() - wtx.GetDepthInMainChain();

std::vector<CTxOut> voutMasternodePaymentsRet;
mnpayments.GetBlockTxOuts(txHeight, CAmount(), voutMasternodePaymentsRet);
mnpayments.GetBlockTxOutsWipeCache(txHeight, CAmount(), voutMasternodePaymentsRet);
//compare address of payee to addr.

bool its_znode_payment = false;
Expand Down

0 comments on commit b39fa5f

Please sign in to comment.