(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 make
Precompiled binaries are available at github, see 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. Always verify the signatures and checksums.

View File

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

View File

@ -20,7 +20,7 @@ Unpack the files into a directory, and then run dash-qt.exe.
### OS X ### 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? ### 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. 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. 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``` ```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 ### 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: - 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 - Dash-development mailing list

View File

@ -115,14 +115,14 @@ testScripts = [
'timestampindex.py', 'timestampindex.py',
'spentindex.py', 'spentindex.py',
'decodescript.py', 'decodescript.py',
'p2p-fullblocktest.py', # TODO: works, needs dash_hash 'p2p-fullblocktest.py', # NOTE: needs dash_hash to pass
'blockchain.py', 'blockchain.py',
'disablewallet.py', 'disablewallet.py',
'sendheaders.py', # TODO: works, needs dash_hash 'sendheaders.py', # NOTE: needs dash_hash to pass
'keypool.py', 'keypool.py',
'prioritise_transaction.py', 'prioritise_transaction.py',
'invalidblockrequest.py', # TODO: works, needs dash_hash 'invalidblockrequest.py', # NOTE: needs dash_hash to pass
'invalidtxrequest.py', # TODO: works, needs dash_hash 'invalidtxrequest.py', # NOTE: needs dash_hash to pass
'abandonconflict.py', 'abandonconflict.py',
'p2p-versionbits-warning.py', 'p2p-versionbits-warning.py',
] ]
@ -132,9 +132,9 @@ if ENABLE_ZMQ:
testScriptsExt = [ testScriptsExt = [
'bip9-softforks.py', 'bip9-softforks.py',
'bip65-cltv.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', 'bip68-sequence.py',
'bipdersig-p2p.py', # TODO: works, needs dash_hash 'bipdersig-p2p.py', # NOTE: needs dash_hash to pass
'bipdersig.py', '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_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', 'getblocktemplate_proposals.py',
@ -146,7 +146,7 @@ testScriptsExt = [
# 'rpcbind_test.py', #temporary, bug in libevent, see #6655 # 'rpcbind_test.py', #temporary, bug in libevent, see #6655
'smartfees.py', 'smartfees.py',
'maxblocksinflight.py', 'maxblocksinflight.py',
'p2p-acceptblock.py', # TODO: works, needs dash_hash 'p2p-acceptblock.py', # NOTE: needs dash_hash to pass
'mempool_packages.py', 'mempool_packages.py',
'maxuploadtarget.py', 'maxuploadtarget.py',
# 'replace-by-fee.py', # RBF is disabled in Dash Core # 'replace-by-fee.py', # RBF is disabled in Dash Core

View File

@ -39,8 +39,7 @@ void CActiveMasternode::ManageState()
if(eType == MASTERNODE_REMOTE) { if(eType == MASTERNODE_REMOTE) {
ManageStateRemote(); ManageStateRemote();
} } else {
else {
ManageStateLocal(); ManageStateLocal();
} }
@ -55,12 +54,12 @@ void CActiveMasternode::ManageState()
std::string CActiveMasternode::GetStatus() std::string CActiveMasternode::GetStatus()
{ {
switch (nState) { 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_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_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_NOT_CAPABLE: return "Not capable masternode: " + strNotCapableReason;
case ACTIVE_MASTERNODE_STARTED: return "Masternode successfully started"; case ACTIVE_MASTERNODE_STARTED: return "Masternode successfully started";
default: return "unknown"; default: return "unknown";
} }
} }
@ -117,22 +116,6 @@ bool CActiveMasternode::SendMasternodePing(std::string& strErrorRet)
return true; 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() void CActiveMasternode::ManageStateInitial()
{ {
LogPrint("masternode", "CActiveMasternode::ManageStateInitial -- Start status = %s, type = %s, pinger enabled = %d\n", GetStatus(), GetType(), fPingerEnabled); 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(); void ManageState();
std::string GetStatus(); std::string GetStatus();
std::string GetType(); std::string GetType();
/// Enable cold wallet mode (run a Masternode with no funds)
bool EnableRemoteMasterNode(CTxIn& vinNew, CService& serviceNew);
private: private:
void ManageStateInitial(); void ManageStateInitial();
void ManageStateRemote(); void ManageStateRemote();
void ManageStateLocal(); void ManageStateLocal();
}; };

View File

@ -96,9 +96,9 @@ public:
}; };
/** base58-encoded Dash addresses. /** 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. * 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. * The data vector contains RIPEMD160(SHA256(cscript)), where cscript is the serialized redemption script.
*/ */
class CBitcoinAddress : public CBase58Data { class CBitcoinAddress : public CBase58Data {

View File

@ -1015,7 +1015,7 @@ bool CDarksendPool::AddEntry(const CDarkSendEntry& entryNew, PoolMessage& nMessa
bool CDarksendPool::AddScriptSig(const CTxIn& txinNew) 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 CDarkSendEntry& entry, vecEntries) {
BOOST_FOREACH(const CTxDSIn& txdsin, entry.vecTxDSIn) { BOOST_FOREACH(const CTxDSIn& txdsin, entry.vecTxDSIn) {
@ -1031,7 +1031,7 @@ bool CDarksendPool::AddScriptSig(const CTxIn& txinNew)
return false; 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) { BOOST_FOREACH(CTxIn& txin, finalMutableTransaction.vin) {
if(txinNew.prevout == txin.prevout && txin.nSequence == txinNew.nSequence) { 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. // 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 // 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; if(fMasterNode) return false;
@ -1265,8 +1265,8 @@ bool CDarksendPool::SignFinalTransaction(const CTransaction& finalTransactionNew
} }
// push all of our signatures to the Masternode // push all of our signatures to the Masternode
if(sigs.size() > 0 && node != NULL) if(!sigs.empty() && pnode != NULL)
node->PushMessage(NetMsgType::DSSIGNFINALTX, sigs); pnode->PushMessage(NetMsgType::DSSIGNFINALTX, sigs);
return true; return true;
} }
@ -1568,13 +1568,13 @@ bool CDarksendPool::DoAutomaticDenominating(bool fDryRun)
std::vector<COutput> vCoinsTmp; std::vector<COutput> vCoinsTmp;
// Try to match their denominations if possible // Try to match their denominations if possible
if(!pwalletMain->SelectCoinsByDenominations(dsq.nDenom, nValueMin, nBalanceNeedsAnonymized, vecTxInTmp, vCoinsTmp, nValueIn, 0, nPrivateSendRounds)) { 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; continue;
} }
CMasternode* pmn = mnodeman.Find(dsq.vin); CMasternode* pmn = mnodeman.Find(dsq.vin);
if(pmn == NULL) { 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; continue;
} }
vecMasternodesUsed.push_back(dsq.vin); vecMasternodesUsed.push_back(dsq.vin);
@ -1588,12 +1588,13 @@ bool CDarksendPool::DoAutomaticDenominating(bool fDryRun)
nSessionDenom = dsq.nDenom; nSessionDenom = dsq.nDenom;
pnode->PushMessage(NetMsgType::DSACCEPT, nSessionDenom, txMyCollateral); 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..."); strAutoDenomResult = _("Mixing in progress...");
dsq.nTime = 0; //remove node dsq.nTime = 0; //remove node
return true; return true;
} else { } else {
LogPrintf("CDarksendPool::DoAutomaticDenominating -- error connecting\n"); LogPrintf("CDarksendPool::DoAutomaticDenominating -- can't connect, addr=%s\n", pmn->addr.ToString());
strAutoDenomResult = _("Error connecting to Masternode."); strAutoDenomResult = _("Error connecting to Masternode.");
dsq.nTime = 0; //remove node dsq.nTime = 0; //remove node
pmn->nPoSeBanScore++; 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()); LogPrintf("CDarksendPool::DoAutomaticDenominating -- attempt %d connection to Masternode %s\n", nTries, pmn->addr.ToString());
CNode* pnode = ConnectNode((CAddress)pmn->addr, NULL, true); CNode* pnode = ConnectNode((CAddress)pmn->addr, NULL, true);
if(pnode) { if(pnode) {
LogPrintf("CDarksendPool::DoAutomaticDenominating -- connected %s\n", pmn->vin.ToString()); LogPrintf("CDarksendPool::DoAutomaticDenominating -- connected, addr=%s\n", pmn->addr.ToString());
pSubmittedToMasternode = pmn; pSubmittedToMasternode = pmn;
std::vector<CAmount> vecAmounts; std::vector<CAmount> vecAmounts;
@ -1642,11 +1643,12 @@ bool CDarksendPool::DoAutomaticDenominating(bool fDryRun)
} }
pnode->PushMessage(NetMsgType::DSACCEPT, nSessionDenom, txMyCollateral); 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..."); strAutoDenomResult = _("Mixing in progress...");
return true; return true;
} else { } 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++; nTries++;
pmn->nPoSeBanScore++; pmn->nPoSeBanScore++;
continue; continue;
@ -2041,7 +2043,8 @@ bool CDarksendPool::IsDenomCompatibleWithSession(int nDenom, CTransaction txColl
return false; 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)) { if(!fUnitTest && !IsCollateralValid(txCollateral)) {
LogPrint("privatesend", "CDarksendPool::IsDenomCompatibleWithSession -- collateral not valid!\n"); LogPrint("privatesend", "CDarksendPool::IsDenomCompatibleWithSession -- collateral not valid!\n");

View File

@ -406,7 +406,7 @@ private:
void SetState(PoolState nStateNew); void SetState(PoolState nStateNew);
/// As a client, check and sign the final transaction /// 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 /// Relay mixing Messages
void RelayFinalTransaction(const CTransaction& txFinal); void RelayFinalTransaction(const CTransaction& txFinal);

View File

@ -1,7 +1,7 @@
// Copyright (c) 2014-2016 The Dash Core developers // Copyright (c) 2014-2016 The Dash Core developers
// Distributed under the MIT/X11 software license, see the accompanying // Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef FLAT_DATABASE_H #ifndef FLAT_DATABASE_H
#define FLAT_DATABASE_H #define FLAT_DATABASE_H
@ -55,14 +55,14 @@ private:
FILE *file = fopen(pathDB.string().c_str(), "wb"); FILE *file = fopen(pathDB.string().c_str(), "wb");
CAutoFile fileout(file, SER_DISK, CLIENT_VERSION); CAutoFile fileout(file, SER_DISK, CLIENT_VERSION);
if (fileout.IsNull()) 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 // Write and commit header, data
try { try {
fileout << ssObj; fileout << ssObj;
} }
catch (std::exception &e) { 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(); fileout.fclose();
@ -82,7 +82,7 @@ private:
CAutoFile filein(file, SER_DISK, CLIENT_VERSION); CAutoFile filein(file, SER_DISK, CLIENT_VERSION);
if (filein.IsNull()) 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; return FileError;
} }
@ -102,7 +102,7 @@ private:
filein >> hashIn; filein >> hashIn;
} }
catch (std::exception &e) { 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; return HashReadError;
} }
filein.fclose(); filein.fclose();
@ -113,7 +113,7 @@ private:
uint256 hashTmp = Hash(ssObj.begin(), ssObj.end()); uint256 hashTmp = Hash(ssObj.begin(), ssObj.end());
if (hashIn != hashTmp) if (hashIn != hashTmp)
{ {
error("%s : Checksum mismatch, data corrupted", __func__); error("%s: Checksum mismatch, data corrupted", __func__);
return IncorrectHash; return IncorrectHash;
} }
@ -127,7 +127,7 @@ private:
// ... verify the message matches predefined one // ... verify the message matches predefined one
if (strMagicMessage != strMagicMessageTmp) if (strMagicMessage != strMagicMessageTmp)
{ {
error("%s : Invalid magic message", __func__); error("%s: Invalid magic message", __func__);
return IncorrectMagicMessage; return IncorrectMagicMessage;
} }
@ -138,7 +138,7 @@ private:
// ... verify the network matches ours // ... verify the network matches ours
if (memcmp(pchMsgTmp, Params().MessageStart(), sizeof(pchMsgTmp))) if (memcmp(pchMsgTmp, Params().MessageStart(), sizeof(pchMsgTmp)))
{ {
error("%s : Invalid network magic number", __func__); error("%s: Invalid network magic number", __func__);
return IncorrectMagicNumber; return IncorrectMagicNumber;
} }
@ -147,16 +147,16 @@ private:
} }
catch (std::exception &e) { catch (std::exception &e) {
objToLoad.Clear(); 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; return IncorrectFormat;
} }
LogPrintf("Loaded info from %s %dms\n", strFilename, GetTimeMillis() - nStart); LogPrintf("Loaded info from %s %dms\n", strFilename, GetTimeMillis() - nStart);
LogPrintf(" %s\n", objToLoad.ToString()); LogPrintf(" %s\n", objToLoad.ToString());
if(!fDryRun) { if(!fDryRun) {
LogPrintf("CFlatDB - cleaning....\n"); LogPrintf("%s: Cleaning....\n", __func__);
objToLoad.CheckAndRemove(); objToLoad.CheckAndRemove();
LogPrintf("CFlatDB - %s\n", objToLoad.ToString()); LogPrintf(" %s\n", objToLoad.ToString());
} }
return Ok; return Ok;
@ -176,16 +176,16 @@ public:
LogPrintf("Reading info from %s...\n", strFilename); LogPrintf("Reading info from %s...\n", strFilename);
ReadResult readResult = Read(objToLoad); ReadResult readResult = Read(objToLoad);
if (readResult == FileError) 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) else if (readResult != Ok)
{ {
LogPrintf("Error reading %s: ", strFilename); LogPrintf("Error reading %s: ", strFilename);
if(readResult == IncorrectFormat) 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 { 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 // program should exit with an error
return false; return false;
} }
@ -197,41 +197,21 @@ public:
{ {
int64_t nStart = GetTimeMillis(); 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); LogPrintf("Verifying %s format...\n", strFilename);
T tmpObjToLoad; T tmpObjToLoad;
ReadResult readResult = Read(tmpObjToLoad, true); ReadResult readResult = Read(tmpObjToLoad, true);
// there was an error and it was not an error on file opening => do not proceed // there was an error and it was not an error on file opening => do not proceed
if (readResult == FileError) 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) else if (readResult != Ok)
{ {
LogPrintf("Error reading %s: ", strFilename); LogPrintf("Error reading %s: ", strFilename);
if(readResult == IncorrectFormat) 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 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; return false;
} }
} }

