merge downstream 0.11.1

This commit is contained in:
vertoe 2015-02-07 16:22:17 +01:00
commit a2ae4c900e
10 changed files with 84 additions and 29 deletions

View File

@ -3,7 +3,7 @@ AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 0) define(_CLIENT_VERSION_MAJOR, 0)
define(_CLIENT_VERSION_MINOR, 11) define(_CLIENT_VERSION_MINOR, 11)
define(_CLIENT_VERSION_REVISION, 1) define(_CLIENT_VERSION_REVISION, 1)
define(_CLIENT_VERSION_BUILD, 11) define(_CLIENT_VERSION_BUILD, 13)
define(_CLIENT_VERSION_IS_RELEASE, true) define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2015) define(_COPYRIGHT_YEAR, 2015)
AC_INIT([Darkcoin Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[info@darkcoin.io],[darkcoin]) AC_INIT([Darkcoin Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[info@darkcoin.io],[darkcoin])

View File

@ -41,6 +41,15 @@ void CActiveMasternode::ManageStatus()
LogPrintf("CActiveMasternode::ManageStatus() - Checking inbound connection to '%s'\n", service.ToString().c_str()); LogPrintf("CActiveMasternode::ManageStatus() - Checking inbound connection to '%s'\n", service.ToString().c_str());
if(Params().NetworkID() == CChainParams::MAIN){
if(service.GetPort() != 9999) {
notCapableReason = "Invalid port: " + boost::lexical_cast<string>(service.GetPort()) + " -only 9999 is supported on mainnet.";
status = MASTERNODE_NOT_CAPABLE;
LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason.c_str());
return;
}
}
if(Params().NetworkID() != CChainParams::REGTEST){ if(Params().NetworkID() != CChainParams::REGTEST){
if(!ConnectNode((CAddress)service, service.ToString().c_str())){ if(!ConnectNode((CAddress)service, service.ToString().c_str())){
notCapableReason = "Could not connect to " + service.ToString(); notCapableReason = "Could not connect to " + service.ToString();

View File

@ -12,7 +12,7 @@
#define CLIENT_VERSION_MAJOR 0 #define CLIENT_VERSION_MAJOR 0
#define CLIENT_VERSION_MINOR 11 #define CLIENT_VERSION_MINOR 11
#define CLIENT_VERSION_REVISION 1 #define CLIENT_VERSION_REVISION 1
#define CLIENT_VERSION_BUILD 11 #define CLIENT_VERSION_BUILD 13

View File

@ -222,7 +222,7 @@ class CDarksendSession
class CDarkSendPool class CDarkSendPool
{ {
public: public:
static const int MIN_PEER_PROTO_VERSION = 70061; static const int MIN_PEER_PROTO_VERSION = 70063;
// clients entries // clients entries
std::vector<CDarkSendEntry> myEntries; std::vector<CDarkSendEntry> myEntries;

View File

@ -20,7 +20,7 @@ using namespace boost;
std::map<uint256, CTransaction> mapTxLockReq; std::map<uint256, CTransaction> mapTxLockReq;
std::map<uint256, CTransaction> mapTxLockReqRejected; std::map<uint256, CTransaction> mapTxLockReqRejected;
std::map<uint256, int> mapTxLockVote; std::map<uint256, CConsensusVote> mapTxLockVote;
std::map<uint256, CTransactionLock> mapTxLocks; std::map<uint256, CTransactionLock> mapTxLocks;
std::map<COutPoint, uint256> mapLockedInputs; std::map<COutPoint, uint256> mapLockedInputs;
std::map<uint256, int64_t> mapUnknownVotes; //track votes with no tx for DOS std::map<uint256, int64_t> mapUnknownVotes; //track votes with no tx for DOS
@ -70,7 +70,12 @@ void ProcessMessageInstantX(CNode* pfrom, std::string& strCommand, CDataStream&
if (AcceptToMemoryPool(mempool, state, tx, true, &fMissingInputs)) if (AcceptToMemoryPool(mempool, state, tx, true, &fMissingInputs))
{ {
RelayTransactionLockReq(tx, tx.GetHash()); vector<CInv> vInv;
vInv.push_back(inv);
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
pnode->PushMessage("inv", vInv);
DoConsensusVote(tx, nBlockHeight); DoConsensusVote(tx, nBlockHeight);
mapTxLockReq.insert(make_pair(tx.GetHash(), tx)); mapTxLockReq.insert(make_pair(tx.GetHash(), tx));
@ -87,8 +92,6 @@ void ProcessMessageInstantX(CNode* pfrom, std::string& strCommand, CDataStream&
// can we get the conflicting transaction as proof? // can we get the conflicting transaction as proof?
RelayTransactionLockReq(tx, inv.hash);
LogPrintf("ProcessMessageInstantX::txlreq - Transaction Lock Request: %s %s : rejected %s\n", LogPrintf("ProcessMessageInstantX::txlreq - Transaction Lock Request: %s %s : rejected %s\n",
pfrom->addr.ToString().c_str(), pfrom->cleanSubVer.c_str(), pfrom->addr.ToString().c_str(), pfrom->cleanSubVer.c_str(),
tx.GetHash().ToString().c_str() tx.GetHash().ToString().c_str()
@ -130,7 +133,7 @@ void ProcessMessageInstantX(CNode* pfrom, std::string& strCommand, CDataStream&
return; return;
} }
mapTxLockVote.insert(make_pair(ctx.GetHash(), 1)); mapTxLockVote.insert(make_pair(ctx.GetHash(), ctx));
if(ProcessConsensusVote(ctx)){ if(ProcessConsensusVote(ctx)){
//Spam/Dos protection //Spam/Dos protection
@ -155,15 +158,12 @@ void ProcessMessageInstantX(CNode* pfrom, std::string& strCommand, CDataStream&
mapUnknownVotes[ctx.vinMasternode.prevout.hash] = GetTime()+(60*10); mapUnknownVotes[ctx.vinMasternode.prevout.hash] = GetTime()+(60*10);
} }
} }
vector<CInv> vInv;
vInv.push_back(inv);
LOCK(cs_vNodes); LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes) BOOST_FOREACH(CNode* pnode, vNodes)
{ pnode->PushMessage("inv", vInv);
if(!pnode->fRelayTxes)
continue;
pnode->PushMessage("txlvote", ctx);
}
} }
return; return;
@ -253,20 +253,20 @@ void DoConsensusVote(CTransaction& tx, int64_t nBlockHeight)
if(n == -1) if(n == -1)
{ {
LogPrintf("InstantX::DoConsensusVote - Unknown Masternode\n"); if(fDebug) LogPrintf("InstantX::DoConsensusVote - Unknown Masternode\n");
return; return;
} }
if(n > INSTANTX_SIGNATURES_TOTAL) if(n > INSTANTX_SIGNATURES_TOTAL)
{ {
LogPrintf("InstantX::DoConsensusVote - Masternode not in the top %d (%d)\n", INSTANTX_SIGNATURES_TOTAL, n); if(fDebug) LogPrintf("InstantX::DoConsensusVote - Masternode not in the top %d (%d)\n", INSTANTX_SIGNATURES_TOTAL, n);
return; return;
} }
/* /*
nBlockHeight calculated from the transaction is the authoritive source nBlockHeight calculated from the transaction is the authoritive source
*/ */
LogPrintf("InstantX::DoConsensusVote - In the top %d (%d)\n", INSTANTX_SIGNATURES_TOTAL, n); if(fDebug) LogPrintf("InstantX::DoConsensusVote - In the top %d (%d)\n", INSTANTX_SIGNATURES_TOTAL, n);
CConsensusVote ctx; CConsensusVote ctx;
ctx.vinMasternode = activeMasternode.vin; ctx.vinMasternode = activeMasternode.vin;
@ -281,13 +281,17 @@ void DoConsensusVote(CTransaction& tx, int64_t nBlockHeight)
return; return;
} }
LOCK(cs_vNodes); mapTxLockVote[ctx.GetHash()] = ctx;
BOOST_FOREACH(CNode* pnode, vNodes)
{
//LogPrintf("%s::check -- %s %s\n", vecMasternodes[winner].addr.ToString().c_str(), pnode->addr.ToString().c_str());
pnode->PushMessage("txlvote", ctx); CInv inv(MSG_TXLOCK_VOTE, ctx.GetHash());
vector<CInv> vInv;
vInv.push_back(inv);
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes){
pnode->PushMessage("inv", vInv);
} }
} }
//received a consensus vote //received a consensus vote
@ -295,15 +299,21 @@ bool ProcessConsensusVote(CConsensusVote& ctx)
{ {
int n = GetMasternodeRank(ctx.vinMasternode, ctx.nBlockHeight, MIN_INSTANTX_PROTO_VERSION); int n = GetMasternodeRank(ctx.vinMasternode, ctx.nBlockHeight, MIN_INSTANTX_PROTO_VERSION);
int x = GetMasternodeByVin(ctx.vinMasternode);
if(x != -1){
if(fDebug) LogPrintf("InstantX::ProcessConsensusVote - Masternode ADDR %s %d\n", vecMasternodes[x].addr.ToString().c_str(), n);
}
if(n == -1) if(n == -1)
{ {
LogPrintf("InstantX::ProcessConsensusVote - Unknown Masternode\n"); //can be caused by past versions trying to vote with an invalid protocol
if(fDebug) LogPrintf("InstantX::ProcessConsensusVote - Unknown Masternode\n");
return false; return false;
} }
if(n > INSTANTX_SIGNATURES_TOTAL) if(n > INSTANTX_SIGNATURES_TOTAL)
{ {
LogPrintf("InstantX::ProcessConsensusVote - Masternode not in the top %d (%d)\n", INSTANTX_SIGNATURES_TOTAL, n); if(fDebug) LogPrintf("InstantX::ProcessConsensusVote - Masternode not in the top %d (%d) - %s\n", INSTANTX_SIGNATURES_TOTAL, n, ctx.GetHash().ToString().c_str());
return false; return false;
} }
@ -435,6 +445,9 @@ void CleanTransactionLocksList()
mapTxLockReq.erase(it->second.txHash); mapTxLockReq.erase(it->second.txHash);
mapTxLockReqRejected.erase(it->second.txHash); mapTxLockReqRejected.erase(it->second.txHash);
BOOST_FOREACH(CConsensusVote& v, it->second.vecConsensusVotes)
mapTxLockVote.erase(v.GetHash());
} }
mapTxLocks.erase(it++); mapTxLocks.erase(it++);
@ -549,7 +562,7 @@ bool CTransactionLock::SignaturesValid()
return true; return true;
} }
void CTransactionLock::AddSignature(CConsensusVote cv) void CTransactionLock::AddSignature(CConsensusVote& cv)
{ {
vecConsensusVotes.push_back(cv); vecConsensusVotes.push_back(cv);
} }

View File

@ -23,9 +23,11 @@ class CConsensusVote;
class CTransaction; class CTransaction;
class CTransactionLock; class CTransactionLock;
static const int MIN_INSTANTX_PROTO_VERSION = 70061; static const int MIN_INSTANTX_PROTO_VERSION = 70063;
extern map<uint256, CTransaction> mapTxLockReq; extern map<uint256, CTransaction> mapTxLockReq;
extern map<uint256, CTransaction> mapTxLockReqRejected;
extern map<uint256, CConsensusVote> mapTxLockVote;
extern map<uint256, CTransactionLock> mapTxLocks; extern map<uint256, CTransactionLock> mapTxLocks;
extern std::map<COutPoint, uint256> mapLockedInputs; extern std::map<COutPoint, uint256> mapLockedInputs;
extern int nCompleteTXLocks; extern int nCompleteTXLocks;
@ -84,7 +86,7 @@ public:
bool SignaturesValid(); bool SignaturesValid();
int CountSignatures(); int CountSignatures();
void AddSignature(CConsensusVote cv); void AddSignature(CConsensusVote& cv);
uint256 GetHash() uint256 GetHash()
{ {

View File

@ -3857,6 +3857,11 @@ bool static AlreadyHave(const CInv& inv)
case MSG_BLOCK: case MSG_BLOCK:
return mapBlockIndex.count(inv.hash) || return mapBlockIndex.count(inv.hash) ||
mapOrphanBlocks.count(inv.hash); mapOrphanBlocks.count(inv.hash);
case MSG_TXLOCK_REQUEST:
return mapTxLockReq.count(inv.hash) ||
mapTxLockReqRejected.count(inv.hash);
case MSG_TXLOCK_VOTE:
return mapTxLockVote.count(inv.hash);
} }
// Don't know what it is, just say we already got one // Don't know what it is, just say we already got one
return true; return true;
@ -3956,6 +3961,7 @@ void static ProcessGetData(CNode* pfrom)
pushed = true; pushed = true;
} }
} }
if (!pushed && inv.type == MSG_TX) { if (!pushed && inv.type == MSG_TX) {
if(mapDarksendBroadcastTxes.count(inv.hash)){ if(mapDarksendBroadcastTxes.count(inv.hash)){
@ -3980,6 +3986,25 @@ void static ProcessGetData(CNode* pfrom)
} }
} }
} }
if (!pushed && inv.type == MSG_TXLOCK_VOTE) {
if(mapTxLockVote.count(inv.hash)){
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
ss.reserve(1000);
ss << mapTxLockVote[inv.hash];
pfrom->PushMessage("txlvote", ss);
pushed = true;
}
}
if (!pushed && inv.type == MSG_TXLOCK_REQUEST) {
if(mapTxLockReq.count(inv.hash)){
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
ss.reserve(1000);
ss << mapTxLockReq[inv.hash];
pfrom->PushMessage("txlreq", ss);
pushed = true;
}
}
if (!pushed) { if (!pushed) {
vNotFound.push_back(inv); vNotFound.push_back(inv);
} }

