(log) tweaks and (general) cleanup (#1086)

* docs

* deprecated/unused/duplicate

* comments

* log cleanup/verbosity tuning

* names/ifs/whitespaces/std
This commit is contained in:
UdjinM6 2016-10-22 20:52:14 +04:00 committed by GitHub
parent 66c40e0687
commit 2d55b70381
30 changed files with 281 additions and 339 deletions

View File

@ -7,7 +7,7 @@ Use the autogen script to prepare the build environment.
make
Precompiled binaries are available at github, see
https://github.com/dashproject/dash-binaries
https://github.com/dashpay/dash-binaries
Always verify the signatures and checksums.

View File

@ -117,8 +117,8 @@ Mixing pool status update
| 4 | nMsgSessionID | int | Session ID
| 4 | nMsgState | int | Current state of mixing process
| 4 | nMsgEntriesCount | int | Number of entries in the mixing pool
| 4 | nMsgAccepted | int | Was entries accepted or not
| 4 | nMsgErrorID | int | Error ID if any
| 4 | nMsgStatusUpdate | int | Update state and/or signal if entry was accepted or not
| 4 | nMsgMessageID | int | ID of the typical masternode reply message
### DSQUEUE - "dsq"

View File

@ -20,7 +20,7 @@ Unpack the files into a directory, and then run dash-qt.exe.
### OS X
Drag Dash-Core to your applications folder, and then run Dash-Core.
Drag Dash-Qt to your applications folder, and then run Dash-Qt.
### Need Help?

View File

@ -36,7 +36,7 @@ Instructions: Homebrew
NOTE: Building with Qt4 is still supported, however, could result in a broken UI. As such, building with Qt5 is recommended.
### Building `Dash Core`
### Building Dash Core
1. Clone the GitHub tree to get the source code and go into the directory.

View File

@ -135,7 +135,7 @@ You can confirm that remote server is on the correct block by issuing
```dash-cli getinfo```
and comparing with the official explorer at http://explorer.dash.org/chain/Dash
and comparing with the official explorer at https://explorer.dash.org/chain/Dash
### Local

View File

@ -188,7 +188,7 @@ Note: check that SHA256SUMS itself doesn't end up in SHA256SUMS, which is a spur
- Announce the release:
- Release sticky on dashtalk: https://dashtalk.org/index.php?board=1.0 ***TODO***
- Release on Dash forum: https://www.dash.org/forum/topic/official-announcements.54/
- Dash-development mailing list

View File

@ -115,14 +115,14 @@ testScripts = [
'timestampindex.py',
'spentindex.py',
'decodescript.py',
'p2p-fullblocktest.py', # TODO: works, needs dash_hash
'p2p-fullblocktest.py', # NOTE: needs dash_hash to pass
'blockchain.py',
'disablewallet.py',
'sendheaders.py', # TODO: works, needs dash_hash
'sendheaders.py', # NOTE: needs dash_hash to pass
'keypool.py',
'prioritise_transaction.py',
'invalidblockrequest.py', # TODO: works, needs dash_hash
'invalidtxrequest.py', # TODO: works, needs dash_hash
'invalidblockrequest.py', # NOTE: needs dash_hash to pass
'invalidtxrequest.py', # NOTE: needs dash_hash to pass
'abandonconflict.py',
'p2p-versionbits-warning.py',
]
@ -132,9 +132,9 @@ if ENABLE_ZMQ:
testScriptsExt = [
'bip9-softforks.py',
'bip65-cltv.py',
'bip65-cltv-p2p.py', # TODO: works, needs dash_hash
'bip65-cltv-p2p.py', # NOTE: needs dash_hash to pass
'bip68-sequence.py',
'bipdersig-p2p.py', # TODO: works, needs dash_hash
'bipdersig-p2p.py', # NOTE: needs dash_hash to pass
'bipdersig.py',
'getblocktemplate_longpoll.py', # FIXME: "socket.error: [Errno 54] Connection reset by peer" on my Mac, same as https://github.com/bitcoin/bitcoin/issues/6651
'getblocktemplate_proposals.py',
@ -146,7 +146,7 @@ testScriptsExt = [
# 'rpcbind_test.py', #temporary, bug in libevent, see #6655
'smartfees.py',
'maxblocksinflight.py',
'p2p-acceptblock.py', # TODO: works, needs dash_hash
'p2p-acceptblock.py', # NOTE: needs dash_hash to pass
'mempool_packages.py',
'maxuploadtarget.py',
# 'replace-by-fee.py', # RBF is disabled in Dash Core

View File

@ -39,8 +39,7 @@ void CActiveMasternode::ManageState()
if(eType == MASTERNODE_REMOTE) {
ManageStateRemote();
}
else {
} else {
ManageStateLocal();
}
@ -55,12 +54,12 @@ void CActiveMasternode::ManageState()
std::string CActiveMasternode::GetStatus()
{
switch (nState) {
case ACTIVE_MASTERNODE_INITIAL: return "Node just started, not yet activated";
case ACTIVE_MASTERNODE_INITIAL: return "Node just started, not yet activated";
case ACTIVE_MASTERNODE_SYNC_IN_PROCESS: return "Sync in progress. Must wait until sync is complete to start Masternode";
case ACTIVE_MASTERNODE_INPUT_TOO_NEW: return strprintf("Masternode input must have at least %d confirmations", Params().GetConsensus().nMasternodeMinimumConfirmations);
case ACTIVE_MASTERNODE_NOT_CAPABLE: return "Not capable masternode: " + strNotCapableReason;
case ACTIVE_MASTERNODE_STARTED: return "Masternode successfully started";
default: return "unknown";
case ACTIVE_MASTERNODE_INPUT_TOO_NEW: return strprintf("Masternode input must have at least %d confirmations", Params().GetConsensus().nMasternodeMinimumConfirmations);
case ACTIVE_MASTERNODE_NOT_CAPABLE: return "Not capable masternode: " + strNotCapableReason;
case ACTIVE_MASTERNODE_STARTED: return "Masternode successfully started";
default: return "unknown";
}
}
@ -117,22 +116,6 @@ bool CActiveMasternode::SendMasternodePing(std::string& strErrorRet)
return true;
}
// when starting a Masternode, this can enable to run as a hot wallet with no funds
bool CActiveMasternode::EnableRemoteMasterNode(CTxIn& vinNew, CService& serviceNew)
{
if(!fMasterNode) return false;
nState = ACTIVE_MASTERNODE_STARTED;
//The values below are needed for signing mnping messages going forward
vin = vinNew;
service = serviceNew;
LogPrintf("CActiveMasternode::EnableHotColdMasterNode -- Enabled! You may shut down the cold daemon.\n");
return true;
}
void CActiveMasternode::ManageStateInitial()
{
LogPrint("masternode", "CActiveMasternode::ManageStateInitial -- Start status = %s, type = %s, pinger enabled = %d\n", GetStatus(), GetType(), fPingerEnabled);

View File

@ -62,17 +62,11 @@ public:
void ManageState();
std::string GetStatus();
std::string GetType();
/// Enable cold wallet mode (run a Masternode with no funds)
bool EnableRemoteMasterNode(CTxIn& vinNew, CService& serviceNew);
private:
void ManageStateInitial();
void ManageStateRemote();
void ManageStateLocal();
};

View File

@ -96,9 +96,9 @@ public:
};
/** base58-encoded Dash addresses.
* Public-key-hash-addresses have version 0 (or 111 testnet).
* Public-key-hash-addresses have version 76 (or 140 testnet).
* The data vector contains RIPEMD160(SHA256(pubkey)), where pubkey is the serialized public key.
* Script-hash-addresses have version 5 (or 196 testnet).
* Script-hash-addresses have version 16 (or 19 testnet).
* The data vector contains RIPEMD160(SHA256(cscript)), where cscript is the serialized redemption script.
*/
class CBitcoinAddress : public CBase58Data {

View File

@ -1015,7 +1015,7 @@ bool CDarksendPool::AddEntry(const CDarkSendEntry& entryNew, PoolMessage& nMessa
bool CDarksendPool::AddScriptSig(const CTxIn& txinNew)
{
LogPrint("privatesend", "CDarksendPool::AddScriptSig -- new sig, scriptSig=%s\n", ScriptToAsmStr(txinNew.scriptSig).substr(0,24));
LogPrint("privatesend", "CDarksendPool::AddScriptSig -- scriptSig=%s\n", ScriptToAsmStr(txinNew.scriptSig).substr(0,24));
BOOST_FOREACH(const CDarkSendEntry& entry, vecEntries) {
BOOST_FOREACH(const CTxDSIn& txdsin, entry.vecTxDSIn) {
@ -1031,7 +1031,7 @@ bool CDarksendPool::AddScriptSig(const CTxIn& txinNew)
return false;
}
LogPrint("privatesend", "CDarksendPool::AddScriptSig -- scriptSig=%s\n", ScriptToAsmStr(txinNew.scriptSig));
LogPrint("privatesend", "CDarksendPool::AddScriptSig -- scriptSig=%s new\n", ScriptToAsmStr(txinNew.scriptSig).substr(0,24));
BOOST_FOREACH(CTxIn& txin, finalMutableTransaction.vin) {
if(txinNew.prevout == txin.prevout && txin.nSequence == txinNew.nSequence) {
@ -1194,7 +1194,7 @@ bool CDarksendPool::UpdatePoolStateOnClient(PoolState nStateNew, int nEntriesCou
// check it to make sure it's what we want, then sign it if we agree.
// If we refuse to sign, it's possible we'll be charged collateral
//
bool CDarksendPool::SignFinalTransaction(const CTransaction& finalTransactionNew, CNode* node)
bool CDarksendPool::SignFinalTransaction(const CTransaction& finalTransactionNew, CNode* pnode)
{
if(fMasterNode) return false;
@ -1265,8 +1265,8 @@ bool CDarksendPool::SignFinalTransaction(const CTransaction& finalTransactionNew
}
// push all of our signatures to the Masternode
if(sigs.size() > 0 && node != NULL)
node->PushMessage(NetMsgType::DSSIGNFINALTX, sigs);
if(!sigs.empty() && pnode != NULL)
pnode->PushMessage(NetMsgType::DSSIGNFINALTX, sigs);
return true;
}
@ -1568,13 +1568,13 @@ bool CDarksendPool::DoAutomaticDenominating(bool fDryRun)
std::vector<COutput> vCoinsTmp;
// Try to match their denominations if possible
if(!pwalletMain->SelectCoinsByDenominations(dsq.nDenom, nValueMin, nBalanceNeedsAnonymized, vecTxInTmp, vCoinsTmp, nValueIn, 0, nPrivateSendRounds)) {
LogPrintf("CDarksendPool::DoAutomaticDenominating -- Couldn't match denominations %d\n", dsq.nDenom);
LogPrintf("CDarksendPool::DoAutomaticDenominating -- Couldn't match denominations %d (%s)\n", dsq.nDenom, GetDenominationsToString(dsq.nDenom));
continue;
}
CMasternode* pmn = mnodeman.Find(dsq.vin);
if(pmn == NULL) {
LogPrintf("CDarksendPool::DoAutomaticDenominating -- dsq masternode is not in masternode list! vin=%s\n", dsq.vin.ToString());
LogPrintf("CDarksendPool::DoAutomaticDenominating -- dsq masternode is not in masternode list, masternode=%s\n", dsq.vin.prevout.ToStringShort());
continue;
}
vecMasternodesUsed.push_back(dsq.vin);
@ -1588,12 +1588,13 @@ bool CDarksendPool::DoAutomaticDenominating(bool fDryRun)
nSessionDenom = dsq.nDenom;
pnode->PushMessage(NetMsgType::DSACCEPT, nSessionDenom, txMyCollateral);
LogPrintf("CDarksendPool::DoAutomaticDenominating -- connected (from queue), sending dsa: nSessionDenom: %d, addr=%s\n", nSessionDenom, pnode->addr.ToString());
LogPrintf("CDarksendPool::DoAutomaticDenominating -- connected (from queue), sending DSACCEPT: nSessionDenom: %d (%s), addr=%s\n",
nSessionDenom, GetDenominationsToString(nSessionDenom), pnode->addr.ToString());
strAutoDenomResult = _("Mixing in progress...");
dsq.nTime = 0; //remove node
return true;
} else {
LogPrintf("CDarksendPool::DoAutomaticDenominating -- error connecting\n");
LogPrintf("CDarksendPool::DoAutomaticDenominating -- can't connect, addr=%s\n", pmn->addr.ToString());
strAutoDenomResult = _("Error connecting to Masternode.");
dsq.nTime = 0; //remove node
pmn->nPoSeBanScore++;
@ -1631,7 +1632,7 @@ bool CDarksendPool::DoAutomaticDenominating(bool fDryRun)
LogPrintf("CDarksendPool::DoAutomaticDenominating -- attempt %d connection to Masternode %s\n", nTries, pmn->addr.ToString());
CNode* pnode = ConnectNode((CAddress)pmn->addr, NULL, true);
if(pnode) {
LogPrintf("CDarksendPool::DoAutomaticDenominating -- connected %s\n", pmn->vin.ToString());
LogPrintf("CDarksendPool::DoAutomaticDenominating -- connected, addr=%s\n", pmn->addr.ToString());
pSubmittedToMasternode = pmn;
std::vector<CAmount> vecAmounts;
@ -1642,11 +1643,12 @@ bool CDarksendPool::DoAutomaticDenominating(bool fDryRun)
}
pnode->PushMessage(NetMsgType::DSACCEPT, nSessionDenom, txMyCollateral);
LogPrintf("CDarksendPool::DoAutomaticDenominating -- connected, sending DSACCEPT, nSessionDenom: %d\n", nSessionDenom);
LogPrintf("CDarksendPool::DoAutomaticDenominating -- connected, sending DSACCEPT, nSessionDenom: %d (%s)\n",
nSessionDenom, GetDenominationsToString(nSessionDenom));
strAutoDenomResult = _("Mixing in progress...");
return true;
} else {
LogPrintf("CDarksendPool::DoAutomaticDenominating -- can't connect %s\n", pmn->vin.ToString());
LogPrintf("CDarksendPool::DoAutomaticDenominating -- can't connect, addr=%s\n", pmn->addr.ToString());
nTries++;
pmn->nPoSeBanScore++;
continue;
@ -2041,7 +2043,8 @@ bool CDarksendPool::IsDenomCompatibleWithSession(int nDenom, CTransaction txColl
return false;
}
LogPrintf("CDarksendPool::IsDenomCompatibleWithSession -- nSessionDenom: %d nSessionUsers: %d\n", nSessionDenom, nSessionUsers);
LogPrintf("CDarksendPool::IsDenomCompatibleWithSession -- nSessionDenom: %d (%s) nSessionUsers: %d\n",
nSessionDenom, GetDenominationsToString(nSessionDenom), nSessionUsers);
if(!fUnitTest && !IsCollateralValid(txCollateral)) {
LogPrint("privatesend", "CDarksendPool::IsDenomCompatibleWithSession -- collateral not valid!\n");

View File

@ -406,7 +406,7 @@ private:
void SetState(PoolState nStateNew);
/// As a client, check and sign the final transaction
bool SignFinalTransaction(const CTransaction& finalTransactionNew, CNode* node);
bool SignFinalTransaction(const CTransaction& finalTransactionNew, CNode* pnode);
/// Relay mixing Messages
void RelayFinalTransaction(const CTransaction& txFinal);

View File

@ -1,7 +1,7 @@
// Copyright (c) 2014-2016 The Dash Core developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef FLAT_DATABASE_H
#define FLAT_DATABASE_H
@ -55,14 +55,14 @@ private:
FILE *file = fopen(pathDB.string().c_str(), "wb");
CAutoFile fileout(file, SER_DISK, CLIENT_VERSION);
if (fileout.IsNull())
return error("%s : Failed to open file %s", __func__, pathDB.string());
return error("%s: Failed to open file %s", __func__, pathDB.string());
// Write and commit header, data
try {
fileout << ssObj;
}
catch (std::exception &e) {
return error("%s : Serialize or I/O error - %s", __func__, e.what());
return error("%s: Serialize or I/O error - %s", __func__, e.what());
}
fileout.fclose();
@ -82,7 +82,7 @@ private:
CAutoFile filein(file, SER_DISK, CLIENT_VERSION);
if (filein.IsNull())
{
error("%s : Failed to open file %s", __func__, pathDB.string());
error("%s: Failed to open file %s", __func__, pathDB.string());
return FileError;
}
@ -102,7 +102,7 @@ private:
filein >> hashIn;
}
catch (std::exception &e) {
error("%s : Deserialize or I/O error - %s", __func__, e.what());
error("%s: Deserialize or I/O error - %s", __func__, e.what());
return HashReadError;
}
filein.fclose();
@ -113,7 +113,7 @@ private:
uint256 hashTmp = Hash(ssObj.begin(), ssObj.end());
if (hashIn != hashTmp)
{
error("%s : Checksum mismatch, data corrupted", __func__);
error("%s: Checksum mismatch, data corrupted", __func__);
return IncorrectHash;
}
@ -127,7 +127,7 @@ private:
// ... verify the message matches predefined one
if (strMagicMessage != strMagicMessageTmp)
{
error("%s : Invalid magic message", __func__);
error("%s: Invalid magic message", __func__);
return IncorrectMagicMessage;
}
@ -138,7 +138,7 @@ private:
// ... verify the network matches ours
if (memcmp(pchMsgTmp, Params().MessageStart(), sizeof(pchMsgTmp)))
{
error("%s : Invalid network magic number", __func__);
error("%s: Invalid network magic number", __func__);
return IncorrectMagicNumber;
}
@ -147,16 +147,16 @@ private:
}
catch (std::exception &e) {
objToLoad.Clear();
error("%s : Deserialize or I/O error - %s", __func__, e.what());
error("%s: Deserialize or I/O error - %s", __func__, e.what());
return IncorrectFormat;
}
LogPrintf("Loaded info from %s %dms\n", strFilename, GetTimeMillis() - nStart);
LogPrintf(" %s\n", objToLoad.ToString());
if(!fDryRun) {
LogPrintf("CFlatDB - cleaning....\n");
LogPrintf("%s: Cleaning....\n", __func__);
objToLoad.CheckAndRemove();
LogPrintf("CFlatDB - %s\n", objToLoad.ToString());
LogPrintf(" %s\n", objToLoad.ToString());
}
return Ok;
@ -176,16 +176,16 @@ public:
LogPrintf("Reading info from %s...\n", strFilename);
ReadResult readResult = Read(objToLoad);
if (readResult == FileError)
LogPrintf("Missing file - %s, will try to recreate\n", strFilename);
LogPrintf("Missing file %s, will try to recreate\n", strFilename);
else if (readResult != Ok)
{
LogPrintf("Error reading %s: ", strFilename);
if(readResult == IncorrectFormat)
{
LogPrintf("magic is ok but data has invalid format, will try to recreate\n");
LogPrintf("%s: Magic is ok but data has invalid format, will try to recreate\n", __func__);
}
else {
LogPrintf("file format is unknown or invalid, please fix it manually\n");
LogPrintf("%s: File format is unknown or invalid, please fix it manually\n", __func__);
// program should exit with an error
return false;
}
@ -197,41 +197,21 @@ public:
{
int64_t nStart = GetTimeMillis();
// LOAD SERIALIZED FILE TO DETERMINE SAFETY OF SAVING INTO THAT FILE
/*
2016-06-02 21:23:55 dash-shutoff | Governance Objects: 1, Seen Budgets: 1, Seen Budget Votes: 0, Vote Count: 0
2016-06-02 21:23:55 dash-shutoff | Governance Objects: 1, Seen Budgets: 0, Seen Budget Votes: 0, Vote Count: 0
2016-06-02 21:29:17 dashd | Governance Objects: 1, Seen Budgets: 0, Seen Budget Votes: 0, Vote Count: 0
2016-06-02 21:29:17 dashd | CFlatDB - Governance Objects: 1, Seen Budgets: 0, Seen Budget Votes: 0, Vote Count: 0
2016-06-02 21:29:25 dash-shutoff | Governance Objects: 1, Seen Budgets: 0, Seen Budget Votes: 0, Vote Count: 0
2016-06-02 21:30:07 dash-shutoff | Governance Objects: 1, Seen Budgets: 1, Seen Budget Votes: 0, Vote Count: 0
2016-06-02 21:30:16 dashd | Governance Objects: 1, Seen Budgets: 1, Seen Budget Votes: 0, Vote Count: 0
2016-06-02 21:30:16 dashd | CFlatDB - Governance Objects: 1, Seen Budgets: 1, Seen Budget Votes: 0, Vote Count: 0
This fact can be demonstrated by adding a governance item, then stopping and starting the client.
With the code enabled, "Seen Budgets" will equal 0, whereas the object should have one entry.
*/
LogPrintf("Verifying %s format...\n", strFilename);
T tmpObjToLoad;
ReadResult readResult = Read(tmpObjToLoad, true);
// there was an error and it was not an error on file opening => do not proceed
if (readResult == FileError)
LogPrintf("Missing file - %s, will try to recreate\n", strFilename);
LogPrintf("Missing file %s, will try to recreate\n", strFilename);
else if (readResult != Ok)
{
LogPrintf("Error reading %s: ", strFilename);
if(readResult == IncorrectFormat)
LogPrintf("magic is ok but data has invalid format, will try to recreate\n");
LogPrintf("%s: Magic is ok but data has invalid format, will try to recreate\n", __func__);
else
{
LogPrintf("file format is unknown or invalid, please fix it manually\n");
LogPrintf("%s: File format is unknown or invalid, please fix it manually\n", __func__);
return false;
}
}

View File

@ -30,12 +30,7 @@
CGovernanceTriggerManager triggerman;
// SPLIT UP STRING BY DELIMITER
/*
NOTE : SplitBy can be simplified via:
http://www.boost.org/doc/libs/1_58_0/doc/html/boost/algorithm/split_idp202406848.html
*/
// http://www.boost.org/doc/libs/1_58_0/doc/html/boost/algorithm/split_idp202406848.html
std::vector<std::string> SplitBy(std::string strCommand, std::string strDelimit)
{
std::vector<std::string> vParts;
@ -721,7 +716,7 @@ bool CSuperblock::IsValid(const CTransaction& txNew, int nBlockHeight, CAmount b
CTxDestination address1;
ExtractDestination(payment.script, address1);
CBitcoinAddress address2(address1);
LogPrintf("CSuperblock::IsValid -- WARNING: Block invalid: output n %d payment %d to %s\n", nVoutIndex, payment.nAmount, address2.ToString());
LogPrintf("CSuperblock::IsValid -- ERROR: Block invalid: output n %d payment %d to %s\n", nVoutIndex, payment.nAmount, address2.ToString());
return false;
}

View File

@ -123,10 +123,6 @@ public:
bool IsValid(bool fSignatureCheck);
void Relay();
std::string GetVoteString() {
return CGovernanceVoting::ConvertOutcomeToString(GetOutcome());
}
CTxIn& GetVinMasternode() { return vinMasternode; }
const CTxIn& GetVinMasternode() const { return vinMasternode; }

View File

@ -110,7 +110,7 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, std::string& strCommand, C
if(nProp == uint256()) {
if(netfulfilledman.HasFulfilledRequest(pfrom->addr, NetMsgType::MNGOVERNANCESYNC)) {
// Asking for the whole list multiple times in a short period of time is no good
LogPrint("gobject", "peer already asked me for the list\n");
LogPrint("gobject", "MNGOVERNANCESYNC -- peer already asked me for the list\n");
Misbehaving(pfrom->GetId(), 20);
return;
}
@ -118,7 +118,7 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, std::string& strCommand, C
}
Sync(pfrom, nProp);
LogPrint("gobject", "syncing governance objects to our peer at %s\n", pfrom->addr.ToString());
LogPrint("gobject", "MNGOVERNANCESYNC -- syncing governance objects to our peer at %s\n", pfrom->addr.ToString());
}
@ -139,34 +139,30 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, std::string& strCommand, C
return;
}
// IS THE COLLATERAL TRANSACTION ASSOCIATED WITH THIS GOVERNANCE OBJECT MATURE/VALID?
std::string strError = "";
// CHECK OBJECT AGAINST LOCAL BLOCKCHAIN
if(!govobj.IsValidLocally(pCurrentBlockIndex, strError, true)) {
mapSeenGovernanceObjects.insert(std::make_pair(govobj.GetHash(), SEEN_OBJECT_ERROR_INVALID));
LogPrintf("Governance object is invalid - %s\n", strError);
LogPrintf("MNGOVERNANCEOBJECT -- Governance object is invalid - %s\n", strError);
return;
}
// UPDATE CACHED VARIABLES FOR THIS OBJECT AND ADD IT TO OUR MANANGED DATA
{
govobj.UpdateSentinelVariables(pCurrentBlockIndex); //this sets local vars in object
govobj.UpdateSentinelVariables(pCurrentBlockIndex); //this sets local vars in object
if(AddGovernanceObject(govobj))
{
govobj.Relay();
}
if(AddGovernanceObject(govobj))
{
LogPrintf("MNGOVERNANCEOBJECT -- %s new\n", govobj.GetHash().ToString());
govobj.Relay();
}
// UPDATE THAT WE'VE SEEN THIS OBJECT
mapSeenGovernanceObjects.insert(make_pair(govobj.GetHash(), SEEN_OBJECT_IS_VALID));
mapSeenGovernanceObjects.insert(std::make_pair(govobj.GetHash(), SEEN_OBJECT_IS_VALID));
masternodeSync.AddedBudgetItem(govobj.GetHash());
LogPrintf("MNGOVERNANCEOBJECT -- %s new\n", govobj.GetHash().ToString());
// WE MIGHT HAVE PENDING/ORPHAN VOTES FOR THIS OBJECT
CheckOrphanVotes();
@ -189,7 +185,7 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, std::string& strCommand, C
// FIND THE MASTERNODE OF THE VOTER
if(!mnodeman.Has(vote.GetVinMasternode())) {
LogPrint("gobject", "gobject - unknown masternode - vin: %s\n", vote.GetVinMasternode().ToString());
LogPrint("gobject", "MNGOVERNANCEOBJECTVOTE -- unknown masternode - vin: %s\n", vote.GetVinMasternode().ToString());
mnodeman.AskForMN(pfrom, vote.GetVinMasternode());
return;
}
@ -197,7 +193,7 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, std::string& strCommand, C
// CHECK LOCAL VALIDITY AGAINST BLOCKCHAIN, TIME DATA, ETC
if(!vote.IsValid(true)){
LogPrintf("gobject - signature invalid\n");
LogPrintf("MNGOVERNANCEOBJECTVOTE -- signature invalid\n");
if(masternodeSync.IsSynced()) Misbehaving(pfrom->GetId(), 20);
// it could just be a non-synced masternode
mnodeman.AskForMN(pfrom, vote.GetVinMasternode());
@ -211,12 +207,12 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, std::string& strCommand, C
std::string strError = "";
if(AddOrUpdateVote(vote, pfrom, strError)) {
LogPrint("gobject", "MNGOVERNANCEOBJECTVOTE -- %s new\n", vote.GetHash().ToString());
vote.Relay();
masternodeSync.AddedBudgetItem(vote.GetHash());
mnodeman.AddGovernanceVote(vote.GetVinMasternode(), vote.GetParentHash());
}
LogPrint("gobject", "NEW governance vote: %s\n", vote.GetHash().ToString());
}
}
@ -229,7 +225,7 @@ void CGovernanceManager::CheckOrphanVotes()
vote_m_it it1 = mapOrphanVotes.begin();
while(it1 != mapOrphanVotes.end()){
if(AddOrUpdateVote(((*it1).second), NULL, strError)){
LogPrintf("CGovernanceManager::CheckOrphanVotes - Governance object is known, activating and removing orphan vote\n");
LogPrintf("CGovernanceManager::CheckOrphanVotes -- Governance object is known, activating and removing orphan vote\n");
mapOrphanVotes.erase(it1++);
} else {
++it1;
@ -247,14 +243,14 @@ bool CGovernanceManager::AddGovernanceObject(CGovernanceObject& govobj)
// MAKE SURE THIS OBJECT IS OK
if(!govobj.IsValidLocally(pCurrentBlockIndex, strError, true)) {
LogPrintf("CGovernanceManager::AddGovernanceObject - invalid governance object - %s - (pCurrentBlockIndex nHeight %d) \n", strError, pCurrentBlockIndex->nHeight);
LogPrintf("CGovernanceManager::AddGovernanceObject -- invalid governance object - %s - (pCurrentBlockIndex nHeight %d) \n", strError, pCurrentBlockIndex->nHeight);
return false;
}
// IF WE HAVE THIS OBJECT ALREADY, WE DON'T WANT ANOTHER COPY
if(mapObjects.count(govobj.GetHash())) {
LogPrintf("CGovernanceManager::AddGovernanceObject - already have governance object - %s\n", strError);
LogPrintf("CGovernanceManager::AddGovernanceObject -- already have governance object - %s\n", strError);
return false;
}
@ -286,7 +282,7 @@ bool CGovernanceManager::AddGovernanceObject(CGovernanceObject& govobj)
void CGovernanceManager::UpdateCachesAndClean()
{
LogPrintf("CGovernanceManager::UpdateCachesAndClean \n");
LogPrint("gobject", "CGovernanceManager::UpdateCachesAndClean\n");
std::vector<uint256> vecDirtyHashes = mnodeman.GetAndClearDirtyGovernanceObjectHashes();
@ -336,7 +332,7 @@ void CGovernanceManager::UpdateCachesAndClean()
// IF DELETE=TRUE, THEN CLEAN THE MESS UP!
if(pObj->fCachedDelete || pObj->fExpired) {
LogPrintf("UpdateCachesAndClean --- erase obj %s\n", (*it).first.ToString());
LogPrintf("UpdateCachesAndClean -- erase obj %s\n", (*it).first.ToString());
mnodeman.RemoveGovernanceObject(pObj->GetHash());
mapObjects.erase(it++);
} else {
@ -490,7 +486,7 @@ void CGovernanceManager::Sync(CNode* pfrom, uint256 nProp)
}
pfrom->PushMessage(NetMsgType::SYNCSTATUSCOUNT, MASTERNODE_SYNC_GOVOBJ, nInvCount);
LogPrintf("CGovernanceManager::Sync - sent %d items\n", nInvCount);
LogPrintf("CGovernanceManager::Sync -- sent %d items\n", nInvCount);
}
void CGovernanceManager::SyncParentObjectByVote(CNode* pfrom, const CGovernanceVote& vote)
@ -517,7 +513,7 @@ bool CGovernanceManager::AddOrUpdateVote(const CGovernanceVote& vote, CNode* pfr
// ADD THE VOTE AS AN ORPHAN, TO BE USED UPON RECEIVAL OF THE PARENT OBJECT
LogPrintf("CGovernanceManager::AddOrUpdateVote - Unknown object %d, asking for source\n", vote.GetParentHash().ToString());
LogPrintf("CGovernanceManager::AddOrUpdateVote -- Unknown object %s, asking for source\n", vote.GetParentHash().ToString());
mapOrphanVotes[vote.GetParentHash()] = vote;
// ASK FOR THIS VOTES PARENT SPECIFICALLY FROM THIS USER (THEY SHOULD HAVE IT, NO?)
@ -525,7 +521,7 @@ bool CGovernanceManager::AddOrUpdateVote(const CGovernanceVote& vote, CNode* pfr
if(!mapAskedForGovernanceObject.count(vote.GetParentHash())){
syncparent = true;
votehash = vote.GetParentHash();
mapAskedForGovernanceObject[vote.GetParentHash()] = GetTime();
mapAskedForGovernanceObject[vote.GetParentHash()] = GetTime();
} else {
strError = "Governance object not found! Sync message has been already pushed.";
return false;
@ -554,12 +550,12 @@ bool CGovernanceManager::AddOrUpdateVote(const CGovernanceVote& vote, CNode* pfr
if(it != mapVotesByType.end()) {
if(it->second.GetTimestamp() > vote.GetTimestamp()) {
strError = strprintf("new vote older than existing vote - %s", nTypeHash.ToString());
LogPrint("gobject", "CGovernanceObject::AddOrUpdateVote - %s\n", strError);
LogPrint("gobject", "CGovernanceObject::AddOrUpdateVote -- %s\n", strError);
return false;
}
if(vote.GetTimestamp() - it->second.GetTimestamp() < GOVERNANCE_UPDATE_MIN) {
strError = strprintf("time between votes is too soon - %s - %lli", nTypeHash.ToString(), vote.GetTimestamp() - it->second.GetTimestamp());
LogPrint("gobject", "CGovernanceObject::AddOrUpdateVote - %s\n", strError);
LogPrint("gobject", "CGovernanceObject::AddOrUpdateVote -- %s\n", strError);
return false;
}
}
@ -581,7 +577,7 @@ bool CGovernanceManager::AddOrUpdateVote(const CGovernanceVote& vote, CNode* pfr
mnodeman.UpdateWatchdogVoteTime(vote.GetVinMasternode());
}
} else {
LogPrintf("Governance object not found! Can't update fDirtyCache - %s\n", vote.GetParentHash().ToString());
LogPrintf("CGovernanceObject::AddOrUpdateVote -- Governance object not found! Can't update fDirtyCache - %s\n", vote.GetParentHash().ToString());
}
return true;
@ -612,7 +608,7 @@ bool CGovernanceManager::MasternodeRateCheck(const CTxIn& vin, int nObjectType)
return true;
}
LogPrintf("CGovernanceManager::MasternodeRateCheck Rate too high: vin = %s, current height = %d, last MN height = %d, minimum difference = %d\n",
LogPrintf("CGovernanceManager::MasternodeRateCheck -- Rate too high: vin = %s, current height = %d, last MN height = %d, minimum difference = %d\n",
vin.prevout.ToStringShort(), nCachedBlockHeight, it->second, mindiff);
return false;
}
@ -691,7 +687,7 @@ void CGovernanceObject::SetMasternodeInfo(const CTxIn& vin)
vinMasternode = vin;
}
bool CGovernanceObject::Sign(CKey& keyMasternode, CPubKey& pubkeyMasternode)
bool CGovernanceObject::Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode)
{
LOCK(cs);
@ -704,26 +700,26 @@ bool CGovernanceObject::Sign(CKey& keyMasternode, CPubKey& pubkeyMasternode)
return false;
}
if(!darkSendSigner.VerifyMessage(pubkeyMasternode, vchSig, strMessage, strError)) {
if(!darkSendSigner.VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) {
LogPrintf("CGovernanceObject::Sign -- VerifyMessage() failed, error: %s\n", strError);
return false;
}
LogPrint("gobject", "CGovernanceObject::Sign: pubkey id = %s, vin = %s\n",
pubkeyMasternode.GetID().ToString(), vinMasternode.prevout.ToStringShort());
LogPrint("gobject", "CGovernanceObject::Sign -- pubkey id = %s, vin = %s\n",
pubKeyMasternode.GetID().ToString(), vinMasternode.prevout.ToStringShort());
return true;
}
bool CGovernanceObject::CheckSignature(CPubKey& pubkeyMasternode)
bool CGovernanceObject::CheckSignature(CPubKey& pubKeyMasternode)
{
LOCK(cs);
std::string strError;
uint256 nHash = GetHash();
std::string strMessage = nHash.ToString();
if(!darkSendSigner.VerifyMessage(pubkeyMasternode, vchSig, strMessage, strError)) {
if(!darkSendSigner.VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) {
LogPrintf("CGovernance::CheckSignature -- VerifyMessage() failed, error: %s\n", strError);
return false;
}
@ -906,16 +902,16 @@ bool CGovernanceObject::IsValidLocally(const CBlockIndex* pindex, std::string& s
if(fCheckCollateral) {
if((nObjectType == GOVERNANCE_OBJECT_TRIGGER) || (nObjectType == GOVERNANCE_OBJECT_WATCHDOG)) {
std::string strVin = vinMasternode.prevout.ToStringShort();
std::string strOutpoint = vinMasternode.prevout.ToStringShort();
masternode_info_t infoMn = mnodeman.GetMasternodeInfo(vinMasternode);
if(!infoMn.fInfoValid) {
strError = "Masternode not found vin: " + strVin;
strError = "Masternode not found: " + strOutpoint;
return false;
}
// Check that we have a valid MN signature
if(!CheckSignature(infoMn.pubKeyMasternode)) {
strError = "Invalid masternode signature for: " + strVin + ", pubkey id = " + infoMn.pubKeyMasternode.GetID().ToString();
strError = "Invalid masternode signature for: " + strOutpoint + ", pubkey id = " + infoMn.pubKeyMasternode.GetID().ToString();
return false;
}
@ -923,7 +919,7 @@ bool CGovernanceObject::IsValidLocally(const CBlockIndex* pindex, std::string& s
// that objects will be seen in rapid succession
if(masternodeSync.IsSynced()) {
if(!governance.MasternodeRateCheck(vinMasternode, nObjectType)) {
strError = "Masternode attempting to create too many objects vin: " + strVin;
strError = "Masternode attempting to create too many objects: " + strOutpoint;
return false;
}
}
@ -978,13 +974,13 @@ bool CGovernanceObject::IsCollateralValid(std::string& strError)
if(!GetTransaction(nCollateralHash, txCollateral, Params().GetConsensus(), nBlockHash, true)){
strError = strprintf("Can't find collateral tx %s", txCollateral.ToString());
LogPrintf("CGovernanceObject::IsCollateralValid - %s\n", strError);
LogPrintf("CGovernanceObject::IsCollateralValid -- %s\n", strError);
return false;
}
if(txCollateral.vout.size() < 1) {
strError = strprintf("tx vout size less than 1 | %d", txCollateral.vout.size());
LogPrintf ("CGovernanceObject::IsCollateralValid - %s\n", strError);
LogPrintf("CGovernanceObject::IsCollateralValid -- %s\n", strError);
return false;
}
@ -1008,7 +1004,7 @@ bool CGovernanceObject::IsCollateralValid(std::string& strError)
<< endl; );
if(!o.scriptPubKey.IsNormalPaymentScript() && !o.scriptPubKey.IsUnspendable()){
strError = strprintf("Invalid Script %s", txCollateral.ToString());
LogPrintf ("CGovernanceObject::IsCollateralValid - %s\n", strError);
LogPrintf ("CGovernanceObject::IsCollateralValid -- %s\n", strError);
return false;
}
if(o.scriptPubKey == findScript && o.nValue >= nMinFee) {
@ -1023,7 +1019,7 @@ bool CGovernanceObject::IsCollateralValid(std::string& strError)
if(!foundOpReturn){
strError = strprintf("Couldn't find opReturn %s in %s", nExpectedHash.ToString(), txCollateral.ToString());
LogPrintf ("CGovernanceObject::IsCollateralValid - %s\n", strError);
LogPrintf ("CGovernanceObject::IsCollateralValid -- %s\n", strError);
return false;
}
@ -1045,7 +1041,7 @@ bool CGovernanceObject::IsCollateralValid(std::string& strError)
strError = "valid";
} else {
strError = strprintf("Collateral requires at least %d confirmations - %d confirmations", GOVERNANCE_FEE_CONFIRMATIONS, nConfirmationsIn);
LogPrintf ("CGovernanceObject::IsCollateralValid - %s - %d confirmations\n", strError, nConfirmationsIn);
LogPrintf ("CGovernanceObject::IsCollateralValid -- %s - %d confirmations\n", strError, nConfirmationsIn);
return false;
}

View File

@ -255,8 +255,8 @@ public:
// Signature related functions
void SetMasternodeInfo(const CTxIn& vin);
bool Sign(CKey& keyMasternode, CPubKey& pubkeyMasternode);
bool CheckSignature(CPubKey& pubkeyMasternode);
bool Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode);
bool CheckSignature(CPubKey& pubKeyMasternode);
// CORE OBJECT FUNCTIONS

View File

@ -561,7 +561,6 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-mnconf=<file>", strprintf(_("Specify masternode configuration file (default: %s)"), "masternode.conf"));
strUsage += HelpMessageOpt("-mnconflock=<n>", strprintf(_("Lock masternodes from masternode configuration file (default: %u)"), 1));
strUsage += HelpMessageOpt("-masternodeprivkey=<n>", _("Set the masternode private key"));
strUsage += HelpMessageOpt("-masternodeaddr=<n>", strprintf(_("Set external address:port to get to this masternode (example: %s)"), "128.127.106.235:9999"));
strUsage += HelpMessageGroup(_("PrivateSend options:"));
strUsage += HelpMessageOpt("-enableprivatesend=<n>", strprintf(_("Enable use of automated PrivateSend for funds stored in this wallet (0-1, default: %u)"), 0));
@ -1853,7 +1852,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
LogPrintf("PrivateSend amount %d\n", nPrivateSendAmount);
darkSendPool.InitDenominations();
mnodeman.InitDummyScriptPubkey();
// ********************************************************* Step 11b: Load cache data

View File

@ -178,20 +178,20 @@ bool IsInstantSendTxValid(const CTransaction& txCandidate)
int64_t nValueIn = 0;
int64_t nValueOut = 0;
bool missingTx = false;
bool fMissingInputs = false;
BOOST_FOREACH(const CTxOut txout, txCandidate.vout) {
BOOST_FOREACH(const CTxOut& txout, txCandidate.vout) {
nValueOut += txout.nValue;
}
BOOST_FOREACH(const CTxIn txin, txCandidate.vin) {
BOOST_FOREACH(const CTxIn& txin, txCandidate.vin) {
CTransaction tx2;
uint256 hash;
if(GetTransaction(txin.prevout.hash, tx2, Params().GetConsensus(), hash, true)) {
if(tx2.vout.size() > txin.prevout.n)
nValueIn += tx2.vout[txin.prevout.n].nValue;
} else {
missingTx = true;
fMissingInputs = true;
}
}
@ -200,8 +200,8 @@ bool IsInstantSendTxValid(const CTransaction& txCandidate)
return false;
}
if(missingTx) {
LogPrint("instantsend", "IsInstantSendTxValid -- Unknown inputs in IX transaction: txCandidate=%s", txCandidate.ToString());
if(fMissingInputs) {
LogPrint("instantsend", "IsInstantSendTxValid -- Unknown inputs in transaction: txCandidate=%s", txCandidate.ToString());
/*
This happens sometimes for an unknown reason, so we'll return that it's a valid transaction.
If someone submits an invalid transaction it will be rejected by the network anyway and this isn't
@ -273,7 +273,7 @@ void DoConsensusVote(CTransaction& tx, int64_t nBlockHeight)
int n = mnodeman.GetMasternodeRank(activeMasternode.vin, nBlockHeight, MIN_INSTANTSEND_PROTO_VERSION);
if(n == -1) {
LogPrint("instantsend", "DoConsensusVote -- Unknown Masternode %s\n", activeMasternode.vin.ToString());
LogPrint("instantsend", "DoConsensusVote -- Unknown Masternode %s\n", activeMasternode.vin.prevout.ToStringShort());
return;
}
@ -324,9 +324,11 @@ bool ProcessConsensusVote(CNode* pnode, CConsensusVote& vote)
mnodeman.AskForMN(pnode, vote.vinMasternode);
return false;
}
LogPrint("instantsend", "ProcessConsensusVote -- Masternode %s, rank=%d\n", vote.vinMasternode.prevout.ToStringShort(), n);
if(n > INSTANTSEND_SIGNATURES_TOTAL) {
LogPrint("instantsend", "ProcessConsensusVote -- Masternode not in the top %d (%d): vote hash %s\n", INSTANTSEND_SIGNATURES_TOTAL, n, vote.GetHash().ToString());
LogPrint("instantsend", "ProcessConsensusVote -- Masternode %s is not in the top %d (%d), vote hash %s\n",
vote.vinMasternode.prevout.ToStringShort(), INSTANTSEND_SIGNATURES_TOTAL, n, vote.GetHash().ToString());
return false;
}
@ -435,7 +437,7 @@ bool FindConflictingLocks(CTransaction& tx)
BOOST_FOREACH(const CTxIn& txin, tx.vin) {
if(mapLockedInputs.count(txin.prevout)) {
if(mapLockedInputs[txin.prevout] != tx.GetHash()) {
LogPrintf("FindConflictingLocks -- found two complete conflicting locks, removing both: txid=%s, txin=%s", tx.GetHash().ToString(), mapLockedInputs[txin.prevout].ToString());
LogPrintf("FindConflictingLocks -- found two complete conflicting Transaction Locks, removing both: txid=%s, txin=%s", tx.GetHash().ToString(), mapLockedInputs[txin.prevout].ToString());
if(mapTxLocks.count(tx.GetHash()))
mapTxLocks[tx.GetHash()].nLockExpirationBlock = -1;
@ -455,7 +457,7 @@ void ResolveConflicts(CTransaction& tx)
{
// resolve conflicts
if (IsLockedInstandSendTransaction(tx.GetHash()) && !FindConflictingLocks(tx)) { //?????
LogPrintf("ResolveConflicts -- Found Existing Complete IX Lock, resolving...\n");
LogPrintf("ResolveConflicts -- Found existing complete Transaction Lock, resolving...\n");
//reprocess the last nInstantSendReprocessBlocks blocks
ReprocessBlocks(Params().GetConsensus().nInstantSendReprocessBlocks);
@ -553,7 +555,6 @@ bool CConsensusVote::CheckSignature()
{
std::string strError;
std::string strMessage = txHash.ToString().c_str() + boost::lexical_cast<std::string>(nBlockHeight);
//LogPrintf("verify strMessage %s \n", strMessage);
CMasternode* pmn = mnodeman.Find(vinMasternode);

View File

@ -953,10 +953,10 @@ int GetInputAge(CTxIn& txin)
if (coins) {
if(coins->nHeight < 0) return 0;
return (chainActive.Tip()->nHeight + 1) - coins->nHeight;
}
else
return chainActive.Height() - coins->nHeight + 1;
} else {
return -1;
}
}
}
@ -1089,13 +1089,11 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState &state, const C
// ----------- InstantSend transaction scanning -----------
BOOST_FOREACH(const CTxIn& in, tx.vin){
if(mapLockedInputs.count(in.prevout)){
if(mapLockedInputs[in.prevout] != tx.GetHash()){
return state.DoS(0,
error("AcceptToMemoryPool : conflicts with existing transaction lock: %s", reason),
REJECT_INVALID, "tx-lock-conflict");
}
BOOST_FOREACH(const CTxIn& txin, tx.vin) {
if(mapLockedInputs.count(txin.prevout) && mapLockedInputs[txin.prevout] != tx.GetHash()) {
return state.DoS(0,
error("AcceptToMemoryPool : conflicts with existing transaction lock: %s", reason),
REJECT_INVALID, "tx-lock-conflict");
}
}
@ -3731,18 +3729,16 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
// DASH : CHECK TRANSACTIONS FOR INSTANT SEND
if(sporkManager.IsSporkActive(SPORK_3_INSTANTSEND_BLOCK_FILTERING)) {
BOOST_FOREACH(const CTransaction& tx, block.vtx){
if (!tx.IsCoinBase()){
// LOOK FOR TRANSACTION LOCK IN OUR MAP OF INPUTS
BOOST_FOREACH(const CTxIn& in, tx.vin){
if(mapLockedInputs.count(in.prevout)){
if(mapLockedInputs[in.prevout] != tx.GetHash()){
mapRejectedBlocks.insert(make_pair(block.GetHash(), GetTime()));
LogPrintf("CheckBlock(DASH) : found conflicting transaction with transaction lock %s %s\n", mapLockedInputs[in.prevout].ToString(), tx.GetHash().ToString());
return state.DoS(0, error("CheckBlock(DASH) : found conflicting transaction with transaction lock"),
REJECT_INVALID, "conflicting-tx-ix");
}
}
BOOST_FOREACH(const CTransaction& tx, block.vtx) {
// skip coinbase, it has no inputs
if (tx.IsCoinBase()) continue;
// LOOK FOR TRANSACTION LOCK IN OUR MAP OF INPUTS
BOOST_FOREACH(const CTxIn& txin, tx.vin) {
if(mapLockedInputs.count(txin.prevout) && mapLockedInputs[txin.prevout] != tx.GetHash()) {
mapRejectedBlocks.insert(make_pair(block.GetHash(), GetTime()));
LogPrintf("CheckBlock(DASH): found conflicting transaction with transaction lock %s %s\n", mapLockedInputs[txin.prevout].ToString(), tx.GetHash().ToString());
return state.DoS(0, error("CheckBlock(DASH): found conflicting transaction with transaction lock"),
REJECT_INVALID, "conflicting-tx-ix");
}
}
}
@ -5181,12 +5177,12 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
{
if(governance.HaveObjectForHash(inv.hash)) {
ss.reserve(1000);
if(governance.SerializeObjectForHash(inv.hash, ss)) {
if(governance.SerializeObjectForHash(inv.hash, ss)) {
topush = true;
}
}
}
if(topush) {
if(topush) {
pfrom->PushMessage(NetMsgType::MNGOVERNANCEOBJECT, ss);
pushed = true;
}
@ -5198,12 +5194,12 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
{
if(governance.HaveVoteForHash(inv.hash)) {
ss.reserve(1000);
if(governance.SerializeVoteForHash(inv.hash, ss)) {
if(governance.SerializeVoteForHash(inv.hash, ss)) {
topush = true;
}
}
}
if(topush) {
if(topush) {
pfrom->PushMessage(NetMsgType::MNGOVERNANCEOBJECTVOTE, ss);
pushed = true;
}
@ -5718,13 +5714,13 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
{
if(!pmn->fAllowMixingTx) {
//multiple peers can send us a valid masternode transaction
LogPrint("privatesend", "dstx: Masternode sending too many transactions %s\n", tx.GetHash().ToString());
LogPrint("privatesend", "DSTX -- Masternode sending too many transactions %s\n", tx.GetHash().ToString());
return true;
}
if(!dstx.CheckSignature()) return false;
LogPrintf("dstx: Got Masternode transaction %s\n", tx.GetHash().ToString());
LogPrintf("DSTX -- Got Masternode transaction %s\n", tx.GetHash().ToString());
pmn->fAllowMixingTx = false;

View File

@ -864,6 +864,4 @@ void CMasternodePayments::UpdatedBlockTip(const CBlockIndex *pindex)
LogPrint("mnpayments", "CMasternodePayments::UpdatedBlockTip -- pCurrentBlockIndex->nHeight=%d\n", pCurrentBlockIndex->nHeight);
ProcessBlock(pindex->nHeight + 10);
// normal wallet does not need to update this every block, doing update on rpc call should be enough
if(fMasterNode) mnodeman.UpdateLastPaid(pindex);
}

View File

@ -20,14 +20,14 @@ CMasternodeSync masternodeSync;
bool CMasternodeSync::IsBlockchainSynced()
{
static bool fBlockchainSynced = false;
static int64_t lastProcess = GetTime();
static int64_t nTimeLastProcess = GetTime();
// if the last call to this function was more than 60 minutes ago (client was in sleep mode) reset the sync process
if(GetTime() - lastProcess > 60*60) {
if(GetTime() - nTimeLastProcess > 60*60) {
Reset();
fBlockchainSynced = false;
}
lastProcess = GetTime();
nTimeLastProcess = GetTime();
if(fBlockchainSynced) return true;
if(!pCurrentBlockIndex || !pindexBestHeader || fImporting || fReindex) return false;
@ -143,7 +143,7 @@ void CMasternodeSync::ProcessMessage(CNode* pfrom, std::string& strCommand, CDat
int nCount;
vRecv >> nItemID >> nCount;
LogPrintf("CMasternodeSync::ProcessMessage -- SYNCSTATUSCOUNT -- got inventory count: nItemID=%d nCount=%d peer=%d\n", nItemID, nCount, pfrom->id);
LogPrintf("SYNCSTATUSCOUNT -- got inventory count: nItemID=%d nCount=%d peer=%d\n", nItemID, nCount, pfrom->id);
}
}
@ -171,7 +171,7 @@ void CMasternodeSync::ProcessTick()
//the actual count of masternodes we have currently
int nMnCount = mnodeman.CountMasternodes();
LogPrintf("CMasternodeSync::ProcessTick -- nTick %d nMnCount = %d\n", nTick, nMnCount);
if(fDebug) LogPrintf("CMasternodeSync::ProcessTick -- nTick %d nMnCount %d\n", nTick, nMnCount);
// RESET SYNCING INCASE OF FAILURE
{
@ -180,6 +180,7 @@ void CMasternodeSync::ProcessTick()
Resync if we lose all masternodes from sleep/wake or failure to sync originally
*/
if(nMnCount == 0) {
LogPrintf("CMasternodeSync::ProcessTick -- WARNING: not enough data, restarting sync\n");
Reset();
} else {
//if syncing is complete and we have masternodes, return
@ -198,12 +199,16 @@ void CMasternodeSync::ProcessTick()
// INITIAL SYNC SETUP / LOG REPORTING
double nSyncProgress = double(nRequestedMasternodeAttempt + (nRequestedMasternodeAssets - 1) * 8) / (8*4);
LogPrintf("CMasternodeSync::Process -- nTick %d nRequestedMasternodeAssets %d nRequestedMasternodeAttempt %d nSyncProgress %f\n", nTick, nRequestedMasternodeAssets, nRequestedMasternodeAttempt, nSyncProgress);
LogPrintf("CMasternodeSync::ProcessTick -- nTick %d nRequestedMasternodeAssets %d nRequestedMasternodeAttempt %d nSyncProgress %f\n", nTick, nRequestedMasternodeAssets, nRequestedMasternodeAttempt, nSyncProgress);
uiInterface.NotifyAdditionalDataSyncProgressChanged(nSyncProgress);
// sporks synced but blockchain is not, wait until we're almost at a recent block to continue
if(Params().NetworkIDString() != CBaseChainParams::REGTEST &&
!IsBlockchainSynced() && nRequestedMasternodeAssets > MASTERNODE_SYNC_SPORKS) return;
!IsBlockchainSynced() && nRequestedMasternodeAssets > MASTERNODE_SYNC_SPORKS)
{
LogPrintf("CMasternodeSync::ProcessTick -- nTick %d nRequestedMasternodeAssets %d nRequestedMasternodeAttempt %d -- blockchain is not synced yet\n", nTick, nRequestedMasternodeAssets, nRequestedMasternodeAttempt);
return;
}
TRY_LOCK(cs_vNodes, lockRecv);
if(!lockRecv) return;
@ -241,7 +246,7 @@ void CMasternodeSync::ProcessTick()
// we already fully synced from this node recently,
// disconnect to free this connection slot for a new node
pnode->fDisconnect = true;
LogPrintf("CMasternodeSync::ProcessTick -- disconnecting from recently synced node %d\n", pnode->id);
LogPrintf("CMasternodeSync::ProcessTick -- disconnecting from recently synced peer %d\n", pnode->id);
continue;
}
@ -252,17 +257,19 @@ void CMasternodeSync::ProcessTick()
netfulfilledman.AddFulfilledRequest(pnode->addr, "spork-sync");
// get current network sporks
pnode->PushMessage(NetMsgType::GETSPORKS);
LogPrintf("CMasternodeSync::ProcessTick -- nTick %d nRequestedMasternodeAssets %d -- requesting sporks from peer %d\n", nTick, nRequestedMasternodeAssets, pnode->id);
continue; // always get sporks first, switch to the next node without waiting for the next tick
}
// MNLIST : SYNC MASTERNODE LIST FROM OTHER CONNECTED CLIENTS
if(nRequestedMasternodeAssets == MASTERNODE_SYNC_LIST) {
LogPrint("masternode", "CMasternodeSync::ProcessTick -- nTick %d nRequestedMasternodeAssets %d nTimeLastMasternodeList %lld GetTime() %lld diff %lld\n", nTick, nRequestedMasternodeAssets, nTimeLastMasternodeList, GetTime(), GetTime() - nTimeLastMasternodeList);
// check for timeout first
if(nTimeLastMasternodeList < GetTime() - MASTERNODE_SYNC_TIMEOUT_SECONDS) {
LogPrintf("CMasternodeSync::Process -- nTick %d nRequestedMasternodeAssets %d -- timeout\n", nTick, nRequestedMasternodeAssets);
LogPrintf("CMasternodeSync::ProcessTick -- nTick %d nRequestedMasternodeAssets %d -- timeout\n", nTick, nRequestedMasternodeAssets);
if (nRequestedMasternodeAttempt == 0) {
LogPrintf("CMasternodeSync::Process -- WARNING: failed to sync %s\n", GetAssetName());
LogPrintf("CMasternodeSync::ProcessTick -- ERROR: failed to sync %s\n", GetAssetName());
// there is no way we can continue without masternode list, fail here and try later
Fail();
return;
@ -276,9 +283,10 @@ void CMasternodeSync::ProcessTick()
/* Note: Is this activing up? It's probably related to int CMasternodeMan::GetEstimatedMasternodes(int nBlock)
Surely doesn't work right for testnet currently */
// try to fetch data from at least two peers though
LogPrintf("CMasternodeSync::ProcessTick -- nTick %d nMnCount %d, Estimated masternode count required: %d\n",
nTick, nMnCount, mnodeman.GetEstimatedMasternodes(pCurrentBlockIndex->nHeight)*0.9);
if(nRequestedMasternodeAttempt > 1 && nMnCount > mnodeman.GetEstimatedMasternodes(pCurrentBlockIndex->nHeight)*0.9) {
int nMnCountEstimated = mnodeman.GetEstimatedMasternodes(pCurrentBlockIndex->nHeight)*0.9;
LogPrintf("CMasternodeSync::ProcessTick -- nTick %d nMnCount %d nMnCountEstimated %d\n",
nTick, nMnCount, nMnCountEstimated);
if(nRequestedMasternodeAttempt > 1 && nMnCount > nMnCountEstimated) {
LogPrintf("CMasternodeSync::ProcessTick -- nTick %d nRequestedMasternodeAssets %d -- found enough data\n", nTick, nRequestedMasternodeAssets);
SwitchToNextAsset();
return;
@ -299,13 +307,14 @@ void CMasternodeSync::ProcessTick()
// MNW : SYNC MASTERNODE PAYMENT VOTES FROM OTHER CONNECTED CLIENTS
if(nRequestedMasternodeAssets == MASTERNODE_SYNC_MNW) {
LogPrint("mnpayments", "CMasternodeSync::ProcessTick -- nTick %d nRequestedMasternodeAssets %d nTimeLastPaymentVote %lld GetTime() %lld diff %lld\n", nTick, nRequestedMasternodeAssets, nTimeLastPaymentVote, GetTime(), GetTime() - nTimeLastPaymentVote);
// check for timeout first
// This might take a lot longer than MASTERNODE_SYNC_TIMEOUT_SECONDS minutes due to new blocks,
// but that should be OK and it should timeout eventually.
if(nTimeLastPaymentVote < GetTime() - MASTERNODE_SYNC_TIMEOUT_SECONDS) {
LogPrintf("CMasternodeSync::Process -- nTick %d nRequestedMasternodeAssets %d -- timeout\n", nTick, nRequestedMasternodeAssets);
LogPrintf("CMasternodeSync::ProcessTick -- nTick %d nRequestedMasternodeAssets %d -- timeout\n", nTick, nRequestedMasternodeAssets);
if (nRequestedMasternodeAttempt == 0) {
LogPrintf("CMasternodeSync::Process -- WARNING: failed to sync %s\n", GetAssetName());
LogPrintf("CMasternodeSync::ProcessTick -- ERROR: failed to sync %s\n", GetAssetName());
// probably not a good idea to proceed without winner list
Fail();
return;
@ -318,7 +327,7 @@ void CMasternodeSync::ProcessTick()
// if mnpayments already has enough blocks and votes, switch to the next asset
// try to fetch data from at least two peers though
if(nRequestedMasternodeAttempt > 1 && mnpayments.IsEnoughData()) {
LogPrintf("CMasternodeSync::Process -- nTick %d nRequestedMasternodeAssets %d -- found enough data\n", nTick, nRequestedMasternodeAssets);
LogPrintf("CMasternodeSync::ProcessTick -- nTick %d nRequestedMasternodeAssets %d -- found enough data\n", nTick, nRequestedMasternodeAssets);
SwitchToNextAsset();
return;
}
@ -341,11 +350,13 @@ void CMasternodeSync::ProcessTick()
// GOVOBJ : SYNC GOVERNANCE ITEMS FROM OUR PEERS
if(nRequestedMasternodeAssets == MASTERNODE_SYNC_GOVERNANCE) {
LogPrint("mnpayments", "CMasternodeSync::ProcessTick -- nTick %d nRequestedMasternodeAssets %d nTimeLastPaymentVote %lld GetTime() %lld diff %lld\n", nTick, nRequestedMasternodeAssets, nTimeLastPaymentVote, GetTime(), GetTime() - nTimeLastPaymentVote);
// check for timeout first
if(nTimeLastBudgetItem < GetTime() - MASTERNODE_SYNC_TIMEOUT_SECONDS){
LogPrintf("CMasternodeSync::Process -- nTick %d nRequestedMasternodeAssets %d -- timeout\n", nTick, nRequestedMasternodeAssets);
LogPrintf("CMasternodeSync::ProcessTick -- nTick %d nRequestedMasternodeAssets %d -- timeout\n", nTick, nRequestedMasternodeAssets);
if(nRequestedMasternodeAttempt == 0) {
LogPrintf("CMasternodeSync::Process -- WARNING: failed to sync %s\n", GetAssetName());
LogPrintf("CMasternodeSync::ProcessTick -- WARNING: failed to sync %s\n", GetAssetName());
// it's kind of ok to skip this for now, hopefully we'll catch up later?
}
SwitchToNextAsset();

View File

@ -396,7 +396,7 @@ bool CMasternodeBroadcast::Create(CTxIn txin, CService service, CKey keyCollater
CMasternodePing mnp(txin);
if(!mnp.Sign(keyMasternodeNew, pubKeyMasternodeNew)) {
strErrorRet = strprintf("Failed to sign ping, masternode=%s", txin.prevout.ToStringShort());
LogPrintf("CMasternodeBroadcast::Create -- %s\n", strErrorRet);
LogPrintf("CMasternodeBroadcast::Create -- %s\n", strErrorRet);
mnbRet = CMasternodeBroadcast();
return false;
}
@ -565,7 +565,7 @@ bool CMasternodeBroadcast::CheckOutpoint(int& nDos)
return false;
}
if(chainActive.Height() - coins.nHeight + 1 < Params().GetConsensus().nMasternodeMinimumConfirmations) {
LogPrintf("CMasternodeBroadcast::CheckOutpoint -- Masternode UTXO must have at least %d confirmations, masternode=\n",
LogPrintf("CMasternodeBroadcast::CheckOutpoint -- Masternode UTXO must have at least %d confirmations, masternode=%s\n",
Params().GetConsensus().nMasternodeMinimumConfirmations, vin.prevout.ToStringShort());
// maybe we miss few blocks, let this mnb to be checked again later
mnodeman.mapSeenMasternodeBroadcast.erase(GetHash());

View File

@ -55,9 +55,8 @@ bool CMasternodeMan::Add(CMasternode &mn)
return false;
CMasternode *pmn = Find(mn.vin);
if (pmn == NULL)
{
LogPrint("masternode", "CMasternodeMan: Adding new Masternode %s - %i now\n", mn.addr.ToString(), size() + 1);
if (pmn == NULL) {
LogPrint("masternode", "CMasternodeMan::Add -- Adding new Masternode: addr=%s, %i now\n", mn.addr.ToString(), size() + 1);
vMasternodes.push_back(mn);
return true;
}
@ -67,19 +66,19 @@ bool CMasternodeMan::Add(CMasternode &mn)
void CMasternodeMan::AskForMN(CNode* pnode, CTxIn &vin)
{
std::map<COutPoint, int64_t>::iterator i = mWeAskedForMasternodeListEntry.find(vin.prevout);
if (i != mWeAskedForMasternodeListEntry.end())
{
int64_t t = (*i).second;
if (GetTime() < t) return; // we've asked recently
if(!pnode) return;
std::map<COutPoint, int64_t>::iterator it = mWeAskedForMasternodeListEntry.find(vin.prevout);
if (it != mWeAskedForMasternodeListEntry.end() && GetTime() < (*it).second) {
// we've asked recently, should not repeat too often or we could get banned
return;
}
// ask for the mnb info once from the node that sent mnp
LogPrintf("CMasternodeMan::AskForMN - Asking node for missing entry, vin: %s\n", vin.ToString());
LogPrintf("CMasternodeMan::AskForMN -- Asking node for missing masternode entry: %s\n", vin.prevout.ToStringShort());
pnode->PushMessage(NetMsgType::DSEG, vin);
int64_t askAgain = GetTime() + MASTERNODE_MIN_MNP_SECONDS;
mWeAskedForMasternodeListEntry[vin.prevout] = askAgain;
mWeAskedForMasternodeListEntry[vin.prevout] = GetTime() + DSEG_UPDATE_SECONDS;;
}
void CMasternodeMan::Check()
@ -127,7 +126,7 @@ void CMasternodeMan::CheckAndRemove(bool fForceExpiredRemoval)
}
// check who's asked for the Masternode list
map<CNetAddr, int64_t>::iterator it1 = mAskedUsForMasternodeList.begin();
std::map<CNetAddr, int64_t>::iterator it1 = mAskedUsForMasternodeList.begin();
while(it1 != mAskedUsForMasternodeList.end()){
if((*it1).second < GetTime()) {
mAskedUsForMasternodeList.erase(it1++);
@ -147,7 +146,7 @@ void CMasternodeMan::CheckAndRemove(bool fForceExpiredRemoval)
}
// check which Masternodes we've asked for
map<COutPoint, int64_t>::iterator it2 = mWeAskedForMasternodeListEntry.begin();
std::map<COutPoint, int64_t>::iterator it2 = mWeAskedForMasternodeListEntry.begin();
while(it2 != mWeAskedForMasternodeListEntry.end()){
if((*it2).second < GetTime()){
mWeAskedForMasternodeListEntry.erase(it2++);
@ -166,10 +165,10 @@ void CMasternodeMan::CheckAndRemove(bool fForceExpiredRemoval)
}
// remove expired mapSeenMasternodeBroadcast
map<uint256, CMasternodeBroadcast>::iterator it3 = mapSeenMasternodeBroadcast.begin();
std::map<uint256, CMasternodeBroadcast>::iterator it3 = mapSeenMasternodeBroadcast.begin();
while(it3 != mapSeenMasternodeBroadcast.end()){
if((*it3).second.lastPing.sigTime < GetTime() - MASTERNODE_REMOVAL_SECONDS*2){
LogPrint("masternode", "CMasternodeMan::CheckAndRemove - Removing expired Masternode broadcast %s\n", (*it3).second.GetHash().ToString());
LogPrint("masternode", "CMasternodeMan::CheckAndRemove -- Removing expired Masternode broadcast: hash=%s\n", (*it3).second.GetHash().ToString());
mapSeenMasternodeBroadcast.erase(it3++);
} else {
++it3;
@ -177,10 +176,10 @@ void CMasternodeMan::CheckAndRemove(bool fForceExpiredRemoval)
}
// remove expired mapSeenMasternodePing
map<uint256, CMasternodePing>::iterator it4 = mapSeenMasternodePing.begin();
std::map<uint256, CMasternodePing>::iterator it4 = mapSeenMasternodePing.begin();
while(it4 != mapSeenMasternodePing.end()){
if((*it4).second.sigTime < GetTime() - MASTERNODE_REMOVAL_SECONDS*2){
LogPrint("masternode", "CMasternodeMan::CheckAndRemove - Removing expired Masternode ping %s\n", (*it4).second.GetHash().ToString());
LogPrint("masternode", "CMasternodeMan::CheckAndRemove -- Removing expired Masternode ping: hash=%s\n", (*it4).second.GetHash().ToString());
mapSeenMasternodePing.erase(it4++);
} else {
++it4;
@ -197,6 +196,8 @@ void CMasternodeMan::CheckAndRemove(bool fForceExpiredRemoval)
++itv2;
}
}
LogPrintf("CMasternodeMan::CheckAndRemove -- %s\n", ToString());
}
void CMasternodeMan::Clear()
@ -212,42 +213,43 @@ void CMasternodeMan::Clear()
nLastWatchdogVoteTime = 0;
}
int CMasternodeMan::CountMasternodes(int protocolVersion)
int CMasternodeMan::CountMasternodes(int nProtocolVersion)
{
LOCK(cs);
int i = 0;
protocolVersion = protocolVersion == -1 ? mnpayments.GetMinMasternodePaymentsProto() : protocolVersion;
int nCount = 0;
nProtocolVersion = nProtocolVersion == -1 ? mnpayments.GetMinMasternodePaymentsProto() : nProtocolVersion;
BOOST_FOREACH(CMasternode& mn, vMasternodes) {
if(mn.nProtocolVersion < protocolVersion) continue;
i++;
if(mn.nProtocolVersion < nProtocolVersion) continue;
nCount++;
}
return i;
return nCount;
}
int CMasternodeMan::CountEnabled(int protocolVersion)
int CMasternodeMan::CountEnabled(int nProtocolVersion)
{
LOCK(cs);
int i = 0;
protocolVersion = protocolVersion == -1 ? mnpayments.GetMinMasternodePaymentsProto() : protocolVersion;
int nCount = 0;
nProtocolVersion = nProtocolVersion == -1 ? mnpayments.GetMinMasternodePaymentsProto() : nProtocolVersion;
BOOST_FOREACH(CMasternode& mn, vMasternodes) {
mn.Check();
if(mn.nProtocolVersion < protocolVersion || !mn.IsEnabled()) continue;
i++;
if(mn.nProtocolVersion < nProtocolVersion || !mn.IsEnabled()) continue;
nCount++;
}
return i;
return nCount;
}
/* Only IPv4 masternodes are allowed in 12.1, saving this for later
int CMasternodeMan::CountByIP(int nNetworkType)
{
LOCK(cs);
int nNodeCount = 0;
BOOST_FOREACH(CMasternode& mn, vMasternodes)
if( (nNetworkType == NET_IPV4 && mn.addr.IsIPv4()) ||
if ((nNetworkType == NET_IPV4 && mn.addr.IsIPv4()) ||
(nNetworkType == NET_TOR && mn.addr.IsTor()) ||
(nNetworkType == NET_IPV6 && mn.addr.IsIPv6())) {
nNodeCount++;
@ -255,20 +257,18 @@ int CMasternodeMan::CountByIP(int nNetworkType)
return nNodeCount;
}
*/
void CMasternodeMan::DsegUpdate(CNode* pnode)
{
LOCK(cs);
if(Params().NetworkIDString() == CBaseChainParams::MAIN) {
if(!(pnode->addr.IsRFC1918() || pnode->addr.IsLocal())){
if(!(pnode->addr.IsRFC1918() || pnode->addr.IsLocal())) {
std::map<CNetAddr, int64_t>::iterator it = mWeAskedForMasternodeList.find(pnode->addr);
if (it != mWeAskedForMasternodeList.end())
{
if (GetTime() < (*it).second) {
LogPrintf("dseg - we already asked %s for the list; skipping...\n", pnode->addr.ToString());
return;
}
if(it != mWeAskedForMasternodeList.end() && GetTime() < (*it).second) {
LogPrintf("CMasternodeMan::DsegUpdate -- we already asked %s for the list; skipping...\n", pnode->addr.ToString());
return;
}
}
}
@ -276,9 +276,11 @@ void CMasternodeMan::DsegUpdate(CNode* pnode)
pnode->PushMessage(NetMsgType::DSEG, CTxIn());
int64_t askAgain = GetTime() + DSEG_UPDATE_SECONDS;
mWeAskedForMasternodeList[pnode->addr] = askAgain;
LogPrint("masternode", "CMasternodeMan::DsegUpdate -- asked %s for the list\n", pnode->addr.ToString());
}
CMasternode *CMasternodeMan::Find(const CScript &payee)
CMasternode* CMasternodeMan::Find(const CScript &payee)
{
LOCK(cs);
@ -290,7 +292,7 @@ CMasternode *CMasternodeMan::Find(const CScript &payee)
return NULL;
}
CMasternode *CMasternodeMan::Find(const CTxIn &vin)
CMasternode* CMasternodeMan::Find(const CTxIn &vin)
{
LOCK(cs);
@ -369,7 +371,7 @@ bool CMasternodeMan::Has(const CTxIn& vin)
return (pMN != NULL);
}
//
//
// Deterministically select the oldest/best masternode to pay on the network
//
CMasternode* CMasternodeMan::GetNextMasternodeInQueueForPayment(int nBlockHeight, bool fFilterSigTime, int& nCount)
@ -398,7 +400,7 @@ CMasternode* CMasternodeMan::GetNextMasternodeInQueueForPayment(int nBlockHeight
//it's too new, wait for a cycle
if(fFilterSigTime && mn.sigTime + (nMnCount*2.6*60) > GetAdjustedTime()) continue;
//make sure it has as many confirmations as there are masternodes
//make sure it has at least as many confirmations as there are masternodes
if(mn.GetCollateralAge() < nMnCount) continue;
vecMasternodeLastPaid.push_back(std::make_pair(mn.GetLastPaidBlock(), &mn));
@ -436,7 +438,7 @@ CMasternode* CMasternodeMan::GetNextMasternodeInQueueForPayment(int nBlockHeight
return pBestMasternode;
}
CMasternode *CMasternodeMan::FindRandomNotInVec(std::vector<CTxIn> &vecToExclude, int nProtocolVersion)
CMasternode* CMasternodeMan::FindRandomNotInVec(const std::vector<CTxIn> &vecToExclude, int nProtocolVersion)
{
LOCK(cs);
@ -445,7 +447,7 @@ CMasternode *CMasternodeMan::FindRandomNotInVec(std::vector<CTxIn> &vecToExclude
int nCountEnabled = CountEnabled(nProtocolVersion);
int nCountNotExcluded = nCountEnabled - vecToExclude.size();
LogPrintf("CMasternodeMan::FindRandomNotInVec -- %d enabled masternodes, %d masternodes aren't yet exluded\n", nCountEnabled, nCountNotExcluded);
LogPrintf("CMasternodeMan::FindRandomNotInVec -- %d enabled masternodes, %d masternodes to choose from\n", nCountEnabled, nCountNotExcluded);
if(nCountNotExcluded < 1) return NULL;
// fill a vector of pointers
@ -462,7 +464,7 @@ CMasternode *CMasternodeMan::FindRandomNotInVec(std::vector<CTxIn> &vecToExclude
BOOST_FOREACH(CMasternode* pmn, vpMasternodesShuffled) {
if(pmn->nProtocolVersion < nProtocolVersion || !pmn->IsEnabled()) continue;
fExclude = false;
BOOST_FOREACH(CTxIn &txinToExclude, vecToExclude) {
BOOST_FOREACH(const CTxIn &txinToExclude, vecToExclude) {
if(pmn->vin.prevout == txinToExclude.prevout) {
fExclude = true;
break;
@ -478,7 +480,7 @@ CMasternode *CMasternodeMan::FindRandomNotInVec(std::vector<CTxIn> &vecToExclude
return NULL;
}
int CMasternodeMan::GetMasternodeRank(const CTxIn& vin, int64_t nBlockHeight, int minProtocol, bool fOnlyActive)
int CMasternodeMan::GetMasternodeRank(const CTxIn& vin, int nBlockHeight, int nMinProtocol, bool fOnlyActive)
{
std::vector<std::pair<int64_t, CMasternode*> > vecMasternodeScores;
@ -490,7 +492,7 @@ int CMasternodeMan::GetMasternodeRank(const CTxIn& vin, int64_t nBlockHeight, in
// scan for winner
BOOST_FOREACH(CMasternode& mn, vMasternodes) {
if(mn.nProtocolVersion < minProtocol) continue;
if(mn.nProtocolVersion < nMinProtocol) continue;
if(fOnlyActive) {
mn.Check();
if(!mn.IsEnabled()) continue;
@ -511,7 +513,7 @@ int CMasternodeMan::GetMasternodeRank(const CTxIn& vin, int64_t nBlockHeight, in
return -1;
}
std::vector<pair<int, CMasternode> > CMasternodeMan::GetMasternodeRanks(int64_t nBlockHeight, int minProtocol)
std::vector<std::pair<int, CMasternode> > CMasternodeMan::GetMasternodeRanks(int nBlockHeight, int nMinProtocol)
{
std::vector<std::pair<int64_t, CMasternode*> > vecMasternodeScores;
std::vector<std::pair<int, CMasternode> > vecMasternodeRanks;
@ -527,7 +529,7 @@ std::vector<pair<int, CMasternode> > CMasternodeMan::GetMasternodeRanks(int64_t
mn.Check();
if(mn.nProtocolVersion < minProtocol || !mn.IsEnabled()) continue;
if(mn.nProtocolVersion < nMinProtocol || !mn.IsEnabled()) continue;
int64_t nScore = mn.CalculateScore(blockHash).GetCompact(false);
@ -545,7 +547,7 @@ std::vector<pair<int, CMasternode> > CMasternodeMan::GetMasternodeRanks(int64_t
return vecMasternodeRanks;
}
CMasternode* CMasternodeMan::GetMasternodeByRank(int nRank, int64_t nBlockHeight, int minProtocol, bool fOnlyActive)
CMasternode* CMasternodeMan::GetMasternodeByRank(int nRank, int nBlockHeight, int nMinProtocol, bool fOnlyActive)
{
std::vector<std::pair<int64_t, CMasternode*> > vecMasternodeScores;
@ -560,7 +562,7 @@ CMasternode* CMasternodeMan::GetMasternodeByRank(int nRank, int64_t nBlockHeight
// Fill scores
BOOST_FOREACH(CMasternode& mn, vMasternodes) {
if(mn.nProtocolVersion < minProtocol) continue;
if(mn.nProtocolVersion < nMinProtocol) continue;
if(fOnlyActive) {
mn.Check();
if(!mn.IsEnabled()) continue;
@ -584,22 +586,6 @@ CMasternode* CMasternodeMan::GetMasternodeByRank(int nRank, int64_t nBlockHeight
return NULL;
}
void CMasternodeMan::InitDummyScriptPubkey() {
CKey secret;
secret.MakeNewKey(true);
CPubKey pubkey = secret.GetPubKey();
assert(secret.VerifyPubKey(pubkey));
if (pubkey.IsValid()) {
CKeyID keyID = pubkey.GetID();
LogPrintf("Generated dummyScriptPubkey: address %s privkey %s\n", CBitcoinAddress(keyID).ToString(), CBitcoinSecret(secret).ToString());
dummyScriptPubkey = GetScriptForDestination(keyID);
} else {
LogPrintf("CMasternodeMan::InitDummyScriptPubkey - ERROR: can't assign dummyScriptPubkey\n");
}
}
void CMasternodeMan::ProcessMasternodeConnections()
{
//we don't care about this for regtest
@ -609,7 +595,7 @@ void CMasternodeMan::ProcessMasternodeConnections()
BOOST_FOREACH(CNode* pnode, vNodes) {
if(pnode->fMasternode) {
if(darkSendPool.pSubmittedToMasternode != NULL && pnode->addr == darkSendPool.pSubmittedToMasternode->addr) continue;
LogPrintf("Closing Masternode connection %s \n", pnode->addr.ToString());
LogPrintf("Closing Masternode connection: peer=%d, addr=%s\n", pnode->id, pnode->addr.ToString());
pnode->fDisconnect = true;
}
}
@ -617,13 +603,13 @@ void CMasternodeMan::ProcessMasternodeConnections()
void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CDataStream& vRecv)
{
if(fLiteMode) return; //disable all Darksend/Masternode related functionality
if(fLiteMode) return; // disable all Dash specific functionality
if(!masternodeSync.IsBlockchainSynced()) return;
LOCK(cs);
if (strCommand == NetMsgType::MNANNOUNCE) { //Masternode Broadcast
CMasternodeBroadcast mnb;
vRecv >> mnb;
@ -632,8 +618,8 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
if (CheckMnbAndUpdateMasternodeList(mnb, nDos)) {
// use announced Masternode as a peer
addrman.Add(CAddress(mnb.addr), pfrom->addr, 2*60*60);
} else {
if(nDos > 0) Misbehaving(pfrom->GetId(), nDos);
} else if(nDos > 0) {
Misbehaving(pfrom->GetId(), nDos);
}
} else if (strCommand == NetMsgType::MNPING) { //Masternode Ping
@ -644,12 +630,12 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
CMasternodePing mnp;
vRecv >> mnp;
LogPrint("masternode", "mnp - Masternode ping, vin: %s\n", mnp.vin.ToString());
LogPrint("masternode", "MNPING -- Masternode ping, masternode=%s\n", mnp.vin.prevout.ToStringShort());
if(mapSeenMasternodePing.count(mnp.GetHash())) return; //seen
mapSeenMasternodePing.insert(make_pair(mnp.GetHash(), mnp));
mapSeenMasternodePing.insert(std::make_pair(mnp.GetHash(), mnp));
LogPrint("masternode", "mnp - Masternode ping, vin: %s new\n", mnp.vin.ToString());
LogPrint("masternode", "MNPING -- Masternode ping, masternode=%s new\n", mnp.vin.prevout.ToStringShort());
int nDos = 0;
if(mnp.CheckAndUpdate(nDos, false)) return;
@ -678,7 +664,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
CTxIn vin;
vRecv >> vin;
LogPrint("masternode", "CMasternodeMan::ProcessMessage -- DSEG -- Masternode list, masternode=%s\n", vin.prevout.ToStringShort());
LogPrint("masternode", "DSEG -- Masternode list, masternode=%s\n", vin.prevout.ToStringShort());
if(vin == CTxIn()) { //only should ask for this once
//local network
@ -690,7 +676,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
int64_t t = (*i).second;
if (GetTime() < t) {
Misbehaving(pfrom->GetId(), 34);
LogPrintf("CMasternodeMan::ProcessMessage -- DSEG -- peer already asked me for the list, peer=\n", pfrom->id);
LogPrintf("DSEG -- peer already asked me for the list, peer=%d\n", pfrom->id);
return;
}
}
@ -706,7 +692,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
if (mn.addr.IsRFC1918() || mn.addr.IsLocal()) continue; // do not send local network masternode
if (!mn.IsEnabled()) continue;
LogPrint("masternode", "CMasternodeMan::ProcessMessage -- DSEG -- Sending Masternode entry: masternode=%s addr=%s\n", mn.vin.prevout.ToStringShort(), mn.addr.ToString());
LogPrint("masternode", "DSEG -- Sending Masternode entry: masternode=%s addr=%s\n", mn.vin.prevout.ToStringShort(), mn.addr.ToString());
CMasternodeBroadcast mnb = CMasternodeBroadcast(mn);
uint256 hash = mnb.GetHash();
pfrom->PushInventory(CInv(MSG_MASTERNODE_ANNOUNCE, hash));
@ -717,18 +703,18 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
}
if (vin == mn.vin) {
LogPrintf("CMasternodeMan::ProcessMessage -- DSEG -- Sent 1 Masternode inv to peer %d\n", pfrom->id);
LogPrintf("DSEG -- Sent 1 Masternode inv to peer %d\n", pfrom->id);
return;
}
}
if(vin == CTxIn()) {
pfrom->PushMessage(NetMsgType::SYNCSTATUSCOUNT, MASTERNODE_SYNC_LIST, nInvCount);
LogPrintf("CMasternodeMan::ProcessMessage -- DSEG -- Sent %d Masternode invs to peer %d\n", nInvCount, pfrom->id);
LogPrintf("DSEG -- Sent %d Masternode invs to peer %d\n", nInvCount, pfrom->id);
return;
}
// smth weird happen - someone asked us for vin we have no idea about?
LogPrint("masternode", "CMasternodeMan::ProcessMessage -- DSEG -- No invs sent to peer %d\n", pfrom->id);
LogPrint("masternode", "DSEG -- No invs sent to peer %d\n", pfrom->id);
} else if (strCommand == NetMsgType::MNVERIFY) { // Masternode Verify
@ -748,6 +734,8 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
}
}
// Verification of masternodes via unique direct requests.
void CMasternodeMan::DoFullVerificationStep()
{
if(activeMasternode.vin == CTxIn()) return;
@ -817,6 +805,11 @@ void CMasternodeMan::DoFullVerificationStep()
LogPrint("masternode", "CMasternodeMan::DoFullVerificationStep -- Sent verification requests to %d masternodes\n", nCount);
}
// This function tries to find masternodes with the same addr,
// find a verified one and ban all the other. If there are many nodes
// with the same addr but none of them is verified yet, then none of them are banned.
// It could take many times to run this before most of the duplicate nodes are banned.
void CMasternodeMan::CheckSameAddr()
{
if(!masternodeSync.IsSynced() || vMasternodes.empty()) return;
@ -1150,10 +1143,10 @@ void CMasternodeMan::Remove(CTxIn vin)
{
LOCK(cs);
vector<CMasternode>::iterator it = vMasternodes.begin();
while(it != vMasternodes.end()){
if((*it).vin == vin){
LogPrint("masternode", "CMasternodeMan: Removing Masternode %s - %i now\n", (*it).addr.ToString(), size() - 1);
std::vector<CMasternode>::iterator it = vMasternodes.begin();
while(it != vMasternodes.end()) {
if((*it).vin == vin) {
LogPrint("masternode", "CMasternodeMan::Remove -- Removing Masternode: %s addr=%s, %i now\n", vin.prevout.ToStringShort(), (*it).addr.ToString(), size() - 1);
vMasternodes.erase(it);
break;
}
@ -1178,35 +1171,34 @@ int CMasternodeMan::GetEstimatedMasternodes(int nBlock)
{
/*
Masternodes = (Coins/1000)*X on average
*X = nPercentage, starting at 0.52
nPercentage goes up 0.01 each period
Period starts at 35040, which has exponential slowing growth
*/
*/
int nPercentage = 52; //0.52
int nPeriod = 35040;
int nCollateral = 1000;
for(int i = nPeriod; i <= nBlock; i += nPeriod)
{
for (int i = nPeriod; i <= nBlock; i += nPeriod) {
nPercentage++;
nPeriod*=2;
}
return (GetTotalCoinEstimate(nBlock)/100*nPercentage/nCollateral);
}
void CMasternodeMan::UpdateMasternodeList(CMasternodeBroadcast mnb) {
void CMasternodeMan::UpdateMasternodeList(CMasternodeBroadcast mnb)
{
LOCK(cs);
mapSeenMasternodePing.insert(make_pair(mnb.lastPing.GetHash(), mnb.lastPing));
mapSeenMasternodeBroadcast.insert(make_pair(mnb.GetHash(), mnb));
mapSeenMasternodePing.insert(std::make_pair(mnb.lastPing.GetHash(), mnb.lastPing));
mapSeenMasternodeBroadcast.insert(std::make_pair(mnb.GetHash(), mnb));
LogPrintf("CMasternodeMan::UpdateMasternodeList() - addr: %s\n vin: %s\n", mnb.addr.ToString(), mnb.vin.ToString());
LogPrintf("CMasternodeMan::UpdateMasternodeList -- masternode=%s addr=%s\n", mnb.vin.prevout.ToStringShort(), mnb.addr.ToString());
CMasternode* pmn = Find(mnb.vin);
if(pmn == NULL)
{
if(pmn == NULL) {
CMasternode mn(mnb);
if(Add(mn)) {
masternodeSync.AddedMasternodeList();

View File

@ -59,8 +59,6 @@ public:
// keep track of dsq count to prevent masternodes from gaming darksend queue
int64_t nDsqCount;
// dummy script pubkey to test masternodes' vins against mempool
CScript dummyScriptPubkey;
CMasternodeMan() : nLastWatchdogVoteTime(0), nDsqCount(0) {}
@ -107,12 +105,15 @@ public:
/// Clear Masternode vector
void Clear();
int CountMasternodes(int protocolVersion = -1);
int CountEnabled(int protocolVersion = -1);
/// Count Masternodes filtered by nProtocolVersion.
/// Masternode nProtocolVersion should match or be above the one specified in param here.
int CountMasternodes(int nProtocolVersion = -1);
/// Count enabled Masternodes filtered by nProtocolVersion.
/// Masternode nProtocolVersion should match or be above the one specified in param here.
int CountEnabled(int nProtocolVersion = -1);
/// Count Masternodes by network type - NET_IPV4, NET_IPV6, NET_TOR
int CountByIP(int nNetworkType);
// int CountByIP(int nNetworkType);
void DsegUpdate(CNode* pnode);
@ -135,15 +136,13 @@ public:
CMasternode* GetNextMasternodeInQueueForPayment(int nBlockHeight, bool fFilterSigTime, int& nCount);
/// Find a random entry
CMasternode* FindRandomNotInVec(std::vector<CTxIn> &vecToExclude, int nProtocolVersion = -1);
CMasternode* FindRandomNotInVec(const std::vector<CTxIn> &vecToExclude, int nProtocolVersion = -1);
std::vector<CMasternode> GetFullMasternodeVector() { Check(); return vMasternodes; }
std::vector<pair<int, CMasternode> > GetMasternodeRanks(int64_t nBlockHeight, int minProtocol=0);
int GetMasternodeRank(const CTxIn &vin, int64_t nBlockHeight, int minProtocol=0, bool fOnlyActive=true);
CMasternode* GetMasternodeByRank(int nRank, int64_t nBlockHeight, int minProtocol=0, bool fOnlyActive=true);
void InitDummyScriptPubkey();
std::vector<std::pair<int, CMasternode> > GetMasternodeRanks(int nBlockHeight = -1, int nMinProtocol=0);
int GetMasternodeRank(const CTxIn &vin, int nBlockHeight, int nMinProtocol=0, bool fOnlyActive=true);
CMasternode* GetMasternodeByRank(int nRank, int nBlockHeight, int nMinProtocol=0, bool fOnlyActive=true);
void ProcessMasternodeConnections();

View File

@ -379,7 +379,7 @@ static bool ProcessBlockFound(const CBlock* pblock, const CChainParams& chainpar
{
LOCK(cs_main);
if (pblock->hashPrevBlock != chainActive.Tip()->GetBlockHash())
return error("DashMiner: generated block is stale");
return error("ProcessBlockFound -- generated block is stale");
}
// Inform about the new block
@ -388,7 +388,7 @@ static bool ProcessBlockFound(const CBlock* pblock, const CChainParams& chainpar
// Process this block the same as if we had received it from another node
CValidationState state;
if (!ProcessNewBlock(state, chainparams, NULL, pblock, true, NULL))
return error("DashMiner: ProcessNewBlock, block not accepted");
return error("ProcessBlockFound -- ProcessNewBlock() failed, block not accepted");
return true;
}
@ -396,7 +396,7 @@ static bool ProcessBlockFound(const CBlock* pblock, const CChainParams& chainpar
// ***TODO*** that part changed in bitcoin, we are using a mix with old one here for now
void static BitcoinMiner(const CChainParams& chainparams)
{
LogPrintf("DashMiner started\n");
LogPrintf("DashMiner -- started\n");
SetThreadPriority(THREAD_PRIORITY_LOWEST);
RenameThread("dash-miner");
@ -439,13 +439,13 @@ void static BitcoinMiner(const CChainParams& chainparams)
auto_ptr<CBlockTemplate> pblocktemplate(CreateNewBlock(chainparams, coinbaseScript->reserveScript));
if (!pblocktemplate.get())
{
LogPrintf("Error in DashMiner: Keypool ran out, please call keypoolrefill before restarting the mining thread\n");
LogPrintf("DashMiner -- Keypool ran out, please call keypoolrefill before restarting the mining thread\n");
return;
}
CBlock *pblock = &pblocktemplate->block;
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
LogPrintf("Running DashMiner with %u transactions in block (%u bytes)\n", pblock->vtx.size(),
LogPrintf("DashMiner -- Running miner with %u transactions in block (%u bytes)\n", pblock->vtx.size(),
::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION));
//
@ -465,8 +465,7 @@ void static BitcoinMiner(const CChainParams& chainparams)
{
// Found a solution
SetThreadPriority(THREAD_PRIORITY_NORMAL);
LogPrintf("BitcoinMiner:\n");
LogPrintf("proof-of-work found \n hash: %s \ntarget: %s\n", hash.GetHex(), hashTarget.GetHex());
LogPrintf("DashMiner:\n proof-of-work found\n hash: %s\n target: %s\n", hash.GetHex(), hashTarget.GetHex());
ProcessBlockFound(pblock, chainparams);
SetThreadPriority(THREAD_PRIORITY_LOWEST);
coinbaseScript->KeepScript();
@ -510,12 +509,12 @@ void static BitcoinMiner(const CChainParams& chainparams)
}
catch (const boost::thread_interrupted&)
{
LogPrintf("DashMiner terminated\n");
LogPrintf("DashMiner -- terminated\n");
throw;
}
catch (const std::runtime_error &e)
{
LogPrintf("BitcoinMiner runtime error: %s\n", e.what());
LogPrintf("DashMiner -- runtime error: %s\n", e.what());
return;
}
}

View File

@ -43,7 +43,6 @@ const char *GETSPORKS="getsporks";
const char *MASTERNODEPAYMENTVOTE="mnw";
const char *MASTERNODEPAYMENTBLOCK="mnwb";
const char *MASTERNODEPAYMENTSYNC="mnget";
const char *MNSCANERROR="mn scan error"; // not implemented
const char *MNBUDGETSYNC="mnvs"; // depreciated since 12.1
const char *MNBUDGETVOTE="mvote"; // depreciated since 12.1
const char *MNBUDGETPROPOSAL="mprop"; // depreciated since 12.1

View File

@ -74,12 +74,14 @@ int ClientModel::getNumConnections(unsigned int flags) const
QString ClientModel::getMasternodeCountString() const
{
return tr("Total: %1 (PS compatible: %2 / Enabled: %3) (IPv4: %4, IPv6: %5, TOR: %6)").arg(QString::number((int)mnodeman.size()))
// return tr("Total: %1 (PS compatible: %2 / Enabled: %3) (IPv4: %4, IPv6: %5, TOR: %6)").arg(QString::number((int)mnodeman.size()))
return tr("Total: %1 (PS compatible: %2 / Enabled: %3)")
.arg(QString::number((int)mnodeman.size()))
.arg(QString::number((int)mnodeman.CountEnabled(MIN_PRIVATESEND_PEER_PROTO_VERSION)))
.arg(QString::number((int)mnodeman.CountEnabled()))
.arg(QString::number((int)mnodeman.CountByIP(NET_IPV4)))
.arg(QString::number((int)mnodeman.CountByIP(NET_IPV6)))
.arg(QString::number((int)mnodeman.CountByIP(NET_TOR)));
.arg(QString::number((int)mnodeman.CountEnabled()));
// .arg(QString::number((int)mnodeman.CountByIP(NET_IPV4)))
// .arg(QString::number((int)mnodeman.CountByIP(NET_IPV6)))
// .arg(QString::number((int)mnodeman.CountByIP(NET_TOR)));
}
int ClientModel::getNumBlocks() const

View File

@ -387,7 +387,7 @@ void OverviewPage::updatePrivateSendProgress()
float denomPart = 0;
// mixing progress of denominated balance
float anonNormPart = 0;
// completeness of full amount anonimization
// completeness of full amount anonymization
float anonFullPart = 0;
CAmount denominatedBalance = nDenominatedConfirmedBalance + nDenominatedUnconfirmedBalance;

View File

@ -2325,7 +2325,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int
s += FormatMoney(vValue[i].first) + " ";
}
}
LogPrintf("%s - total %s\n", s, FormatMoney(nBest));
LogPrint("selectcoins", "%s - total %s\n", s, FormatMoney(nBest));
}
return true;