From e230762d5a6e997c7bc2b152f20b66be9b51b6db Mon Sep 17 00:00:00 2001 From: Evan Duffield Date: Wed, 29 Jul 2015 15:50:25 -0700 Subject: [PATCH] lock debugging --- src/main.cpp | 2 +- src/masternode-budget.cpp | 19 +++++++++++++++++++ src/masternode-budget.h | 3 +++ src/masternode-payments.cpp | 9 +++++++++ src/masternode-payments.h | 5 +++++ 5 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index ccd5885e40..d16cf209d8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4130,7 +4130,6 @@ void static ProcessGetData(CNode* pfrom) } if (!pushed && inv.type == MSG_TX) { - CTransaction tx; if (mempool.lookup(inv.hash, tx)) { CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); @@ -4662,6 +4661,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, else if (strCommand == "tx"|| strCommand == "dstx") { + vector vWorkQueue; vector vEraseQueue; CTransaction tx; diff --git a/src/masternode-budget.cpp b/src/masternode-budget.cpp index 4ba56f271e..93b3f124a3 100644 --- a/src/masternode-budget.cpp +++ b/src/masternode-budget.cpp @@ -85,6 +85,7 @@ bool IsBudgetCollateralValid(uint256 nTxCollateralHash, uint256 nExpectedHash, s void CBudgetManager::CheckOrphanVotes() { + LogPrintf("LOCK - %\n", __func__); LOCK(cs); std::string strError = ""; @@ -183,6 +184,7 @@ void CBudgetManager::SubmitFinalBudget() return; } + LogPrintf("LOCK - %\n", __func__); LOCK(cs); mapSeenFinalizedBudgets.insert(make_pair(finalizedBudgetBroadcast.GetHash(), finalizedBudgetBroadcast)); finalizedBudgetBroadcast.Relay(); @@ -368,6 +370,7 @@ bool CBudgetManager::AddFinalizedBudget(CFinalizedBudget& finalizedBudget) bool CBudgetManager::AddProposal(CBudgetProposal& budgetProposal) { + LogPrintf("LOCK - %\n", __func__); LOCK(cs); std::string strError = ""; if(!budgetProposal.IsValid(strError)) { @@ -410,6 +413,7 @@ void CBudgetManager::CheckAndRemove() void CBudgetManager::FillBlockPayee(CMutableTransaction& txNew, CAmount nFees) { + LogPrintf("LOCK - %\n", __func__); LOCK(cs); CBlockIndex* pindexPrev = chainActive.Tip(); @@ -487,6 +491,7 @@ CBudgetProposal *CBudgetManager::FindProposal(const std::string &strProposalName CBudgetProposal *CBudgetManager::FindProposal(uint256 nHash) { + LogPrintf("LOCK - %\n", __func__); LOCK(cs); if(mapProposals.count(nHash)) @@ -539,6 +544,7 @@ bool CBudgetManager::HasNextFinalizedBudget() bool CBudgetManager::IsTransactionValid(const CTransaction& txNew, int nBlockHeight) { + LogPrintf("LOCK - %\n", __func__); LOCK(cs); int nHighestCount = 0; @@ -588,6 +594,7 @@ bool CBudgetManager::IsTransactionValid(const CTransaction& txNew, int nBlockHei std::vector CBudgetManager::GetAllProposals() { + LogPrintf("LOCK - %\n", __func__); LOCK(cs); std::vector vBudgetProposalRet; @@ -620,6 +627,7 @@ struct sortProposalsByVotes { //Need to review this function std::vector CBudgetManager::GetBudget() { + LogPrintf("LOCK - %\n", __func__); LOCK(cs); // ------- Sort budgets by Yes Count @@ -683,6 +691,7 @@ struct sortFinalizedBudgetsByVotes { std::vector CBudgetManager::GetFinalizedBudgets() { + LogPrintf("LOCK - %\n", __func__); LOCK(cs); std::vector vFinalizedBudgetsRet; @@ -712,6 +721,7 @@ std::vector CBudgetManager::GetFinalizedBudgets() std::string CBudgetManager::GetRequiredPaymentsString(int nBlockHeight) { + LogPrintf("LOCK - %\n", __func__); LOCK(cs); std::string ret = "unknown-budget"; @@ -763,6 +773,7 @@ CAmount CBudgetManager::GetTotalBudget(int nHeight) void CBudgetManager::NewBlock() { + LogPrintf("LOCK - %\n", __func__); LOCK(cs); if (masternodeSync.RequestedMasternodeAssets <= MASTERNODE_SYNC_BUDGET) return; @@ -805,6 +816,7 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData // lite mode is not supported if(IsInitialBlockDownload()) return; + LogPrintf("LOCK - %\n", __func__); LOCK(cs_budget); if (strCommand == "mnvs") { //Masternode vote sync @@ -957,6 +969,7 @@ bool CBudgetManager::PropExists(uint256 nHash) void CBudgetManager::Sync(CNode* pfrom, uint256 nProp) { + LogPrintf("LOCK - %\n", __func__); LOCK(cs); /* @@ -1021,6 +1034,7 @@ void CBudgetManager::Sync(CNode* pfrom, uint256 nProp) bool CBudgetManager::UpdateProposal(CBudgetVote& vote, CNode* pfrom, std::string& strError) { + LogPrintf("LOCK - %\n", __func__); LOCK(cs); if(!mapProposals.count(vote.nProposalHash)){ @@ -1048,6 +1062,7 @@ bool CBudgetManager::UpdateProposal(CBudgetVote& vote, CNode* pfrom, std::string bool CBudgetManager::UpdateFinalizedBudget(CFinalizedBudgetVote& vote, CNode* pfrom, std::string& strError) { + LogPrintf("LOCK - %\n", __func__); LOCK(cs); if(!mapFinalizedBudgets.count(vote.nBudgetHash)){ @@ -1175,6 +1190,7 @@ bool CBudgetProposal::IsValid(std::string& strError, bool fCheckCollateral) bool CBudgetProposal::AddOrUpdateVote(CBudgetVote& vote, std::string& strError) { + LogPrintf("LOCK - %\n", __func__); LOCK(cs); uint256 hash = vote.vin.prevout.GetHash(); @@ -1457,6 +1473,7 @@ CFinalizedBudget::CFinalizedBudget(const CFinalizedBudget& other) bool CFinalizedBudget::AddOrUpdateVote(CFinalizedBudgetVote& vote, std::string& strError) { + LogPrintf("LOCK - %\n", __func__); LOCK(cs); uint256 hash = vote.vin.prevout.GetHash(); @@ -1496,6 +1513,7 @@ bool CFinalizedBudget::AddOrUpdateVote(CFinalizedBudgetVote& vote, std::string& //evaluate if we should vote for this. Masternode only void CFinalizedBudget::AutoCheck() { + LogPrintf("LOCK - %\n", __func__); LOCK(cs); if(!fMasterNode || fAutoChecked) return; @@ -1566,6 +1584,7 @@ CAmount CFinalizedBudget::GetTotalPayout() std::string CFinalizedBudget::GetProposals() { + LogPrintf("LOCK - %\n", __func__); LOCK(cs); std::string ret = ""; diff --git a/src/masternode-budget.h b/src/masternode-budget.h index d47b13f0ed..f7e1bc352f 100644 --- a/src/masternode-budget.h +++ b/src/masternode-budget.h @@ -131,6 +131,7 @@ public: void CheckOrphanVotes(); void Clear(){ + LogPrintf("LOCK - %\n", __func__); LOCK(cs); LogPrintf("Budget object cleared\n"); @@ -226,6 +227,7 @@ public: bool IsTransactionValid(const CTransaction& txNew, int nBlockHeight); bool GetBudgetPaymentByBlock(int64_t nBlockHeight, CTxBudgetPayment& payment) { + LogPrintf("LOCK - %\n", __func__); LOCK(cs); int i = nBlockHeight - GetBlockStart(); @@ -236,6 +238,7 @@ public: } bool GetPayeeAndAmount(int64_t nBlockHeight, CScript& payee, CAmount& nAmount) { + LogPrintf("LOCK - %\n", __func__); LOCK(cs); int i = nBlockHeight - GetBlockStart(); diff --git a/src/masternode-payments.cpp b/src/masternode-payments.cpp index 3452a4a1b6..653846ad1b 100644 --- a/src/masternode-payments.cpp +++ b/src/masternode-payments.cpp @@ -438,6 +438,7 @@ bool CMasternodePayments::GetBlockPayee(int nBlockHeight, CScript& payee) // -- Only look ahead up to 8 blocks to allow for propagation of the latest 2 winners bool CMasternodePayments::IsScheduled(CMasternode& mn, int nNotBlockHeight) { + LogPrintf("LOCK - %\n", __func__); LOCK(cs_mapMasternodeBlocks); CBlockIndex* pindexPrev = chainActive.Tip(); @@ -492,6 +493,7 @@ bool CMasternodePayments::AddWinningMasternode(CMasternodePaymentWinner& winnerI bool CMasternodeBlockPayees::IsTransactionValid(const CTransaction& txNew) { + LogPrintf("LOCK - %\n", __func__); LOCK(cs_vecPayments); int nMaxSignatures = 0; @@ -539,6 +541,7 @@ bool CMasternodeBlockPayees::IsTransactionValid(const CTransaction& txNew) std::string CMasternodeBlockPayees::GetRequiredPaymentsString() { + LogPrintf("LOCK - %\n", __func__); LOCK(cs_vecPayments); std::string ret = "Unknown"; @@ -561,6 +564,7 @@ std::string CMasternodeBlockPayees::GetRequiredPaymentsString() std::string CMasternodePayments::GetRequiredPaymentsString(int nBlockHeight) { + LogPrintf("LOCK - %\n", __func__); LOCK(cs_mapMasternodeBlocks); if(mapMasternodeBlocks.count(nBlockHeight)){ @@ -572,6 +576,7 @@ std::string CMasternodePayments::GetRequiredPaymentsString(int nBlockHeight) bool CMasternodePayments::IsTransactionValid(const CTransaction& txNew, int nBlockHeight) { + LogPrintf("LOCK - %\n", __func__); LOCK(cs_mapMasternodeBlocks); if(mapMasternodeBlocks.count(nBlockHeight)){ @@ -583,6 +588,7 @@ bool CMasternodePayments::IsTransactionValid(const CTransaction& txNew, int nBlo void CMasternodePayments::CleanPaymentList() { + LogPrintf("LOCK - %\n", __func__); LOCK(cs_mapMasternodePayeeVotes); if(chainActive.Tip() == NULL) return; @@ -756,6 +762,7 @@ bool CMasternodePaymentWinner::SignatureValid() void CMasternodePayments::Sync(CNode* node, int nCountNeeded) { + LogPrintf("LOCK - %\n", __func__); LOCK(cs_mapMasternodePayeeVotes); if(chainActive.Tip() == NULL) return; @@ -791,6 +798,7 @@ std::string CMasternodePayments::ToString() const int CMasternodePayments::GetOldestBlock() { + LogPrintf("LOCK - %\n", __func__); LOCK(cs_mapMasternodeBlocks); int nOldestBlock = std::numeric_limits::max(); @@ -810,6 +818,7 @@ int CMasternodePayments::GetOldestBlock() int CMasternodePayments::GetNewestBlock() { + LogPrintf("LOCK - %\n", __func__); LOCK(cs_mapMasternodeBlocks); int nNewestBlock = 0; diff --git a/src/masternode-payments.h b/src/masternode-payments.h index 21d937420d..46a52210c1 100644 --- a/src/masternode-payments.h +++ b/src/masternode-payments.h @@ -100,6 +100,7 @@ public: } void AddPayee(CScript payeeIn, int nIncrement){ + LogPrintf("LOCK - %\n", __func__); LOCK(cs_vecPayments); BOOST_FOREACH(CMasternodePayee& payee, vecPayments){ @@ -115,6 +116,7 @@ public: bool GetPayee(CScript& payee) { + LogPrintf("LOCK - %\n", __func__); LOCK(cs_vecPayments); int nVotes = -1; @@ -130,6 +132,7 @@ public: bool HasPayeeWithVotes(CScript payee, int nVotesReq) { + LogPrintf("LOCK - %\n", __func__); LOCK(cs_vecPayments); BOOST_FOREACH(CMasternodePayee& p, vecPayments){ @@ -235,6 +238,7 @@ public: } void Clear() { + LogPrintf("LOCK - %\n", __func__); LOCK2(cs_mapMasternodeBlocks, cs_mapMasternodePayeeVotes); mapMasternodeBlocks.clear(); mapMasternodePayeeVotes.clear(); @@ -252,6 +256,7 @@ public: bool IsScheduled(CMasternode& mn, int nNotBlockHeight); bool CanVote(COutPoint outMasternode, int nBlockHeight) { + LogPrintf("LOCK - %\n", __func__); LOCK(cs_mapMasternodePayeeVotes); if(mapMasternodesLastVote.count(outMasternode.hash + outMasternode.n)) {