View File

@ -105,6 +105,10 @@ void ProcessMessageMasternode(CNode* pfrom, std::string& strCommand, CDataStream
return; return;
} }
if(Params().NetworkID() == CChainParams::MAIN){
if(addr.GetPort() != 9999) return;
}
//search existing masternode list, this is where we update existing masternodes with new dsee broadcasts //search existing masternode list, this is where we update existing masternodes with new dsee broadcasts
BOOST_FOREACH(CMasterNode& mn, vecMasternodes) { BOOST_FOREACH(CMasterNode& mn, vecMasternodes) {

View File

@ -16,7 +16,9 @@ static const char* ppszTypeName[] =
"ERROR", "ERROR",
"tx", "tx",
"block", "block",
"filtered block" "filtered block",
"tx lock request",
"tx lock vote"
}; };
CMessageHeader::CMessageHeader() CMessageHeader::CMessageHeader()

View File

@ -27,7 +27,7 @@ extern const std::string CLIENT_DATE;
// network protocol versioning // network protocol versioning
// //
static const int PROTOCOL_VERSION = 70061; static const int PROTOCOL_VERSION = 70063;
// intial proto version, to be increased after version/verack negotiation // intial proto version, to be increased after version/verack negotiation
static const int INIT_PROTO_VERSION = 209; static const int INIT_PROTO_VERSION = 209;