Skip to content

Commit

Permalink
Merge #893: Cleanup
Browse files Browse the repository at this point in the history
3249a63 Fix logging - CTransaction::ToString() always has `\n` at the end of a string, avoid adding empty line
ec03753 make mnw errors and ThreadCheckDarkSendPool less spammy
5b678af fix errorMessage - it should not have `\n`, let output code handle line endings instead
a81cdf7 rename `dash-darksend` thread to `dash-privatesend`
5e4f468 fix/remove outdated code
f1c9678 Break tooltip about third party urls in 2 lines
  • Loading branch information
UdjinM6 authored and schinzelh committed Jun 27, 2016
1 parent a38d983 commit 9764e22
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 31 deletions.
24 changes: 10 additions & 14 deletions src/darksend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,21 +242,21 @@ void CDarksendPool::ProcessMessage(CNode* pfrom, std::string& strCommand, CDataS
}

if (nValueIn > DARKSEND_POOL_MAX) {
LogPrintf("dsi -- more than PrivateSend pool max! %s\n", tx.ToString());
LogPrintf("dsi -- more than PrivateSend pool max! %s", tx.ToString());
errorID = ERR_MAXIMUM;
pfrom->PushMessage(NetMsgType::DSSTATUSUPDATE, sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID);
return;
}

