aboutsummaryrefslogtreecommitdiff
path: root/src/net.h
diff options
context:
space:
mode:
authorCory Fields <cory-nospam-@coryfields.com>2016-04-19 00:04:58 -0400
committerCory Fields <cory-nospam-@coryfields.com>2016-09-08 12:24:06 -0400
commitbd72937dc462b86f0e84184b270a232f7bfaa8db (patch)
tree7d36243302d3001bb36b9fdb27e8642568e814ac /src/net.h
parentbe9c796dc51c05cab0b84d2e66c928973c6e5ed6 (diff)
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).
Diffstat (limited to 'src/net.h')
-rw-r--r--src/net.h24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/net.h b/src/net.h
index e5fbf65492..25e473c5fc 100644
--- a/src/net.h
+++ b/src/net.h
@@ -107,7 +107,7 @@ public:
CConnman();
~CConnman();
- bool Start(boost::thread_group& threadGroup, CScheduler& scheduler, std::string& strNodeError);
+ bool Start(boost::thread_group& threadGroup, CScheduler& scheduler, ServiceFlags nLocalServicesIn, ServiceFlags nRelevantServicesIn, std::string& strNodeError);
void Stop();
bool BindListenPort(const CService &bindAddr, std::string& strError, bool fWhitelisted = false);
bool OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound = NULL, const char *strDest = NULL, bool fOneShot = false, bool fFeeler = false);
@@ -171,6 +171,8 @@ public:
void AddWhitelistedRange(const CSubNet &subnet);
+ ServiceFlags GetLocalServices() const;
+
//!set the max outbound target in bytes
void SetMaxOutboundTarget(uint64_t limit);
uint64_t GetMaxOutboundTarget();
@@ -274,12 +276,18 @@ private:
mutable CCriticalSection cs_vNodes;
std::atomic<NodeId> nLastNodeId;
boost::condition_variable messageHandlerCondition;
+
+ /** Services this instance offers */
+ ServiceFlags nLocalServices;
+
+ /** Services this instance cares about */
+ ServiceFlags nRelevantServices;
};
extern std::unique_ptr<CConnman> g_connman;
void MapPort(bool fUseUPnP);
unsigned short GetListenPort();
bool BindListenPort(const CService &bindAddr, std::string& strError, bool fWhitelisted = false);
-bool StartNode(CConnman& connman, boost::thread_group& threadGroup, CScheduler& scheduler, std::string& strNodeError);
+bool StartNode(CConnman& connman, boost::thread_group& threadGroup, CScheduler& scheduler, ServiceFlags nLocalServices, ServiceFlags nRelevantServices, std::string& strNodeError);
bool StopNode(CConnman& connman);
size_t SocketSendData(CNode *pnode);
@@ -336,13 +344,11 @@ bool IsLocal(const CService& addr);
bool GetLocal(CService &addr, const CNetAddr *paddrPeer = NULL);
bool IsReachable(enum Network net);
bool IsReachable(const CNetAddr &addr);
-CAddress GetLocalAddress(const CNetAddr *paddrPeer = NULL);
+CAddress GetLocalAddress(const CNetAddr *paddrPeer, ServiceFlags nLocalServices);
extern bool fDiscover;
extern bool fListen;
-extern ServiceFlags nLocalServices;
-extern ServiceFlags nRelevantServices;
extern bool fRelayTxes;
/** Maximum number of connections to simultaneously allow (aka connection slots) */
@@ -549,7 +555,7 @@ public:
CAmount lastSentFeeFilter;
int64_t nextSendTimeFeeFilter;
- CNode(NodeId id, SOCKET hSocketIn, const CAddress &addrIn, const std::string &addrNameIn = "", bool fInboundIn = false);
+ CNode(NodeId id, ServiceFlags nLocalServicesIn, SOCKET hSocketIn, const CAddress &addrIn, const std::string &addrNameIn = "", bool fInboundIn = false);
~CNode();
private:
@@ -559,6 +565,7 @@ private:
static uint64_t CalculateKeyedNetGroup(const CAddress& ad);
uint64_t nLocalHostNonce;
+ ServiceFlags nLocalServices;
public:
NodeId GetId() const {
@@ -846,6 +853,11 @@ public:
void CloseSocketDisconnect();
void copyStats(CNodeStats &stats);
+
+ ServiceFlags GetLocalServices() const
+ {
+ return nLocalServices;
+ }
};