Rename fAddnode to a more-descriptive "manual_connection"

This commit is contained in:
Matt Corallo 2017-10-05 11:49:16 -04:00
parent 44407100ff
commit 57edc0b0c8
4 changed files with 14 additions and 14 deletions

View File

@ -684,7 +684,7 @@ void CNode::copyStats(CNodeStats &stats)
X(cleanSubVer); X(cleanSubVer);
} }
X(fInbound); X(fInbound);
X(fAddnode); X(m_manual_connection);
X(nStartingHeight); X(nStartingHeight);
{ {
LOCK(cs_vSend); LOCK(cs_vSend);
@ -1756,7 +1756,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
{ {
LOCK(cs_vNodes); LOCK(cs_vNodes);
for (CNode* pnode : vNodes) { for (CNode* pnode : vNodes) {
if (!pnode->fInbound && !pnode->fAddnode) { if (!pnode->fInbound && !pnode->m_manual_connection) {
// Netgroups for inbound and addnode peers are not excluded because our goal here // Netgroups for inbound and addnode peers are not excluded because our goal here
// is to not use multiple of our limited outbound slots on a single netgroup // is to not use multiple of our limited outbound slots on a single netgroup
// but inbound and addnode peers do not use our outbound slots. Inbound peers // but inbound and addnode peers do not use our outbound slots. Inbound peers
@ -1927,7 +1927,7 @@ void CConnman::ThreadOpenAddedConnections()
} }
// if successful, this moves the passed grant to the constructed node // if successful, this moves the passed grant to the constructed node
bool CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound, const char *pszDest, bool fOneShot, bool fFeeler, bool fAddnode) bool CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound, const char *pszDest, bool fOneShot, bool fFeeler, bool manual_connection)
{ {
// //
// Initiate outbound network connection // Initiate outbound network connection
@ -1956,8 +1956,8 @@ bool CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFai
pnode->fOneShot = true; pnode->fOneShot = true;
if (fFeeler) if (fFeeler)
pnode->fFeeler = true; pnode->fFeeler = true;
if (fAddnode) if (manual_connection)
pnode->fAddnode = true; pnode->m_manual_connection = true;
m_msgproc->InitializeNode(pnode); m_msgproc->InitializeNode(pnode);
{ {
@ -2705,7 +2705,7 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn
strSubVer = ""; strSubVer = "";
fWhitelisted = false; fWhitelisted = false;
fOneShot = false; fOneShot = false;
fAddnode = false; m_manual_connection = false;
fClient = false; // set by version message fClient = false; // set by version message
fFeeler = false; fFeeler = false;
fSuccessfullyConnected = false; fSuccessfullyConnected = false;

View File

@ -171,7 +171,7 @@ public:
void Interrupt(); void Interrupt();
bool GetNetworkActive() const { return fNetworkActive; }; bool GetNetworkActive() const { return fNetworkActive; };
void SetNetworkActive(bool active); void SetNetworkActive(bool active);
bool OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound = nullptr, const char *strDest = nullptr, bool fOneShot = false, bool fFeeler = false, bool fAddnode = false); bool OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound = nullptr, const char *strDest = nullptr, bool fOneShot = false, bool fFeeler = false, bool manual_connection = false);
bool CheckIncomingNonce(uint64_t nonce); bool CheckIncomingNonce(uint64_t nonce);
bool ForNode(NodeId id, std::function<bool(CNode* pnode)> func); bool ForNode(NodeId id, std::function<bool(CNode* pnode)> func);
@ -506,7 +506,7 @@ public:
int nVersion; int nVersion;
std::string cleanSubVer; std::string cleanSubVer;
bool fInbound; bool fInbound;
bool fAddnode; bool m_manual_connection;
int nStartingHeight; int nStartingHeight;
uint64_t nSendBytes; uint64_t nSendBytes;
mapMsgCmdSize mapSendBytesPerMsgCmd; mapMsgCmdSize mapSendBytesPerMsgCmd;
@ -615,7 +615,7 @@ public:
bool fWhitelisted; // This peer can bypass DoS banning. bool fWhitelisted; // This peer can bypass DoS banning.
bool fFeeler; // If true this node is being used as a short lived feeler. bool fFeeler; // If true this node is being used as a short lived feeler.
bool fOneShot; bool fOneShot;
bool fAddnode; bool m_manual_connection;
bool fClient; bool fClient;
const bool fInbound; const bool fInbound;
std::atomic_bool fSuccessfullyConnected; std::atomic_bool fSuccessfullyConnected;

View File

@ -1232,7 +1232,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
{ {
connman->SetServices(pfrom->addr, nServices); connman->SetServices(pfrom->addr, nServices);
} }
if (!pfrom->fInbound && !pfrom->fFeeler && !pfrom->fAddnode && !HasAllDesirableServiceFlags(nServices)) if (!pfrom->fInbound && !pfrom->fFeeler && !pfrom->m_manual_connection && !HasAllDesirableServiceFlags(nServices))
{ {
LogPrint(BCLog::NET, "peer=%d does not offer the expected services (%08x offered, %08x expected); disconnecting\n", pfrom->GetId(), nServices, GetDesirableServiceFlags(nServices)); LogPrint(BCLog::NET, "peer=%d does not offer the expected services (%08x offered, %08x expected); disconnecting\n", pfrom->GetId(), nServices, GetDesirableServiceFlags(nServices));
connman->PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_NONSTANDARD, connman->PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_NONSTANDARD,
@ -2628,8 +2628,8 @@ static bool SendRejectsAndCheckIfBanned(CNode* pnode, CConnman* connman)
state.fShouldBan = false; state.fShouldBan = false;
if (pnode->fWhitelisted) if (pnode->fWhitelisted)
LogPrintf("Warning: not punishing whitelisted peer %s!\n", pnode->addr.ToString()); LogPrintf("Warning: not punishing whitelisted peer %s!\n", pnode->addr.ToString());
else if (pnode->fAddnode) else if (pnode->m_manual_connection)
LogPrintf("Warning: not punishing addnoded peer %s!\n", pnode->addr.ToString()); LogPrintf("Warning: not punishing manually-connected peer %s!\n", pnode->addr.ToString());
else { else {
pnode->fDisconnect = true; pnode->fDisconnect = true;
if (pnode->addr.IsLocal()) if (pnode->addr.IsLocal())

View File

@ -92,7 +92,7 @@ UniValue getpeerinfo(const JSONRPCRequest& request)
" \"version\": v, (numeric) The peer version, such as 7001\n" " \"version\": v, (numeric) The peer version, such as 7001\n"
" \"subver\": \"/Satoshi:0.8.5/\", (string) The string version\n" " \"subver\": \"/Satoshi:0.8.5/\", (string) The string version\n"
" \"inbound\": true|false, (boolean) Inbound (true) or Outbound (false)\n" " \"inbound\": true|false, (boolean) Inbound (true) or Outbound (false)\n"
" \"addnode\": true|false, (boolean) Whether connection was due to addnode and is using an addnode slot\n" " \"addnode\": true|false, (boolean) Whether connection was due to addnode/-connect or if it was an automatic/inbound connection\n"
" \"startingheight\": n, (numeric) The starting height (block) of the peer\n" " \"startingheight\": n, (numeric) The starting height (block) of the peer\n"
" \"banscore\": n, (numeric) The ban score\n" " \"banscore\": n, (numeric) The ban score\n"
" \"synced_headers\": n, (numeric) The last header we have in common with this peer\n" " \"synced_headers\": n, (numeric) The last header we have in common with this peer\n"
@ -156,7 +156,7 @@ UniValue getpeerinfo(const JSONRPCRequest& request)
// their ver message. // their ver message.
obj.push_back(Pair("subver", stats.cleanSubVer)); obj.push_back(Pair("subver", stats.cleanSubVer));
obj.push_back(Pair("inbound", stats.fInbound)); obj.push_back(Pair("inbound", stats.fInbound));
obj.push_back(Pair("addnode", stats.fAddnode)); obj.push_back(Pair("addnode", stats.m_manual_connection));
obj.push_back(Pair("startingheight", stats.nStartingHeight)); obj.push_back(Pair("startingheight", stats.nStartingHeight));
if (fStateStats) { if (fStateStats) {
obj.push_back(Pair("banscore", statestats.nMisbehavior)); obj.push_back(Pair("banscore", statestats.nMisbehavior));