if(!missingTx){
if (nValueIn-nValueOut > nValueIn*.01) {
LogPrintf("dsi -- fees are too high! %s\n", tx.ToString());
LogPrintf("dsi -- fees are too high! %s", tx.ToString());
errorID = ERR_FEES;
pfrom->PushMessage(NetMsgType::DSSTATUSUPDATE, sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID);
return;
}
} else {
LogPrintf("dsi -- missing input tx! %s\n", tx.ToString());
LogPrintf("dsi -- missing input tx! %s", tx.ToString());
errorID = ERR_MISSING_TX;
pfrom->PushMessage(NetMsgType::DSSTATUSUPDATE, sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID);
return;
Expand All @@ -267,7 +267,7 @@ void CDarksendPool::ProcessMessage(CNode* pfrom, std::string& strCommand, CDataS
CValidationState validationState;
mempool.PrioritiseTransaction(tx.GetHash(), tx.GetHash().ToString(), 1000, 0.1*COIN);
if(!AcceptToMemoryPool(mempool, validationState, CTransaction(tx), false, NULL, false, true, true)) {
LogPrintf("dsi -- transaction not valid! \n");
LogPrintf("dsi -- transaction not valid! %s", tx.ToString());
errorID = ERR_INVALID_TX;
pfrom->PushMessage(NetMsgType::DSSTATUSUPDATE, sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID);
return;
Expand Down Expand Up @@ -500,9 +500,6 @@ std::string CDarksendPool::GetStatus()
//
void CDarksendPool::Check()
{
if(fMasterNode) LogPrint("privatesend", "CDarksendPool::Check() - entries count %lu\n", entries.size());
//printf("CDarksendPool::Check() %d - %d - %d\n", state, anonTx.CountEntries(), GetTimeMillis()-lastTimeChanged);

if(fMasterNode) {
LogPrint("privatesend", "CDarksendPool::Check() - entries count %lu\n", entries.size());

Expand Down Expand Up @@ -1157,12 +1154,12 @@ void CDarksendPool::SendDarksendDenominate(std::vector<CTxIn>& vin, std::vector<
LogPrint("privatesend", "CDarksendPool::SendDarksendDenominate() -- tx in %s\n", i.ToString());
}

LogPrintf("Submitting tx %s\n", tx.ToString());
LogPrintf("CDarksendPool::SendDarksendDenominate() -- Submitting tx %s", tx.ToString());

mempool.PrioritiseTransaction(tx.GetHash(), tx.GetHash().ToString(), 1000, 0.1*COIN);
TRY_LOCK(cs_main, lockMain);
if(!lockMain || !AcceptToMemoryPool(mempool, validationState, CTransaction(tx), false, NULL, false, true, true)){
LogPrintf("CDarksendPool::SendDarksendDenominate() -- transaction failed! %s \n", tx.ToString());
LogPrintf("CDarksendPool::SendDarksendDenominate() -- transaction failed! %s", tx.ToString());
UnlockCoins();
SetNull();
return;
Expand Down Expand Up @@ -2175,7 +2172,7 @@ bool CDarkSendSigner::VerifyMessage(CPubKey pubkey, vector<unsigned char>& vchSi
}

if (pubkey2.GetID() != pubkey.GetID()) {
errorMessage = strprintf("keys don't match - input: %s, recovered: %s, message: %s, sig: %s\n",
errorMessage = strprintf("keys don't match - input: %s, recovered: %s, message: %s, sig: %s",
pubkey.GetID().ToString(), pubkey2.GetID().ToString(), strMessage,
EncodeBase64(&vchSig[0], vchSig.size()));
return false;
Expand Down Expand Up @@ -2300,22 +2297,21 @@ void CDarksendPool::UpdatedBlockTip(const CBlockIndex *pindex)
//TODO: Rename/move to core
void ThreadCheckDarkSendPool()
{
if(fLiteMode) return; //disable all Darksend/Masternode related functionality
if(fLiteMode) return; // disable all Dash specific functionality

static bool fOneThread;
if (fOneThread)
return;
fOneThread = true;

// Make this thread recognisable as the Darksend/Masternode thread
RenameThread("dash-darksend");
// Make this thread recognisable as the PrivateSend thread
RenameThread("dash-privatesend");

unsigned int c = 0;

while (true)
{
MilliSleep(1000);
//LogPrintf("ThreadCheckDarkSendPool::check timeout\n");

// try to sync from all available nodes, one step at a time
masternodeSync.Process();
Expand Down
2 changes: 1 addition & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1886,7 +1886,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
mnpayments.UpdatedBlockTip(chainActive.Tip());
masternodeSync.UpdatedBlockTip(chainActive.Tip());

// ********************************************************* Step 11d: start dash-darksend thread
// ********************************************************* Step 11d: start dash-privatesend thread

threadGroup.create_thread(boost::bind(&ThreadCheckDarkSendPool));

Expand Down
2 changes: 1 addition & 1 deletion src/instantx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void ProcessMessageInstantX(CNode* pfrom, std::string& strCommand, CDataStream&
// IX supports normal scripts and unspendable scripts (used in DS collateral and Budget collateral).
// TODO: Look into other script types that are normal and can be included
if(!o.scriptPubKey.IsNormalPaymentScript() && !o.scriptPubKey.IsUnspendable()){
LogPrintf("ProcessMessageInstantX::ix - Invalid Script %s\n", tx.ToString());
LogPrintf("ProcessMessageInstantX::ix - Invalid Script %s", tx.ToString());
return;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/masternode-payments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ void CMasternodePayments::ProcessMessage(CNode* pfrom, std::string& strCommand,

std::string strError = "";
if(!winner.IsValid(pfrom, strError)){
if(strError != "") LogPrintf("mnw - invalid message - %s\n", strError);
if(strError != "") LogPrint("mnpayments", "mnw - invalid message - %s\n", strError);
return;
}

Expand Down Expand Up @@ -471,15 +471,15 @@ bool CMasternodePaymentWinner::IsValid(CNode* pnode, std::string& strError)
if(!pmn)
{
strError = strprintf("Unknown Masternode %s", vinMasternode.prevout.ToStringShort());
LogPrintf ("CMasternodePaymentWinner::IsValid - %s\n", strError);
LogPrint("mnpayments", "CMasternodePaymentWinner::IsValid - %s\n", strError);
mnodeman.AskForMN(pnode, vinMasternode);
return false;
}

if(pmn->protocolVersion < MIN_MNW_PEER_PROTO_VERSION)
{
strError = strprintf("Masternode protocol too old %d - req %d", pmn->protocolVersion, MIN_MNW_PEER_PROTO_VERSION);
LogPrintf ("CMasternodePaymentWinner::IsValid - %s\n", strError);
LogPrint("mnpayments", "CMasternodePaymentWinner::IsValid - %s\n", strError);
return false;
}

Expand All @@ -492,7 +492,7 @@ bool CMasternodePaymentWinner::IsValid(CNode* pnode, std::string& strError)
if(n > MNPAYMENTS_SIGNATURES_TOTAL*2)
{
strError = strprintf("Masternode not in the top %d (%d)", MNPAYMENTS_SIGNATURES_TOTAL, n);
LogPrintf("CMasternodePaymentWinner::IsValid - %s\n", strError);
LogPrint("mnpayments", "CMasternodePaymentWinner::IsValid - %s\n", strError);
if(masternodeSync.IsSynced()) Misbehaving(pnode->GetId(), 20);
}
return false;
Expand Down
5 changes: 1 addition & 4 deletions src/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,6 @@ void CMasternode::Check(bool forceCheck)
}

int64_t CMasternode::SecondsSincePayment() {
CScript pubkeyScript;
pubkeyScript = GetScriptForDestination(pubkey.GetID());

int64_t sec = (GetAdjustedTime() - GetLastPaid());
int64_t month = 60*60*24*30;
if(sec < month) return sec; //if it's less than 30 days, give seconds
Expand Down Expand Up @@ -490,7 +487,7 @@ bool CMasternodeBroadcast::CheckInputsAndAdd(int& nDos)

if(!AcceptToMemoryPool(mempool, state, CTransaction(tx), false, NULL, false, true, true)) {
//set nDos
LogPrint("masternode", "CMasternodeBroadcast::CheckInputsAndAdd - Failed to accepted Masternode entry tx to mempool - %s\n", tx.ToString());
LogPrint("masternode", "CMasternodeBroadcast::CheckInputsAndAdd - Failed to accepted Masternode entry tx to mempool - %s", tx.ToString());
state.IsInvalid(nDos);
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/qt/forms/optionsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ https://www.transifex.com/projects/p/dash/</string>
<item>
<widget class="QLabel" name="thirdPartyTxUrlsLabel">
<property name="toolTip">
<string>Third party URLs (e.g. a block explorer) that appear in the transactions tab as context menu items. %s in the URL is replaced by transaction hash. Multiple URLs are separated by vertical bar |.</string>
<string>Third party URLs (e.g. a block explorer) that appear in the transactions tab as context menu items.&lt;br/&gt;%s in the URL is replaced by transaction hash. Multiple URLs are separated by vertical bar |.</string>
</property>
<property name="text">
<string>Third party transaction URLs</string>
Expand All @@ -773,7 +773,7 @@ https://www.transifex.com/projects/p/dash/</string>
<item>
<widget class="QLineEdit" name="thirdPartyTxUrls">
<property name="toolTip">
<string>Third party URLs (e.g. a block explorer) that appear in the transactions tab as context menu items. %s in the URL is replaced by transaction hash. Multiple URLs are separated by vertical bar |.</string>
<string>Third party URLs (e.g. a block explorer) that appear in the transactions tab as context menu items.&lt;br/&gt;%s in the URL is replaced by transaction hash. Multiple URLs are separated by vertical bar |.</string>
</property>
</widget>
</item>
Expand Down
2 changes: 1 addition & 1 deletion src/qt/overviewpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ void OverviewPage::privateSendStatus()
static int64_t nLastDSProgressBlockTime = 0;
int nBestHeight = clientModel->getNumBlocks();

// we we're processing more then 1 block per second, we'll just leave
// We are processing more then 1 block per second, we'll just leave
if(((nBestHeight - darkSendPool.cachedNumBlocks) / (GetTimeMillis() - nLastDSProgressBlockTime + 1) > 1)) return;
nLastDSProgressBlockTime = GetTimeMillis();

Expand Down
1 change: 0 additions & 1 deletion src/qt/res/css/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,6 @@ padding-bottom:8px;
}

QDialog#OptionsDialog QCheckBox {
qproperty-alignment: 'AlignVCenter';
min-height:20px;
}

Expand Down
6 changes: 3 additions & 3 deletions src/qt/sendcoinsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,9 +642,9 @@ void SendCoinsDialog::processSendCoinsReturn(const WalletModel::SendCoinsReturn
msgParams.second = CClientUIInterface::MSG_ERROR;
break;
case WalletModel::AnonymizeOnlyUnlocked:
QMessageBox::warning(this, tr("Send Coins"),
tr("Error: The wallet was unlocked only to anonymize coins."),
QMessageBox::Ok, QMessageBox::Ok);
msgParams.first = tr("Transaction creation failed!") + " " + tr("The wallet was unlocked only to anonymize coins."),
msgParams.second = CClientUIInterface::MSG_ERROR;
break;
case WalletModel::AbsurdFee:
msgParams.first = tr("A fee higher than %1 is considered an absurdly high fee.").arg(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), maxTxFee));
break;
Expand Down

0 comments on commit 9764e22

Please sign in to comment.