Added LiteMode

LiteMode disables Darksend/Masternodes/InstantX for clients
who want speed and don't need access to these features. UI
for Darksend is also hidden while in this mode.
This commit is contained in:
Evan Duffield 2015-01-18 08:28:16 -07:00
parent daab1083cf
commit 539a8683a4
7 changed files with 33 additions and 14 deletions

View File

@ -42,6 +42,8 @@ int RequestedMasterNodeList = 0;
void ProcessMessageDarksend(CNode* pfrom, std::string& strCommand, CDataStream& vRecv)
{
if(fLiteMode) return; //disable all darksend/masternode related functionality
if (strCommand == "dsf") { //DarkSend Final tx
if (pfrom->nVersion < darkSendPool.MIN_PEER_PROTO_VERSION) {
return;
@ -579,8 +581,8 @@ void CDarkSendPool::Check()
if(!darkSendSigner.SetKey(strMasterNodePrivKey, strError, key2, pubkey2))
{
LogPrintf("Invalid masternodeprivkey: '%s'\n", strError.c_str());
exit(0);
LogPrintf("CDarkSendPool::Check() - ERROR: Invalid masternodeprivkey: '%s'\n", strError.c_str());
return;
}
if(!darkSendSigner.SignMessage(strMessage, strError, vchSig, key2)) {
@ -2137,8 +2139,8 @@ bool CDarksendQueue::Sign()
if(!darkSendSigner.SetKey(strMasterNodePrivKey, errorMessage, key2, pubkey2))
{
LogPrintf("Invalid masternodeprivkey: '%s'\n", errorMessage.c_str());
exit(0);
LogPrintf("CDarksendQueue():Relay - ERROR: Invalid masternodeprivkey: '%s'\n", errorMessage.c_str());
return false;
}
if(!darkSendSigner.SignMessage(strMessage, errorMessage, vchSig, key2)) {
@ -2188,6 +2190,8 @@ bool CDarksendQueue::CheckSignature()
void ThreadCheckDarkSendPool()
{
if(fLiteMode) return; //disable all darksend/masternode related functionality
// Make this thread recognisable as the wallet flushing thread
RenameThread("bitcoin-darksend");

View File

@ -1115,8 +1115,7 @@ bool AppInit2(boost::thread_group& threadGroup)
if(!strMasterNodeAddr.empty()){
CService addrTest = CService(strMasterNodeAddr);
if (!addrTest.IsValid()) {
printf("Invalid -masternodeaddr address: '%s'\n", mapArgs["-strMasterNodeAddr"].c_str());
exit(0);
return InitError("Invalid -masternodeaddr address: " + strMasterNodeAddr);
}
}
@ -1165,6 +1164,12 @@ bool AppInit2(boost::thread_group& threadGroup)
nInstantXDepth = 0;
}
//lite mode disables all Masternode and Darksend related functionality
fLiteMode = GetBoolArg("-litemode", false);
if(fMasterNode && fLiteMode){
return InitError("You can not start a masternode in litemode");
}
LogPrintf("nInstantXDepth %d\n", nInstantXDepth);
LogPrintf("Darksend rounds %d\n", nDarksendRounds);
LogPrintf("Anonymize Darkcoin Amount %d\n", nAnonymizeDarkcoinAmount);

View File

@ -35,6 +35,7 @@ std::map<uint256, CTransactionLock> mapTxLocks;
void ProcessMessageInstantX(CNode* pfrom, std::string& strCommand, CDataStream& vRecv)
{
return;
if(fLiteMode) return; //disable all darksend/masternode related functionality
if (strCommand == "txlreq")
{
@ -387,8 +388,8 @@ bool CConsensusVote::Sign()
if(!darkSendSigner.SetKey(strMasterNodePrivKey, errorMessage, key2, pubkey2))
{
LogPrintf("Invalid masternodeprivkey: '%s'\n", errorMessage.c_str());
exit(0);
LogPrintf("CActiveMasternode::RegisterAsMasterNode() - ERROR: Invalid masternodeprivkey: '%s'\n", errorMessage.c_str());
return false;
}
CScript pubkey;

View File

@ -37,6 +37,8 @@ void ProcessMasternodeConnections(){
void ProcessMessageMasternode(CNode* pfrom, std::string& strCommand, CDataStream& vRecv)
{
if(fLiteMode) return; //disable all darksend/masternode related functionality
if (strCommand == "dsee") { //DarkSend Election Entry
bool fIsInitialDownload = IsInitialBlockDownload();
if(fIsInitialDownload) return;
@ -633,8 +635,8 @@ bool CMasternodePayments::Sign(CMasternodePaymentWinner& winner)
if(!darkSendSigner.SetKey(strMasterPrivKey, errorMessage, key2, pubkey2))
{
LogPrintf("CMasternodePayments::Sign - Invalid masternodeprivkey: '%s'\n", errorMessage.c_str());
exit(0);
LogPrintf("CMasternodePayments::Sign - ERROR: Invalid masternodeprivkey: '%s'\n", errorMessage.c_str());
return false;
}
if(!darkSendSigner.SignMessage(strMessage, errorMessage, winner.vchSig, key2)) {

View File

@ -121,9 +121,6 @@ OverviewPage::OverviewPage(QWidget *parent) :
connect(ui->listTransactions, SIGNAL(clicked(QModelIndex)), this, SLOT(handleTransactionClicked(QModelIndex)));
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(darkSendStatus()));
timer->start(333);
// init "out of sync" warning labels
ui->labelWalletStatus->setText("(" + tr("out of sync") + ")");
@ -132,7 +129,15 @@ OverviewPage::OverviewPage(QWidget *parent) :
showingDarkSendMessage = 0;
darksendActionCheck = 0;
if(fMasterNode){
if(fLiteMode){
ui->frameDarksend->setVisible(false);
} else {
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(darkSendStatus()));
timer->start(333);
}
if(fMasterNode || fLiteMode){
ui->toggleDarksend->setText("(Disabled)");
ui->toggleDarksend->setEnabled(false);
}else if(!fEnableDarksend){

View File

@ -97,6 +97,7 @@ using namespace std;
bool fMasterNode = false;
string strMasterNodePrivKey = "";
string strMasterNodeAddr = "";
bool fLiteMode = false;
int nInstantXDepth = 1;
int nDarksendRounds = 2;
int nAnonymizeDarkcoinAmount = 1000;

View File

@ -95,6 +95,7 @@ inline void MilliSleep(int64_t n)
//Darkcoin only features
extern bool fMasterNode;
extern bool fLiteMode;
extern int nInstantXDepth;
extern int nDarksendRounds;
extern int nAnonymizeDarkcoinAmount;