mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-13 07:28:59 +01:00
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).
This commit is contained in:
24
src/net.h
24
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;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user