mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
refactor: Mark member functions const
This commit is contained in:
parent
0dd7b23489
commit
faabeb854a
4 changed files with 34 additions and 34 deletions
28
src/net.cpp
28
src/net.cpp
|
@ -1732,7 +1732,7 @@ void CConnman::ProcessAddrFetch()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CConnman::GetTryNewOutboundPeer()
|
bool CConnman::GetTryNewOutboundPeer() const
|
||||||
{
|
{
|
||||||
return m_try_another_outbound_peer;
|
return m_try_another_outbound_peer;
|
||||||
}
|
}
|
||||||
|
@ -1749,7 +1749,7 @@ void CConnman::SetTryNewOutboundPeer(bool flag)
|
||||||
// Also exclude peers that haven't finished initial connection handshake yet
|
// Also exclude peers that haven't finished initial connection handshake yet
|
||||||
// (so that we don't decide we're over our desired connection limit, and then
|
// (so that we don't decide we're over our desired connection limit, and then
|
||||||
// evict some peer that has finished the handshake)
|
// evict some peer that has finished the handshake)
|
||||||
int CConnman::GetExtraFullOutboundCount()
|
int CConnman::GetExtraFullOutboundCount() const
|
||||||
{
|
{
|
||||||
int full_outbound_peers = 0;
|
int full_outbound_peers = 0;
|
||||||
{
|
{
|
||||||
|
@ -1763,7 +1763,7 @@ int CConnman::GetExtraFullOutboundCount()
|
||||||
return std::max(full_outbound_peers - m_max_outbound_full_relay, 0);
|
return std::max(full_outbound_peers - m_max_outbound_full_relay, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CConnman::GetExtraBlockRelayCount()
|
int CConnman::GetExtraBlockRelayCount() const
|
||||||
{
|
{
|
||||||
int block_relay_peers = 0;
|
int block_relay_peers = 0;
|
||||||
{
|
{
|
||||||
|
@ -2061,7 +2061,7 @@ std::vector<CAddress> CConnman::GetCurrentBlockRelayOnlyConns() const
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<AddedNodeInfo> CConnman::GetAddedNodeInfo()
|
std::vector<AddedNodeInfo> CConnman::GetAddedNodeInfo() const
|
||||||
{
|
{
|
||||||
std::vector<AddedNodeInfo> ret;
|
std::vector<AddedNodeInfo> ret;
|
||||||
|
|
||||||
|
@ -2671,7 +2671,7 @@ CConnman::~CConnman()
|
||||||
Stop();
|
Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<CAddress> CConnman::GetAddresses(size_t max_addresses, size_t max_pct)
|
std::vector<CAddress> CConnman::GetAddresses(size_t max_addresses, size_t max_pct) const
|
||||||
{
|
{
|
||||||
std::vector<CAddress> addresses = addrman.GetAddr(max_addresses, max_pct);
|
std::vector<CAddress> addresses = addrman.GetAddr(max_addresses, max_pct);
|
||||||
if (m_banman) {
|
if (m_banman) {
|
||||||
|
@ -2746,7 +2746,7 @@ bool CConnman::RemoveAddedNode(const std::string& strNode)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t CConnman::GetNodeCount(ConnectionDirection flags)
|
size_t CConnman::GetNodeCount(ConnectionDirection flags) const
|
||||||
{
|
{
|
||||||
LOCK(cs_vNodes);
|
LOCK(cs_vNodes);
|
||||||
if (flags == ConnectionDirection::Both) // Shortcut if we want total
|
if (flags == ConnectionDirection::Both) // Shortcut if we want total
|
||||||
|
@ -2762,7 +2762,7 @@ size_t CConnman::GetNodeCount(ConnectionDirection flags)
|
||||||
return nNum;
|
return nNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConnman::GetNodeStats(std::vector<CNodeStats>& vstats)
|
void CConnman::GetNodeStats(std::vector<CNodeStats>& vstats) const
|
||||||
{
|
{
|
||||||
vstats.clear();
|
vstats.clear();
|
||||||
LOCK(cs_vNodes);
|
LOCK(cs_vNodes);
|
||||||
|
@ -2839,18 +2839,18 @@ void CConnman::RecordBytesSent(uint64_t bytes)
|
||||||
nMaxOutboundTotalBytesSentInCycle += bytes;
|
nMaxOutboundTotalBytesSentInCycle += bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t CConnman::GetMaxOutboundTarget()
|
uint64_t CConnman::GetMaxOutboundTarget() const
|
||||||
{
|
{
|
||||||
LOCK(cs_totalBytesSent);
|
LOCK(cs_totalBytesSent);
|
||||||
return nMaxOutboundLimit;
|
return nMaxOutboundLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::chrono::seconds CConnman::GetMaxOutboundTimeframe()
|
std::chrono::seconds CConnman::GetMaxOutboundTimeframe() const
|
||||||
{
|
{
|
||||||
return MAX_UPLOAD_TIMEFRAME;
|
return MAX_UPLOAD_TIMEFRAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::chrono::seconds CConnman::GetMaxOutboundTimeLeftInCycle()
|
std::chrono::seconds CConnman::GetMaxOutboundTimeLeftInCycle() const
|
||||||
{
|
{
|
||||||
LOCK(cs_totalBytesSent);
|
LOCK(cs_totalBytesSent);
|
||||||
if (nMaxOutboundLimit == 0)
|
if (nMaxOutboundLimit == 0)
|
||||||
|
@ -2864,7 +2864,7 @@ std::chrono::seconds CConnman::GetMaxOutboundTimeLeftInCycle()
|
||||||
return (cycleEndTime < now) ? 0s : cycleEndTime - now;
|
return (cycleEndTime < now) ? 0s : cycleEndTime - now;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CConnman::OutboundTargetReached(bool historicalBlockServingLimit)
|
bool CConnman::OutboundTargetReached(bool historicalBlockServingLimit) const
|
||||||
{
|
{
|
||||||
LOCK(cs_totalBytesSent);
|
LOCK(cs_totalBytesSent);
|
||||||
if (nMaxOutboundLimit == 0)
|
if (nMaxOutboundLimit == 0)
|
||||||
|
@ -2884,7 +2884,7 @@ bool CConnman::OutboundTargetReached(bool historicalBlockServingLimit)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t CConnman::GetOutboundTargetBytesLeft()
|
uint64_t CConnman::GetOutboundTargetBytesLeft() const
|
||||||
{
|
{
|
||||||
LOCK(cs_totalBytesSent);
|
LOCK(cs_totalBytesSent);
|
||||||
if (nMaxOutboundLimit == 0)
|
if (nMaxOutboundLimit == 0)
|
||||||
|
@ -2893,13 +2893,13 @@ uint64_t CConnman::GetOutboundTargetBytesLeft()
|
||||||
return (nMaxOutboundTotalBytesSentInCycle >= nMaxOutboundLimit) ? 0 : nMaxOutboundLimit - nMaxOutboundTotalBytesSentInCycle;
|
return (nMaxOutboundTotalBytesSentInCycle >= nMaxOutboundLimit) ? 0 : nMaxOutboundLimit - nMaxOutboundTotalBytesSentInCycle;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t CConnman::GetTotalBytesRecv()
|
uint64_t CConnman::GetTotalBytesRecv() const
|
||||||
{
|
{
|
||||||
LOCK(cs_totalBytesRecv);
|
LOCK(cs_totalBytesRecv);
|
||||||
return nTotalBytesRecv;
|
return nTotalBytesRecv;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t CConnman::GetTotalBytesSent()
|
uint64_t CConnman::GetTotalBytesSent() const
|
||||||
{
|
{
|
||||||
LOCK(cs_totalBytesSent);
|
LOCK(cs_totalBytesSent);
|
||||||
return nTotalBytesSent;
|
return nTotalBytesSent;
|
||||||
|
|
34
src/net.h
34
src/net.h
|
@ -923,7 +923,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// Addrman functions
|
// Addrman functions
|
||||||
std::vector<CAddress> GetAddresses(size_t max_addresses, size_t max_pct);
|
std::vector<CAddress> GetAddresses(size_t max_addresses, size_t max_pct) const;
|
||||||
/**
|
/**
|
||||||
* Cache is used to minimize topology leaks, so it should
|
* Cache is used to minimize topology leaks, so it should
|
||||||
* be used for all non-trusted calls, for example, p2p.
|
* be used for all non-trusted calls, for example, p2p.
|
||||||
|
@ -935,7 +935,7 @@ public:
|
||||||
// This allows temporarily exceeding m_max_outbound_full_relay, with the goal of finding
|
// This allows temporarily exceeding m_max_outbound_full_relay, with the goal of finding
|
||||||
// a peer that is better than all our current peers.
|
// a peer that is better than all our current peers.
|
||||||
void SetTryNewOutboundPeer(bool flag);
|
void SetTryNewOutboundPeer(bool flag);
|
||||||
bool GetTryNewOutboundPeer();
|
bool GetTryNewOutboundPeer() const;
|
||||||
|
|
||||||
void StartExtraBlockRelayPeers() {
|
void StartExtraBlockRelayPeers() {
|
||||||
LogPrint(BCLog::NET, "net: enabling extra block-relay-only peers\n");
|
LogPrint(BCLog::NET, "net: enabling extra block-relay-only peers\n");
|
||||||
|
@ -948,13 +948,13 @@ public:
|
||||||
// return a value less than (num_outbound_connections - num_outbound_slots)
|
// return a value less than (num_outbound_connections - num_outbound_slots)
|
||||||
// in cases where some outbound connections are not yet fully connected, or
|
// in cases where some outbound connections are not yet fully connected, or
|
||||||
// not yet fully disconnected.
|
// not yet fully disconnected.
|
||||||
int GetExtraFullOutboundCount();
|
int GetExtraFullOutboundCount() const;
|
||||||
// Count the number of block-relay-only peers we have over our limit.
|
// Count the number of block-relay-only peers we have over our limit.
|
||||||
int GetExtraBlockRelayCount();
|
int GetExtraBlockRelayCount() const;
|
||||||
|
|
||||||
bool AddNode(const std::string& node);
|
bool AddNode(const std::string& node);
|
||||||
bool RemoveAddedNode(const std::string& node);
|
bool RemoveAddedNode(const std::string& node);
|
||||||
std::vector<AddedNodeInfo> GetAddedNodeInfo();
|
std::vector<AddedNodeInfo> GetAddedNodeInfo() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to open a connection. Currently only used from tests.
|
* Attempts to open a connection. Currently only used from tests.
|
||||||
|
@ -969,8 +969,8 @@ public:
|
||||||
*/
|
*/
|
||||||
bool AddConnection(const std::string& address, ConnectionType conn_type);
|
bool AddConnection(const std::string& address, ConnectionType conn_type);
|
||||||
|
|
||||||
size_t GetNodeCount(ConnectionDirection);
|
size_t GetNodeCount(ConnectionDirection) const;
|
||||||
void GetNodeStats(std::vector<CNodeStats>& vstats);
|
void GetNodeStats(std::vector<CNodeStats>& vstats) const;
|
||||||
bool DisconnectNode(const std::string& node);
|
bool DisconnectNode(const std::string& node);
|
||||||
bool DisconnectNode(const CSubNet& subnet);
|
bool DisconnectNode(const CSubNet& subnet);
|
||||||
bool DisconnectNode(const CNetAddr& addr);
|
bool DisconnectNode(const CNetAddr& addr);
|
||||||
|
@ -984,24 +984,24 @@ public:
|
||||||
//! that peer during `net_processing.cpp:PushNodeVersion()`.
|
//! that peer during `net_processing.cpp:PushNodeVersion()`.
|
||||||
ServiceFlags GetLocalServices() const;
|
ServiceFlags GetLocalServices() const;
|
||||||
|
|
||||||
uint64_t GetMaxOutboundTarget();
|
uint64_t GetMaxOutboundTarget() const;
|
||||||
std::chrono::seconds GetMaxOutboundTimeframe();
|
std::chrono::seconds GetMaxOutboundTimeframe() const;
|
||||||
|
|
||||||
//! check if the outbound target is reached
|
//! check if the outbound target is reached
|
||||||
//! if param historicalBlockServingLimit is set true, the function will
|
//! if param historicalBlockServingLimit is set true, the function will
|
||||||
//! response true if the limit for serving historical blocks has been reached
|
//! response true if the limit for serving historical blocks has been reached
|
||||||
bool OutboundTargetReached(bool historicalBlockServingLimit);
|
bool OutboundTargetReached(bool historicalBlockServingLimit) const;
|
||||||
|
|
||||||
//! response the bytes left in the current max outbound cycle
|
//! response the bytes left in the current max outbound cycle
|
||||||
//! in case of no limit, it will always response 0
|
//! in case of no limit, it will always response 0
|
||||||
uint64_t GetOutboundTargetBytesLeft();
|
uint64_t GetOutboundTargetBytesLeft() const;
|
||||||
|
|
||||||
//! returns the time left in the current max outbound cycle
|
//! returns the time left in the current max outbound cycle
|
||||||
//! in case of no limit, it will always return 0
|
//! in case of no limit, it will always return 0
|
||||||
std::chrono::seconds GetMaxOutboundTimeLeftInCycle();
|
std::chrono::seconds GetMaxOutboundTimeLeftInCycle() const;
|
||||||
|
|
||||||
uint64_t GetTotalBytesRecv();
|
uint64_t GetTotalBytesRecv() const;
|
||||||
uint64_t GetTotalBytesSent();
|
uint64_t GetTotalBytesSent() const;
|
||||||
|
|
||||||
/** Get a unique deterministic randomizer. */
|
/** Get a unique deterministic randomizer. */
|
||||||
CSipHasher GetDeterministicRandomizer(uint64_t id) const;
|
CSipHasher GetDeterministicRandomizer(uint64_t id) const;
|
||||||
|
@ -1106,8 +1106,8 @@ private:
|
||||||
static bool NodeFullyConnected(const CNode* pnode);
|
static bool NodeFullyConnected(const CNode* pnode);
|
||||||
|
|
||||||
// Network usage totals
|
// Network usage totals
|
||||||
RecursiveMutex cs_totalBytesRecv;
|
mutable RecursiveMutex cs_totalBytesRecv;
|
||||||
RecursiveMutex cs_totalBytesSent;
|
mutable RecursiveMutex cs_totalBytesSent;
|
||||||
uint64_t nTotalBytesRecv GUARDED_BY(cs_totalBytesRecv) {0};
|
uint64_t nTotalBytesRecv GUARDED_BY(cs_totalBytesRecv) {0};
|
||||||
uint64_t nTotalBytesSent GUARDED_BY(cs_totalBytesSent) {0};
|
uint64_t nTotalBytesSent GUARDED_BY(cs_totalBytesSent) {0};
|
||||||
|
|
||||||
|
@ -1133,7 +1133,7 @@ private:
|
||||||
std::deque<std::string> m_addr_fetches GUARDED_BY(m_addr_fetches_mutex);
|
std::deque<std::string> m_addr_fetches GUARDED_BY(m_addr_fetches_mutex);
|
||||||
RecursiveMutex m_addr_fetches_mutex;
|
RecursiveMutex m_addr_fetches_mutex;
|
||||||
std::vector<std::string> vAddedNodes GUARDED_BY(cs_vAddedNodes);
|
std::vector<std::string> vAddedNodes GUARDED_BY(cs_vAddedNodes);
|
||||||
RecursiveMutex cs_vAddedNodes;
|
mutable RecursiveMutex cs_vAddedNodes;
|
||||||
std::vector<CNode*> vNodes GUARDED_BY(cs_vNodes);
|
std::vector<CNode*> vNodes GUARDED_BY(cs_vNodes);
|
||||||
std::list<CNode*> vNodesDisconnected;
|
std::list<CNode*> vNodesDisconnected;
|
||||||
mutable RecursiveMutex cs_vNodes;
|
mutable RecursiveMutex cs_vNodes;
|
||||||
|
|
|
@ -246,7 +246,7 @@ public:
|
||||||
|
|
||||||
/** Implement PeerManager */
|
/** Implement PeerManager */
|
||||||
void CheckForStaleTipAndEvictPeers() override;
|
void CheckForStaleTipAndEvictPeers() override;
|
||||||
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats) override;
|
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats) const override;
|
||||||
bool IgnoresIncomingTxs() override { return m_ignore_incoming_txs; }
|
bool IgnoresIncomingTxs() override { return m_ignore_incoming_txs; }
|
||||||
void SendPings() override;
|
void SendPings() override;
|
||||||
void RelayTransaction(const uint256& txid, const uint256& wtxid) override;
|
void RelayTransaction(const uint256& txid, const uint256& wtxid) override;
|
||||||
|
@ -1101,7 +1101,7 @@ PeerRef PeerManagerImpl::RemovePeer(NodeId id)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PeerManagerImpl::GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats)
|
bool PeerManagerImpl::GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats) const
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
virtual ~PeerManager() { }
|
virtual ~PeerManager() { }
|
||||||
|
|
||||||
/** Get statistics from node state */
|
/** Get statistics from node state */
|
||||||
virtual bool GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats) = 0;
|
virtual bool GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats) const = 0;
|
||||||
|
|
||||||
/** Whether this node ignores txs received over p2p. */
|
/** Whether this node ignores txs received over p2p. */
|
||||||
virtual bool IgnoresIncomingTxs() = 0;
|
virtual bool IgnoresIncomingTxs() = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue