From d6816f09bc36b9247615b8a13c0ef6b97b2c9202 Mon Sep 17 00:00:00 2001 From: Evan Duffield Date: Fri, 19 Sep 2014 13:52:41 -0700 Subject: [PATCH] cleared up masternode status messages --- src/darksend.cpp | 10 +++++++--- src/darksend.h | 2 +- src/main.cpp | 35 +++++++++++++---------------------- src/main.h | 5 +++++ 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/darksend.cpp b/src/darksend.cpp index ab168f6a65..649e4811be 100644 --- a/src/darksend.cpp +++ b/src/darksend.cpp @@ -192,7 +192,7 @@ void CDarkSendPool::Check() LogPrintf("CDarkSendPool::Check() -- COMPLETED -- RESETTING \n"); SetNull(true); UnlockCoins(); - if(fMasterNode) RelayDarkSendStatus(darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), -1); + if(fMasterNode) RelayDarkSendStatus(darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_RESET); pwalletMain->Lock(); } @@ -200,7 +200,7 @@ void CDarkSendPool::Check() if((state == POOL_STATUS_ERROR || state == POOL_STATUS_SUCCESS) && GetTimeMillis()-lastTimeChanged >= 10000) { LogPrintf("CDarkSendPool::Check() -- RESETTING MESSAGE \n"); SetNull(true); - if(fMasterNode) RelayDarkSendStatus(darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), -1); + if(fMasterNode) RelayDarkSendStatus(darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_RESET); UnlockCoins(); } } @@ -299,7 +299,7 @@ void CDarkSendPool::CheckTimeout(){ UnlockCoins(); } if(fMasterNode){ - RelayDarkSendStatus(darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), -1); + RelayDarkSendStatus(darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_RESET); } break; } @@ -580,6 +580,10 @@ void CDarkSendPool::SendDarksendDenominate(const CTransaction& collateral, std:: } // Incoming message from masternode updating the progress of darksend +// newAccepted: -1 mean's it'n not a "transaction accepted/not accepted" message, just a standard update +// 0 means transaction was not accepted +// 1 means transaction was accepted + bool CDarkSendPool::StatusUpdate(int newState, int newEntriesCount, int newAccepted, std::string& error, int newSessionID){ if(fMasterNode) return false; if(state == POOL_STATUS_ERROR || state == POOL_STATUS_SUCCESS) return false; diff --git a/src/darksend.h b/src/darksend.h index b72b2493bc..fd667ce288 100644 --- a/src/darksend.h +++ b/src/darksend.h @@ -362,7 +362,7 @@ public: if(state != newState){ lastTimeChanged = GetTimeMillis(); if(fMasterNode) { - RelayDarkSendStatus(darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), -1); + RelayDarkSendStatus(darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_RESET); } } state = newState; diff --git a/src/main.cpp b/src/main.cpp index 2b3860c81f..ccd7b3ee73 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3916,13 +3916,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) if(!darkSendPool.IsCompatibleWithSession(nAmount, error)) { LogPrintf("dsa -- not compatible with existing transactions! \n"); - accepted = 0; - pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), accepted, error); + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_REJECTED, error); return true; } else { LogPrintf("dsa -- is compatible, please submit! \n"); - accepted = 1; - pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), accepted, error); + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_ACCEPTED, error); return true; } } else if (strCommand == "dsq") { //DarkSend Queue @@ -3977,9 +3975,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) /* if(!darkSendPool.IsCompatibleWithEntries(out)) { LogPrintf("dsi -- not compatible with existing transactions! \n"); - accepted = 0; error = "not compatible with existing transactions"; - pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), accepted, error); + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_REJECTED, error); return true; } @@ -4011,9 +4008,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) if(o.scriptPubKey.size() != 25){ LogPrintf("dsi - non-standard pubkey detected! %s\n", o.scriptPubKey.ToString().c_str()); - accepted = 0; error = "non-standard pubkey detected"; - pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), accepted, error); + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_REJECTED, error); return false; } @@ -4043,45 +4039,40 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) LogPrintf("dsi -- fees %"PRI64d"-%"PRI64d"=%"PRI64d" \ntx:%s\n", nValueIn, nValueOut, nFees, tx.ToString().c_str()); if (nFees < txMinFee) { LogPrintf("dsi -- fees are too low! %"PRI64d"-%"PRI64d"=%"PRI64d" \ntx:%s\n", nValueIn, nValueOut, nFees, tx.ToString().c_str()); - accepted = 0; error = "transaction fees are too low"; - pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), accepted, error); + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_REJECTED, error); return false; } if (nValueIn-nValueOut > nValueIn*.01) { LogPrintf("dsi -- fees are too high! %s\n", tx.ToString().c_str()); - accepted = 0; error = "transaction fees are too high"; - pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), accepted, error); + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_REJECTED, error); return false; } } else { LogPrintf("dsi -- missing input tx! %s\n", tx.ToString().c_str()); - accepted = 0; error = "missing input tx information"; - pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), accepted, error); + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_REJECTED, error); return false; } bool missing = false; if (!tx.IsAcceptable(state, true, false, &missing, false)){ //AcceptableInputs(state, true)){ LogPrintf("dsi -- transactione not valid! \n"); - accepted = 0; error = "transaction not valid"; - pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), accepted, error); + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_REJECTED, error); return false; } } if(darkSendPool.AddEntry(in, nAmount, txCollateral, out, error)){ - accepted = 1; - pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), accepted, error); + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_ACCEPTED, error); darkSendPool.Check(); - RelayDarkSendStatus(darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), -1); + RelayDarkSendStatus(darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_RESET); } else { - pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), accepted, error); + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_REJECTED, error); } } @@ -4093,7 +4084,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) if(!fMasterNode) return true; std::string error = ""; - pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), -1, error); + pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_RESET, error); //pfrom->fDisconnect = true; return true; } @@ -4148,7 +4139,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) if(success){ darkSendPool.Check(); - RelayDarkSendStatus(darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), -1); + RelayDarkSendStatus(darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_RESET); } } diff --git a/src/main.h b/src/main.h index 4f414a102d..9efd7123f7 100644 --- a/src/main.h +++ b/src/main.h @@ -47,6 +47,11 @@ #define MASTERNODE_EXPIRATION_MICROSECONDS 35*60*1000*1000 #define MASTERNODE_REMOVAL_MICROSECONDS 35.5*60*1000*1000 +// status update message constants +#define MASTERNODE_ACCEPTED 1 +#define MASTERNODE_REJECTED 0 +#define MASTERNODE_RESET -1 + class CWallet; class CBlock; class CBlockIndex;