Added masternode payee caching
This commit is contained in:
parent
837fe9b417
commit
7e38235e5a
@ -3,7 +3,7 @@ AC_PREREQ([2.60])
|
||||
define(_CLIENT_VERSION_MAJOR, 0)
|
||||
define(_CLIENT_VERSION_MINOR, 11)
|
||||
define(_CLIENT_VERSION_REVISION, 1)
|
||||
define(_CLIENT_VERSION_BUILD, 0)
|
||||
define(_CLIENT_VERSION_BUILD, 2)
|
||||
define(_CLIENT_VERSION_IS_RELEASE, true)
|
||||
define(_COPYRIGHT_YEAR, 2015)
|
||||
AC_INIT([Darkcoin Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[info@darkcoin.io],[darkcoin])
|
||||
|
@ -12,7 +12,7 @@
|
||||
#define CLIENT_VERSION_MAJOR 0
|
||||
#define CLIENT_VERSION_MINOR 11
|
||||
#define CLIENT_VERSION_REVISION 1
|
||||
#define CLIENT_VERSION_BUILD 1
|
||||
#define CLIENT_VERSION_BUILD 2
|
||||
|
||||
|
||||
|
||||
|
@ -2931,6 +2931,7 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
|
||||
foundPayee = true; //doesn't require a specific payee
|
||||
foundPaymentAmount = true;
|
||||
foundPaymentAndPayee = true;
|
||||
LogPrintf("CheckBlock() : Using non-specific masternode payments %d\n", chainActive.Tip()->nHeight+1);
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < block.vtx[0].vout.size(); i++) {
|
||||
@ -2949,11 +2950,17 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
|
||||
|
||||
LogPrintf("CheckBlock() : Couldn't find masternode payment(%d|%d) or payee(%d|%s) nHeight %d. \n", foundPaymentAmount, masternodePaymentAmount, foundPayee, address2.ToString().c_str(), chainActive.Tip()->nHeight+1);
|
||||
if(!RegTest()) return state.DoS(100, error("CheckBlock() : Couldn't find masternode payment or payee"));
|
||||
} else {
|
||||
LogPrintf("CheckBlock() : Found masternode payment %d\n", chainActive.Tip()->nHeight+1);
|
||||
}
|
||||
} else {
|
||||
LogPrintf("CheckBlock() : Is initial download, skipping masternode payment check %d\n", chainActive.Tip()->nHeight+1);
|
||||
}
|
||||
} else {
|
||||
LogPrintf("CheckBlock() : Skipping masternode payment check - nHeight %d Hash %s\n", chainActive.Tip()->nHeight+1, block.GetHash().ToString().c_str());
|
||||
}
|
||||
} else {
|
||||
LogPrintf("CheckBlock() : pindex is null, skipping masternode payment check\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,8 @@ map<uint256, int> mapSeenMasternodeScanningErrors;
|
||||
std::map<CNetAddr, int64_t> askedForMasternodeList;
|
||||
// which masternodes we've asked for
|
||||
std::map<COutPoint, int64_t> askedForMasternodeListEntry;
|
||||
// which masternodes we've asked for
|
||||
std::map<int, CScript> cacheBlockPayee;
|
||||
|
||||
// manage the masternode connections
|
||||
void ProcessMasternodeConnections(){
|
||||
@ -357,32 +359,23 @@ void ProcessMessageMasternode(CNode* pfrom, std::string& strCommand, CDataStream
|
||||
if(masternodePayments.AddWinningMasternode(winner)){
|
||||
masternodePayments.Relay(winner);
|
||||
}
|
||||
} /*else if (strCommand == "mnse") { //Masternode Scanning Error
|
||||
CMasternodeScanningError entry;
|
||||
vRecv >> entry;
|
||||
|
||||
if(chainActive.Tip() == NULL) return;
|
||||
|
||||
uint256 hash = entry.GetHash();
|
||||
if(mapSeenMasternodeScanningErrors.count(hash)) {
|
||||
if(fDebug) LogPrintf("mnse - seen entry addr %d error %d\n", entry.addr.ToString().c_str(), entry.error.c_str());
|
||||
return;
|
||||
if(chainActive.Tip()){
|
||||
//cache payments
|
||||
int success = 0;
|
||||
int fail = 0;
|
||||
for(int nBlockHeight = chainActive.Tip()->nHeight; nBlockHeight < chainActive.Tip()->nHeight+10; nBlockHeight++){
|
||||
CScript payee;
|
||||
if(masternodePayments.GetBlockPayee(nBlockHeight, payee)){
|
||||
success++;
|
||||
} else {
|
||||
fail++;
|
||||
}
|
||||
}
|
||||
LogPrintf("mnw - cached block payees - success %d fail %d\n", success, fail);
|
||||
}
|
||||
|
||||
LogPrintf("mnse - seen entry addr %d error %d\n", entry.addr.ToString().c_str(), entry.error.c_str());
|
||||
|
||||
if(!masternodeScanningError.CheckSignature(entry)){
|
||||
LogPrintf("mnse - invalid signature\n");
|
||||
Misbehaving(pfrom->GetId(), 100);
|
||||
return;
|
||||
}
|
||||
|
||||
mapSeenMasternodeVotes.insert(make_pair(hash, 1));
|
||||
|
||||
if(masternodeScanningError.AddWinningMasternode(entry)){
|
||||
masternodeScanningError.Relay(entry);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
struct CompareValueOnly
|
||||
@ -668,6 +661,13 @@ uint64_t CMasternodePayments::CalculateScore(uint256 blockHash, CTxIn& vin)
|
||||
|
||||
bool CMasternodePayments::GetBlockPayee(int nBlockHeight, CScript& payee)
|
||||
{
|
||||
|
||||
// if it's cached, use it
|
||||
if(cacheBlockPayee.count(nBlockHeight)){
|
||||
payee = cacheBlockPayee[nBlockHeight];
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOST_FOREACH(CMasternodePaymentWinner& winner, vWinning){
|
||||
if(winner.nBlockHeight == nBlockHeight) {
|
||||
|
||||
@ -677,6 +677,7 @@ bool CMasternodePayments::GetBlockPayee(int nBlockHeight, CScript& payee)
|
||||
BOOST_FOREACH(CTxOut out, tx.vout){
|
||||
if(out.nValue == 1000*COIN){
|
||||
payee = out.scriptPubKey;
|
||||
cacheBlockPayee.insert(make_pair(nBlockHeight, payee));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user