2016-12-20 14:26:45 +01:00
|
|
|
// Copyright (c) 2014-2017 The Dash Core developers
|
2016-02-02 16:28:56 +01:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
2015-02-09 21:54:51 +01:00
|
|
|
|
2017-04-12 09:04:06 +02:00
|
|
|
#include "chainparams.h"
|
2017-08-09 02:19:06 +02:00
|
|
|
#include "validation.h"
|
2017-04-12 09:04:06 +02:00
|
|
|
#include "messagesigner.h"
|
2017-08-09 02:19:06 +02:00
|
|
|
#include "net_processing.h"
|
2016-07-30 13:04:27 +02:00
|
|
|
#include "spork.h"
|
2015-02-09 21:54:51 +01:00
|
|
|
|
2016-07-30 13:04:27 +02:00
|
|
|
#include <boost/lexical_cast.hpp>
|
2015-02-09 21:54:51 +01:00
|
|
|
|
|
|
|
class CSporkMessage;
|
|
|
|
class CSporkManager;
|
|
|
|
|
2015-02-26 15:02:39 +01:00
|
|
|
CSporkManager sporkManager;
|
|
|
|
|
2015-02-09 21:54:51 +01:00
|
|
|
std::map<uint256, CSporkMessage> mapSporks;
|
|
|
|
|
2016-07-30 13:04:27 +02:00
|
|
|
void CSporkManager::ProcessSpork(CNode* pfrom, std::string& strCommand, CDataStream& vRecv)
|
2015-02-09 21:54:51 +01:00
|
|
|
{
|
2016-07-30 13:04:27 +02:00
|
|
|
if(fLiteMode) return; // disable all Dash specific functionality
|
2015-02-09 21:54:51 +01:00
|
|
|
|
2016-08-29 21:16:02 +02:00
|
|
|
if (strCommand == NetMsgType::SPORK) {
|
|
|
|
|
2015-02-09 21:54:51 +01:00
|
|
|
CSporkMessage spork;
|
|
|
|
vRecv >> spork;
|
|
|
|
|
|
|
|
uint256 hash = spork.GetHash();
|
2016-09-15 08:50:16 +02:00
|
|
|
|
|
|
|
std::string strLogMsg;
|
|
|
|
{
|
|
|
|
LOCK(cs_main);
|
2017-01-17 21:02:59 +01:00
|
|
|
pfrom->setAskFor.erase(hash);
|
2016-09-15 08:50:16 +02:00
|
|
|
if(!chainActive.Tip()) return;
|
|
|
|
strLogMsg = strprintf("SPORK -- hash: %s id: %d value: %10d bestHeight: %d peer=%d", hash.ToString(), spork.nSporkID, spork.nValue, chainActive.Height(), pfrom->id);
|
|
|
|
}
|
|
|
|
|
2015-04-07 17:17:50 +02:00
|
|
|
if(mapSporksActive.count(spork.nSporkID)) {
|
2016-08-29 21:16:02 +02:00
|
|
|
if (mapSporksActive[spork.nSporkID].nTimeSigned >= spork.nTimeSigned) {
|
2016-09-15 08:50:16 +02:00
|
|
|
LogPrint("spork", "%s seen\n", strLogMsg);
|
2015-02-09 21:54:51 +01:00
|
|
|
return;
|
|
|
|
} else {
|
2016-09-15 08:50:16 +02:00
|
|
|
LogPrintf("%s updated\n", strLogMsg);
|
2015-02-09 21:54:51 +01:00
|
|
|
}
|
2016-09-15 08:50:16 +02:00
|
|
|
} else {
|
|
|
|
LogPrintf("%s new\n", strLogMsg);
|
2015-02-09 21:54:51 +01:00
|
|
|
}
|
|
|
|
|
2016-08-29 21:16:02 +02:00
|
|
|
if(!spork.CheckSignature()) {
|
2016-07-30 13:04:27 +02:00
|
|
|
LogPrintf("CSporkManager::ProcessSpork -- invalid signature\n");
|
2015-02-09 21:54:51 +01:00
|
|
|
Misbehaving(pfrom->GetId(), 100);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-02-11 21:39:33 +01:00
|
|
|
mapSporks[hash] = spork;
|
2015-02-09 21:54:51 +01:00
|
|
|
mapSporksActive[spork.nSporkID] = spork;
|
2016-07-30 13:04:27 +02:00
|
|
|
spork.Relay();
|
2015-02-09 21:54:51 +01:00
|
|
|
|
2015-02-12 05:05:09 +01:00
|
|
|
//does a task if needed
|
|
|
|
ExecuteSpork(spork.nSporkID, spork.nValue);
|
2016-08-29 21:16:02 +02:00
|
|
|
|
|
|
|
} else if (strCommand == NetMsgType::GETSPORKS) {
|
|
|
|
|
2015-02-09 21:54:51 +01:00
|
|
|
std::map<int, CSporkMessage>::iterator it = mapSporksActive.begin();
|
|
|
|
|
|
|
|
while(it != mapSporksActive.end()) {
|
2017-07-27 16:28:05 +02:00
|
|
|
g_connman->PushMessage(pfrom, NetMsgType::SPORK, it->second);
|
2015-02-09 21:54:51 +01:00
|
|
|
it++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-07-30 13:04:27 +02:00
|
|
|
void CSporkManager::ExecuteSpork(int nSporkID, int nValue)
|
|
|
|
{
|
|
|
|
//correct fork via spork technology
|
|
|
|
if(nSporkID == SPORK_12_RECONSIDER_BLOCKS && nValue > 0) {
|
2017-02-04 01:42:04 +01:00
|
|
|
// allow to reprocess 24h of blocks max, which should be enough to resolve any issues
|
|
|
|
int64_t nMaxBlocks = 576;
|
|
|
|
// this potentially can be a heavy operation, so only allow this to be executed once per 10 minutes
|
|
|
|
int64_t nTimeout = 10 * 60;
|
|
|
|
|
|
|
|
static int64_t nTimeExecuted = 0; // i.e. it was never executed before
|
|
|
|
|
|
|
|
if(GetTime() - nTimeExecuted < nTimeout) {
|
|
|
|
LogPrint("spork", "CSporkManager::ExecuteSpork -- ERROR: Trying to reconsider blocks, too soon - %d/%d\n", GetTime() - nTimeExecuted, nTimeout);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(nValue > nMaxBlocks) {
|
|
|
|
LogPrintf("CSporkManager::ExecuteSpork -- ERROR: Trying to reconsider too many blocks %d/%d\n", nValue, nMaxBlocks);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-30 13:04:27 +02:00
|
|
|
LogPrintf("CSporkManager::ExecuteSpork -- Reconsider Last %d Blocks\n", nValue);
|
|
|
|
|
|
|
|
ReprocessBlocks(nValue);
|
2017-02-04 01:42:04 +01:00
|
|
|
nTimeExecuted = GetTime();
|
2016-07-30 13:04:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CSporkManager::UpdateSpork(int nSporkID, int64_t nValue)
|
|
|
|
{
|
|
|
|
|
2017-08-29 01:51:44 +02:00
|
|
|
CSporkMessage spork = CSporkMessage(nSporkID, nValue, GetAdjustedTime());
|
2016-07-30 13:04:27 +02:00
|
|
|
|
2016-08-29 21:16:02 +02:00
|
|
|
if(spork.Sign(strMasterPrivKey)) {
|
2016-07-30 13:04:27 +02:00
|
|
|
spork.Relay();
|
|
|
|
mapSporks[spork.GetHash()] = spork;
|
|
|
|
mapSporksActive[nSporkID] = spork;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-02-09 21:54:51 +01:00
|
|
|
// grab the spork, otherwise say it's off
|
2016-07-30 13:04:27 +02:00
|
|
|
bool CSporkManager::IsSporkActive(int nSporkID)
|
2015-02-09 21:54:51 +01:00
|
|
|
{
|
2015-06-25 21:59:11 +02:00
|
|
|
int64_t r = -1;
|
2015-02-09 21:54:51 +01:00
|
|
|
|
|
|
|
if(mapSporksActive.count(nSporkID)){
|
2015-02-11 15:47:21 +01:00
|
|
|
r = mapSporksActive[nSporkID].nValue;
|
2015-02-09 21:54:51 +01:00
|
|
|
} else {
|
2016-08-29 21:16:02 +02:00
|
|
|
switch (nSporkID) {
|
2016-09-01 16:55:25 +02:00
|
|
|
case SPORK_2_INSTANTSEND_ENABLED: r = SPORK_2_INSTANTSEND_ENABLED_DEFAULT; break;
|
|
|
|
case SPORK_3_INSTANTSEND_BLOCK_FILTERING: r = SPORK_3_INSTANTSEND_BLOCK_FILTERING_DEFAULT; break;
|
|
|
|
case SPORK_5_INSTANTSEND_MAX_VALUE: r = SPORK_5_INSTANTSEND_MAX_VALUE_DEFAULT; break;
|
2016-08-29 21:16:02 +02:00
|
|
|
case SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT: r = SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT_DEFAULT; break;
|
|
|
|
case SPORK_9_SUPERBLOCKS_ENABLED: r = SPORK_9_SUPERBLOCKS_ENABLED_DEFAULT; break;
|
|
|
|
case SPORK_10_MASTERNODE_PAY_UPDATED_NODES: r = SPORK_10_MASTERNODE_PAY_UPDATED_NODES_DEFAULT; break;
|
|
|
|
case SPORK_12_RECONSIDER_BLOCKS: r = SPORK_12_RECONSIDER_BLOCKS_DEFAULT; break;
|
|
|
|
case SPORK_13_OLD_SUPERBLOCK_FLAG: r = SPORK_13_OLD_SUPERBLOCK_FLAG_DEFAULT; break;
|
2016-11-23 16:30:36 +01:00
|
|
|
case SPORK_14_REQUIRE_SENTINEL_FLAG: r = SPORK_14_REQUIRE_SENTINEL_FLAG_DEFAULT; break;
|
2016-08-29 21:16:02 +02:00
|
|
|
default:
|
2016-09-15 08:50:16 +02:00
|
|
|
LogPrint("spork", "CSporkManager::IsSporkActive -- Unknown Spork ID %d\n", nSporkID);
|
2016-12-14 14:33:46 +01:00
|
|
|
r = 4070908800ULL; // 2099-1-1 i.e. off by default
|
2016-08-29 21:16:02 +02:00
|
|
|
break;
|
|
|
|
}
|
2015-02-09 21:54:51 +01:00
|
|
|
}
|
|
|
|
|
2017-08-29 01:51:44 +02:00
|
|
|
return r < GetAdjustedTime();
|
2015-02-09 21:54:51 +01:00
|
|
|
}
|
|
|
|
|
2015-02-11 15:47:21 +01:00
|
|
|
// grab the value of the spork on the network, or the default
|
2016-07-30 13:04:27 +02:00
|
|
|
int64_t CSporkManager::GetSporkValue(int nSporkID)
|
2015-02-11 15:47:21 +01:00
|
|
|
{
|
2016-08-29 21:16:02 +02:00
|
|
|
if (mapSporksActive.count(nSporkID))
|
|
|
|
return mapSporksActive[nSporkID].nValue;
|
|
|
|
|
|
|
|
switch (nSporkID) {
|
2016-09-01 16:55:25 +02:00
|
|
|
case SPORK_2_INSTANTSEND_ENABLED: return SPORK_2_INSTANTSEND_ENABLED_DEFAULT;
|
|
|
|
case SPORK_3_INSTANTSEND_BLOCK_FILTERING: return SPORK_3_INSTANTSEND_BLOCK_FILTERING_DEFAULT;
|
|
|
|
case SPORK_5_INSTANTSEND_MAX_VALUE: return SPORK_5_INSTANTSEND_MAX_VALUE_DEFAULT;
|
2016-08-29 21:16:02 +02:00
|
|
|
case SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT: return SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT_DEFAULT;
|
|
|
|
case SPORK_9_SUPERBLOCKS_ENABLED: return SPORK_9_SUPERBLOCKS_ENABLED_DEFAULT;
|
|
|
|
case SPORK_10_MASTERNODE_PAY_UPDATED_NODES: return SPORK_10_MASTERNODE_PAY_UPDATED_NODES_DEFAULT;
|
|
|
|
case SPORK_12_RECONSIDER_BLOCKS: return SPORK_12_RECONSIDER_BLOCKS_DEFAULT;
|
|
|
|
case SPORK_13_OLD_SUPERBLOCK_FLAG: return SPORK_13_OLD_SUPERBLOCK_FLAG_DEFAULT;
|
2016-11-23 16:30:36 +01:00
|
|
|
case SPORK_14_REQUIRE_SENTINEL_FLAG: return SPORK_14_REQUIRE_SENTINEL_FLAG_DEFAULT;
|
2016-08-29 21:16:02 +02:00
|
|
|
default:
|
2016-09-15 08:50:16 +02:00
|
|
|
LogPrint("spork", "CSporkManager::GetSporkValue -- Unknown Spork ID %d\n", nSporkID);
|
2016-08-29 21:16:02 +02:00
|
|
|
return -1;
|
2015-02-11 15:47:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-07-30 13:04:27 +02:00
|
|
|
int CSporkManager::GetSporkIDByName(std::string strName)
|
2015-02-12 05:05:09 +01:00
|
|
|
{
|
2016-09-01 16:55:25 +02:00
|
|
|
if (strName == "SPORK_2_INSTANTSEND_ENABLED") return SPORK_2_INSTANTSEND_ENABLED;
|
|
|
|
if (strName == "SPORK_3_INSTANTSEND_BLOCK_FILTERING") return SPORK_3_INSTANTSEND_BLOCK_FILTERING;
|
|
|
|
if (strName == "SPORK_5_INSTANTSEND_MAX_VALUE") return SPORK_5_INSTANTSEND_MAX_VALUE;
|
2016-08-29 21:16:02 +02:00
|
|
|
if (strName == "SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT") return SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT;
|
|
|
|
if (strName == "SPORK_9_SUPERBLOCKS_ENABLED") return SPORK_9_SUPERBLOCKS_ENABLED;
|
|
|
|
if (strName == "SPORK_10_MASTERNODE_PAY_UPDATED_NODES") return SPORK_10_MASTERNODE_PAY_UPDATED_NODES;
|
|
|
|
if (strName == "SPORK_12_RECONSIDER_BLOCKS") return SPORK_12_RECONSIDER_BLOCKS;
|
|
|
|
if (strName == "SPORK_13_OLD_SUPERBLOCK_FLAG") return SPORK_13_OLD_SUPERBLOCK_FLAG;
|
2016-11-23 16:30:36 +01:00
|
|
|
if (strName == "SPORK_14_REQUIRE_SENTINEL_FLAG") return SPORK_14_REQUIRE_SENTINEL_FLAG;
|
2016-08-29 21:16:02 +02:00
|
|
|
|
2016-09-15 08:50:16 +02:00
|
|
|
LogPrint("spork", "CSporkManager::GetSporkIDByName -- Unknown Spork name '%s'\n", strName);
|
2016-07-30 13:04:27 +02:00
|
|
|
return -1;
|
2015-08-03 01:08:37 +02:00
|
|
|
}
|
2015-08-02 23:59:28 +02:00
|
|
|
|
2016-07-30 13:04:27 +02:00
|
|
|
std::string CSporkManager::GetSporkNameByID(int nSporkID)
|
|
|
|
{
|
2016-08-29 21:16:02 +02:00
|
|
|
switch (nSporkID) {
|
2016-09-01 16:55:25 +02:00
|
|
|
case SPORK_2_INSTANTSEND_ENABLED: return "SPORK_2_INSTANTSEND_ENABLED";
|
|
|
|
case SPORK_3_INSTANTSEND_BLOCK_FILTERING: return "SPORK_3_INSTANTSEND_BLOCK_FILTERING";
|
|
|
|
case SPORK_5_INSTANTSEND_MAX_VALUE: return "SPORK_5_INSTANTSEND_MAX_VALUE";
|
|
|
|
case SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT: return "SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT";
|
2016-08-29 21:16:02 +02:00
|
|
|
case SPORK_9_SUPERBLOCKS_ENABLED: return "SPORK_9_SUPERBLOCKS_ENABLED";
|
2016-09-01 16:55:25 +02:00
|
|
|
case SPORK_10_MASTERNODE_PAY_UPDATED_NODES: return "SPORK_10_MASTERNODE_PAY_UPDATED_NODES";
|
|
|
|
case SPORK_12_RECONSIDER_BLOCKS: return "SPORK_12_RECONSIDER_BLOCKS";
|
2016-08-29 21:16:02 +02:00
|
|
|
case SPORK_13_OLD_SUPERBLOCK_FLAG: return "SPORK_13_OLD_SUPERBLOCK_FLAG";
|
2016-11-23 16:30:36 +01:00
|
|
|
case SPORK_14_REQUIRE_SENTINEL_FLAG: return "SPORK_14_REQUIRE_SENTINEL_FLAG";
|
2016-08-29 21:16:02 +02:00
|
|
|
default:
|
2016-09-15 08:50:16 +02:00
|
|
|
LogPrint("spork", "CSporkManager::GetSporkNameByID -- Unknown Spork ID %d\n", nSporkID);
|
2016-08-29 21:16:02 +02:00
|
|
|
return "Unknown";
|
|
|
|
}
|
2015-02-12 05:05:09 +01:00
|
|
|
}
|
|
|
|
|
2016-07-30 13:04:27 +02:00
|
|
|
bool CSporkManager::SetPrivKey(std::string strPrivKey)
|
2015-02-09 21:54:51 +01:00
|
|
|
{
|
2016-07-30 13:04:27 +02:00
|
|
|
CSporkMessage spork;
|
2015-02-09 21:54:51 +01:00
|
|
|
|
2016-09-30 00:19:00 +02:00
|
|
|
spork.Sign(strPrivKey);
|
2016-07-30 13:04:27 +02:00
|
|
|
|
|
|
|
if(spork.CheckSignature()){
|
|
|
|
// Test signing successful, proceed
|
|
|
|
LogPrintf("CSporkManager::SetPrivKey -- Successfully initialized as spork signer\n");
|
|
|
|
strMasterPrivKey = strPrivKey;
|
|
|
|
return true;
|
|
|
|
} else {
|
2015-02-09 21:54:51 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-30 13:04:27 +02:00
|
|
|
bool CSporkMessage::Sign(std::string strSignKey)
|
2015-02-09 21:54:51 +01:00
|
|
|
{
|
2016-07-30 13:04:27 +02:00
|
|
|
CKey key;
|
|
|
|
CPubKey pubkey;
|
2016-08-19 13:50:04 +02:00
|
|
|
std::string strError = "";
|
|
|
|
std::string strMessage = boost::lexical_cast<std::string>(nSporkID) + boost::lexical_cast<std::string>(nValue) + boost::lexical_cast<std::string>(nTimeSigned);
|
2015-02-09 21:54:51 +01:00
|
|
|
|
2017-04-12 09:04:06 +02:00
|
|
|
if(!CMessageSigner::GetKeysFromSecret(strSignKey, key, pubkey)) {
|
2016-08-19 13:50:04 +02:00
|
|
|
LogPrintf("CSporkMessage::Sign -- GetKeysFromSecret() failed, invalid spork key %s\n", strSignKey);
|
2015-02-09 21:54:51 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-04-12 09:04:06 +02:00
|
|
|
if(!CMessageSigner::SignMessage(strMessage, vchSig, key)) {
|
2016-08-19 13:50:04 +02:00
|
|
|
LogPrintf("CSporkMessage::Sign -- SignMessage() failed\n");
|
2015-02-09 21:54:51 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-04-12 09:04:06 +02:00
|
|
|
if(!CMessageSigner::VerifyMessage(pubkey, vchSig, strMessage, strError)) {
|
2016-08-19 13:50:04 +02:00
|
|
|
LogPrintf("CSporkMessage::Sign -- VerifyMessage() failed, error: %s\n", strError);
|
2015-02-09 21:54:51 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-07-30 13:04:27 +02:00
|
|
|
bool CSporkMessage::CheckSignature()
|
2015-02-09 21:54:51 +01:00
|
|
|
{
|
2016-07-30 13:04:27 +02:00
|
|
|
//note: need to investigate why this is failing
|
2016-08-19 13:50:04 +02:00
|
|
|
std::string strError = "";
|
2016-07-30 13:04:27 +02:00
|
|
|
std::string strMessage = boost::lexical_cast<std::string>(nSporkID) + boost::lexical_cast<std::string>(nValue) + boost::lexical_cast<std::string>(nTimeSigned);
|
|
|
|
CPubKey pubkey(ParseHex(Params().SporkPubKey()));
|
2015-02-09 21:54:51 +01:00
|
|
|
|
2017-04-12 09:04:06 +02:00
|
|
|
if(!CMessageSigner::VerifyMessage(pubkey, vchSig, strMessage, strError)) {
|
2016-08-19 13:50:04 +02:00
|
|
|
LogPrintf("CSporkMessage::CheckSignature -- VerifyMessage() failed, error: %s\n", strError);
|
2015-02-09 21:54:51 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-07-30 13:04:27 +02:00
|
|
|
return true;
|
2015-02-09 21:54:51 +01:00
|
|
|
}
|
|
|
|
|
2016-07-30 13:04:27 +02:00
|
|
|
void CSporkMessage::Relay()
|
2015-02-09 21:54:51 +01:00
|
|
|
{
|
2016-07-30 13:04:27 +02:00
|
|
|
CInv inv(MSG_SPORK, GetHash());
|
Backport Bitcoin PR#8085: p2p: Begin encapsulation (#1537)
* net: move CBanDB and CAddrDB out of net.h/cpp
This will eventually solve a circular dependency
* net: Create CConnman to encapsulate p2p connections
* net: Move socket binding into CConnman
* net: move OpenNetworkConnection into CConnman
* net: move ban and addrman functions into CConnman
* net: Add oneshot functions to CConnman
* net: move added node functions to CConnman
* net: Add most functions needed for vNodes to CConnman
* net: handle nodesignals in CConnman
* net: Pass CConnection to wallet rather than using the global
* net: Add rpc error for missing/disabled p2p functionality
* net: Pass CConnman around as needed
* gui: add NodeID to the peer table
* net: create generic functor accessors and move vNodes to CConnman
* net: move whitelist functions into CConnman
* net: move nLastNodeId to CConnman
* net: move nLocalHostNonce to CConnman
This behavior seems to have been quite racy and broken.
Move nLocalHostNonce into CNode, and check received nonces against all
non-fully-connected nodes. If there's a match, assume we've connected
to ourself.
* net: move messageHandlerCondition to CConnman
* net: move send/recv statistics to CConnman
* net: move SendBufferSize/ReceiveFloodSize to CConnman
* net: move nLocalServices/nRelevantServices to CConnman
These are in-turn passed to CNode at connection time. This allows us to offer
different services to different peers (or test the effects of doing so).
* net: move semOutbound and semMasternodeOutbound to CConnman
* net: SocketSendData returns written size
* net: move max/max-outbound to CConnman
* net: Pass best block known height into CConnman
CConnman then passes the current best height into CNode at creation time.
This way CConnman/CNode have no dependency on main for height, and the signals
only move in one direction.
This also helps to prevent identity leakage a tiny bit. Before this change, an
attacker could theoretically make 2 connections on different interfaces. They
would connect fully on one, and only establish the initial connection on the
other. Once they receive a new block, they would relay it to your first
connection, and immediately commence the version handshake on the second. Since
the new block height is reflected immediately, they could attempt to learn
whether the two connections were correlated.
This is, of course, incredibly unlikely to work due to the small timings
involved and receipt from other senders. But it doesn't hurt to lock-in
nBestHeight at the time of connection, rather than letting the remote choose
the time.
* net: pass CClientUIInterface into CConnman
* net: Drop StartNode/StopNode and use CConnman directly
* net: Introduce CConnection::Options to avoid passing so many params
* net: add nSendBufferMaxSize/nReceiveFloodSize to CConnection::Options
* net: move vNodesDisconnected into CConnman
* Made the ForEachNode* functions in src/net.cpp more pragmatic and self documenting
* Convert ForEachNode* functions to take a templated function argument rather than a std::function to eliminate std::function overhead
* net: move MAX_FEELER_CONNECTIONS into connman
2017-07-21 11:35:19 +02:00
|
|
|
g_connman->RelayInv(inv);
|
2015-04-03 00:51:08 +02:00
|
|
|
}
|