mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
scripted-diff: Rename OneShot to AddrFetch
-BEGIN VERIFY SCRIPT- sed -i 's/a oneshot/an addrfetch/g' src/chainparams.cpp #comment sed -i 's/oneshot/addrfetch/g' src/net.cpp #comment sed -i 's/AddOneShot/AddAddrFetch/g' src/net.h src/net.cpp sed -i 's/cs_vOneShots/m_addr_fetches_mutex/g' src/net.h src/net.cpp sed -i 's/vOneShots/m_addr_fetches/g' src/net.h src/net.cpp sed -i 's/fOneShot/m_addr_fetch/g' src/net.h src/net.cpp src/net_processing.cpp sed -i 's/ProcessOneShot/ProcessAddrFetch/g' src/net.h src/net.cpp -END VERIFY SCRIPT-
This commit is contained in:
parent
a41ae68053
commit
3f1b7140e9
4 changed files with 30 additions and 30 deletions
|
@ -110,7 +110,7 @@ public:
|
|||
|
||||
// Note that of those which support the service bits prefix, most only support a subset of
|
||||
// possible options.
|
||||
// This is fine at runtime as we'll fall back to using them as a oneshot if they don't support the
|
||||
// This is fine at runtime as we'll fall back to using them as an addrfetch if they don't support the
|
||||
// service bits we want, but we should get them updated to support all service bits wanted by any
|
||||
// release ASAP to avoid it where possible.
|
||||
vSeeds.emplace_back("seed.bitcoin.sipa.be"); // Pieter Wuille, only supports x1, x5, x9, and xd
|
||||
|
|
38
src/net.cpp
38
src/net.cpp
|
@ -105,10 +105,10 @@ std::map<CNetAddr, LocalServiceInfo> mapLocalHost GUARDED_BY(cs_mapLocalHost);
|
|||
static bool vfLimited[NET_MAX] GUARDED_BY(cs_mapLocalHost) = {};
|
||||
std::string strSubVersion;
|
||||
|
||||
void CConnman::AddOneShot(const std::string& strDest)
|
||||
void CConnman::AddAddrFetch(const std::string& strDest)
|
||||
{
|
||||
LOCK(cs_vOneShots);
|
||||
vOneShots.push_back(strDest);
|
||||
LOCK(m_addr_fetches_mutex);
|
||||
m_addr_fetches.push_back(strDest);
|
||||
}
|
||||
|
||||
uint16_t GetListenPort()
|
||||
|
@ -1646,7 +1646,7 @@ void CConnman::ThreadDNSAddressSeed()
|
|||
{
|
||||
LOCK(cs_vNodes);
|
||||
for (const CNode* pnode : vNodes) {
|
||||
nRelevant += pnode->fSuccessfullyConnected && !pnode->fFeeler && !pnode->fOneShot && !pnode->m_manual_connection && !pnode->fInbound;
|
||||
nRelevant += pnode->fSuccessfullyConnected && !pnode->fFeeler && !pnode->m_addr_fetch && !pnode->m_manual_connection && !pnode->fInbound;
|
||||
}
|
||||
}
|
||||
if (nRelevant >= 2) {
|
||||
|
@ -1674,7 +1674,7 @@ void CConnman::ThreadDNSAddressSeed()
|
|||
|
||||
LogPrintf("Loading addresses from DNS seed %s\n", seed);
|
||||
if (HaveNameProxy()) {
|
||||
AddOneShot(seed);
|
||||
AddAddrFetch(seed);
|
||||
} else {
|
||||
std::vector<CNetAddr> vIPs;
|
||||
std::vector<CAddress> vAdd;
|
||||
|
@ -1696,8 +1696,8 @@ void CConnman::ThreadDNSAddressSeed()
|
|||
addrman.Add(vAdd, resolveSource);
|
||||
} else {
|
||||
// We now avoid directly using results from DNS Seeds which do not support service bit filtering,
|
||||
// instead using them as a oneshot to get nodes with our desired service bits.
|
||||
AddOneShot(seed);
|
||||
// instead using them as a addrfetch to get nodes with our desired service bits.
|
||||
AddAddrFetch(seed);
|
||||
}
|
||||
}
|
||||
--seeds_right_now;
|
||||
|
@ -1727,15 +1727,15 @@ void CConnman::DumpAddresses()
|
|||
addrman.size(), GetTimeMillis() - nStart);
|
||||
}
|
||||
|
||||
void CConnman::ProcessOneShot()
|
||||
void CConnman::ProcessAddrFetch()
|
||||
{
|
||||
std::string strDest;
|
||||
{
|
||||
LOCK(cs_vOneShots);
|
||||
if (vOneShots.empty())
|
||||
LOCK(m_addr_fetches_mutex);
|
||||
if (m_addr_fetches.empty())
|
||||
return;
|
||||
strDest = vOneShots.front();
|
||||
vOneShots.pop_front();
|
||||
strDest = m_addr_fetches.front();
|
||||
m_addr_fetches.pop_front();
|
||||
}
|
||||
CAddress addr;
|
||||
CSemaphoreGrant grant(*semOutbound, true);
|
||||
|
@ -1767,7 +1767,7 @@ int CConnman::GetExtraOutboundCount()
|
|||
{
|
||||
LOCK(cs_vNodes);
|
||||
for (const CNode* pnode : vNodes) {
|
||||
if (!pnode->fInbound && !pnode->m_manual_connection && !pnode->fFeeler && !pnode->fDisconnect && !pnode->fOneShot && pnode->fSuccessfullyConnected) {
|
||||
if (!pnode->fInbound && !pnode->m_manual_connection && !pnode->fFeeler && !pnode->fDisconnect && !pnode->m_addr_fetch && pnode->fSuccessfullyConnected) {
|
||||
++nOutbound;
|
||||
}
|
||||
}
|
||||
|
@ -1782,7 +1782,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
|
|||
{
|
||||
for (int64_t nLoop = 0;; nLoop++)
|
||||
{
|
||||
ProcessOneShot();
|
||||
ProcessAddrFetch();
|
||||
for (const std::string& strAddr : connect)
|
||||
{
|
||||
CAddress addr(CService(), NODE_NONE);
|
||||
|
@ -1805,7 +1805,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
|
|||
int64_t nNextFeeler = PoissonNextSend(nStart*1000*1000, FEELER_INTERVAL);
|
||||
while (!interruptNet)
|
||||
{
|
||||
ProcessOneShot();
|
||||
ProcessAddrFetch();
|
||||
|
||||
if (!interruptNet.sleep_for(std::chrono::milliseconds(500)))
|
||||
return;
|
||||
|
@ -2039,7 +2039,7 @@ void CConnman::ThreadOpenAddedConnections()
|
|||
}
|
||||
|
||||
// if successful, this moves the passed grant to the constructed node
|
||||
void CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound, const char *pszDest, bool fOneShot, bool fFeeler, bool manual_connection, bool block_relay_only)
|
||||
void CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound, const char *pszDest, bool m_addr_fetch, bool fFeeler, bool manual_connection, bool block_relay_only)
|
||||
{
|
||||
//
|
||||
// Initiate outbound network connection
|
||||
|
@ -2064,8 +2064,8 @@ void CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFai
|
|||
return;
|
||||
if (grantOutbound)
|
||||
grantOutbound->MoveTo(pnode->grantOutbound);
|
||||
if (fOneShot)
|
||||
pnode->fOneShot = true;
|
||||
if (m_addr_fetch)
|
||||
pnode->m_addr_fetch = true;
|
||||
if (fFeeler)
|
||||
pnode->fFeeler = true;
|
||||
if (manual_connection)
|
||||
|
@ -2337,7 +2337,7 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
|
|||
}
|
||||
|
||||
for (const auto& strDest : connOptions.vSeedNodes) {
|
||||
AddOneShot(strDest);
|
||||
AddAddrFetch(strDest);
|
||||
}
|
||||
|
||||
if (clientInterface) {
|
||||
|
|
12
src/net.h
12
src/net.h
|
@ -197,7 +197,7 @@ public:
|
|||
bool GetNetworkActive() const { return fNetworkActive; };
|
||||
bool GetUseAddrmanOutgoing() const { return m_use_addrman_outgoing; };
|
||||
void SetNetworkActive(bool active);
|
||||
void OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound = nullptr, const char *strDest = nullptr, bool fOneShot = false, bool fFeeler = false, bool manual_connection = false, bool block_relay_only = false);
|
||||
void OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound = nullptr, const char *strDest = nullptr, bool m_addr_fetch = false, bool fFeeler = false, bool manual_connection = false, bool block_relay_only = false);
|
||||
bool CheckIncomingNonce(uint64_t nonce);
|
||||
|
||||
bool ForNode(NodeId id, std::function<bool(CNode* pnode)> func);
|
||||
|
@ -340,8 +340,8 @@ private:
|
|||
bool Bind(const CService& addr, unsigned int flags, NetPermissionFlags permissions);
|
||||
bool InitBinds(const std::vector<CService>& binds, const std::vector<NetWhitebindPermissions>& whiteBinds);
|
||||
void ThreadOpenAddedConnections();
|
||||
void AddOneShot(const std::string& strDest);
|
||||
void ProcessOneShot();
|
||||
void AddAddrFetch(const std::string& strDest);
|
||||
void ProcessAddrFetch();
|
||||
void ThreadOpenConnections(std::vector<std::string> connect);
|
||||
void ThreadMessageHandler();
|
||||
void AcceptConnection(const ListenSocket& hListenSocket);
|
||||
|
@ -405,8 +405,8 @@ private:
|
|||
std::atomic<bool> fNetworkActive{true};
|
||||
bool fAddressesInitialized{false};
|
||||
CAddrMan addrman;
|
||||
std::deque<std::string> vOneShots GUARDED_BY(cs_vOneShots);
|
||||
RecursiveMutex cs_vOneShots;
|
||||
std::deque<std::string> m_addr_fetches GUARDED_BY(m_addr_fetches_mutex);
|
||||
RecursiveMutex m_addr_fetches_mutex;
|
||||
std::vector<std::string> vAddedNodes GUARDED_BY(cs_vAddedNodes);
|
||||
RecursiveMutex cs_vAddedNodes;
|
||||
std::vector<CNode*> vNodes GUARDED_BY(cs_vNodes);
|
||||
|
@ -765,7 +765,7 @@ public:
|
|||
// This boolean is unusued in actual processing, only present for backward compatibility at RPC/QT level
|
||||
bool m_legacyWhitelisted{false};
|
||||
bool fFeeler{false}; // If true this node is being used as a short lived feeler.
|
||||
bool fOneShot{false};
|
||||
bool m_addr_fetch{false};
|
||||
bool m_manual_connection{false};
|
||||
bool fClient{false}; // set by version message
|
||||
bool m_limited_node{false}; //after BIP159, set by version message
|
||||
|
|
|
@ -473,7 +473,7 @@ static void UpdatePreferredDownload(const CNode& node, CNodeState* state) EXCLUS
|
|||
nPreferredDownload -= state->fPreferredDownload;
|
||||
|
||||
// Whether this node should be marked as a preferred download node.
|
||||
state->fPreferredDownload = (!node.fInbound || node.HasPermission(PF_NOBAN)) && !node.fOneShot && !node.fClient;
|
||||
state->fPreferredDownload = (!node.fInbound || node.HasPermission(PF_NOBAN)) && !node.m_addr_fetch && !node.fClient;
|
||||
|
||||
nPreferredDownload += state->fPreferredDownload;
|
||||
}
|
||||
|
@ -831,7 +831,7 @@ void UpdateLastBlockAnnounceTime(NodeId node, int64_t time_in_seconds)
|
|||
// one-shots.
|
||||
static bool IsOutboundDisconnectionCandidate(const CNode& node)
|
||||
{
|
||||
return !(node.fInbound || node.m_manual_connection || node.fFeeler || node.fOneShot);
|
||||
return !(node.fInbound || node.m_manual_connection || node.fFeeler || node.m_addr_fetch);
|
||||
}
|
||||
|
||||
void PeerLogicValidation::InitializeNode(CNode *pnode) {
|
||||
|
@ -2584,7 +2584,7 @@ void ProcessMessage(
|
|||
connman.AddNewAddresses(vAddrOk, pfrom.addr, 2 * 60 * 60);
|
||||
if (vAddr.size() < 1000)
|
||||
pfrom.fGetAddr = false;
|
||||
if (pfrom.fOneShot)
|
||||
if (pfrom.m_addr_fetch)
|
||||
pfrom.fDisconnect = true;
|
||||
return;
|
||||
}
|
||||
|
@ -4097,7 +4097,7 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
|
|||
// Start block sync
|
||||
if (pindexBestHeader == nullptr)
|
||||
pindexBestHeader = ::ChainActive().Tip();
|
||||
bool fFetch = state.fPreferredDownload || (nPreferredDownload == 0 && !pto->fClient && !pto->fOneShot); // Download if this is a nice peer, or we have no nice peers and this one might do.
|
||||
bool fFetch = state.fPreferredDownload || (nPreferredDownload == 0 && !pto->fClient && !pto->m_addr_fetch); // Download if this is a nice peer, or we have no nice peers and this one might do.
|
||||
if (!state.fSyncStarted && !pto->fClient && !fImporting && !fReindex) {
|
||||
// Only actively request headers from a single peer, unless we're close to today.
|
||||
if ((nSyncStarted == 0 && fFetch) || pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) {
|
||||
|
|
Loading…
Add table
Reference in a new issue