lock debugging

This commit is contained in:
Evan Duffield 2015-07-29 15:50:25 -07:00
parent ff2fa918b6
commit e230762d5a
5 changed files with 37 additions and 1 deletions

View File

@ -4130,7 +4130,6 @@ void static ProcessGetData(CNode* pfrom)
} }
if (!pushed && inv.type == MSG_TX) { if (!pushed && inv.type == MSG_TX) {
CTransaction tx; CTransaction tx;
if (mempool.lookup(inv.hash, tx)) { if (mempool.lookup(inv.hash, tx)) {
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); 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") else if (strCommand == "tx"|| strCommand == "dstx")
{ {
vector<uint256> vWorkQueue; vector<uint256> vWorkQueue;
vector<uint256> vEraseQueue; vector<uint256> vEraseQueue;
CTransaction tx; CTransaction tx;

View File

@ -85,6 +85,7 @@ bool IsBudgetCollateralValid(uint256 nTxCollateralHash, uint256 nExpectedHash, s
void CBudgetManager::CheckOrphanVotes() void CBudgetManager::CheckOrphanVotes()
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs); LOCK(cs);
std::string strError = ""; std::string strError = "";
@ -183,6 +184,7 @@ void CBudgetManager::SubmitFinalBudget()
return; return;
} }
LogPrintf("LOCK - %\n", __func__);
LOCK(cs); LOCK(cs);
mapSeenFinalizedBudgets.insert(make_pair(finalizedBudgetBroadcast.GetHash(), finalizedBudgetBroadcast)); mapSeenFinalizedBudgets.insert(make_pair(finalizedBudgetBroadcast.GetHash(), finalizedBudgetBroadcast));
finalizedBudgetBroadcast.Relay(); finalizedBudgetBroadcast.Relay();
@ -368,6 +370,7 @@ bool CBudgetManager::AddFinalizedBudget(CFinalizedBudget& finalizedBudget)
bool CBudgetManager::AddProposal(CBudgetProposal& budgetProposal) bool CBudgetManager::AddProposal(CBudgetProposal& budgetProposal)
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs); LOCK(cs);
std::string strError = ""; std::string strError = "";
if(!budgetProposal.IsValid(strError)) { if(!budgetProposal.IsValid(strError)) {
@ -410,6 +413,7 @@ void CBudgetManager::CheckAndRemove()
void CBudgetManager::FillBlockPayee(CMutableTransaction& txNew, CAmount nFees) void CBudgetManager::FillBlockPayee(CMutableTransaction& txNew, CAmount nFees)
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs); LOCK(cs);
CBlockIndex* pindexPrev = chainActive.Tip(); CBlockIndex* pindexPrev = chainActive.Tip();
@ -487,6 +491,7 @@ CBudgetProposal *CBudgetManager::FindProposal(const std::string &strProposalName
CBudgetProposal *CBudgetManager::FindProposal(uint256 nHash) CBudgetProposal *CBudgetManager::FindProposal(uint256 nHash)
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs); LOCK(cs);
if(mapProposals.count(nHash)) if(mapProposals.count(nHash))
@ -539,6 +544,7 @@ bool CBudgetManager::HasNextFinalizedBudget()
bool CBudgetManager::IsTransactionValid(const CTransaction& txNew, int nBlockHeight) bool CBudgetManager::IsTransactionValid(const CTransaction& txNew, int nBlockHeight)
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs); LOCK(cs);
int nHighestCount = 0; int nHighestCount = 0;
@ -588,6 +594,7 @@ bool CBudgetManager::IsTransactionValid(const CTransaction& txNew, int nBlockHei
std::vector<CBudgetProposal*> CBudgetManager::GetAllProposals() std::vector<CBudgetProposal*> CBudgetManager::GetAllProposals()
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs); LOCK(cs);
std::vector<CBudgetProposal*> vBudgetProposalRet; std::vector<CBudgetProposal*> vBudgetProposalRet;
@ -620,6 +627,7 @@ struct sortProposalsByVotes {
//Need to review this function //Need to review this function
std::vector<CBudgetProposal*> CBudgetManager::GetBudget() std::vector<CBudgetProposal*> CBudgetManager::GetBudget()
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs); LOCK(cs);
// ------- Sort budgets by Yes Count // ------- Sort budgets by Yes Count
@ -683,6 +691,7 @@ struct sortFinalizedBudgetsByVotes {
std::vector<CFinalizedBudget*> CBudgetManager::GetFinalizedBudgets() std::vector<CFinalizedBudget*> CBudgetManager::GetFinalizedBudgets()
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs); LOCK(cs);
std::vector<CFinalizedBudget*> vFinalizedBudgetsRet; std::vector<CFinalizedBudget*> vFinalizedBudgetsRet;
@ -712,6 +721,7 @@ std::vector<CFinalizedBudget*> CBudgetManager::GetFinalizedBudgets()
std::string CBudgetManager::GetRequiredPaymentsString(int nBlockHeight) std::string CBudgetManager::GetRequiredPaymentsString(int nBlockHeight)
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs); LOCK(cs);
std::string ret = "unknown-budget"; std::string ret = "unknown-budget";
@ -763,6 +773,7 @@ CAmount CBudgetManager::GetTotalBudget(int nHeight)
void CBudgetManager::NewBlock() void CBudgetManager::NewBlock()
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs); LOCK(cs);
if (masternodeSync.RequestedMasternodeAssets <= MASTERNODE_SYNC_BUDGET) return; 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 // lite mode is not supported
if(IsInitialBlockDownload()) return; if(IsInitialBlockDownload()) return;
LogPrintf("LOCK - %\n", __func__);
LOCK(cs_budget); LOCK(cs_budget);
if (strCommand == "mnvs") { //Masternode vote sync if (strCommand == "mnvs") { //Masternode vote sync
@ -957,6 +969,7 @@ bool CBudgetManager::PropExists(uint256 nHash)
void CBudgetManager::Sync(CNode* pfrom, uint256 nProp) void CBudgetManager::Sync(CNode* pfrom, uint256 nProp)
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs); LOCK(cs);
/* /*
@ -1021,6 +1034,7 @@ void CBudgetManager::Sync(CNode* pfrom, uint256 nProp)
bool CBudgetManager::UpdateProposal(CBudgetVote& vote, CNode* pfrom, std::string& strError) bool CBudgetManager::UpdateProposal(CBudgetVote& vote, CNode* pfrom, std::string& strError)
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs); LOCK(cs);
if(!mapProposals.count(vote.nProposalHash)){ 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) bool CBudgetManager::UpdateFinalizedBudget(CFinalizedBudgetVote& vote, CNode* pfrom, std::string& strError)
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs); LOCK(cs);
if(!mapFinalizedBudgets.count(vote.nBudgetHash)){ 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) bool CBudgetProposal::AddOrUpdateVote(CBudgetVote& vote, std::string& strError)
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs); LOCK(cs);
uint256 hash = vote.vin.prevout.GetHash(); uint256 hash = vote.vin.prevout.GetHash();
@ -1457,6 +1473,7 @@ CFinalizedBudget::CFinalizedBudget(const CFinalizedBudget& other)
bool CFinalizedBudget::AddOrUpdateVote(CFinalizedBudgetVote& vote, std::string& strError) bool CFinalizedBudget::AddOrUpdateVote(CFinalizedBudgetVote& vote, std::string& strError)
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs); LOCK(cs);
uint256 hash = vote.vin.prevout.GetHash(); 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 //evaluate if we should vote for this. Masternode only
void CFinalizedBudget::AutoCheck() void CFinalizedBudget::AutoCheck()
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs); LOCK(cs);
if(!fMasterNode || fAutoChecked) return; if(!fMasterNode || fAutoChecked) return;
@ -1566,6 +1584,7 @@ CAmount CFinalizedBudget::GetTotalPayout()
std::string CFinalizedBudget::GetProposals() std::string CFinalizedBudget::GetProposals()
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs); LOCK(cs);
std::string ret = ""; std::string ret = "";

View File

@ -131,6 +131,7 @@ public:
void CheckOrphanVotes(); void CheckOrphanVotes();
void Clear(){ void Clear(){
LogPrintf("LOCK - %\n", __func__);
LOCK(cs); LOCK(cs);
LogPrintf("Budget object cleared\n"); LogPrintf("Budget object cleared\n");
@ -226,6 +227,7 @@ public:
bool IsTransactionValid(const CTransaction& txNew, int nBlockHeight); bool IsTransactionValid(const CTransaction& txNew, int nBlockHeight);
bool GetBudgetPaymentByBlock(int64_t nBlockHeight, CTxBudgetPayment& payment) bool GetBudgetPaymentByBlock(int64_t nBlockHeight, CTxBudgetPayment& payment)
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs); LOCK(cs);
int i = nBlockHeight - GetBlockStart(); int i = nBlockHeight - GetBlockStart();
@ -236,6 +238,7 @@ public:
} }
bool GetPayeeAndAmount(int64_t nBlockHeight, CScript& payee, CAmount& nAmount) bool GetPayeeAndAmount(int64_t nBlockHeight, CScript& payee, CAmount& nAmount)
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs); LOCK(cs);
int i = nBlockHeight - GetBlockStart(); int i = nBlockHeight - GetBlockStart();

View File

@ -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 // -- Only look ahead up to 8 blocks to allow for propagation of the latest 2 winners
bool CMasternodePayments::IsScheduled(CMasternode& mn, int nNotBlockHeight) bool CMasternodePayments::IsScheduled(CMasternode& mn, int nNotBlockHeight)
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs_mapMasternodeBlocks); LOCK(cs_mapMasternodeBlocks);
CBlockIndex* pindexPrev = chainActive.Tip(); CBlockIndex* pindexPrev = chainActive.Tip();
@ -492,6 +493,7 @@ bool CMasternodePayments::AddWinningMasternode(CMasternodePaymentWinner& winnerI
bool CMasternodeBlockPayees::IsTransactionValid(const CTransaction& txNew) bool CMasternodeBlockPayees::IsTransactionValid(const CTransaction& txNew)
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs_vecPayments); LOCK(cs_vecPayments);
int nMaxSignatures = 0; int nMaxSignatures = 0;
@ -539,6 +541,7 @@ bool CMasternodeBlockPayees::IsTransactionValid(const CTransaction& txNew)
std::string CMasternodeBlockPayees::GetRequiredPaymentsString() std::string CMasternodeBlockPayees::GetRequiredPaymentsString()
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs_vecPayments); LOCK(cs_vecPayments);
std::string ret = "Unknown"; std::string ret = "Unknown";
@ -561,6 +564,7 @@ std::string CMasternodeBlockPayees::GetRequiredPaymentsString()
std::string CMasternodePayments::GetRequiredPaymentsString(int nBlockHeight) std::string CMasternodePayments::GetRequiredPaymentsString(int nBlockHeight)
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs_mapMasternodeBlocks); LOCK(cs_mapMasternodeBlocks);
if(mapMasternodeBlocks.count(nBlockHeight)){ if(mapMasternodeBlocks.count(nBlockHeight)){
@ -572,6 +576,7 @@ std::string CMasternodePayments::GetRequiredPaymentsString(int nBlockHeight)
bool CMasternodePayments::IsTransactionValid(const CTransaction& txNew, int nBlockHeight) bool CMasternodePayments::IsTransactionValid(const CTransaction& txNew, int nBlockHeight)
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs_mapMasternodeBlocks); LOCK(cs_mapMasternodeBlocks);
if(mapMasternodeBlocks.count(nBlockHeight)){ if(mapMasternodeBlocks.count(nBlockHeight)){
@ -583,6 +588,7 @@ bool CMasternodePayments::IsTransactionValid(const CTransaction& txNew, int nBlo
void CMasternodePayments::CleanPaymentList() void CMasternodePayments::CleanPaymentList()
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs_mapMasternodePayeeVotes); LOCK(cs_mapMasternodePayeeVotes);
if(chainActive.Tip() == NULL) return; if(chainActive.Tip() == NULL) return;
@ -756,6 +762,7 @@ bool CMasternodePaymentWinner::SignatureValid()
void CMasternodePayments::Sync(CNode* node, int nCountNeeded) void CMasternodePayments::Sync(CNode* node, int nCountNeeded)
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs_mapMasternodePayeeVotes); LOCK(cs_mapMasternodePayeeVotes);
if(chainActive.Tip() == NULL) return; if(chainActive.Tip() == NULL) return;
@ -791,6 +798,7 @@ std::string CMasternodePayments::ToString() const
int CMasternodePayments::GetOldestBlock() int CMasternodePayments::GetOldestBlock()
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs_mapMasternodeBlocks); LOCK(cs_mapMasternodeBlocks);
int nOldestBlock = std::numeric_limits<int>::max(); int nOldestBlock = std::numeric_limits<int>::max();
@ -810,6 +818,7 @@ int CMasternodePayments::GetOldestBlock()
int CMasternodePayments::GetNewestBlock() int CMasternodePayments::GetNewestBlock()
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs_mapMasternodeBlocks); LOCK(cs_mapMasternodeBlocks);
int nNewestBlock = 0; int nNewestBlock = 0;

View File

@ -100,6 +100,7 @@ public:
} }
void AddPayee(CScript payeeIn, int nIncrement){ void AddPayee(CScript payeeIn, int nIncrement){
LogPrintf("LOCK - %\n", __func__);
LOCK(cs_vecPayments); LOCK(cs_vecPayments);
BOOST_FOREACH(CMasternodePayee& payee, vecPayments){ BOOST_FOREACH(CMasternodePayee& payee, vecPayments){
@ -115,6 +116,7 @@ public:
bool GetPayee(CScript& payee) bool GetPayee(CScript& payee)
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs_vecPayments); LOCK(cs_vecPayments);
int nVotes = -1; int nVotes = -1;
@ -130,6 +132,7 @@ public:
bool HasPayeeWithVotes(CScript payee, int nVotesReq) bool HasPayeeWithVotes(CScript payee, int nVotesReq)
{ {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs_vecPayments); LOCK(cs_vecPayments);
BOOST_FOREACH(CMasternodePayee& p, vecPayments){ BOOST_FOREACH(CMasternodePayee& p, vecPayments){
@ -235,6 +238,7 @@ public:
} }
void Clear() { void Clear() {
LogPrintf("LOCK - %\n", __func__);
LOCK2(cs_mapMasternodeBlocks, cs_mapMasternodePayeeVotes); LOCK2(cs_mapMasternodeBlocks, cs_mapMasternodePayeeVotes);
mapMasternodeBlocks.clear(); mapMasternodeBlocks.clear();
mapMasternodePayeeVotes.clear(); mapMasternodePayeeVotes.clear();
@ -252,6 +256,7 @@ public:
bool IsScheduled(CMasternode& mn, int nNotBlockHeight); bool IsScheduled(CMasternode& mn, int nNotBlockHeight);
bool CanVote(COutPoint outMasternode, int nBlockHeight) { bool CanVote(COutPoint outMasternode, int nBlockHeight) {
LogPrintf("LOCK - %\n", __func__);
LOCK(cs_mapMasternodePayeeVotes); LOCK(cs_mapMasternodePayeeVotes);
if(mapMasternodesLastVote.count(outMasternode.hash + outMasternode.n)) { if(mapMasternodesLastVote.count(outMasternode.hash + outMasternode.n)) {