Skip to content

Commit ede0bb6

Browse files
Merge pull request #62 from freynder/start-many-enhanced
Improve support for start-many
2 parents b40755d + 2d3420c commit ede0bb6

20 files changed

+765
-294
lines changed

bitcoin-qt.pro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ HEADERS += src/qt/bitcoingui.h \
168168
src/core.h \
169169
src/masternode.h \
170170
src/activemasternode.h \
171+
src/masternodeconfig.h \
171172
src/net.h \
172173
src/key.h \
173174
src/db.h \
@@ -269,6 +270,7 @@ SOURCES += src/qt/bitcoin.cpp \
269270
src/instantx.cpp \
270271
src/masternode.cpp \
271272
src/activemasternode.cpp \
273+
src/masternodeconfig.cpp \
272274
src/core.cpp \
273275
src/init.cpp \
274276
src/net.cpp \

src/activemasternode.cpp

Lines changed: 282 additions & 188 deletions
Large diffs are not rendered by default.

src/activemasternode.h

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
// Copyright (c) 2009-2010 Satoshi Nakamoto
32
// Copyright (c) 2009-2012 The Bitcoin developers
43
// Distributed under the MIT/X11 software license, see the accompanying
@@ -21,36 +20,45 @@ extern CActiveMasternode activeMasternode;
2120
class CActiveMasternode
2221
{
2322
public:
24-
CTxIn vinMasternode;
25-
CPubKey pubkeyMasterNode;
26-
CPubKey pubkeyMasterNode2;
27-
28-
std::string strMasterNodeSignMessage;
29-
std::vector<unsigned char> vchMasterNodeSignature;
23+
// Initialized by init.cpp
24+
// Keys for the main masternode
25+
CPubKey pubKeyMasternode;
3026

31-
std::string masterNodeAddr;
32-
CService masterNodeSignAddr;
27+
// Initialized while registering masternode
28+
CTxIn vin;
29+
CService service;
3330

34-
int isCapableMasterNode;
35-
int64 masterNodeSignatureTime;
36-
int masternodePortOpen;
31+
int status;
32+
std::string notCapableReason;
3733

3834
CActiveMasternode()
3935
{
40-
isCapableMasterNode = MASTERNODE_NOT_PROCESSED;
41-
masternodePortOpen = 0;
36+
status = MASTERNODE_NOT_PROCESSED;
4237
}
4338

39+
void ManageStatus(); // manage status of main masternode
40+
41+
bool Dseep(std::string& errorMessage); // ping for main masternode
42+
bool Dseep(CTxIn vin, CService service, CKey key, CPubKey pubKey, std::string &retErrorMessage, bool stop); // ping for any masternode
43+
44+
bool StopMasterNode(std::string& errorMessage); // stop main masternode
45+
bool StopMasterNode(std::string strService, std::string strKeyMasternode, std::string& errorMessage); // stop remote masternode
46+
bool StopMasterNode(CTxIn vin, CService service, CKey key, CPubKey pubKey, std::string& errorMessage); // stop any masternode
47+
48+
bool Register(std::string strService, std::string strKey, std::string txHash, std::string strOutputIndex, std::string& errorMessage); // register remote masternode
49+
bool Register(CTxIn vin, CService service, CKey key, CPubKey pubKey, CKey keyMasternode, CPubKey pubKeyMasternode, std::string &retErrorMessage); // register any masternode
50+
4451
// get 1000DRK input that can be used for the masternode
4552
bool GetMasterNodeVin(CTxIn& vin, CPubKey& pubkey, CKey& secretKey);
53+
bool GetMasterNodeVin(CTxIn& vin, CPubKey& pubkey, CKey& secretKey, std::string strTxHash, std::string strOutputIndex);
54+
vector<COutput> SelectCoinsMasternode();
55+
bool GetVinFromOutput(COutput out, CTxIn& vin, CPubKey& pubkey, CKey& secretKey);
4656

47-
// start the masternode and register with the network
48-
void RegisterAsMasterNode(bool stop);
49-
// start a remote masternode
50-
bool RegisterAsMasterNodeRemoteOnly(std::string strMasterNodeAddr, std::string strMasterNodePrivKey);
57+
//bool SelectCoinsMasternode(CTxIn& vin, int64& nValueIn, CScript& pubScript, std::string strTxHash, std::string strOutputIndex);
5158

5259
// enable hot wallet mode (run a masternode with no funds)
53-
bool EnableHotColdMasterNode(CTxIn& vin, int64 sigTime, CService& addr);
60+
bool EnableHotColdMasterNode(CTxIn& vin, CService& addr);
61+
5462
};
5563

