mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Cleanup
- lower unobvious dependency through header files, move few includes to the right places - some trivial code cleanup Closes #680
This commit is contained in:
parent
8143059f41
commit
e2aaf09700
@ -2,9 +2,10 @@
|
||||
#include "addrman.h"
|
||||
#include "protocol.h"
|
||||
#include "activemasternode.h"
|
||||
#include "masternodeman.h"
|
||||
#include "masternode.h"
|
||||
#include "masternode-sync.h"
|
||||
#include "masternodeconfig.h"
|
||||
#include "masternodeman.h"
|
||||
#include "spork.h"
|
||||
|
||||
//
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include "main.h"
|
||||
#include "init.h"
|
||||
#include "util.h"
|
||||
#include "masternode-payments.h"
|
||||
#include "masternode-sync.h"
|
||||
#include "masternodeman.h"
|
||||
#include "script/sign.h"
|
||||
#include "instantx.h"
|
||||
@ -1650,43 +1652,6 @@ bool CDarksendPool::PrepareDarksendDenominate()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CDarksendPool::SendRandomPaymentToSelf()
|
||||
{
|
||||
CAmount nBalance = pwalletMain->GetBalance();
|
||||
CAmount nPayment = (nBalance*0.35) + (rand() % nBalance);
|
||||
|
||||
if(nPayment > nBalance) nPayment = nBalance-(0.1*COIN);
|
||||
|
||||
// make our change address
|
||||
CReserveKey reservekey(pwalletMain);
|
||||
|
||||
CScript scriptChange;
|
||||
CPubKey vchPubKey;
|
||||
assert(reservekey.GetReservedKey(vchPubKey)); // should never fail, as we just unlocked
|
||||
scriptChange = GetScriptForDestination(vchPubKey.GetID());
|
||||
|
||||
CWalletTx wtx;
|
||||
CAmount nFeeRet = 0;
|
||||
std::string strFail = "";
|
||||
vector< pair<CScript, CAmount> > vecSend;
|
||||
|
||||
// ****** Add fees ************ /
|
||||
vecSend.push_back(make_pair(scriptChange, nPayment));
|
||||
|
||||
CCoinControl *coinControl=NULL;
|
||||
bool success = pwalletMain->CreateTransaction(vecSend, wtx, reservekey, nFeeRet, strFail, coinControl, ONLY_DENOMINATED);
|
||||
if(!success){
|
||||
LogPrintf("SendRandomPaymentToSelf: Error - %s\n", strFail);
|
||||
return false;
|
||||
}
|
||||
|
||||
pwalletMain->CommitTransaction(wtx, reservekey);
|
||||
|
||||
LogPrintf("SendRandomPaymentToSelf Success: tx %s\n", wtx.GetHash().GetHex());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Split up large inputs or create fee sized inputs
|
||||
bool CDarksendPool::MakeCollateralAmounts()
|
||||
{
|
||||
@ -1839,13 +1804,6 @@ bool CDarksendPool::IsCompatibleWithEntries(std::vector<CTxOut>& vout)
|
||||
|
||||
BOOST_FOREACH(const CDarkSendEntry v, entries) {
|
||||
LogPrintf(" IsCompatibleWithEntries %d %d\n", GetDenominations(vout), GetDenominations(v.vout));
|
||||
/*
|
||||
BOOST_FOREACH(CTxOut o1, vout)
|
||||
LogPrintf(" vout 1 - %s\n", o1.ToString());
|
||||
|
||||
BOOST_FOREACH(CTxOut o2, v.vout)
|
||||
LogPrintf(" vout 2 - %s\n", o2.ToString());
|
||||
*/
|
||||
if(GetDenominations(vout) != GetDenominations(v.vout)) return false;
|
||||
}
|
||||
|
||||
|
@ -9,9 +9,7 @@
|
||||
#include "sync.h"
|
||||
#include "activemasternode.h"
|
||||
#include "masternodeman.h"
|
||||
#include "masternode-payments.h"
|
||||
#include "darksend-relay.h"
|
||||
#include "masternode-sync.h"
|
||||
|
||||
class CTxIn;
|
||||
class CDarksendPool;
|
||||
@ -378,6 +376,27 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
void InitDenominations() {
|
||||
darkSendDenominations.clear();
|
||||
/* Denominations
|
||||
|
||||
A note about convertability. Within Darksend pools, each denomination
|
||||
is convertable to another.
|
||||
|
||||
For example:
|
||||
1DRK+1000 == (.1DRK+100)*10
|
||||
10DRK+10000 == (1DRK+1000)*10
|
||||
*/
|
||||
darkSendDenominations.push_back( (100 * COIN)+100000 );
|
||||
darkSendDenominations.push_back( (10 * COIN)+10000 );
|
||||
darkSendDenominations.push_back( (1 * COIN)+1000 );
|
||||
darkSendDenominations.push_back( (.1 * COIN)+100 );
|
||||
/* Disabled till we need them
|
||||
darkSendDenominations.push_back( (.01 * COIN)+10 );
|
||||
darkSendDenominations.push_back( (.001 * COIN)+1 );
|
||||
*/
|
||||
}
|
||||
|
||||
void SetMinBlockSpacing(int minBlockSpacingIn){
|
||||
minBlockSpacing = minBlockSpacingIn;
|
||||
}
|
||||
@ -489,8 +508,6 @@ public:
|
||||
void NewBlock();
|
||||
void CompletedTransaction(bool error, int errorID);
|
||||
void ClearLastMessage();
|
||||
/// Used for liquidity providers
|
||||
bool SendRandomPaymentToSelf();
|
||||
|
||||
/// Split up large inputs or make fee sized inputs
|
||||
bool MakeCollateralAmounts();
|
||||
|
19
src/init.cpp
19
src/init.cpp
@ -1564,24 +1564,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
LogPrintf("Anonymize Dash Amount %d\n", nAnonymizeDarkcoinAmount);
|
||||
LogPrintf("Budget Mode %s\n", strBudgetMode.c_str());
|
||||
|
||||
/* Denominations
|
||||
|
||||
A note about convertability. Within Darksend pools, each denomination
|
||||
is convertable to another.
|
||||
|
||||
For example:
|
||||
1DRK+1000 == (.1DRK+100)*10
|
||||
10DRK+10000 == (1DRK+1000)*10
|
||||
*/
|
||||
darkSendDenominations.push_back( (100 * COIN)+100000 );
|
||||
darkSendDenominations.push_back( (10 * COIN)+10000 );
|
||||
darkSendDenominations.push_back( (1 * COIN)+1000 );
|
||||
darkSendDenominations.push_back( (.1 * COIN)+100 );
|
||||
/* Disabled till we need them
|
||||
darkSendDenominations.push_back( (.01 * COIN)+10 );
|
||||
darkSendDenominations.push_back( (.001 * COIN)+1 );
|
||||
*/
|
||||
|
||||
darkSendPool.InitDenominations();
|
||||
darkSendPool.InitCollateralAddress();
|
||||
|
||||
threadGroup.create_thread(boost::bind(&ThreadCheckDarkSendPool));
|
||||
|
@ -9,8 +9,9 @@
|
||||
#include "protocol.h"
|
||||
#include "instantx.h"
|
||||
#include "activemasternode.h"
|
||||
#include "masternodeman.h"
|
||||
#include "darksend.h"
|
||||
#include "masternode-sync.h"
|
||||
#include "masternodeman.h"
|
||||
#include "spork.h"
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
@ -206,7 +207,7 @@ bool IsIXTXValid(const CTransaction& txCollateral){
|
||||
return true;
|
||||
}
|
||||
|
||||
if(nValueIn-nValueOut < COIN*0.01) {
|
||||
if(nValueIn-nValueOut < CENT) {
|
||||
LogPrint("instantx", "IsIXTXValid - did not include enough fees in transaction %d\n%s\n", nValueOut-nValueIn, txCollateral.ToString().c_str());
|
||||
return false;
|
||||
}
|
||||
|
@ -14,9 +14,10 @@
|
||||
#include "init.h"
|
||||
#include "instantx.h"
|
||||
#include "darksend.h"
|
||||
#include "masternodeman.h"
|
||||
#include "masternode-payments.h"
|
||||
#include "masternode-budget.h"
|
||||
#include "masternode-payments.h"
|
||||
#include "masternode-sync.h"
|
||||
#include "masternodeman.h"
|
||||
#include "merkleblock.h"
|
||||
#include "net.h"
|
||||
#include "pow.h"
|
||||
@ -1578,7 +1579,7 @@ CAmount GetBlockValue(int nBits, int nHeight, const CAmount& nFees)
|
||||
if(Params().NetworkID() == CBaseChainParams::TESTNET){
|
||||
if(nHeight > 77900+576) nSubsidy -= nSubsidy/10;
|
||||
} else {
|
||||
if(nHeight > 309759+(553*33)) nSubsidy -= nSubsidy/10; // 328008 - 10.0% - September 6, 2015
|
||||
if(nHeight > 309759+(553*33)) nSubsidy -= nSubsidy/10; // 328008 - 10.0% - 2015-08-30
|
||||
}
|
||||
|
||||
return nSubsidy + nFees;
|
||||
|
@ -426,7 +426,7 @@ public:
|
||||
//Proposals must be at least a day old to make it into a budget
|
||||
if(Params().NetworkID() == CBaseChainParams::MAIN) return (nTime < GetTime() - (60*60*24));
|
||||
|
||||
//for testing purposes - 4 hours
|
||||
//for testing purposes - 20 minutes
|
||||
return (nTime < GetTime() - (60*20));
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,7 @@ void CMasternodePayments::FillBlockPayee(CMutableTransaction& txNew, CAmount nFe
|
||||
//spork
|
||||
if(!masternodePayments.GetBlockPayee(pindexPrev->nHeight+1, payee)){
|
||||
//no masternode detected
|
||||
CMasternode* winningNode = mnodeman.GetCurrentMasterNode(1);
|
||||
CMasternode* winningNode = mnodeman.GetCurrentMasterNode();
|
||||
if(winningNode){
|
||||
payee = GetScriptForDestination(winningNode->pubkey.GetID());
|
||||
} else {
|
||||
|
@ -2,9 +2,11 @@
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "masternode.h"
|
||||
#include "masternodeman.h"
|
||||
#include "darksend.h"
|
||||
#include "masternode.h"
|
||||
#include "masternode-payments.h"
|
||||
#include "masternode-sync.h"
|
||||
#include "masternodeman.h"
|
||||
#include "util.h"
|
||||
#include "sync.h"
|
||||
#include "addrman.h"
|
||||
|
@ -3,7 +3,10 @@
|
||||
#include "masternodeconfig.h"
|
||||
#include "util.h"
|
||||
#include "ui_interface.h"
|
||||
#include <base58.h>
|
||||
#include "chainparams.h"
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
|
||||
CMasternodeConfig masternodeConfig;
|
||||
|
||||
|
@ -6,12 +6,6 @@
|
||||
#ifndef SRC_MASTERNODECONFIG_H_
|
||||
#define SRC_MASTERNODECONFIG_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
|
||||
class CMasternodeConfig;
|
||||
extern CMasternodeConfig masternodeConfig;
|
||||
|
||||
|
@ -3,9 +3,11 @@
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "masternodeman.h"
|
||||
#include "masternode.h"
|
||||
#include "activemasternode.h"
|
||||
#include "darksend.h"
|
||||
#include "masternode.h"
|
||||
#include "masternode-payments.h"
|
||||
#include "masternode-sync.h"
|
||||
#include "util.h"
|
||||
#include "addrman.h"
|
||||
#include "spork.h"
|
||||
@ -454,7 +456,7 @@ CMasternode* CMasternodeMan::GetNextMasternodeInQueueForPayment(int nBlockHeight
|
||||
mn.Check();
|
||||
if(!mn.IsEnabled()) continue;
|
||||
|
||||
// //check protocol version
|
||||
//check protocol version
|
||||
if(mn.protocolVersion < masternodePayments.GetMinMasternodePaymentsProto()) continue;
|
||||
|
||||
//it's in the list (up to 8 entries ahead of current block to allow propagation) -- so let's skip it
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "init.h"
|
||||
#include "ui_interface.h"
|
||||
#include "util.h"
|
||||
#include "masternode-sync.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "transactiontablemodel.h"
|
||||
#include "walletmodel.h"
|
||||
#include "init.h"
|
||||
#include "masternode-sync.h"
|
||||
|
||||
#include <QAbstractItemDelegate>
|
||||
#include <QPainter>
|
||||
|
@ -6,10 +6,11 @@
|
||||
#include "db.h"
|
||||
#include "init.h"
|
||||
#include "activemasternode.h"
|
||||
#include "masternodeman.h"
|
||||
#include "masternode-payments.h"
|
||||
#include "masternode-budget.h"
|
||||
#include "masternode-payments.h"
|
||||
#include "masternode-sync.h"
|
||||
#include "masternodeconfig.h"
|
||||
#include "masternodeman.h"
|
||||
#include "rpcserver.h"
|
||||
#include "utilmoneystr.h"
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
@ -7,10 +7,11 @@
|
||||
#include "db.h"
|
||||
#include "init.h"
|
||||
#include "activemasternode.h"
|
||||
#include "masternodeman.h"
|
||||
#include "masternode-payments.h"
|
||||
#include "masternode-budget.h"
|
||||
#include "masternode-payments.h"
|
||||
#include "masternode-sync.h"
|
||||
#include "masternodeconfig.h"
|
||||
#include "masternodeman.h"
|
||||
#include "rpcserver.h"
|
||||
#include "utilmoneystr.h"
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
#ifdef ENABLE_WALLET
|
||||
#include "db.h"
|
||||
#include "wallet.h"
|
||||
#include "masternode-sync.h"
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
@ -583,8 +584,6 @@ Value getblocktemplate(const Array& params, bool fHelp)
|
||||
aMutable.push_back("prevblock");
|
||||
}
|
||||
|
||||
Array aVotes;
|
||||
|
||||
Object result;
|
||||
result.push_back(Pair("capabilities", aCaps));
|
||||
result.push_back(Pair("version", pblock->nVersion));
|
||||
@ -602,7 +601,6 @@ Value getblocktemplate(const Array& params, bool fHelp)
|
||||
result.push_back(Pair("curtime", pblock->GetBlockTime()));
|
||||
result.push_back(Pair("bits", strprintf("%08x", pblock->nBits)));
|
||||
result.push_back(Pair("height", (int64_t)(pindexPrev->nHeight+1)));
|
||||
result.push_back(Pair("votes", aVotes));
|
||||
|
||||
|
||||
if(pblock->payee != CScript()){
|
||||
|
Loading…
Reference in New Issue
Block a user