Merge branch 'v0.11.2.x' of https://github.com/darkcoin/darkcoin into v0.11.2.x-remove-unused

This commit is contained in:
Mike Kinney 2015-03-06 06:14:12 -08:00
commit 1d9c0b1ebc
9 changed files with 57 additions and 46 deletions

View File

@ -40,7 +40,7 @@ CActiveMasternode activeMasternode;
int RequestedMasterNodeList = 0; int RequestedMasterNodeList = 0;
/* *** BEGIN DARKSEND MAGIC - DARKCOIN ********** /* *** BEGIN DARKSEND MAGIC - DARKCOIN **********
Copyright 2014-2015, Darkcoin Developers Copyright (c) 2014-2015, Darkcoin Developers
eduffield - evan@darkcoin.io eduffield - evan@darkcoin.io
udjinm6 - udjinm6@darkcoin.io udjinm6 - udjinm6@darkcoin.io
*/ */
@ -1103,7 +1103,7 @@ void CDarksendPool::CheckForCompleteQueue(){
// which is the active state right before merging the transaction // which is the active state right before merging the transaction
// //
if(state == POOL_STATUS_QUEUE && sessionUsers == GetMaxPoolTransactions()) { if(state == POOL_STATUS_QUEUE && sessionUsers == GetMaxPoolTransactions()) {
printf("Q ready"); LogPrintf("Q ready");
UpdateState(POOL_STATUS_ACCEPTING_ENTRIES); UpdateState(POOL_STATUS_ACCEPTING_ENTRIES);
if(strMasternodeSharedKey == ""){ if(strMasternodeSharedKey == ""){
@ -1433,7 +1433,7 @@ bool CDarksendPool::StatusUpdate(int newState, int newEntriesCount, int newAccep
sessionFoundMasternode = true; sessionFoundMasternode = true;
//wait for other users. Masternode will report when ready //wait for other users. Masternode will report when ready
UpdateState(POOL_STATUS_QUEUE); UpdateState(POOL_STATUS_QUEUE);
printf("Updated 1\n"); LogPrintf("Updated 1\n");
} else if (newAccepted == 0 && sessionID == 0 && !sessionFoundMasternode) { } else if (newAccepted == 0 && sessionID == 0 && !sessionFoundMasternode) {
LogPrintf("CDarksendPool::StatusUpdate - entry not accepted by Masternode \n"); LogPrintf("CDarksendPool::StatusUpdate - entry not accepted by Masternode \n");
UnlockCoins(); UnlockCoins();
@ -2070,7 +2070,7 @@ bool CDarksendPool::IsCompatibleWithSession(int64_t nDenom, CTransaction txColla
} }
UpdateState(POOL_STATUS_QUEUE); UpdateState(POOL_STATUS_QUEUE);
printf("Updated 2\n"); LogPrintf("Updated 2\n");
vecSessionCollateral.push_back(txCollateral); vecSessionCollateral.push_back(txCollateral);
return true; return true;
} }

View File

@ -62,7 +62,7 @@ int GetInputDarksendRounds(CTxIn in, int rounds=0);
class CTxDSIn : public CTxIn class CTxDSIn : public CTxIn
{ {
public: public:
bool fHasSig; bool fHasSig; // flag to indicate if signed
CTxDSIn(const CTxIn& in) CTxDSIn(const CTxIn& in)
{ {
@ -86,7 +86,7 @@ public:
CTransaction collateral; CTransaction collateral;
std::vector<CTxOut> vout; std::vector<CTxOut> vout;
CTransaction txSupporting; CTransaction txSupporting;
int64_t addedTime; int64_t addedTime; // time in UTC milliseconds
CDarkSendEntry() CDarkSendEntry()
{ {
@ -133,7 +133,7 @@ public:
//information used for the anonymous relay system //information used for the anonymous relay system
int nBlockHeight; int nBlockHeight;
std::vector<unsigned char> vchRelaySig; std::vector<unsigned char> vchRelaySig;
std::string strSharedKey; std::string strSharedKey; // shared key
CDarksendQueue() CDarksendQueue()
{ {
@ -173,6 +173,7 @@ public:
return false; return false;
} }
/// Get the protocol version
bool GetProtocolVersion(int &protocolVersion) bool GetProtocolVersion(int &protocolVersion)
{ {
CMasternode* pmn = mnodeman.Find(vin); CMasternode* pmn = mnodeman.Find(vin);
@ -184,6 +185,7 @@ public:
return false; return false;
} }
/// Set the 'strSharedKey'
void SetSharedKey(std::string strSharedKey); void SetSharedKey(std::string strSharedKey);
/** Sign this Darksend transaction /** Sign this Darksend transaction
@ -224,9 +226,13 @@ public:
class CDarkSendSigner class CDarkSendSigner
{ {
public: public:
/// Is the inputs associated with this public key? (and there is 1000 DRK - checking if valid masternode)
bool IsVinAssociatedWithPubkey(CTxIn& vin, CPubKey& pubkey); bool IsVinAssociatedWithPubkey(CTxIn& vin, CPubKey& pubkey);
/// Set the private/public key values, returns true if successful
bool SetKey(std::string strSecret, std::string& errorMessage, CKey& key, CPubKey& pubkey); bool SetKey(std::string strSecret, std::string& errorMessage, CKey& key, CPubKey& pubkey);
/// Sign the message, returns true if successful
bool SignMessage(std::string strMessage, std::string& errorMessage, std::vector<unsigned char>& vchSig, CKey key); bool SignMessage(std::string strMessage, std::string& errorMessage, std::vector<unsigned char>& vchSig, CKey key);
/// Verify the message, returns true if succcessful
bool VerifyMessage(CPubKey pubkey, std::vector<unsigned char>& vchSig, std::string strMessage, std::string& errorMessage); bool VerifyMessage(CPubKey pubkey, std::vector<unsigned char>& vchSig, std::string strMessage, std::string& errorMessage);
}; };
@ -235,18 +241,22 @@ public:
class CDSAnonTx class CDSAnonTx
{ {
public: public:
std::vector<CTxDSIn> vin; std::vector<CTxDSIn> vin; // collection of inputs
std::vector<CTxOut> vout; std::vector<CTxOut> vout; // collection of outputs
/// Is the transaction valid? (TODO: not defined - remove? or code?)
bool IsTransactionValid(); bool IsTransactionValid();
/// Add an output
bool AddOutput(const CTxOut out); bool AddOutput(const CTxOut out);
/// Add an input
bool AddInput(const CTxIn in); bool AddInput(const CTxIn in);
/// Add Signature /// Add Signature
bool AddSig(const CTxIn in); bool AddSig(const CTxIn in);
/// Count the number of entries in the transaction
int CountEntries() {return (int)vin.size() + (int)vout.size();} int CountEntries() {return (int)vin.size() + (int)vout.size();}
}; };
/// TODO: not defined - remove?
void ConnectToDarkSendMasterNodeWinner(); void ConnectToDarkSendMasterNodeWinner();
@ -256,21 +266,17 @@ class CDarksendPool
{ {
public: public:
// clients entries std::vector<CDarkSendEntry> myEntries; // clients entries
std::vector<CDarkSendEntry> myEntries; std::vector<CDarkSendEntry> entries; // Masternode entries
// Masternode entries CTransaction finalTransaction; // the finalized transaction ready for signing
std::vector<CDarkSendEntry> entries; CDSAnonTx anonTx; // anonymous inputs/outputs
// the finalized transaction ready for signing bool fSubmitAnonymousFailed; // initally false, will change to true if when attempts > 5
CTransaction finalTransaction; int nCountAttempts; // number of submitted attempts
// anonymous inputs/outputs
CDSAnonTx anonTx;
bool fSubmitAnonymousFailed;
int nCountAttempts;
int64_t lastTimeChanged; // time in UTC milliseconds int64_t lastTimeChanged; // last time the 'state' changed, in UTC milliseconds
int64_t lastAutoDenomination; // Note: possibly not used TODO: Delete? int64_t lastAutoDenomination; // TODO; not used - Delete?
unsigned int state; unsigned int state; // should be one of the POOL_STATUS_XXX values
unsigned int entriesCount; unsigned int entriesCount;
unsigned int lastEntryAccepted; unsigned int lastEntryAccepted;
unsigned int countEntriesAccepted; unsigned int countEntriesAccepted;
@ -390,21 +396,25 @@ public:
} }
} }
/// Get the time the last entry was accepted (time in UTC milliseconds)
int GetLastEntryAccepted() const int GetLastEntryAccepted() const
{ {
return lastEntryAccepted; return lastEntryAccepted;
} }
/// Get the count of the accepted entries
int GetCountEntriesAccepted() const int GetCountEntriesAccepted() const
{ {
return countEntriesAccepted; return countEntriesAccepted;
} }
/// Get the client's transaction count
int GetMyTransactionCount() const int GetMyTransactionCount() const
{ {
return myEntries.size(); return myEntries.size();
} }
// Set the 'state' value, with some logging and capturing when the state changed
void UpdateState(unsigned int newState) void UpdateState(unsigned int newState)
{ {
if (fMasterNode && (newState == POOL_STATUS_ERROR || newState == POOL_STATUS_SUCCESS)){ if (fMasterNode && (newState == POOL_STATUS_ERROR || newState == POOL_STATUS_SUCCESS)){
@ -422,6 +432,7 @@ public:
state = newState; state = newState;
} }
/// Get the maximum number of transactions for the pool
int GetMaxPoolTransactions() int GetMaxPoolTransactions()
{ {
//if we're on testnet, just use two transactions per merge //if we're on testnet, just use two transactions per merge

View File

@ -1152,14 +1152,14 @@ bool AppInit2(boost::thread_group& threadGroup)
//CAddress addr; //CAddress addr;
//ConnectNode(addr, strNode.c_str(), true); //ConnectNode(addr, strNode.c_str(), true);
uiInterface.InitMessage(_("Loading masternode list...")); uiInterface.InitMessage(_("Loading masternode cache..."));
CMasternodeDB mndb; CMasternodeDB mndb;
CMasternodeDB::ReadResult readResult = mndb.Read(mnodeman); CMasternodeDB::ReadResult readResult = mndb.Read(mnodeman);
if (readResult == CMasternodeDB::FileError) if (readResult == CMasternodeDB::FileError)
LogPrintf("Missing masternode list file - masternodes.dat, will try to recreate\n"); LogPrintf("Missing masternode cache file - mncache.dat, will try to recreate\n");
else if (readResult != CMasternodeDB::Ok) else if (readResult != CMasternodeDB::Ok)
LogPrintf("Masternode list file masternodes.dat has invalid format\n"); LogPrintf("Masternode cache file mncache.dat has invalid format\n");
fMasterNode = GetBoolArg("-masternode", false); fMasterNode = GetBoolArg("-masternode", false);
if(fMasterNode) { if(fMasterNode) {

View File

@ -59,7 +59,7 @@ void ProcessMessageInstantX(CNode* pfrom, std::string& strCommand, CDataStream&
BOOST_FOREACH(const CTxOut o, tx.vout){ BOOST_FOREACH(const CTxOut o, tx.vout){
if(!o.scriptPubKey.IsNormalPaymentScript()){ if(!o.scriptPubKey.IsNormalPaymentScript()){
printf ("ProcessMessageInstantX::txlreq - Invalid Script %s\n", tx.ToString().c_str()); LogPrintf("ProcessMessageInstantX::txlreq - Invalid Script %s\n", tx.ToString().c_str());
return; return;
} }
} }

View File

@ -30,7 +30,7 @@ struct CompareValueOnly
CMasternodeDB::CMasternodeDB() CMasternodeDB::CMasternodeDB()
{ {
pathMN = GetDataDir() / "masternodes.dat"; pathMN = GetDataDir() / "mncache.dat";
} }
bool CMasternodeDB::Write(const CMasternodeMan& mnodemanToSave) bool CMasternodeDB::Write(const CMasternodeMan& mnodemanToSave)
@ -60,7 +60,7 @@ bool CMasternodeDB::Write(const CMasternodeMan& mnodemanToSave)
FileCommit(fileout); FileCommit(fileout);
fileout.fclose(); fileout.fclose();
LogPrintf("Written info to masternodes.dat %dms\n", GetTimeMillis() - nStart); LogPrintf("Written info to mncache.dat %dms\n", GetTimeMillis() - nStart);
LogPrintf(" %s\n", mnodemanToSave.ToString()); LogPrintf(" %s\n", mnodemanToSave.ToString());
return true; return true;
@ -131,7 +131,7 @@ CMasternodeDB::ReadResult CMasternodeDB::Read(CMasternodeMan& mnodemanToLoad)
} }
mnodemanToLoad.CheckAndRemove(); // clean out expired mnodemanToLoad.CheckAndRemove(); // clean out expired
LogPrintf("Loaded info from masternodes.dat %dms\n", GetTimeMillis() - nStart); LogPrintf("Loaded info from mncache.dat %dms\n", GetTimeMillis() - nStart);
LogPrintf(" %s\n", mnodemanToLoad.ToString()); LogPrintf(" %s\n", mnodemanToLoad.ToString());
return Ok; return Ok;
@ -144,17 +144,17 @@ void DumpMasternodes()
CMasternodeDB mndb; CMasternodeDB mndb;
CMasternodeMan tempMnodeman; CMasternodeMan tempMnodeman;
LogPrintf("Verifying masternodes.dat format...\n"); LogPrintf("Verifying mncache.dat format...\n");
CMasternodeDB::ReadResult readResult = mndb.Read(tempMnodeman); CMasternodeDB::ReadResult readResult = mndb.Read(tempMnodeman);
// there was an error and it was not an error on file openning => do not proceed // there was an error and it was not an error on file openning => do not proceed
if (readResult == CMasternodeDB::FileError) if (readResult == CMasternodeDB::FileError)
LogPrintf("Missing masternode list file - masternodes.dat, will try to recreate\n"); LogPrintf("Missing masternode cache file - mncache.dat, will try to recreate\n");
else if (readResult != CMasternodeDB::Ok) else if (readResult != CMasternodeDB::Ok)
{ {
LogPrintf("Masternode list file masternodes.dat has invalid format\n"); LogPrintf("Masternode cache file mncache.dat has invalid format\n");
return; return;
} }
LogPrintf("Writting info to masternodes.dat...\n"); LogPrintf("Writting info to mncache.dat...\n");
mndb.Write(mnodeman); mndb.Write(mnodeman);
LogPrintf("Masternode dump finished %dms\n", GetTimeMillis() - nStart); LogPrintf("Masternode dump finished %dms\n", GetTimeMillis() - nStart);

View File

@ -26,7 +26,7 @@ class CMasternodeMan;
extern CMasternodeMan mnodeman; extern CMasternodeMan mnodeman;
void DumpMasternodes(); void DumpMasternodes();
/** Access to the MN database (masternodes.dat) /** Access to the MN database (mncache.dat)
*/ */
class CMasternodeDB class CMasternodeDB
{ {

View File

@ -276,7 +276,7 @@ QT_TRANSLATE_NOOP("darkcoin-core", "List commands"),
QT_TRANSLATE_NOOP("darkcoin-core", "Listen for connections on <port> (default: 9999 or testnet: 19999)"), QT_TRANSLATE_NOOP("darkcoin-core", "Listen for connections on <port> (default: 9999 or testnet: 19999)"),
QT_TRANSLATE_NOOP("darkcoin-core", "Loading addresses..."), QT_TRANSLATE_NOOP("darkcoin-core", "Loading addresses..."),
QT_TRANSLATE_NOOP("darkcoin-core", "Loading block index..."), QT_TRANSLATE_NOOP("darkcoin-core", "Loading block index..."),
QT_TRANSLATE_NOOP("darkcoin-core", "Loading masternode list..."), QT_TRANSLATE_NOOP("darkcoin-core", "Loading masternode cache..."),
QT_TRANSLATE_NOOP("darkcoin-core", "Loading wallet... (%3.2f %%)"), QT_TRANSLATE_NOOP("darkcoin-core", "Loading wallet... (%3.2f %%)"),
QT_TRANSLATE_NOOP("darkcoin-core", "Loading wallet..."), QT_TRANSLATE_NOOP("darkcoin-core", "Loading wallet..."),
QT_TRANSLATE_NOOP("darkcoin-core", "Log transaction priority and fee per kB when mining blocks (default: 0)"), QT_TRANSLATE_NOOP("darkcoin-core", "Log transaction priority and fee per kB when mining blocks (default: 0)"),

View File

@ -391,15 +391,15 @@ void OverviewPage::darkSendStatus()
} }
} else { } else {
if(showingDarkSendMessage % 70 <= 40) convert << tr("Submitted following entries to masternode:").toStdString() << " " << entries << "/" << darkSendPool.GetMaxPoolTransactions(); if(showingDarkSendMessage % 70 <= 40) convert << tr("Submitted following entries to masternode:").toStdString() << " " << entries << "/" << darkSendPool.GetMaxPoolTransactions();
else if(showingDarkSendMessage % 70 <= 50) convert << tr("Submitted to masternode, Waiting for more entries").toStdString() << " (" << entries << "/" << darkSendPool.GetMaxPoolTransactions() << " ) ."; else if(showingDarkSendMessage % 70 <= 50) convert << tr("Submitted to masternode, waiting for more entries").toStdString() << " (" << entries << "/" << darkSendPool.GetMaxPoolTransactions() << " ) .";
else if(showingDarkSendMessage % 70 <= 60) convert << tr("Submitted to masternode, Waiting for more entries").toStdString() << " (" << entries << "/" << darkSendPool.GetMaxPoolTransactions() << " ) .."; else if(showingDarkSendMessage % 70 <= 60) convert << tr("Submitted to masternode, waiting for more entries").toStdString() << " (" << entries << "/" << darkSendPool.GetMaxPoolTransactions() << " ) ..";
else if(showingDarkSendMessage % 70 <= 70) convert << tr("Submitted to masternode, Waiting for more entries").toStdString() << " (" << entries << "/" << darkSendPool.GetMaxPoolTransactions() << " ) ..."; else if(showingDarkSendMessage % 70 <= 70) convert << tr("Submitted to masternode, waiting for more entries").toStdString() << " (" << entries << "/" << darkSendPool.GetMaxPoolTransactions() << " ) ...";
} }
} else if(state == POOL_STATUS_SIGNING) { } else if(state == POOL_STATUS_SIGNING) {
if(showingDarkSendMessage % 70 <= 10) convert << tr("Found enough users, signing ...").toStdString(); if(showingDarkSendMessage % 70 <= 10) convert << tr("Found enough users, signing ...").toStdString();
else if(showingDarkSendMessage % 70 <= 20) convert << tr("Found enough users, signing ( waiting. )").toStdString(); else if(showingDarkSendMessage % 70 <= 20) convert << tr("Found enough users, signing ( waiting").toStdString() << ". )";
else if(showingDarkSendMessage % 70 <= 30) convert << tr("Found enough users, signing ( waiting.. )").toStdString(); else if(showingDarkSendMessage % 70 <= 30) convert << tr("Found enough users, signing ( waiting").toStdString() << ".. )";
else if(showingDarkSendMessage % 70 <= 40) convert << tr("Found enough users, signing ( waiting... )").toStdString(); else if(showingDarkSendMessage % 70 <= 40) convert << tr("Found enough users, signing ( waiting").toStdString() << "... )";
} else if(state == POOL_STATUS_TRANSMISSION) { } else if(state == POOL_STATUS_TRANSMISSION) {
convert << tr("Transmitting final transaction.").toStdString(); convert << tr("Transmitting final transaction.").toStdString();
} else if (state == POOL_STATUS_IDLE) { } else if (state == POOL_STATUS_IDLE) {
@ -411,9 +411,9 @@ void OverviewPage::darkSendStatus()
} else if(state == POOL_STATUS_SUCCESS) { } else if(state == POOL_STATUS_SUCCESS) {
convert << tr("Darksend request complete:").toStdString() << " " << darkSendPool.lastMessage; convert << tr("Darksend request complete:").toStdString() << " " << darkSendPool.lastMessage;
} else if(state == POOL_STATUS_QUEUE) { } else if(state == POOL_STATUS_QUEUE) {
if(showingDarkSendMessage % 70 <= 50) convert << tr("Submitted to masternode, waiting in queue .").toStdString(); if(showingDarkSendMessage % 70 <= 50) convert << tr("Submitted to masternode, waiting in queue").toStdString() << " .";
else if(showingDarkSendMessage % 70 <= 60) convert << tr("Submitted to masternode, waiting in queue ..").toStdString(); else if(showingDarkSendMessage % 70 <= 60) convert << tr("Submitted to masternode, waiting in queue").toStdString() << " ..";
else if(showingDarkSendMessage % 70 <= 70) convert << tr("Submitted to masternode, waiting in queue ...").toStdString(); else if(showingDarkSendMessage % 70 <= 70) convert << tr("Submitted to masternode, waiting in queue").toStdString() << " ...";
} else { } else {
convert << tr("Unknown state:").toStdString() << " id = " << state; convert << tr("Unknown state:").toStdString() << " id = " << state;
} }

View File

@ -1565,7 +1565,7 @@ Value walletpassphrase(const Array& params, bool fHelp)
{ {
if (pwalletMain->IsCrypted() && (fHelp || params.size() < 2 || params.size() > 3)) if (pwalletMain->IsCrypted() && (fHelp || params.size() < 2 || params.size() > 3))
throw runtime_error( throw runtime_error(
"walletpassphrase \"passphrase\" timeout ( anonymizeonly )>\n" "walletpassphrase \"passphrase\" timeout ( anonymizeonly )\n"
"\nStores the wallet decryption key in memory for 'timeout' seconds.\n" "\nStores the wallet decryption key in memory for 'timeout' seconds.\n"
"This is needed prior to performing transactions related to private keys such as sending darkcoins\n" "This is needed prior to performing transactions related to private keys such as sending darkcoins\n"
"\nArguments:\n" "\nArguments:\n"