56-
#endif
64+
#endif

src/darksend.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ void ProcessMessageDarksend(CNode* pfrom, std::string& strCommand, CDataStream&
109109
vRecv >> nDenom >> txCollateral;
110110

111111
std::string error = "";
112-
int mn = GetMasternodeByVin(activeMasternode.vinMasternode);
112+
int mn = GetMasternodeByVin(activeMasternode.vin);
113113
if(mn == -1){
114114
std::string strError = "Not in the masternode list";
115115
pfrom->PushMessage("dssu", darkSendPool.sessionID, darkSendPool.GetState(), darkSendPool.GetEntriesCount(), MASTERNODE_REJECTED, strError);
@@ -591,7 +591,7 @@ void CDarkSendPool::Check()
591591
if(!mapDarksendBroadcastTxes.count(txNew.GetHash())){
592592
CDarksendBroadcastTx dstx;
593593
dstx.tx = txNew;
594-
dstx.vin = activeMasternode.vinMasternode;
594+
dstx.vin = activeMasternode.vin;
595595
dstx.vchSig = vchSig;
596596
dstx.sigTime = sigTime;
597597

@@ -799,7 +799,7 @@ void CDarkSendPool::CheckTimeout(){
799799
if(state == POOL_STATUS_QUEUE && sessionUsers == GetMaxPoolTransactions()) {
800800
CDarksendQueue dsq;
801801
dsq.nDenom = sessionDenom;
802-
dsq.vin = activeMasternode.vinMasternode;
802+
dsq.vin = activeMasternode.vin;
803803
dsq.time = GetTime();
804804
dsq.ready = true;
805805
dsq.Sign();
@@ -1852,7 +1852,7 @@ bool CDarkSendPool::IsCompatibleWithSession(int64 nDenom, CTransaction txCollate
18521852
//broadcast that I'm accepting entries, only if it's the first entry though
18531853
CDarksendQueue dsq;
18541854
dsq.nDenom = nDenom;
1855-
dsq.vin = activeMasternode.vinMasternode;
1855+
dsq.vin = activeMasternode.vin;
18561856
dsq.time = GetTime();
18571857
dsq.Sign();
18581858
dsq.Relay();
@@ -2104,6 +2104,8 @@ void ThreadCheckDarkSendPool()
21042104
RenameThread("bitcoin-darksend");
21052105

21062106
unsigned int c = 0;
2107+
std::string errorMessage;
2108+
21072109
while (true)
21082110
{
21092111
c++;
@@ -2152,16 +2154,14 @@ void ThreadCheckDarkSendPool()
21522154
}
21532155
}
21542156

2155-
21562157
if(c % MASTERNODE_PING_SECONDS == 0){
2157-
activeMasternode.RegisterAsMasterNode(false);
2158+
activeMasternode.ManageStatus();
21582159
}
21592160

21602161
if(c % 60 == 0){
21612162
//if we've used 1/5 of the masternode list, then clear the list.
21622163
if((int)vecMasternodesUsed.size() > (int)darkSendMasterNodes.size() / 5)
21632164
vecMasternodesUsed.clear();
2164-
21652165
}
21662166

21672167
//auto denom every 2.5 minutes (liquidity provides try less often)

src/init.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "ui_interface.h"
1313
#include "checkpointsync.h"
1414
#include "activemasternode.h"
15+
#include "masternodeconfig.h"
1516

1617
#include <boost/filesystem.hpp>
1718
#include <boost/filesystem/fstream.hpp>
@@ -198,6 +199,10 @@ bool AppInit(int argc, char* argv[])
198199
return false;
199200
}
200201

202+
// Process masternode config
203+
masternodeConfig.read(GetMasternodeConfigFile());
204+
205+
201206
// Command-line RPC
202207
for (int i = 1; i < argc; i++)
203208
if (!IsSwitchChar(argv[i][0]) && !boost::algorithm::istarts_with(argv[i], "darkcoin:"))
@@ -384,7 +389,8 @@ std::string HelpMessage()
384389

385390
"\n" + _("Masternode options:") + "\n" +
386391
" -masternode=<n> " + _("Enable the client to act as a masternode (0-1, default: 0)") + "\n" +
387-
" -masternodeprivkey=<n> " + _("Set the masternode private key") + "\n" +
392+
" -mnconf=<file> " + _("Specify masternode configuration file (default: masternode.conf)") + "\n" +
393+
" -masternodeprivkey=<n> " + _("Set the masternode private key") + "\n" +
388394
" -masternodeaddr=<n> " + _("Set external address:port to get to this masternode (example: address:port)") + "\n" +
389395
" -masternodeminprotocol=<n> " + _("Ignore masternodes less than version (example: 70050; default : 0)") + "\n" +
390396

@@ -1232,7 +1238,7 @@ bool AppInit2(boost::thread_group& threadGroup)
12321238
return InitError(_("Invalid masternodeprivkey. Please see documenation."));
12331239
}
12341240

1235-
activeMasternode.pubkeyMasterNode2 = pubkey;
1241+
activeMasternode.pubKeyMasternode = pubkey;
12361242

12371243
} else {
12381244
return InitError(_("You must specify a masternodeprivkey in the configuration. Please see documentation for help."));

src/instantx.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ void DoConsensusVote(CTransaction& tx, bool approved, int64 nBlockHeight)
207207
}
208208

209209
int winner = GetCurrentMasterNode(1, nBlockHeight);
210-
int n = GetMasternodeRank(activeMasternode.vinMasternode, nBlockHeight, MIN_INSTANTX_PROTO_VERSION);
210+
int n = GetMasternodeRank(activeMasternode.vin, nBlockHeight, MIN_INSTANTX_PROTO_VERSION);
211211

212212
if(n == -1 || winner == -1)
213213
{
@@ -225,7 +225,7 @@ void DoConsensusVote(CTransaction& tx, bool approved, int64 nBlockHeight)
225225
}
226226

227227
CConsensusVote ctx;
228-
ctx.vinMasternode = activeMasternode.vinMasternode;
228+
ctx.vinMasternode = activeMasternode.vin;
229229
ctx.approved = approved;
230230
ctx.txHash = tx.GetHash();
231231
ctx.nBlockHeight = nBlockHeight;
@@ -274,7 +274,7 @@ void ProcessConsensusVote(CConsensusVote& ctx)
274274
}
275275

276276
//We're not the winning masternode
277-
if(darkSendMasterNodes[winner].vin != activeMasternode.vinMasternode) {
277+
if(darkSendMasterNodes[winner].vin != activeMasternode.vin) {
278278
LogPrintf("InstantX::ProcessConsensusVote - I'm not the winning masternode\n");
279279
return;
280280
}
@@ -453,4 +453,4 @@ void CTransactionLock::AddSignature(CConsensusVote cv)
453453
int CTransactionLock::CountSignatures()
454454
{
455455
return vecConsensusVotes.size();
456-
}
456+
}

src/makefile.linux-mingw

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ OBJS= \
7373
obj/core.o \
7474
obj/masternode.o \
7575
obj/activemasternode.o \
76+
obj/masternodeconfig.o \
7677
obj/instantx.o \
7778
obj/keystore.o \
7879
obj/darksend.o \

src/makefile.mingw

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ OBJS= \
8585
obj/core.o \
8686
obj/masternode.o \
8787
obj/activemasternode.o \
88+
obj/masternodeconfig.o \
8889
obj/instantx.o \
8990
obj/keystore.o \
9091
obj/main.o \

src/makefile.osx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ OBJS= \
9090
obj/core.o \
9191
obj/masternode.o \
9292
obj/activemasternode.o \
93+
obj/masternodeconfig.o \
9394
obj/instantx.o \
9495
obj/keystore.o \
9596
obj/main.o \

src/makefile.unix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ OBJS= \
127127
obj/init.o \
128128
obj/core.o \
129129
obj/masternode.o \
130+
obj/masternodeconfig.o \
130131
obj/activemasternode.o \
131132
obj/instantx.o \
132133
obj/keystore.o \

0 commit comments

Comments
 (0)