View File

@ -30,12 +30,7 @@
CGovernanceTriggerManager triggerman; CGovernanceTriggerManager triggerman;
// SPLIT UP STRING BY DELIMITER // SPLIT UP STRING BY DELIMITER
// http://www.boost.org/doc/libs/1_58_0/doc/html/boost/algorithm/split_idp202406848.html
/*
NOTE : SplitBy can be simplified via:
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> SplitBy(std::string strCommand, std::string strDelimit)
{ {
std::vector<std::string> vParts; std::vector<std::string> vParts;
@ -721,7 +716,7 @@ bool CSuperblock::IsValid(const CTransaction& txNew, int nBlockHeight, CAmount b
CTxDestination address1; CTxDestination address1;
ExtractDestination(payment.script, address1); ExtractDestination(payment.script, address1);
CBitcoinAddress address2(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; return false;
} }

View File

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

View File

@ -255,8 +255,8 @@ public:
// Signature related functions // Signature related functions
void SetMasternodeInfo(const CTxIn& vin); void SetMasternodeInfo(const CTxIn& vin);
bool Sign(CKey& keyMasternode, CPubKey& pubkeyMasternode); bool Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode);
bool CheckSignature(CPubKey& pubkeyMasternode); bool CheckSignature(CPubKey& pubKeyMasternode);
// CORE OBJECT FUNCTIONS // 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("-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("-mnconflock=<n>", strprintf(_("Lock masternodes from masternode configuration file (default: %u)"), 1));
strUsage += HelpMessageOpt("-masternodeprivkey=<n>", _("Set the masternode private key")); 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 += HelpMessageGroup(_("PrivateSend options:"));
strUsage += HelpMessageOpt("-enableprivatesend=<n>", strprintf(_("Enable use of automated PrivateSend for funds stored in this wallet (0-1, default: %u)"), 0)); 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); LogPrintf("PrivateSend amount %d\n", nPrivateSendAmount);
darkSendPool.InitDenominations(); darkSendPool.InitDenominations();
mnodeman.InitDummyScriptPubkey();
// ********************************************************* Step 11b: Load cache data // ********************************************************* Step 11b: Load cache data

View File

@ -178,20 +178,20 @@ bool IsInstantSendTxValid(const CTransaction& txCandidate)
int64_t nValueIn = 0; int64_t nValueIn = 0;
int64_t nValueOut = 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; nValueOut += txout.nValue;
} }
BOOST_FOREACH(const CTxIn txin, txCandidate.vin) { BOOST_FOREACH(const CTxIn& txin, txCandidate.vin) {
CTransaction tx2; CTransaction tx2;
uint256 hash; uint256 hash;
if(GetTransaction(txin.prevout.hash, tx2, Params().GetConsensus(), hash, true)) { if(GetTransaction(txin.prevout.hash, tx2, Params().GetConsensus(), hash, true)) {
if(tx2.vout.size() > txin.prevout.n) if(tx2.vout.size() > txin.prevout.n)
nValueIn += tx2.vout[txin.prevout.n].nValue; nValueIn += tx2.vout[txin.prevout.n].nValue;
} else { } else {
missingTx = true; fMissingInputs = true;
} }
} }
@ -200,8 +200,8 @@ bool IsInstantSendTxValid(const CTransaction& txCandidate)
return false; return false;
} }
if(missingTx) { if(fMissingInputs) {
LogPrint("instantsend", "IsInstantSendTxValid -- Unknown inputs in IX transaction: txCandidate=%s", txCandidate.ToString()); 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. 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 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); int n = mnodeman.GetMasternodeRank(activeMasternode.vin, nBlockHeight, MIN_INSTANTSEND_PROTO_VERSION);
if(n == -1) { 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; return;
} }
@ -324,9 +324,11 @@ bool ProcessConsensusVote(CNode* pnode, CConsensusVote& vote)
mnodeman.AskForMN(pnode, vote.vinMasternode); mnodeman.AskForMN(pnode, vote.vinMasternode);
return false; return false;
} }
LogPrint("instantsend", "ProcessConsensusVote -- Masternode %s, rank=%d\n", vote.vinMasternode.prevout.ToStringShort(), n);
if(n > INSTANTSEND_SIGNATURES_TOTAL) { 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; return false;
} }
@ -435,7 +437,7 @@ bool FindConflictingLocks(CTransaction& tx)
BOOST_FOREACH(const CTxIn& txin, tx.vin) { BOOST_FOREACH(const CTxIn& txin, tx.vin) {
if(mapLockedInputs.count(txin.prevout)) { if(mapLockedInputs.count(txin.prevout)) {
if(mapLockedInputs[txin.prevout] != tx.GetHash()) { 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())) if(mapTxLocks.count(tx.GetHash()))
mapTxLocks[tx.GetHash()].nLockExpirationBlock = -1; mapTxLocks[tx.GetHash()].nLockExpirationBlock = -1;
@ -455,7 +457,7 @@ void ResolveConflicts(CTransaction& tx)
{ {
// resolve conflicts // resolve conflicts
if (IsLockedInstandSendTransaction(tx.GetHash()) && !FindConflictingLocks(tx)) { //????? 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 //reprocess the last nInstantSendReprocessBlocks blocks
ReprocessBlocks(Params().GetConsensus().nInstantSendReprocessBlocks); ReprocessBlocks(Params().GetConsensus().nInstantSendReprocessBlocks);
@ -553,7 +555,6 @@ bool CConsensusVote::CheckSignature()
{ {
std::string strError; std::string strError;
std::string strMessage = txHash.ToString().c_str() + boost::lexical_cast<std::string>(nBlockHeight); std::string strMessage = txHash.ToString().c_str() + boost::lexical_cast<std::string>(nBlockHeight);
//LogPrintf("verify strMessage %s \n", strMessage);
CMasternode* pmn = mnodeman.Find(vinMasternode); CMasternode* pmn = mnodeman.Find(vinMasternode);

View File

@ -953,10 +953,10 @@ int GetInputAge(CTxIn& txin)
if (coins) { if (coins) {
if(coins->nHeight < 0) return 0; if(coins->nHeight < 0) return 0;
return (chainActive.Tip()->nHeight + 1) - coins->nHeight; return chainActive.Height() - coins->nHeight + 1;
} } else {
else
return -1; return -1;
}
} }
} }
@ -1089,13 +1089,11 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState &state, const C
// ----------- InstantSend transaction scanning ----------- // ----------- InstantSend transaction scanning -----------
BOOST_FOREACH(const CTxIn& in, tx.vin){ BOOST_FOREACH(const CTxIn& txin, tx.vin) {
if(mapLockedInputs.count(in.prevout)){ if(mapLockedInputs.count(txin.prevout) && mapLockedInputs[txin.prevout] != tx.GetHash()) {
if(mapLockedInputs[in.prevout] != tx.GetHash()){ return state.DoS(0,
return state.DoS(0, error("AcceptToMemoryPool : conflicts with existing transaction lock: %s", reason),
error("AcceptToMemoryPool : conflicts with existing transaction lock: %s", reason), REJECT_INVALID, "tx-lock-conflict");
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 // DASH : CHECK TRANSACTIONS FOR INSTANT SEND
if(sporkManager.IsSporkActive(SPORK_3_INSTANTSEND_BLOCK_FILTERING)) { if(sporkManager.IsSporkActive(SPORK_3_INSTANTSEND_BLOCK_FILTERING)) {
BOOST_FOREACH(const CTransaction& tx, block.vtx){ BOOST_FOREACH(const CTransaction& tx, block.vtx) {
if (!tx.IsCoinBase()){ // skip coinbase, it has no inputs
// LOOK FOR TRANSACTION LOCK IN OUR MAP OF INPUTS if (tx.IsCoinBase()) continue;
BOOST_FOREACH(const CTxIn& in, tx.vin){ // LOOK FOR TRANSACTION LOCK IN OUR MAP OF INPUTS
if(mapLockedInputs.count(in.prevout)){ BOOST_FOREACH(const CTxIn& txin, tx.vin) {
if(mapLockedInputs[in.prevout] != tx.GetHash()){ if(mapLockedInputs.count(txin.prevout) && mapLockedInputs[txin.prevout] != tx.GetHash()) {
mapRejectedBlocks.insert(make_pair(block.GetHash(), GetTime())); 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()); 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"), return state.DoS(0, error("CheckBlock(DASH): found conflicting transaction with transaction lock"),
REJECT_INVALID, "conflicting-tx-ix"); REJECT_INVALID, "conflicting-tx-ix");
}
}
} }
} }
} }
@ -5181,12 +5177,12 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
{ {
if(governance.HaveObjectForHash(inv.hash)) { if(governance.HaveObjectForHash(inv.hash)) {
ss.reserve(1000); ss.reserve(1000);
if(governance.SerializeObjectForHash(inv.hash, ss)) { if(governance.SerializeObjectForHash(inv.hash, ss)) {
topush = true; topush = true;
} }
} }
} }
if(topush) { if(topush) {
pfrom->PushMessage(NetMsgType::MNGOVERNANCEOBJECT, ss); pfrom->PushMessage(NetMsgType::MNGOVERNANCEOBJECT, ss);
pushed = true; pushed = true;
} }
@ -5198,12 +5194,12 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
{ {
if(governance.HaveVoteForHash(inv.hash)) { if(governance.HaveVoteForHash(inv.hash)) {
ss.reserve(1000); ss.reserve(1000);
if(governance.SerializeVoteForHash(inv.hash, ss)) { if(governance.SerializeVoteForHash(inv.hash, ss)) {
topush = true; topush = true;
} }
} }
} }
if(topush) { if(topush) {
pfrom->PushMessage(NetMsgType::MNGOVERNANCEOBJECTVOTE, ss); pfrom->PushMessage(NetMsgType::MNGOVERNANCEOBJECTVOTE, ss);
pushed = true; pushed = true;
} }
@ -5718,13 +5714,13 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
{ {
if(!pmn->fAllowMixingTx) { if(!pmn->fAllowMixingTx) {
//multiple peers can send us a valid masternode transaction //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; return true;
} }
if(!dstx.CheckSignature()) return false; 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; 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); LogPrint("mnpayments", "CMasternodePayments::UpdatedBlockTip -- pCurrentBlockIndex->nHeight=%d\n", pCurrentBlockIndex->nHeight);
ProcessBlock(pindex->nHeight + 10); 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() bool CMasternodeSync::IsBlockchainSynced()
{ {
static bool fBlockchainSynced = false; 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 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(); Reset();
fBlockchainSynced = false; fBlockchainSynced = false;
} }
lastProcess = GetTime(); nTimeLastProcess = GetTime();
if(fBlockchainSynced) return true; if(fBlockchainSynced) return true;
if(!pCurrentBlockIndex || !pindexBestHeader || fImporting || fReindex) return false; if(!pCurrentBlockIndex || !pindexBestHeader || fImporting || fReindex) return false;
@ -143,7 +143,7 @@ void CMasternodeSync::ProcessMessage(CNode* pfrom, std::string& strCommand, CDat
int nCount; int nCount;
vRecv >> nItemID >> 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 //the actual count of masternodes we have currently
int nMnCount = mnodeman.CountMasternodes(); 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 // 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 Resync if we lose all masternodes from sleep/wake or failure to sync originally
*/ */
if(nMnCount == 0) { if(nMnCount == 0) {
LogPrintf("CMasternodeSync::ProcessTick -- WARNING: not enough data, restarting sync\n");
Reset(); Reset();
} else { } else {
//if syncing is complete and we have masternodes, return //if syncing is complete and we have masternodes, return
@ -198,12 +199,16 @@ void CMasternodeSync::ProcessTick()
// INITIAL SYNC SETUP / LOG REPORTING // INITIAL SYNC SETUP / LOG REPORTING
double nSyncProgress = double(nRequestedMasternodeAttempt + (nRequestedMasternodeAssets - 1) * 8) / (8*4); 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); uiInterface.NotifyAdditionalDataSyncProgressChanged(nSyncProgress);
// sporks synced but blockchain is not, wait until we're almost at a recent block to continue // sporks synced but blockchain is not, wait until we're almost at a recent block to continue
if(Params().NetworkIDString() != CBaseChainParams::REGTEST && 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); TRY_LOCK(cs_vNodes, lockRecv);
if(!lockRecv) return; if(!lockRecv) return;
@ -241,7 +246,7 @@ void CMasternodeSync::ProcessTick()
// we already fully synced from this node recently, // we already fully synced from this node recently,
// disconnect to free this connection slot for a new node // disconnect to free this connection slot for a new node
pnode->fDisconnect = true; 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; continue;
} }
@ -252,17 +257,19 @@ void CMasternodeSync::ProcessTick()
netfulfilledman.AddFulfilledRequest(pnode->addr, "spork-sync"); netfulfilledman.AddFulfilledRequest(pnode->addr, "spork-sync");
// get current network sporks // get current network sporks
pnode->PushMessage(NetMsgType::GETSPORKS); 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 continue; // always get sporks first, switch to the next node without waiting for the next tick
} }
// MNLIST : SYNC MASTERNODE LIST FROM OTHER CONNECTED CLIENTS // MNLIST : SYNC MASTERNODE LIST FROM OTHER CONNECTED CLIENTS
if(nRequestedMasternodeAssets == MASTERNODE_SYNC_LIST) { 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 // check for timeout first
if(nTimeLastMasternodeList < GetTime() - MASTERNODE_SYNC_TIMEOUT_SECONDS) { 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) { 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 // there is no way we can continue without masternode list, fail here and try later
Fail(); Fail();
return; return;
@ -276,9 +283,10 @@ void CMasternodeSync::ProcessTick()
/* Note: Is this activing up? It's probably related to int CMasternodeMan::GetEstimatedMasternodes(int nBlock) /* Note: Is this activing up? It's probably related to int CMasternodeMan::GetEstimatedMasternodes(int nBlock)
Surely doesn't work right for testnet currently */ Surely doesn't work right for testnet currently */
// try to fetch data from at least two peers though // try to fetch data from at least two peers though
LogPrintf("CMasternodeSync::ProcessTick -- nTick %d nMnCount %d, Estimated masternode count required: %d\n", int nMnCountEstimated = mnodeman.GetEstimatedMasternodes(pCurrentBlockIndex->nHeight)*0.9;
nTick, nMnCount, mnodeman.GetEstimatedMasternodes(pCurrentBlockIndex->nHeight)*0.9); LogPrintf("CMasternodeSync::ProcessTick -- nTick %d nMnCount %d nMnCountEstimated %d\n",
if(nRequestedMasternodeAttempt > 1 && nMnCount > mnodeman.GetEstimatedMasternodes(pCurrentBlockIndex->nHeight)*0.9) { nTick, nMnCount, nMnCountEstimated);
if(nRequestedMasternodeAttempt > 1 && nMnCount > nMnCountEstimated) {
LogPrintf("CMasternodeSync::ProcessTick -- nTick %d nRequestedMasternodeAssets %d -- found enough data\n", nTick, nRequestedMasternodeAssets); LogPrintf("CMasternodeSync::ProcessTick -- nTick %d nRequestedMasternodeAssets %d -- found enough data\n", nTick, nRequestedMasternodeAssets);
SwitchToNextAsset(); SwitchToNextAsset();
return; return;
@ -299,13 +307,14 @@ void CMasternodeSync::ProcessTick()
// MNW : SYNC MASTERNODE PAYMENT VOTES FROM OTHER CONNECTED CLIENTS // MNW : SYNC MASTERNODE PAYMENT VOTES FROM OTHER CONNECTED CLIENTS
if(nRequestedMasternodeAssets == MASTERNODE_SYNC_MNW) { 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 // check for timeout first
// This might take a lot longer than MASTERNODE_SYNC_TIMEOUT_SECONDS minutes due to new blocks, // 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. // but that should be OK and it should timeout eventually.
if(nTimeLastPaymentVote < GetTime() - MASTERNODE_SYNC_TIMEOUT_SECONDS) { 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) { 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 // probably not a good idea to proceed without winner list
Fail(); Fail();
return; return;
@ -318,7 +327,7 @@ void CMasternodeSync::ProcessTick()
// if mnpayments already has enough blocks and votes, switch to the next asset // if mnpayments already has enough blocks and votes, switch to the next asset
// try to fetch data from at least two peers though // try to fetch data from at least two peers though
if(nRequestedMasternodeAttempt > 1 && mnpayments.IsEnoughData()) { 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(); SwitchToNextAsset();
return; return;
} }
@ -341,11 +350,13 @@ void CMasternodeSync::ProcessTick()
// GOVOBJ : SYNC GOVERNANCE ITEMS FROM OUR PEERS // GOVOBJ : SYNC GOVERNANCE ITEMS FROM OUR PEERS
if(nRequestedMasternodeAssets == MASTERNODE_SYNC_GOVERNANCE) { 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 // check for timeout first
if(nTimeLastBudgetItem < GetTime() - MASTERNODE_SYNC_TIMEOUT_SECONDS){ 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) { 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? // it's kind of ok to skip this for now, hopefully we'll catch up later?
} }
SwitchToNextAsset(); SwitchToNextAsset();

View File

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

View File

@ -55,9 +55,8 @@ bool CMasternodeMan::Add(CMasternode &mn)
return false; return false;
CMasternode *pmn = Find(mn.vin); CMasternode *pmn = Find(mn.vin);
if (pmn == NULL) if (pmn == NULL) {
{ LogPrint("masternode", "CMasternodeMan::Add -- Adding new Masternode: addr=%s, %i now\n", mn.addr.ToString(), size() + 1);
LogPrint("masternode", "CMasternodeMan: Adding new Masternode %s - %i now\n", mn.addr.ToString(), size() + 1);
vMasternodes.push_back(mn); vMasternodes.push_back(mn);
return true; return true;
} }
@ -67,19 +66,19 @@ bool CMasternodeMan::Add(CMasternode &mn)
void CMasternodeMan::AskForMN(CNode* pnode, CTxIn &vin) void CMasternodeMan::AskForMN(CNode* pnode, CTxIn &vin)
{ {
std::map<COutPoint, int64_t>::iterator i = mWeAskedForMasternodeListEntry.find(vin.prevout); if(!pnode) return;
if (i != mWeAskedForMasternodeListEntry.end())
{ std::map<COutPoint, int64_t>::iterator it = mWeAskedForMasternodeListEntry.find(vin.prevout);
int64_t t = (*i).second; if (it != mWeAskedForMasternodeListEntry.end() && GetTime() < (*it).second) {
if (GetTime() < t) return; // we've asked recently // 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 // 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); pnode->PushMessage(NetMsgType::DSEG, vin);
int64_t askAgain = GetTime() + MASTERNODE_MIN_MNP_SECONDS; mWeAskedForMasternodeListEntry[vin.prevout] = GetTime() + DSEG_UPDATE_SECONDS;;
mWeAskedForMasternodeListEntry[vin.prevout] = askAgain;
} }
void CMasternodeMan::Check() void CMasternodeMan::Check()
@ -127,7 +126,7 @@ void CMasternodeMan::CheckAndRemove(bool fForceExpiredRemoval)
} }
// check who's asked for the Masternode list // 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()){ while(it1 != mAskedUsForMasternodeList.end()){
if((*it1).second < GetTime()) { if((*it1).second < GetTime()) {
mAskedUsForMasternodeList.erase(it1++); mAskedUsForMasternodeList.erase(it1++);
@ -147,7 +146,7 @@ void CMasternodeMan::CheckAndRemove(bool fForceExpiredRemoval)
} }
// check which Masternodes we've asked for // 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()){ while(it2 != mWeAskedForMasternodeListEntry.end()){
if((*it2).second < GetTime()){ if((*it2).second < GetTime()){
mWeAskedForMasternodeListEntry.erase(it2++); mWeAskedForMasternodeListEntry.erase(it2++);
@ -166,10 +165,10 @@ void CMasternodeMan::CheckAndRemove(bool fForceExpiredRemoval)
} }
// remove expired mapSeenMasternodeBroadcast // remove expired mapSeenMasternodeBroadcast
map<uint256, CMasternodeBroadcast>::iterator it3 = mapSeenMasternodeBroadcast.begin(); std::map<uint256, CMasternodeBroadcast>::iterator it3 = mapSeenMasternodeBroadcast.begin();
while(it3 != mapSeenMasternodeBroadcast.end()){ while(it3 != mapSeenMasternodeBroadcast.end()){
if((*it3).second.lastPing.sigTime < GetTime() - MASTERNODE_REMOVAL_SECONDS*2){ 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++); mapSeenMasternodeBroadcast.erase(it3++);
} else { } else {
++it3; ++it3;
@ -177,10 +176,10 @@ void CMasternodeMan::CheckAndRemove(bool fForceExpiredRemoval)
} }
// remove expired mapSeenMasternodePing // remove expired mapSeenMasternodePing
map<uint256, CMasternodePing>::iterator it4 = mapSeenMasternodePing.begin(); std::map<uint256, CMasternodePing>::iterator it4 = mapSeenMasternodePing.begin();
while(it4 != mapSeenMasternodePing.end()){ while(it4 != mapSeenMasternodePing.end()){
if((*it4).second.sigTime < GetTime() - MASTERNODE_REMOVAL_SECONDS*2){ 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++); mapSeenMasternodePing.erase(it4++);
} else { } else {
++it4; ++it4;
@ -197,6 +196,8 @@ void CMasternodeMan::CheckAndRemove(bool fForceExpiredRemoval)
++itv2; ++itv2;
} }
} }
LogPrintf("CMasternodeMan::CheckAndRemove -- %s\n", ToString());
} }
void CMasternodeMan::Clear() void CMasternodeMan::Clear()
@ -212,42 +213,43 @@ void CMasternodeMan::Clear()
nLastWatchdogVoteTime = 0; nLastWatchdogVoteTime = 0;
} }
int CMasternodeMan::CountMasternodes(int protocolVersion) int CMasternodeMan::CountMasternodes(int nProtocolVersion)
{ {
LOCK(cs); LOCK(cs);
int i = 0; int nCount = 0;
protocolVersion = protocolVersion == -1 ? mnpayments.GetMinMasternodePaymentsProto() : protocolVersion; nProtocolVersion = nProtocolVersion == -1 ? mnpayments.GetMinMasternodePaymentsProto() : nProtocolVersion;
BOOST_FOREACH(CMasternode& mn, vMasternodes) { BOOST_FOREACH(CMasternode& mn, vMasternodes) {
if(mn.nProtocolVersion < protocolVersion) continue; if(mn.nProtocolVersion < nProtocolVersion) continue;
i++; nCount++;
} }
return i; return nCount;
} }
int CMasternodeMan::CountEnabled(int protocolVersion) int CMasternodeMan::CountEnabled(int nProtocolVersion)
{ {
LOCK(cs); LOCK(cs);
int i = 0; int nCount = 0;
protocolVersion = protocolVersion == -1 ? mnpayments.GetMinMasternodePaymentsProto() : protocolVersion; nProtocolVersion = nProtocolVersion == -1 ? mnpayments.GetMinMasternodePaymentsProto() : nProtocolVersion;
BOOST_FOREACH(CMasternode& mn, vMasternodes) { BOOST_FOREACH(CMasternode& mn, vMasternodes) {
mn.Check(); mn.Check();
if(mn.nProtocolVersion < protocolVersion || !mn.IsEnabled()) continue; if(mn.nProtocolVersion < nProtocolVersion || !mn.IsEnabled()) continue;
i++; nCount++;
} }
return i; return nCount;
} }
/* Only IPv4 masternodes are allowed in 12.1, saving this for later
int CMasternodeMan::CountByIP(int nNetworkType) int CMasternodeMan::CountByIP(int nNetworkType)
{ {
LOCK(cs); LOCK(cs);
int nNodeCount = 0; int nNodeCount = 0;
BOOST_FOREACH(CMasternode& mn, vMasternodes) 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_TOR && mn.addr.IsTor()) ||
(nNetworkType == NET_IPV6 && mn.addr.IsIPv6())) { (nNetworkType == NET_IPV6 && mn.addr.IsIPv6())) {
nNodeCount++; nNodeCount++;
@ -255,20 +257,18 @@ int CMasternodeMan::CountByIP(int nNetworkType)
return nNodeCount; return nNodeCount;
} }
*/
void CMasternodeMan::DsegUpdate(CNode* pnode) void CMasternodeMan::DsegUpdate(CNode* pnode)
{ {
LOCK(cs); LOCK(cs);
if(Params().NetworkIDString() == CBaseChainParams::MAIN) { 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); std::map<CNetAddr, int64_t>::iterator it = mWeAskedForMasternodeList.find(pnode->addr);
if (it != mWeAskedForMasternodeList.end()) if(it != mWeAskedForMasternodeList.end() && GetTime() < (*it).second) {
{ LogPrintf("CMasternodeMan::DsegUpdate -- we already asked %s for the list; skipping...\n", pnode->addr.ToString());
if (GetTime() < (*it).second) { return;
LogPrintf("dseg - 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()); pnode->PushMessage(NetMsgType::DSEG, CTxIn());
int64_t askAgain = GetTime() + DSEG_UPDATE_SECONDS; int64_t askAgain = GetTime() + DSEG_UPDATE_SECONDS;
mWeAskedForMasternodeList[pnode->addr] = askAgain; 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); LOCK(cs);
@ -290,7 +292,7 @@ CMasternode *CMasternodeMan::Find(const CScript &payee)
return NULL; return NULL;
} }
CMasternode *CMasternodeMan::Find(const CTxIn &vin) CMasternode* CMasternodeMan::Find(const CTxIn &vin)
{ {
LOCK(cs); LOCK(cs);
@ -369,7 +371,7 @@ bool CMasternodeMan::Has(const CTxIn& vin)
return (pMN != NULL); return (pMN != NULL);
} }
// //
// Deterministically select the oldest/best masternode to pay on the network // Deterministically select the oldest/best masternode to pay on the network
// //
CMasternode* CMasternodeMan::GetNextMasternodeInQueueForPayment(int nBlockHeight, bool fFilterSigTime, int& nCount) 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 //it's too new, wait for a cycle
if(fFilterSigTime && mn.sigTime + (nMnCount*2.6*60) > GetAdjustedTime()) continue; 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; if(mn.GetCollateralAge() < nMnCount) continue;
vecMasternodeLastPaid.push_back(std::make_pair(mn.GetLastPaidBlock(), &mn)); vecMasternodeLastPaid.push_back(std::make_pair(mn.GetLastPaidBlock(), &mn));
@ -436,7 +438,7 @@ CMasternode* CMasternodeMan::GetNextMasternodeInQueueForPayment(int nBlockHeight
return pBestMasternode; return pBestMasternode;
} }
CMasternode *CMasternodeMan::FindRandomNotInVec(std::vector<CTxIn> &vecToExclude, int nProtocolVersion) CMasternode* CMasternodeMan::FindRandomNotInVec(const std::vector<CTxIn> &vecToExclude, int nProtocolVersion)
{ {
LOCK(cs); LOCK(cs);
@ -445,7 +447,7 @@ CMasternode *CMasternodeMan::FindRandomNotInVec(std::vector<CTxIn> &vecToExclude
int nCountEnabled = CountEnabled(nProtocolVersion); int nCountEnabled = CountEnabled(nProtocolVersion);
int nCountNotExcluded = nCountEnabled - vecToExclude.size(); 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; if(nCountNotExcluded < 1) return NULL;
// fill a vector of pointers // fill a vector of pointers
@ -462,7 +464,7 @@ CMasternode *CMasternodeMan::FindRandomNotInVec(std::vector<CTxIn> &vecToExclude
BOOST_FOREACH(CMasternode* pmn, vpMasternodesShuffled) { BOOST_FOREACH(CMasternode* pmn, vpMasternodesShuffled) {
if(pmn->nProtocolVersion < nProtocolVersion || !pmn->IsEnabled()) continue; if(pmn->nProtocolVersion < nProtocolVersion || !pmn->IsEnabled()) continue;
fExclude = false; fExclude = false;
BOOST_FOREACH(CTxIn &txinToExclude, vecToExclude) { BOOST_FOREACH(const CTxIn &txinToExclude, vecToExclude) {
if(pmn->vin.prevout == txinToExclude.prevout) { if(pmn->vin.prevout == txinToExclude.prevout) {
fExclude = true; fExclude = true;
break; break;
@ -478,7 +480,7 @@ CMasternode *CMasternodeMan::FindRandomNotInVec(std::vector<CTxIn> &vecToExclude
return NULL; 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; 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 // scan for winner
BOOST_FOREACH(CMasternode& mn, vMasternodes) { BOOST_FOREACH(CMasternode& mn, vMasternodes) {
if(mn.nProtocolVersion < minProtocol) continue; if(mn.nProtocolVersion < nMinProtocol) continue;
if(fOnlyActive) { if(fOnlyActive) {
mn.Check(); mn.Check();
if(!mn.IsEnabled()) continue; if(!mn.IsEnabled()) continue;
@ -511,7 +513,7 @@ int CMasternodeMan::GetMasternodeRank(const CTxIn& vin, int64_t nBlockHeight, in
return -1; 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<int64_t, CMasternode*> > vecMasternodeScores;
std::vector<std::pair<int, CMasternode> > vecMasternodeRanks; std::vector<std::pair<int, CMasternode> > vecMasternodeRanks;
@ -527,7 +529,7 @@ std::vector<pair<int, CMasternode> > CMasternodeMan::GetMasternodeRanks(int64_t
mn.Check(); mn.Check();
if(mn.nProtocolVersion < minProtocol || !mn.IsEnabled()) continue; if(mn.nProtocolVersion < nMinProtocol || !mn.IsEnabled()) continue;
int64_t nScore = mn.CalculateScore(blockHash).GetCompact(false); int64_t nScore = mn.CalculateScore(blockHash).GetCompact(false);
@ -545,7 +547,7 @@ std::vector<pair<int, CMasternode> > CMasternodeMan::GetMasternodeRanks(int64_t
return vecMasternodeRanks; 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; std::vector<std::pair<int64_t, CMasternode*> > vecMasternodeScores;
@ -560,7 +562,7 @@ CMasternode* CMasternodeMan::GetMasternodeByRank(int nRank, int64_t nBlockHeight
// Fill scores // Fill scores
BOOST_FOREACH(CMasternode& mn, vMasternodes) { BOOST_FOREACH(CMasternode& mn, vMasternodes) {
if(mn.nProtocolVersion < minProtocol) continue; if(mn.nProtocolVersion < nMinProtocol) continue;
if(fOnlyActive) { if(fOnlyActive) {
mn.Check(); mn.Check();
if(!mn.IsEnabled()) continue; if(!mn.IsEnabled()) continue;
@ -584,22 +586,6 @@ CMasternode* CMasternodeMan::GetMasternodeByRank(int nRank, int64_t nBlockHeight
return NULL; 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() void CMasternodeMan::ProcessMasternodeConnections()
{ {
//we don't care about this for regtest //we don't care about this for regtest
@ -609,7 +595,7 @@ void CMasternodeMan::ProcessMasternodeConnections()
BOOST_FOREACH(CNode* pnode, vNodes) { BOOST_FOREACH(CNode* pnode, vNodes) {
if(pnode->fMasternode) { if(pnode->fMasternode) {
if(darkSendPool.pSubmittedToMasternode != NULL && pnode->addr == darkSendPool.pSubmittedToMasternode->addr) continue; 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; pnode->fDisconnect = true;
} }
} }
@ -617,13 +603,13 @@ void CMasternodeMan::ProcessMasternodeConnections()
void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CDataStream& vRecv) void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CDataStream& vRecv)
{ {
if(fLiteMode) return; // disable all Dash specific functionality
if(fLiteMode) return; //disable all Darksend/Masternode related functionality
if(!masternodeSync.IsBlockchainSynced()) return; if(!masternodeSync.IsBlockchainSynced()) return;
LOCK(cs); LOCK(cs);
if (strCommand == NetMsgType::MNANNOUNCE) { //Masternode Broadcast if (strCommand == NetMsgType::MNANNOUNCE) { //Masternode Broadcast
CMasternodeBroadcast mnb; CMasternodeBroadcast mnb;
vRecv >> mnb; vRecv >> mnb;
@ -632,8 +618,8 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
if (CheckMnbAndUpdateMasternodeList(mnb, nDos)) { if (CheckMnbAndUpdateMasternodeList(mnb, nDos)) {
// use announced Masternode as a peer // use announced Masternode as a peer
addrman.Add(CAddress(mnb.addr), pfrom->addr, 2*60*60); addrman.Add(CAddress(mnb.addr), pfrom->addr, 2*60*60);
} else { } else if(nDos > 0) {
if(nDos > 0) Misbehaving(pfrom->GetId(), nDos); Misbehaving(pfrom->GetId(), nDos);
} }
} else if (strCommand == NetMsgType::MNPING) { //Masternode Ping } else if (strCommand == NetMsgType::MNPING) { //Masternode Ping
@ -644,12 +630,12 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
CMasternodePing mnp; CMasternodePing mnp;
vRecv >> 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 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; int nDos = 0;
if(mnp.CheckAndUpdate(nDos, false)) return; if(mnp.CheckAndUpdate(nDos, false)) return;
@ -678,7 +664,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
CTxIn vin; CTxIn vin;
vRecv >> 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 if(vin == CTxIn()) { //only should ask for this once
//local network //local network
@ -690,7 +676,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
int64_t t = (*i).second; int64_t t = (*i).second;
if (GetTime() < t) { if (GetTime() < t) {
Misbehaving(pfrom->GetId(), 34); 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; 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.addr.IsRFC1918() || mn.addr.IsLocal()) continue; // do not send local network masternode
if (!mn.IsEnabled()) continue; 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); CMasternodeBroadcast mnb = CMasternodeBroadcast(mn);
uint256 hash = mnb.GetHash(); uint256 hash = mnb.GetHash();
pfrom->PushInventory(CInv(MSG_MASTERNODE_ANNOUNCE, hash)); pfrom->PushInventory(CInv(MSG_MASTERNODE_ANNOUNCE, hash));
@ -717,18 +703,18 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
} }
if (vin == mn.vin) { 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; return;
} }
} }
if(vin == CTxIn()) { if(vin == CTxIn()) {
pfrom->PushMessage(NetMsgType::SYNCSTATUSCOUNT, MASTERNODE_SYNC_LIST, nInvCount); 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; return;
} }
// smth weird happen - someone asked us for vin we have no idea about? // 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 } 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() void CMasternodeMan::DoFullVerificationStep()
{ {
if(activeMasternode.vin == CTxIn()) return; if(activeMasternode.vin == CTxIn()) return;
@ -817,6 +805,11 @@ void CMasternodeMan::DoFullVerificationStep()
LogPrint("masternode", "CMasternodeMan::DoFullVerificationStep -- Sent verification requests to %d masternodes\n", nCount); 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() void CMasternodeMan::CheckSameAddr()
{ {
if(!masternodeSync.IsSynced() || vMasternodes.empty()) return; if(!masternodeSync.IsSynced() || vMasternodes.empty()) return;
@ -1150,10 +1143,10 @@ void CMasternodeMan::Remove(CTxIn vin)
{ {
LOCK(cs); LOCK(cs);
vector<CMasternode>::iterator it = vMasternodes.begin(); std::vector<CMasternode>::iterator it = vMasternodes.begin();
while(it != vMasternodes.end()){ while(it != vMasternodes.end()) {
if((*it).vin == vin){ if((*it).vin == vin) {
LogPrint("masternode", "CMasternodeMan: Removing Masternode %s - %i now\n", (*it).addr.ToString(), size() - 1); LogPrint("masternode", "CMasternodeMan::Remove -- Removing Masternode: %s addr=%s, %i now\n", vin.prevout.ToStringShort(), (*it).addr.ToString(), size() - 1);
vMasternodes.erase(it); vMasternodes.erase(it);
break; break;
} }
@ -1178,35 +1171,34 @@ int CMasternodeMan::GetEstimatedMasternodes(int nBlock)
{ {
/* /*
Masternodes = (Coins/1000)*X on average Masternodes = (Coins/1000)*X on average
*X = nPercentage, starting at 0.52 *X = nPercentage, starting at 0.52
nPercentage goes up 0.01 each period nPercentage goes up 0.01 each period
Period starts at 35040, which has exponential slowing growth Period starts at 35040, which has exponential slowing growth
*/ */
int nPercentage = 52; //0.52 int nPercentage = 52; //0.52
int nPeriod = 35040; int nPeriod = 35040;
int nCollateral = 1000; int nCollateral = 1000;
for(int i = nPeriod; i <= nBlock; i += nPeriod) for (int i = nPeriod; i <= nBlock; i += nPeriod) {
{
nPercentage++; nPercentage++;
nPeriod*=2; nPeriod*=2;
} }
return (GetTotalCoinEstimate(nBlock)/100*nPercentage/nCollateral); return (GetTotalCoinEstimate(nBlock)/100*nPercentage/nCollateral);
} }
void CMasternodeMan::UpdateMasternodeList(CMasternodeBroadcast mnb) { void CMasternodeMan::UpdateMasternodeList(CMasternodeBroadcast mnb)
{
LOCK(cs); LOCK(cs);
mapSeenMasternodePing.insert(make_pair(mnb.lastPing.GetHash(), mnb.lastPing)); mapSeenMasternodePing.insert(std::make_pair(mnb.lastPing.GetHash(), mnb.lastPing));
mapSeenMasternodeBroadcast.insert(make_pair(mnb.GetHash(), mnb)); 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); CMasternode* pmn = Find(mnb.vin);
if(pmn == NULL) if(pmn == NULL) {
{
CMasternode mn(mnb); CMasternode mn(mnb);
if(Add(mn)) { if(Add(mn)) {
masternodeSync.AddedMasternodeList(); masternodeSync.AddedMasternodeList();

View File

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

View File

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

View File

@ -43,7 +43,6 @@ const char *GETSPORKS="getsporks";
const char *MASTERNODEPAYMENTVOTE="mnw"; const char *MASTERNODEPAYMENTVOTE="mnw";
const char *MASTERNODEPAYMENTBLOCK="mnwb"; const char *MASTERNODEPAYMENTBLOCK="mnwb";
const char *MASTERNODEPAYMENTSYNC="mnget"; const char *MASTERNODEPAYMENTSYNC="mnget";
const char *MNSCANERROR="mn scan error"; // not implemented
const char *MNBUDGETSYNC="mnvs"; // depreciated since 12.1 const char *MNBUDGETSYNC="mnvs"; // depreciated since 12.1
const char *MNBUDGETVOTE="mvote"; // depreciated since 12.1 const char *MNBUDGETVOTE="mvote"; // depreciated since 12.1
const char *MNBUDGETPROPOSAL="mprop"; // 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 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(MIN_PRIVATESEND_PEER_PROTO_VERSION)))
.arg(QString::number((int)mnodeman.CountEnabled())) .arg(QString::number((int)mnodeman.CountEnabled()));
.arg(QString::number((int)mnodeman.CountByIP(NET_IPV4))) // .arg(QString::number((int)mnodeman.CountByIP(NET_IPV4)))
.arg(QString::number((int)mnodeman.CountByIP(NET_IPV6))) // .arg(QString::number((int)mnodeman.CountByIP(NET_IPV6)))
.arg(QString::number((int)mnodeman.CountByIP(NET_TOR))); // .arg(QString::number((int)mnodeman.CountByIP(NET_TOR)));
} }
int ClientModel::getNumBlocks() const int ClientModel::getNumBlocks() const

View File

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

View File

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