Changeset View
Changeset View
Standalone View
Standalone View
src/net.h
Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | |||||
/** -listen default */ | /** -listen default */ | ||||
static const bool DEFAULT_LISTEN = true; | static const bool DEFAULT_LISTEN = true; | ||||
/** -upnp default */ | /** -upnp default */ | ||||
#ifdef USE_UPNP | #ifdef USE_UPNP | ||||
static const bool DEFAULT_UPNP = USE_UPNP; | static const bool DEFAULT_UPNP = USE_UPNP; | ||||
#else | #else | ||||
static const bool DEFAULT_UPNP = false; | static const bool DEFAULT_UPNP = false; | ||||
#endif | #endif | ||||
/** The maximum number of entries in mapAskFor */ | |||||
static const size_t MAPASKFOR_MAX_SZ = MAX_INV_SZ; | |||||
/** The maximum number of entries in setAskFor (larger due to getdata latency)*/ | |||||
static const size_t SETASKFOR_MAX_SZ = 2 * MAX_INV_SZ; | |||||
/** The maximum number of peer connections to maintain. */ | /** The maximum number of peer connections to maintain. */ | ||||
static const unsigned int DEFAULT_MAX_PEER_CONNECTIONS = 125; | static const unsigned int DEFAULT_MAX_PEER_CONNECTIONS = 125; | ||||
/** The default for -maxuploadtarget. 0 = Unlimited */ | /** The default for -maxuploadtarget. 0 = Unlimited */ | ||||
static const uint64_t DEFAULT_MAX_UPLOAD_TARGET = 0; | static const uint64_t DEFAULT_MAX_UPLOAD_TARGET = 0; | ||||
/** The default timeframe for -maxuploadtarget. 1 day. */ | /** The default timeframe for -maxuploadtarget. 1 day. */ | ||||
static const uint64_t MAX_UPLOAD_TIMEFRAME = 60 * 60 * 24; | static const uint64_t MAX_UPLOAD_TIMEFRAME = 60 * 60 * 24; | ||||
/** Default for blocks only*/ | /** Default for blocks only*/ | ||||
static const bool DEFAULT_BLOCKSONLY = false; | static const bool DEFAULT_BLOCKSONLY = false; | ||||
▲ Show 20 Lines • Show All 403 Lines • ▼ Show 20 Lines | |||||
bool IsReachable(const CNetAddr &addr); | bool IsReachable(const CNetAddr &addr); | ||||
CAddress GetLocalAddress(const CNetAddr *paddrPeer, | CAddress GetLocalAddress(const CNetAddr *paddrPeer, | ||||
ServiceFlags nLocalServices); | ServiceFlags nLocalServices); | ||||
extern bool fDiscover; | extern bool fDiscover; | ||||
extern bool fListen; | extern bool fListen; | ||||
extern bool fRelayTxes; | extern bool fRelayTxes; | ||||
extern limitedmap<uint256, int64_t> mapAlreadyAskedFor; | |||||
struct LocalServiceInfo { | struct LocalServiceInfo { | ||||
int nScore; | int nScore; | ||||
int nPort; | int nPort; | ||||
}; | }; | ||||
extern CCriticalSection cs_mapLocalHost; | extern CCriticalSection cs_mapLocalHost; | ||||
extern std::map<CNetAddr, LocalServiceInfo> | extern std::map<CNetAddr, LocalServiceInfo> | ||||
mapLocalHost GUARDED_BY(cs_mapLocalHost); | mapLocalHost GUARDED_BY(cs_mapLocalHost); | ||||
▲ Show 20 Lines • Show All 185 Lines • ▼ Show 20 Lines | public: | ||||
// Set of transaction ids we still have to announce. They are sorted by the | // Set of transaction ids we still have to announce. They are sorted by the | ||||
// mempool before relay, so the order is not important. | // mempool before relay, so the order is not important. | ||||
std::set<uint256> setInventoryTxToSend; | std::set<uint256> setInventoryTxToSend; | ||||
// List of block ids we still have announce. There is no final sorting | // List of block ids we still have announce. There is no final sorting | ||||
// before sending, as they are always sent immediately and in the order | // before sending, as they are always sent immediately and in the order | ||||
// requested. | // requested. | ||||
std::vector<uint256> vInventoryBlockToSend GUARDED_BY(cs_inventory); | std::vector<uint256> vInventoryBlockToSend GUARDED_BY(cs_inventory); | ||||
CCriticalSection cs_inventory; | CCriticalSection cs_inventory; | ||||
std::set<uint256> setAskFor; | |||||
std::multimap<int64_t, CInv> mapAskFor; | |||||
int64_t nNextInvSend{0}; | int64_t nNextInvSend{0}; | ||||
// Used for headers announcements - unfiltered blocks to relay. | // Used for headers announcements - unfiltered blocks to relay. | ||||
std::vector<uint256> vBlockHashesToAnnounce GUARDED_BY(cs_inventory); | std::vector<uint256> vBlockHashesToAnnounce GUARDED_BY(cs_inventory); | ||||
// Used for BIP35 mempool sending. | // Used for BIP35 mempool sending. | ||||
bool fSendMempool GUARDED_BY(cs_inventory){false}; | bool fSendMempool GUARDED_BY(cs_inventory){false}; | ||||
// Last time a "MEMPOOL" request was serviced. | // Last time a "MEMPOOL" request was serviced. | ||||
std::atomic<int64_t> timeLastMempoolReq{0}; | std::atomic<int64_t> timeLastMempoolReq{0}; | ||||
▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | void PushInventory(const CInv &inv) { | ||||
} | } | ||||
} | } | ||||
void PushBlockHash(const uint256 &hash) { | void PushBlockHash(const uint256 &hash) { | ||||
LOCK(cs_inventory); | LOCK(cs_inventory); | ||||
vBlockHashesToAnnounce.push_back(hash); | vBlockHashesToAnnounce.push_back(hash); | ||||
} | } | ||||
void AskFor(const CInv &inv); | |||||
void CloseSocketDisconnect(); | void CloseSocketDisconnect(); | ||||
void copyStats(CNodeStats &stats); | void copyStats(CNodeStats &stats); | ||||
ServiceFlags GetLocalServices() const { return nLocalServices; } | ServiceFlags GetLocalServices() const { return nLocalServices; } | ||||
std::string GetAddrName() const; | std::string GetAddrName() const; | ||||
//! Sets the addrName only if it was not previously set | //! Sets the addrName only if it was not previously set | ||||
Show All 12 Lines |