mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
drop pCurrentBlockIndex and use cached block height instead (nCachedBlockHeight) (#1579)
This commit is contained in:
parent
23582aea45
commit
fe81d641da
@ -23,8 +23,7 @@ const int CGovernanceManager::MAX_TIME_FUTURE_DEVIATION = 60*60;
|
|||||||
const int CGovernanceManager::RELIABLE_PROPAGATION_TIME = 60;
|
const int CGovernanceManager::RELIABLE_PROPAGATION_TIME = 60;
|
||||||
|
|
||||||
CGovernanceManager::CGovernanceManager()
|
CGovernanceManager::CGovernanceManager()
|
||||||
: pCurrentBlockIndex(NULL),
|
: nTimeLastDiff(0),
|
||||||
nTimeLastDiff(0),
|
|
||||||
nCachedBlockHeight(0),
|
nCachedBlockHeight(0),
|
||||||
mapObjects(),
|
mapObjects(),
|
||||||
mapErasedGovernanceObjects(),
|
mapErasedGovernanceObjects(),
|
||||||
@ -149,10 +148,6 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, std::string& strCommand, C
|
|||||||
{
|
{
|
||||||
// MAKE SURE WE HAVE A VALID REFERENCE TO THE TIP BEFORE CONTINUING
|
// MAKE SURE WE HAVE A VALID REFERENCE TO THE TIP BEFORE CONTINUING
|
||||||
|
|
||||||
if(!pCurrentBlockIndex) {
|
|
||||||
LogPrintf("MNGOVERNANCEOBJECT -- pCurrentBlockIndex is NULL\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!masternodeSync.IsMasternodeListSynced()) {
|
if(!masternodeSync.IsMasternodeListSynced()) {
|
||||||
LogPrint("gobject", "MNGOVERNANCEOBJECT -- masternode list not synced\n");
|
LogPrint("gobject", "MNGOVERNANCEOBJECT -- masternode list not synced\n");
|
||||||
@ -472,14 +467,8 @@ void CGovernanceManager::UpdateCachesAndClean()
|
|||||||
it->second.fDirtyCache = true;
|
it->second.fDirtyCache = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DOUBLE CHECK THAT WE HAVE A VALID POINTER TO TIP
|
|
||||||
|
|
||||||
if(!pCurrentBlockIndex) return;
|
|
||||||
|
|
||||||
CRateChecksGuard guard(false, *this);
|
CRateChecksGuard guard(false, *this);
|
||||||
|
|
||||||
LogPrint("gobject", "CGovernanceManager::UpdateCachesAndClean -- After pCurrentBlockIndex (not NULL)\n");
|
|
||||||
|
|
||||||
// UPDATE CACHE FOR EACH OBJECT THAT IS FLAGGED DIRTYCACHE=TRUE
|
// UPDATE CACHE FOR EACH OBJECT THAT IS FLAGGED DIRTYCACHE=TRUE
|
||||||
|
|
||||||
object_m_it it = mapObjects.begin();
|
object_m_it it = mapObjects.begin();
|
||||||
@ -681,15 +670,7 @@ struct sortProposalsByVotes {
|
|||||||
|
|
||||||
void CGovernanceManager::DoMaintenance()
|
void CGovernanceManager::DoMaintenance()
|
||||||
{
|
{
|
||||||
// NOTHING TO DO IN LITEMODE
|
if(fLiteMode || !masternodeSync.IsSynced()) return;
|
||||||
if(fLiteMode) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// IF WE'RE NOT SYNCED, EXIT
|
|
||||||
if(!masternodeSync.IsSynced()) return;
|
|
||||||
|
|
||||||
if(!pCurrentBlockIndex) return;
|
|
||||||
|
|
||||||
// CHECK OBJECTS WE'VE ASKED FOR, REMOVE OLD ENTRIES
|
// CHECK OBJECTS WE'VE ASKED FOR, REMOVE OLD ENTRIES
|
||||||
|
|
||||||
@ -1400,12 +1381,8 @@ void CGovernanceManager::UpdatedBlockTip(const CBlockIndex *pindex)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
nCachedBlockHeight = pindex->nHeight;
|
||||||
LOCK(cs);
|
LogPrint("gobject", "CGovernanceManager::UpdatedBlockTip -- nCachedBlockHeight: %d\n", nCachedBlockHeight);
|
||||||
pCurrentBlockIndex = pindex;
|
|
||||||
nCachedBlockHeight = pCurrentBlockIndex->nHeight;
|
|
||||||
LogPrint("gobject", "CGovernanceManager::UpdatedBlockTip pCurrentBlockIndex->nHeight: %d\n", pCurrentBlockIndex->nHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckPostponedObjects();
|
CheckPostponedObjects();
|
||||||
}
|
}
|
||||||
|
@ -226,10 +226,9 @@ private:
|
|||||||
static const int MAX_TIME_FUTURE_DEVIATION;
|
static const int MAX_TIME_FUTURE_DEVIATION;
|
||||||
static const int RELIABLE_PROPAGATION_TIME;
|
static const int RELIABLE_PROPAGATION_TIME;
|
||||||
|
|
||||||
// Keep track of current block index
|
|
||||||
const CBlockIndex *pCurrentBlockIndex;
|
|
||||||
|
|
||||||
int64_t nTimeLastDiff;
|
int64_t nTimeLastDiff;
|
||||||
|
|
||||||
|
// keep track of current block height
|
||||||
int nCachedBlockHeight;
|
int nCachedBlockHeight;
|
||||||
|
|
||||||
// keep track of the scanning errors
|
// keep track of the scanning errors
|
||||||
|
@ -1972,7 +1972,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
|
|
||||||
// ********************************************************* Step 11c: update block tip in Dash modules
|
// ********************************************************* Step 11c: update block tip in Dash modules
|
||||||
|
|
||||||
// force UpdatedBlockTip to initialize pCurrentBlockIndex for DS, MN payments and budgets
|
// force UpdatedBlockTip to initialize nCachedBlockHeight for DS, MN payments and budgets
|
||||||
// but don't call it directly to prevent triggering of other listeners like zmq etc.
|
// but don't call it directly to prevent triggering of other listeners like zmq etc.
|
||||||
// GetMainSignals().UpdatedBlockTip(chainActive.Tip());
|
// GetMainSignals().UpdatedBlockTip(chainActive.Tip());
|
||||||
mnodeman.UpdatedBlockTip(chainActive.Tip());
|
mnodeman.UpdatedBlockTip(chainActive.Tip());
|
||||||
|
@ -605,7 +605,7 @@ int64_t CInstantSend::GetAverageMasternodeOrphanVoteTime()
|
|||||||
|
|
||||||
void CInstantSend::CheckAndRemove()
|
void CInstantSend::CheckAndRemove()
|
||||||
{
|
{
|
||||||
if(!pCurrentBlockIndex) return;
|
if(!masternodeSync.IsMasternodeListSynced()) return;
|
||||||
|
|
||||||
LOCK(cs_instantsend);
|
LOCK(cs_instantsend);
|
||||||
|
|
||||||
@ -615,7 +615,7 @@ void CInstantSend::CheckAndRemove()
|
|||||||
while(itLockCandidate != mapTxLockCandidates.end()) {
|
while(itLockCandidate != mapTxLockCandidates.end()) {
|
||||||
CTxLockCandidate &txLockCandidate = itLockCandidate->second;
|
CTxLockCandidate &txLockCandidate = itLockCandidate->second;
|
||||||
uint256 txHash = txLockCandidate.GetHash();
|
uint256 txHash = txLockCandidate.GetHash();
|
||||||
if(txLockCandidate.IsExpired(pCurrentBlockIndex->nHeight)) {
|
if(txLockCandidate.IsExpired(nCachedBlockHeight)) {
|
||||||
LogPrintf("CInstantSend::CheckAndRemove -- Removing expired Transaction Lock Candidate: txid=%s\n", txHash.ToString());
|
LogPrintf("CInstantSend::CheckAndRemove -- Removing expired Transaction Lock Candidate: txid=%s\n", txHash.ToString());
|
||||||
std::map<COutPoint, COutPointLock>::iterator itOutpointLock = txLockCandidate.mapOutPointLocks.begin();
|
std::map<COutPoint, COutPointLock>::iterator itOutpointLock = txLockCandidate.mapOutPointLocks.begin();
|
||||||
while(itOutpointLock != txLockCandidate.mapOutPointLocks.end()) {
|
while(itOutpointLock != txLockCandidate.mapOutPointLocks.end()) {
|
||||||
@ -634,7 +634,7 @@ void CInstantSend::CheckAndRemove()
|
|||||||
// remove expired votes
|
// remove expired votes
|
||||||
std::map<uint256, CTxLockVote>::iterator itVote = mapTxLockVotes.begin();
|
std::map<uint256, CTxLockVote>::iterator itVote = mapTxLockVotes.begin();
|
||||||
while(itVote != mapTxLockVotes.end()) {
|
while(itVote != mapTxLockVotes.end()) {
|
||||||
if(itVote->second.IsExpired(pCurrentBlockIndex->nHeight)) {
|
if(itVote->second.IsExpired(nCachedBlockHeight)) {
|
||||||
LogPrint("instantsend", "CInstantSend::CheckAndRemove -- Removing expired vote: txid=%s masternode=%s\n",
|
LogPrint("instantsend", "CInstantSend::CheckAndRemove -- Removing expired vote: txid=%s masternode=%s\n",
|
||||||
itVote->second.GetTxHash().ToString(), itVote->second.GetMasternodeOutpoint().ToStringShort());
|
itVote->second.GetTxHash().ToString(), itVote->second.GetMasternodeOutpoint().ToStringShort());
|
||||||
mapTxLockVotes.erase(itVote++);
|
mapTxLockVotes.erase(itVote++);
|
||||||
@ -803,7 +803,7 @@ void CInstantSend::Relay(const uint256& txHash)
|
|||||||
|
|
||||||
void CInstantSend::UpdatedBlockTip(const CBlockIndex *pindex)
|
void CInstantSend::UpdatedBlockTip(const CBlockIndex *pindex)
|
||||||
{
|
{
|
||||||
pCurrentBlockIndex = pindex;
|
nCachedBlockHeight = pindex->nHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInstantSend::SyncTransaction(const CTransaction& tx, const CBlock* pblock)
|
void CInstantSend::SyncTransaction(const CTransaction& tx, const CBlock* pblock)
|
||||||
|
@ -39,8 +39,8 @@ class CInstantSend
|
|||||||
private:
|
private:
|
||||||
static const int ORPHAN_VOTE_SECONDS = 60;
|
static const int ORPHAN_VOTE_SECONDS = 60;
|
||||||
|
|
||||||
// Keep track of current block index
|
// Keep track of current block height
|
||||||
const CBlockIndex *pCurrentBlockIndex;
|
int nCachedBlockHeight;
|
||||||
|
|
||||||
// maps for AlreadyHave
|
// maps for AlreadyHave
|
||||||
std::map<uint256, CTxLockRequest> mapLockRequestAccepted; // tx hash - tx
|
std::map<uint256, CTxLockRequest> mapLockRequestAccepted; // tx hash - tx
|
||||||
|
@ -338,8 +338,6 @@ void CMasternodePayments::ProcessMessage(CNode* pfrom, std::string& strCommand,
|
|||||||
|
|
||||||
if(pfrom->nVersion < GetMinMasternodePaymentsProto()) return;
|
if(pfrom->nVersion < GetMinMasternodePaymentsProto()) return;
|
||||||
|
|
||||||
if(!pCurrentBlockIndex) return;
|
|
||||||
|
|
||||||
uint256 nHash = vote.GetHash();
|
uint256 nHash = vote.GetHash();
|
||||||
|
|
||||||
pfrom->setAskFor.erase(nHash);
|
pfrom->setAskFor.erase(nHash);
|
||||||
@ -347,7 +345,7 @@ void CMasternodePayments::ProcessMessage(CNode* pfrom, std::string& strCommand,
|
|||||||
{
|
{
|
||||||
LOCK(cs_mapMasternodePaymentVotes);
|
LOCK(cs_mapMasternodePaymentVotes);
|
||||||
if(mapMasternodePaymentVotes.count(nHash)) {
|
if(mapMasternodePaymentVotes.count(nHash)) {
|
||||||
LogPrint("mnpayments", "MASTERNODEPAYMENTVOTE -- hash=%s, nHeight=%d seen\n", nHash.ToString(), pCurrentBlockIndex->nHeight);
|
LogPrint("mnpayments", "MASTERNODEPAYMENTVOTE -- hash=%s, nHeight=%d seen\n", nHash.ToString(), nCachedBlockHeight);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,14 +356,14 @@ void CMasternodePayments::ProcessMessage(CNode* pfrom, std::string& strCommand,
|
|||||||
mapMasternodePaymentVotes[nHash].MarkAsNotVerified();
|
mapMasternodePaymentVotes[nHash].MarkAsNotVerified();
|
||||||
}
|
}
|
||||||
|
|
||||||
int nFirstBlock = pCurrentBlockIndex->nHeight - GetStorageLimit();
|
int nFirstBlock = nCachedBlockHeight - GetStorageLimit();
|
||||||
if(vote.nBlockHeight < nFirstBlock || vote.nBlockHeight > pCurrentBlockIndex->nHeight+20) {
|
if(vote.nBlockHeight < nFirstBlock || vote.nBlockHeight > nCachedBlockHeight+20) {
|
||||||
LogPrint("mnpayments", "MASTERNODEPAYMENTVOTE -- vote out of range: nFirstBlock=%d, nBlockHeight=%d, nHeight=%d\n", nFirstBlock, vote.nBlockHeight, pCurrentBlockIndex->nHeight);
|
LogPrint("mnpayments", "MASTERNODEPAYMENTVOTE -- vote out of range: nFirstBlock=%d, nBlockHeight=%d, nHeight=%d\n", nFirstBlock, vote.nBlockHeight, nCachedBlockHeight);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string strError = "";
|
std::string strError = "";
|
||||||
if(!vote.IsValid(pfrom, pCurrentBlockIndex->nHeight, strError)) {
|
if(!vote.IsValid(pfrom, nCachedBlockHeight, strError)) {
|
||||||
LogPrint("mnpayments", "MASTERNODEPAYMENTVOTE -- invalid message, error: %s\n", strError);
|
LogPrint("mnpayments", "MASTERNODEPAYMENTVOTE -- invalid message, error: %s\n", strError);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -384,7 +382,7 @@ void CMasternodePayments::ProcessMessage(CNode* pfrom, std::string& strCommand,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int nDos = 0;
|
int nDos = 0;
|
||||||
if(!vote.CheckSignature(mnInfo.pubKeyMasternode, pCurrentBlockIndex->nHeight, nDos)) {
|
if(!vote.CheckSignature(mnInfo.pubKeyMasternode, nCachedBlockHeight, nDos)) {
|
||||||
if(nDos) {
|
if(nDos) {
|
||||||
LogPrintf("MASTERNODEPAYMENTVOTE -- ERROR: invalid signature\n");
|
LogPrintf("MASTERNODEPAYMENTVOTE -- ERROR: invalid signature\n");
|
||||||
Misbehaving(pfrom->GetId(), nDos);
|
Misbehaving(pfrom->GetId(), nDos);
|
||||||
@ -406,7 +404,7 @@ void CMasternodePayments::ProcessMessage(CNode* pfrom, std::string& strCommand,
|
|||||||
CBitcoinAddress address2(address1);
|
CBitcoinAddress address2(address1);
|
||||||
|
|
||||||
LogPrint("mnpayments", "MASTERNODEPAYMENTVOTE -- vote: address=%s, nBlockHeight=%d, nHeight=%d, prevout=%s, hash=%s new\n",
|
LogPrint("mnpayments", "MASTERNODEPAYMENTVOTE -- vote: address=%s, nBlockHeight=%d, nHeight=%d, prevout=%s, hash=%s new\n",
|
||||||
address2.ToString(), vote.nBlockHeight, pCurrentBlockIndex->nHeight, vote.vinMasternode.prevout.ToStringShort(), nHash.ToString());
|
address2.ToString(), vote.nBlockHeight, nCachedBlockHeight, vote.vinMasternode.prevout.ToStringShort(), nHash.ToString());
|
||||||
|
|
||||||
if(AddPaymentVote(vote)){
|
if(AddPaymentVote(vote)){
|
||||||
vote.Relay();
|
vote.Relay();
|
||||||
@ -450,13 +448,13 @@ bool CMasternodePayments::IsScheduled(CMasternode& mn, int nNotBlockHeight)
|
|||||||
{
|
{
|
||||||
LOCK(cs_mapMasternodeBlocks);
|
LOCK(cs_mapMasternodeBlocks);
|
||||||
|
|
||||||
if(!pCurrentBlockIndex) return false;
|
if(!masternodeSync.IsMasternodeListSynced()) return false;
|
||||||
|
|
||||||
CScript mnpayee;
|
CScript mnpayee;
|
||||||
mnpayee = GetScriptForDestination(mn.pubKeyCollateralAddress.GetID());
|
mnpayee = GetScriptForDestination(mn.pubKeyCollateralAddress.GetID());
|
||||||
|
|
||||||
CScript payee;
|
CScript payee;
|
||||||
for(int64_t h = pCurrentBlockIndex->nHeight; h <= pCurrentBlockIndex->nHeight + 8; h++){
|
for(int64_t h = nCachedBlockHeight; h <= nCachedBlockHeight + 8; h++){
|
||||||
if(h == nNotBlockHeight) continue;
|
if(h == nNotBlockHeight) continue;
|
||||||
if(mapMasternodeBlocks.count(h) && mapMasternodeBlocks[h].GetBestPayee(payee) && mnpayee == payee) {
|
if(mapMasternodeBlocks.count(h) && mapMasternodeBlocks[h].GetBestPayee(payee) && mnpayee == payee) {
|
||||||
return true;
|
return true;
|
||||||
@ -633,7 +631,7 @@ bool CMasternodePayments::IsTransactionValid(const CTransaction& txNew, int nBlo
|
|||||||
|
|
||||||
void CMasternodePayments::CheckAndRemove()
|
void CMasternodePayments::CheckAndRemove()
|
||||||
{
|
{
|
||||||
if(!pCurrentBlockIndex) return;
|
if(!masternodeSync.IsBlockchainSynced()) return;
|
||||||
|
|
||||||
LOCK2(cs_mapMasternodeBlocks, cs_mapMasternodePaymentVotes);
|
LOCK2(cs_mapMasternodeBlocks, cs_mapMasternodePaymentVotes);
|
||||||
|
|
||||||
@ -643,7 +641,7 @@ void CMasternodePayments::CheckAndRemove()
|
|||||||
while(it != mapMasternodePaymentVotes.end()) {
|
while(it != mapMasternodePaymentVotes.end()) {
|
||||||
CMasternodePaymentVote vote = (*it).second;
|
CMasternodePaymentVote vote = (*it).second;
|
||||||
|
|
||||||
if(pCurrentBlockIndex->nHeight - vote.nBlockHeight > nLimit) {
|
if(nCachedBlockHeight - vote.nBlockHeight > nLimit) {
|
||||||
LogPrint("mnpayments", "CMasternodePayments::CheckAndRemove -- Removing old Masternode payment: nBlockHeight=%d\n", vote.nBlockHeight);
|
LogPrint("mnpayments", "CMasternodePayments::CheckAndRemove -- Removing old Masternode payment: nBlockHeight=%d\n", vote.nBlockHeight);
|
||||||
mapMasternodePaymentVotes.erase(it++);
|
mapMasternodePaymentVotes.erase(it++);
|
||||||
mapMasternodeBlocks.erase(vote.nBlockHeight);
|
mapMasternodeBlocks.erase(vote.nBlockHeight);
|
||||||
@ -824,11 +822,11 @@ void CMasternodePayments::Sync(CNode* pnode)
|
|||||||
{
|
{
|
||||||
LOCK(cs_mapMasternodeBlocks);
|
LOCK(cs_mapMasternodeBlocks);
|
||||||
|
|
||||||
if(!pCurrentBlockIndex) return;
|
if(!masternodeSync.IsWinnersListSynced()) return;
|
||||||
|
|
||||||
int nInvCount = 0;
|
int nInvCount = 0;
|
||||||
|
|
||||||
for(int h = pCurrentBlockIndex->nHeight; h < pCurrentBlockIndex->nHeight + 20; h++) {
|
for(int h = nCachedBlockHeight; h < nCachedBlockHeight + 20; h++) {
|
||||||
if(mapMasternodeBlocks.count(h)) {
|
if(mapMasternodeBlocks.count(h)) {
|
||||||
BOOST_FOREACH(CMasternodePayee& payee, mapMasternodeBlocks[h].vecPayees) {
|
BOOST_FOREACH(CMasternodePayee& payee, mapMasternodeBlocks[h].vecPayees) {
|
||||||
std::vector<uint256> vecVoteHashes = payee.GetVoteHashes();
|
std::vector<uint256> vecVoteHashes = payee.GetVoteHashes();
|
||||||
@ -848,16 +846,16 @@ void CMasternodePayments::Sync(CNode* pnode)
|
|||||||
// Request low data/unknown payment blocks in batches directly from some node instead of/after preliminary Sync.
|
// Request low data/unknown payment blocks in batches directly from some node instead of/after preliminary Sync.
|
||||||
void CMasternodePayments::RequestLowDataPaymentBlocks(CNode* pnode)
|
void CMasternodePayments::RequestLowDataPaymentBlocks(CNode* pnode)
|
||||||
{
|
{
|
||||||
if(!pCurrentBlockIndex) return;
|
if(!masternodeSync.IsMasternodeListSynced()) return;
|
||||||
|
|
||||||
LOCK2(cs_main, cs_mapMasternodeBlocks);
|
LOCK2(cs_main, cs_mapMasternodeBlocks);
|
||||||
|
|
||||||
std::vector<CInv> vToFetch;
|
std::vector<CInv> vToFetch;
|
||||||
int nLimit = GetStorageLimit();
|
int nLimit = GetStorageLimit();
|
||||||
|
|
||||||
const CBlockIndex *pindex = pCurrentBlockIndex;
|
const CBlockIndex *pindex = chainActive.Tip();
|
||||||
|
|
||||||
while(pCurrentBlockIndex->nHeight - pindex->nHeight < nLimit) {
|
while(nCachedBlockHeight - pindex->nHeight < nLimit) {
|
||||||
if(!mapMasternodeBlocks.count(pindex->nHeight)) {
|
if(!mapMasternodeBlocks.count(pindex->nHeight)) {
|
||||||
// We have no idea about this block height, let's ask
|
// We have no idea about this block height, let's ask
|
||||||
vToFetch.push_back(CInv(MSG_MASTERNODE_PAYMENT_BLOCK, pindex->GetBlockHash()));
|
vToFetch.push_back(CInv(MSG_MASTERNODE_PAYMENT_BLOCK, pindex->GetBlockHash()));
|
||||||
@ -949,8 +947,10 @@ int CMasternodePayments::GetStorageLimit()
|
|||||||
|
|
||||||
void CMasternodePayments::UpdatedBlockTip(const CBlockIndex *pindex)
|
void CMasternodePayments::UpdatedBlockTip(const CBlockIndex *pindex)
|
||||||
{
|
{
|
||||||
pCurrentBlockIndex = pindex;
|
if(!pindex) return;
|
||||||
LogPrint("mnpayments", "CMasternodePayments::UpdatedBlockTip -- pCurrentBlockIndex->nHeight=%d\n", pCurrentBlockIndex->nHeight);
|
|
||||||
|
|
||||||
ProcessBlock(pindex->nHeight + 10);
|
nCachedBlockHeight = pindex->nHeight;
|
||||||
|
LogPrint("mnpayments", "CMasternodePayments::UpdatedBlockTip -- nCachedBlockHeight=%d\n", nCachedBlockHeight);
|
||||||
|
|
||||||
|
ProcessBlock(nCachedBlockHeight + 10);
|
||||||
}
|
}
|
||||||
|
@ -172,8 +172,8 @@ private:
|
|||||||
// ... but at least nMinBlocksToStore (payments blocks)
|
// ... but at least nMinBlocksToStore (payments blocks)
|
||||||
const int nMinBlocksToStore;
|
const int nMinBlocksToStore;
|
||||||
|
|
||||||
// Keep track of current block index
|
// Keep track of current block height
|
||||||
const CBlockIndex *pCurrentBlockIndex;
|
int nCachedBlockHeight;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::map<uint256, CMasternodePaymentVote> mapMasternodePaymentVotes;
|
std::map<uint256, CMasternodePaymentVote> mapMasternodePaymentVotes;
|
||||||
|
@ -145,7 +145,6 @@ void CMasternodeSync::ProcessTick()
|
|||||||
{
|
{
|
||||||
static int nTick = 0;
|
static int nTick = 0;
|
||||||
if(nTick++ % MASTERNODE_SYNC_TICK_SECONDS != 0) return;
|
if(nTick++ % MASTERNODE_SYNC_TICK_SECONDS != 0) return;
|
||||||
if(!pCurrentBlockIndex) return;
|
|
||||||
|
|
||||||
// reset the sync process if the last call to this function was more than 60 minutes ago (client was in sleep mode)
|
// reset the sync process if the last call to this function was more than 60 minutes ago (client was in sleep mode)
|
||||||
static int64_t nTimeLastProcess = GetTime();
|
static int64_t nTimeLastProcess = GetTime();
|
||||||
@ -389,8 +388,7 @@ void CMasternodeSync::SendGovernanceSyncRequest(CNode* pnode)
|
|||||||
|
|
||||||
void CMasternodeSync::UpdatedBlockTip(const CBlockIndex *pindexNew, bool fInitialDownload)
|
void CMasternodeSync::UpdatedBlockTip(const CBlockIndex *pindexNew, bool fInitialDownload)
|
||||||
{
|
{
|
||||||
pCurrentBlockIndex = pindexNew;
|
if(fDebug) LogPrintf("CMasternodeSync::UpdatedBlockTip -- pindexNew->nHeight: %d fInitialDownload=%d\n", pindexNew->nHeight, fInitialDownload);
|
||||||
if(fDebug) LogPrintf("CMasternodeSync::UpdatedBlockTip -- pCurrentBlockIndex->nHeight: %d fInitialDownload=%d\n", pCurrentBlockIndex->nHeight, fInitialDownload);
|
|
||||||
// nothing to do here if we failed to sync previousely,
|
// nothing to do here if we failed to sync previousely,
|
||||||
// just wait till status reset after a cooldown (see ProcessTick)
|
// just wait till status reset after a cooldown (see ProcessTick)
|
||||||
if(IsFailed()) return;
|
if(IsFailed()) return;
|
||||||
|
@ -46,9 +46,6 @@ private:
|
|||||||
// ... or failed
|
// ... or failed
|
||||||
int64_t nTimeLastFailure;
|
int64_t nTimeLastFailure;
|
||||||
|
|
||||||
// Keep track of current block index
|
|
||||||
const CBlockIndex *pCurrentBlockIndex;
|
|
||||||
|
|
||||||
void Fail();
|
void Fail();
|
||||||
void ClearFulfilledRequests();
|
void ClearFulfilledRequests();
|
||||||
|
|
||||||
|
@ -210,8 +210,7 @@ void CMasternodeMan::CheckAndRemove()
|
|||||||
it = vMasternodes.erase(it);
|
it = vMasternodes.erase(it);
|
||||||
fMasternodesRemoved = true;
|
fMasternodesRemoved = true;
|
||||||
} else {
|
} else {
|
||||||
bool fAsk = pCurrentBlockIndex &&
|
bool fAsk = (nAskForMnbRecovery > 0) &&
|
||||||
(nAskForMnbRecovery > 0) &&
|
|
||||||
masternodeSync.IsSynced() &&
|
masternodeSync.IsSynced() &&
|
||||||
it->IsNewStartRequired() &&
|
it->IsNewStartRequired() &&
|
||||||
!IsMnbRecoveryRequested(hash);
|
!IsMnbRecoveryRequested(hash);
|
||||||
@ -220,7 +219,7 @@ void CMasternodeMan::CheckAndRemove()
|
|||||||
std::set<CNetAddr> setRequested;
|
std::set<CNetAddr> setRequested;
|
||||||
// calulate only once and only when it's needed
|
// calulate only once and only when it's needed
|
||||||
if(vecMasternodeRanks.empty()) {
|
if(vecMasternodeRanks.empty()) {
|
||||||
int nRandomBlockHeight = GetRandInt(pCurrentBlockIndex->nHeight);
|
int nRandomBlockHeight = GetRandInt(nCachedBlockHeight);
|
||||||
vecMasternodeRanks = GetMasternodeRanks(nRandomBlockHeight);
|
vecMasternodeRanks = GetMasternodeRanks(nRandomBlockHeight);
|
||||||
}
|
}
|
||||||
bool fAskedForMnbRecovery = false;
|
bool fAskedForMnbRecovery = false;
|
||||||
@ -321,7 +320,7 @@ void CMasternodeMan::CheckAndRemove()
|
|||||||
|
|
||||||
std::map<CNetAddr, CMasternodeVerification>::iterator it3 = mWeAskedForVerification.begin();
|
std::map<CNetAddr, CMasternodeVerification>::iterator it3 = mWeAskedForVerification.begin();
|
||||||
while(it3 != mWeAskedForVerification.end()){
|
while(it3 != mWeAskedForVerification.end()){
|
||||||
if(it3->second.nBlockHeight < pCurrentBlockIndex->nHeight - MAX_POSE_BLOCKS) {
|
if(it3->second.nBlockHeight < nCachedBlockHeight - MAX_POSE_BLOCKS) {
|
||||||
mWeAskedForVerification.erase(it3++);
|
mWeAskedForVerification.erase(it3++);
|
||||||
} else {
|
} else {
|
||||||
++it3;
|
++it3;
|
||||||
@ -344,7 +343,7 @@ void CMasternodeMan::CheckAndRemove()
|
|||||||
// remove expired mapSeenMasternodeVerification
|
// remove expired mapSeenMasternodeVerification
|
||||||
std::map<uint256, CMasternodeVerification>::iterator itv2 = mapSeenMasternodeVerification.begin();
|
std::map<uint256, CMasternodeVerification>::iterator itv2 = mapSeenMasternodeVerification.begin();
|
||||||
while(itv2 != mapSeenMasternodeVerification.end()){
|
while(itv2 != mapSeenMasternodeVerification.end()){
|
||||||
if((*itv2).second.nBlockHeight < pCurrentBlockIndex->nHeight - MAX_POSE_BLOCKS){
|
if((*itv2).second.nBlockHeight < nCachedBlockHeight - MAX_POSE_BLOCKS){
|
||||||
LogPrint("masternode", "CMasternodeMan::CheckAndRemove -- Removing expired Masternode verification: hash=%s\n", (*itv2).first.ToString());
|
LogPrint("masternode", "CMasternodeMan::CheckAndRemove -- Removing expired Masternode verification: hash=%s\n", (*itv2).first.ToString());
|
||||||
mapSeenMasternodeVerification.erase(itv2++);
|
mapSeenMasternodeVerification.erase(itv2++);
|
||||||
} else {
|
} else {
|
||||||
@ -541,15 +540,17 @@ bool CMasternodeMan::Has(const CTxIn& vin)
|
|||||||
//
|
//
|
||||||
CMasternode* CMasternodeMan::GetNextMasternodeInQueueForPayment(bool fFilterSigTime, int& nCount)
|
CMasternode* CMasternodeMan::GetNextMasternodeInQueueForPayment(bool fFilterSigTime, int& nCount)
|
||||||
{
|
{
|
||||||
if(!pCurrentBlockIndex) {
|
return GetNextMasternodeInQueueForPayment(nCachedBlockHeight, fFilterSigTime, nCount);
|
||||||
nCount = 0;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return GetNextMasternodeInQueueForPayment(pCurrentBlockIndex->nHeight, fFilterSigTime, nCount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CMasternode* CMasternodeMan::GetNextMasternodeInQueueForPayment(int nBlockHeight, bool fFilterSigTime, int& nCount)
|
CMasternode* CMasternodeMan::GetNextMasternodeInQueueForPayment(int nBlockHeight, bool fFilterSigTime, int& nCount)
|
||||||
{
|
{
|
||||||
|
if (!masternodeSync.IsWinnersListSynced()) {
|
||||||
|
// without winner list we can't reliably find the next winner anyway
|
||||||
|
nCount = 0;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// Need LOCK2 here to ensure consistent locking order because the GetBlockHash call below locks cs_main
|
// Need LOCK2 here to ensure consistent locking order because the GetBlockHash call below locks cs_main
|
||||||
LOCK2(cs_main,cs);
|
LOCK2(cs_main,cs);
|
||||||
|
|
||||||
@ -961,7 +962,7 @@ void CMasternodeMan::DoFullVerificationStep()
|
|||||||
if(activeMasternode.vin == CTxIn()) return;
|
if(activeMasternode.vin == CTxIn()) return;
|
||||||
if(!masternodeSync.IsSynced()) return;
|
if(!masternodeSync.IsSynced()) return;
|
||||||
|
|
||||||
std::vector<std::pair<int, CMasternode> > vecMasternodeRanks = GetMasternodeRanks(pCurrentBlockIndex->nHeight - 1, MIN_POSE_PROTO_VERSION);
|
std::vector<std::pair<int, CMasternode> > vecMasternodeRanks = GetMasternodeRanks(nCachedBlockHeight - 1, MIN_POSE_PROTO_VERSION);
|
||||||
|
|
||||||
// Need LOCK2 here to ensure consistent locking order because the SendVerifyRequest call below locks cs_main
|
// Need LOCK2 here to ensure consistent locking order because the SendVerifyRequest call below locks cs_main
|
||||||
// through GetHeight() signal in ConnectNode
|
// through GetHeight() signal in ConnectNode
|
||||||
@ -1106,7 +1107,7 @@ bool CMasternodeMan::SendVerifyRequest(const CAddress& addr, const std::vector<C
|
|||||||
|
|
||||||
netfulfilledman.AddFulfilledRequest(addr, strprintf("%s", NetMsgType::MNVERIFY)+"-request");
|
netfulfilledman.AddFulfilledRequest(addr, strprintf("%s", NetMsgType::MNVERIFY)+"-request");
|
||||||
// use random nonce, store it and require node to reply with correct one later
|
// use random nonce, store it and require node to reply with correct one later
|
||||||
CMasternodeVerification mnv(addr, GetRandInt(999999), pCurrentBlockIndex->nHeight - 1);
|
CMasternodeVerification mnv(addr, GetRandInt(999999), nCachedBlockHeight - 1);
|
||||||
mWeAskedForVerification[addr] = mnv;
|
mWeAskedForVerification[addr] = mnv;
|
||||||
LogPrintf("CMasternodeMan::SendVerifyRequest -- verifying node using nonce %d addr=%s\n", mnv.nonce, addr.ToString());
|
LogPrintf("CMasternodeMan::SendVerifyRequest -- verifying node using nonce %d addr=%s\n", mnv.nonce, addr.ToString());
|
||||||
g_connman->PushMessage(pnode, NetMsgType::MNVERIFY, mnv);
|
g_connman->PushMessage(pnode, NetMsgType::MNVERIFY, mnv);
|
||||||
@ -1274,9 +1275,9 @@ void CMasternodeMan::ProcessVerifyBroadcast(CNode* pnode, const CMasternodeVerif
|
|||||||
mapSeenMasternodeVerification[mnv.GetHash()] = mnv;
|
mapSeenMasternodeVerification[mnv.GetHash()] = mnv;
|
||||||
|
|
||||||
// we don't care about history
|
// we don't care about history
|
||||||
if(mnv.nBlockHeight < pCurrentBlockIndex->nHeight - MAX_POSE_BLOCKS) {
|
if(mnv.nBlockHeight < nCachedBlockHeight - MAX_POSE_BLOCKS) {
|
||||||
LogPrint("masternode", "CMasternodeMan::ProcessVerifyBroadcast -- Outdated: current block %d, verification block %d, peer=%d\n",
|
LogPrint("masternode", "CMasternodeMan::ProcessVerifyBroadcast -- Outdated: current block %d, verification block %d, peer=%d\n",
|
||||||
pCurrentBlockIndex->nHeight, mnv.nBlockHeight, pnode->id);
|
nCachedBlockHeight, mnv.nBlockHeight, pnode->id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1495,12 +1496,11 @@ bool CMasternodeMan::CheckMnbAndUpdateMasternodeList(CNode* pfrom, CMasternodeBr
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMasternodeMan::UpdateLastPaid()
|
void CMasternodeMan::UpdateLastPaid(const CBlockIndex* pindex)
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
|
|
||||||
if(fLiteMode || !pCurrentBlockIndex) return;
|
if(fLiteMode || !masternodeSync.IsWinnersListSynced() || vMasternodes.empty()) return;
|
||||||
if(!masternodeSync.IsWinnersListSynced() || vMasternodes.empty()) return;
|
|
||||||
|
|
||||||
static bool IsFirstRun = true;
|
static bool IsFirstRun = true;
|
||||||
// Do full scan on first run or if we are not a masternode
|
// Do full scan on first run or if we are not a masternode
|
||||||
@ -1508,10 +1508,10 @@ void CMasternodeMan::UpdateLastPaid()
|
|||||||
int nMaxBlocksToScanBack = (IsFirstRun || !fMasterNode) ? mnpayments.GetStorageLimit() : LAST_PAID_SCAN_BLOCKS;
|
int nMaxBlocksToScanBack = (IsFirstRun || !fMasterNode) ? mnpayments.GetStorageLimit() : LAST_PAID_SCAN_BLOCKS;
|
||||||
|
|
||||||
// LogPrint("mnpayments", "CMasternodeMan::UpdateLastPaid -- nHeight=%d, nMaxBlocksToScanBack=%d, IsFirstRun=%s\n",
|
// LogPrint("mnpayments", "CMasternodeMan::UpdateLastPaid -- nHeight=%d, nMaxBlocksToScanBack=%d, IsFirstRun=%s\n",
|
||||||
// pCurrentBlockIndex->nHeight, nMaxBlocksToScanBack, IsFirstRun ? "true" : "false");
|
// nCachedBlockHeight, nMaxBlocksToScanBack, IsFirstRun ? "true" : "false");
|
||||||
|
|
||||||
BOOST_FOREACH(CMasternode& mn, vMasternodes) {
|
BOOST_FOREACH(CMasternode& mn, vMasternodes) {
|
||||||
mn.UpdateLastPaid(pCurrentBlockIndex, nMaxBlocksToScanBack);
|
mn.UpdateLastPaid(pindex, nMaxBlocksToScanBack);
|
||||||
}
|
}
|
||||||
|
|
||||||
IsFirstRun = false;
|
IsFirstRun = false;
|
||||||
@ -1666,14 +1666,14 @@ void CMasternodeMan::SetMasternodeLastPing(const CTxIn& vin, const CMasternodePi
|
|||||||
|
|
||||||
void CMasternodeMan::UpdatedBlockTip(const CBlockIndex *pindex)
|
void CMasternodeMan::UpdatedBlockTip(const CBlockIndex *pindex)
|
||||||
{
|
{
|
||||||
pCurrentBlockIndex = pindex;
|
nCachedBlockHeight = pindex->nHeight;
|
||||||
LogPrint("masternode", "CMasternodeMan::UpdatedBlockTip -- pCurrentBlockIndex->nHeight=%d\n", pCurrentBlockIndex->nHeight);
|
LogPrint("masternode", "CMasternodeMan::UpdatedBlockTip -- nCachedBlockHeight=%d\n", nCachedBlockHeight);
|
||||||
|
|
||||||
CheckSameAddr();
|
CheckSameAddr();
|
||||||
|
|
||||||
if(fMasterNode) {
|
if(fMasterNode) {
|
||||||
// normal wallet does not need to update this every block, doing update on rpc call should be enough
|
// normal wallet does not need to update this every block, doing update on rpc call should be enough
|
||||||
UpdateLastPaid();
|
UpdateLastPaid(pindex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,8 +114,8 @@ private:
|
|||||||
// critical section to protect the inner data structures
|
// critical section to protect the inner data structures
|
||||||
mutable CCriticalSection cs;
|
mutable CCriticalSection cs;
|
||||||
|
|
||||||
// Keep track of current block index
|
// Keep track of current block height
|
||||||
const CBlockIndex *pCurrentBlockIndex;
|
int nCachedBlockHeight;
|
||||||
|
|
||||||
// map to hold all MNs
|
// map to hold all MNs
|
||||||
std::vector<CMasternode> vMasternodes;
|
std::vector<CMasternode> vMasternodes;
|
||||||
@ -321,7 +321,7 @@ public:
|
|||||||
bool CheckMnbAndUpdateMasternodeList(CNode* pfrom, CMasternodeBroadcast mnb, int& nDos);
|
bool CheckMnbAndUpdateMasternodeList(CNode* pfrom, CMasternodeBroadcast mnb, int& nDos);
|
||||||
bool IsMnbRecoveryRequested(const uint256& hash) { return mMnbRecoveryRequests.count(hash); }
|
bool IsMnbRecoveryRequested(const uint256& hash) { return mMnbRecoveryRequests.count(hash); }
|
||||||
|
|
||||||
void UpdateLastPaid();
|
void UpdateLastPaid(const CBlockIndex* pindex);
|
||||||
bool UpdateLastDsq(const CTxIn& vin);
|
bool UpdateLastDsq(const CTxIn& vin);
|
||||||
|
|
||||||
void CheckAndRebuildMasternodeIndex();
|
void CheckAndRebuildMasternodeIndex();
|
||||||
|
@ -242,7 +242,7 @@ std::string CPrivateSendClient::GetStatus()
|
|||||||
nStatusMessageProgress += 10;
|
nStatusMessageProgress += 10;
|
||||||
std::string strSuffix = "";
|
std::string strSuffix = "";
|
||||||
|
|
||||||
if((pCurrentBlockIndex && pCurrentBlockIndex->nHeight - nCachedLastSuccessBlock < nMinBlockSpacing) || !masternodeSync.IsBlockchainSynced())
|
if((nCachedBlockHeight - nCachedLastSuccessBlock < nMinBlockSpacing) || !masternodeSync.IsBlockchainSynced())
|
||||||
return strAutoDenomResult;
|
return strAutoDenomResult;
|
||||||
|
|
||||||
switch(nState) {
|
switch(nState) {
|
||||||
@ -578,7 +578,7 @@ void CPrivateSendClient::CompletedTransaction(PoolMessage nMessageID)
|
|||||||
|
|
||||||
if(nMessageID == MSG_SUCCESS) {
|
if(nMessageID == MSG_SUCCESS) {
|
||||||
LogPrintf("CompletedTransaction -- success\n");
|
LogPrintf("CompletedTransaction -- success\n");
|
||||||
nCachedLastSuccessBlock = pCurrentBlockIndex->nHeight;
|
nCachedLastSuccessBlock = nCachedBlockHeight;
|
||||||
} else {
|
} else {
|
||||||
LogPrintf("CompletedTransaction -- error\n");
|
LogPrintf("CompletedTransaction -- error\n");
|
||||||
}
|
}
|
||||||
@ -658,7 +658,8 @@ bool CPrivateSendClient::CheckAutomaticBackup()
|
|||||||
//
|
//
|
||||||
bool CPrivateSendClient::DoAutomaticDenominating(CConnman& connman, bool fDryRun)
|
bool CPrivateSendClient::DoAutomaticDenominating(CConnman& connman, bool fDryRun)
|
||||||
{
|
{
|
||||||
if(!fEnablePrivateSend || fMasterNode || !pCurrentBlockIndex) return false;
|
if(fMasterNode) return false; // no client-side mixing on masternodes
|
||||||
|
if(!fEnablePrivateSend) return false;
|
||||||
if(!pwalletMain || pwalletMain->IsLocked(true)) return false;
|
if(!pwalletMain || pwalletMain->IsLocked(true)) return false;
|
||||||
if(nState != POOL_STATE_IDLE) return false;
|
if(nState != POOL_STATE_IDLE) return false;
|
||||||
|
|
||||||
@ -686,7 +687,7 @@ bool CPrivateSendClient::DoAutomaticDenominating(CConnman& connman, bool fDryRun
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!fPrivateSendMultiSession && pCurrentBlockIndex->nHeight - nCachedLastSuccessBlock < nMinBlockSpacing) {
|
if(!fPrivateSendMultiSession && nCachedBlockHeight - nCachedLastSuccessBlock < nMinBlockSpacing) {
|
||||||
LogPrintf("CPrivateSendClient::DoAutomaticDenominating -- Last successful PrivateSend action was too recent\n");
|
LogPrintf("CPrivateSendClient::DoAutomaticDenominating -- Last successful PrivateSend action was too recent\n");
|
||||||
strAutoDenomResult = _("Last successful PrivateSend action was too recent.");
|
strAutoDenomResult = _("Last successful PrivateSend action was too recent.");
|
||||||
return false;
|
return false;
|
||||||
@ -1214,7 +1215,7 @@ bool CPrivateSendClient::MakeCollateralAmounts(const CompactTallyItem& tallyItem
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nCachedLastSuccessBlock = pCurrentBlockIndex->nHeight;
|
nCachedLastSuccessBlock = nCachedBlockHeight;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1362,7 +1363,7 @@ bool CPrivateSendClient::CreateDenominated(const CompactTallyItem& tallyItem, bo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// use the same nCachedLastSuccessBlock as for DS mixing to prevent race
|
// use the same nCachedLastSuccessBlock as for DS mixing to prevent race
|
||||||
nCachedLastSuccessBlock = pCurrentBlockIndex->nHeight;
|
nCachedLastSuccessBlock = nCachedBlockHeight;
|
||||||
LogPrintf("CPrivateSendClient::CreateDenominated -- txid=%s\n", wtx.GetHash().GetHex());
|
LogPrintf("CPrivateSendClient::CreateDenominated -- txid=%s\n", wtx.GetHash().GetHex());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -1387,8 +1388,8 @@ void CPrivateSendClient::SetState(PoolState nStateNew)
|
|||||||
|
|
||||||
void CPrivateSendClient::UpdatedBlockTip(const CBlockIndex *pindex)
|
void CPrivateSendClient::UpdatedBlockTip(const CBlockIndex *pindex)
|
||||||
{
|
{
|
||||||
pCurrentBlockIndex = pindex;
|
nCachedBlockHeight = pindex->nHeight;
|
||||||
LogPrint("privatesend", "CPrivateSendClient::UpdatedBlockTip -- pCurrentBlockIndex->nHeight: %d\n", pCurrentBlockIndex->nHeight);
|
LogPrint("privatesend", "CPrivateSendClient::UpdatedBlockTip -- nCachedBlockHeight: %d\n", nCachedBlockHeight);
|
||||||
|
|
||||||
if(!fLiteMode && masternodeSync.IsMasternodeListSynced()) {
|
if(!fLiteMode && masternodeSync.IsMasternodeListSynced()) {
|
||||||
NewBlock();
|
NewBlock();
|
||||||
|
@ -43,7 +43,9 @@ private:
|
|||||||
|
|
||||||
int nCachedLastSuccessBlock;
|
int nCachedLastSuccessBlock;
|
||||||
int nMinBlockSpacing; //required blocks between mixes
|
int nMinBlockSpacing; //required blocks between mixes
|
||||||
const CBlockIndex *pCurrentBlockIndex; // Keep track of current block index
|
|
||||||
|
// Keep track of current block height
|
||||||
|
int nCachedBlockHeight;
|
||||||
|
|
||||||
int nEntriesCount;
|
int nEntriesCount;
|
||||||
bool fLastEntryAccepted;
|
bool fLastEntryAccepted;
|
||||||
|
@ -188,11 +188,13 @@ UniValue masternode(const UniValue& params, bool fHelp)
|
|||||||
int nCount;
|
int nCount;
|
||||||
int nHeight;
|
int nHeight;
|
||||||
CMasternode* winner = NULL;
|
CMasternode* winner = NULL;
|
||||||
|
CBlockIndex* pindex = NULL;
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
nHeight = chainActive.Height() + (strCommand == "current" ? 1 : 10);
|
pindex = chainActive.Tip();
|
||||||
}
|
}
|
||||||
mnodeman.UpdateLastPaid();
|
nHeight = pindex->nHeight + (strCommand == "current" ? 1 : 10);
|
||||||
|
mnodeman.UpdateLastPaid(pindex);
|
||||||
winner = mnodeman.GetNextMasternodeInQueueForPayment(nHeight, true, nCount);
|
winner = mnodeman.GetNextMasternodeInQueueForPayment(nHeight, true, nCount);
|
||||||
if(!winner) return "unknown";
|
if(!winner) return "unknown";
|
||||||
|
|
||||||
@ -487,7 +489,12 @@ UniValue masternodelist(const UniValue& params, bool fHelp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (strMode == "full" || strMode == "lastpaidtime" || strMode == "lastpaidblock") {
|
if (strMode == "full" || strMode == "lastpaidtime" || strMode == "lastpaidblock") {
|
||||||
mnodeman.UpdateLastPaid();
|
CBlockIndex* pindex = NULL;
|
||||||
|
{
|
||||||
|
LOCK(cs_main);
|
||||||
|
pindex = chainActive.Tip();
|
||||||
|
}
|
||||||
|
mnodeman.UpdateLastPaid(pindex);
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue obj(UniValue::VOBJ);
|
UniValue obj(UniValue::VOBJ);
|
||||||
|
@ -89,7 +89,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
|||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
fCheckpointsEnabled = false;
|
fCheckpointsEnabled = false;
|
||||||
|
|
||||||
// force UpdatedBlockTip to initialize pCurrentBlockIndex
|
// force UpdatedBlockTip to initialize nCachedBlockHeight
|
||||||
mnpayments.UpdatedBlockTip(chainActive.Tip());
|
mnpayments.UpdatedBlockTip(chainActive.Tip());
|
||||||
|
|
||||||
// Simple block creation, nothing special yet:
|
// Simple block creation, nothing special yet:
|
||||||
|
Loading…
Reference in New Issue
Block a user