Skip to content

Commit 3f1b714

Browse files
committed
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-
1 parent a41ae68 commit 3f1b714

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

src/chainparams.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class CMainParams : public CChainParams {
110110

111111
// Note that of those which support the service bits prefix, most only support a subset of
112112
// possible options.
113-
// This is fine at runtime as we'll fall back to using them as a oneshot if they don't support the
113+
// This is fine at runtime as we'll fall back to using them as an addrfetch if they don't support the
114114
// service bits we want, but we should get them updated to support all service bits wanted by any
115115
// release ASAP to avoid it where possible.
116116
vSeeds.emplace_back("seed.bitcoin.sipa.be"); // Pieter Wuille, only supports x1, x5, x9, and xd

src/net.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ std::map<CNetAddr, LocalServiceInfo> mapLocalHost GUARDED_BY(cs_mapLocalHost);
105105
static bool vfLimited[NET_MAX] GUARDED_BY(cs_mapLocalHost) = {};
106106
std::string strSubVersion;
107107

108-
void CConnman::AddOneShot(const std::string& strDest)
108+
void CConnman::AddAddrFetch(const std::string& strDest)
109109
{
110-
LOCK(cs_vOneShots);
111-
vOneShots.push_back(strDest);
110+
LOCK(m_addr_fetches_mutex);
111+
m_addr_fetches.push_back(strDest);
112112
}
113113

114114
uint16_t GetListenPort()
@@ -1646,7 +1646,7 @@ void CConnman::ThreadDNSAddressSeed()
16461646
{
16471647
LOCK(cs_vNodes);
16481648
for (const CNode* pnode : vNodes) {
1649-
nRelevant += pnode->fSuccessfullyConnected && !pnode->fFeeler && !pnode->fOneShot && !pnode->m_manual_connection && !pnode->fInbound;
1649+
nRelevant += pnode->fSuccessfullyConnected && !pnode->fFeeler && !pnode->m_addr_fetch && !pnode->m_manual_connection && !pnode->fInbound;
16501650
}
16511651
}
16521652
if (nRelevant >= 2) {
@@ -1674,7 +1674,7 @@ void CConnman::ThreadDNSAddressSeed()
16741674

16751675
LogPrintf("Loading addresses from DNS seed %s\n", seed);
16761676
if (HaveNameProxy()) {
1677-
AddOneShot(seed);
1677+
AddAddrFetch(seed);
16781678
} else {
16791679
std::vector<CNetAddr> vIPs;
16801680
std::vector<CAddress> vAdd;
@@ -1696,8 +1696,8 @@ void CConnman::ThreadDNSAddressSeed()
16961696
addrman.Add(vAdd, resolveSource);
16971697
} else {
16981698
// We now avoid directly using results from DNS Seeds which do not support service bit filtering,
1699-
// instead using them as a oneshot to get nodes with our desired service bits.
1700-
AddOneShot(seed);
1699+
// instead using them as a addrfetch to get nodes with our desired service bits.
1700+
AddAddrFetch(seed);
17011701
}
17021702
}
17031703
--seeds_right_now;
@@ -1727,15 +1727,15 @@ void CConnman::DumpAddresses()
17271727
addrman.size(), GetTimeMillis() - nStart);
17281728
}
17291729

1730-
void CConnman::ProcessOneShot()
1730+
void CConnman::ProcessAddrFetch()
17311731
{
17321732
std::string strDest;
17331733
{
1734-
LOCK(cs_vOneShots);
1735-
if (vOneShots.empty())
1734+
LOCK(m_addr_fetches_mutex);
1735+
if (m_addr_fetches.empty())
17361736
return;
1737-
strDest = vOneShots.front();
1738-
vOneShots.pop_front();
1737+
strDest = m_addr_fetches.front();
1738+
m_addr_fetches.pop_front();
17391739
}
17401740
CAddress addr;
17411741
CSemaphoreGrant grant(*semOutbound, true);
@@ -1767,7 +1767,7 @@ int CConnman::GetExtraOutboundCount()
17671767
{
17681768
LOCK(cs_vNodes);
17691769
for (const CNode* pnode : vNodes) {
1770-
if (!pnode->fInbound && !pnode->m_manual_connection && !pnode->fFeeler && !pnode->fDisconnect && !pnode->fOneShot && pnode->fSuccessfullyConnected) {
1770+
if (!pnode->fInbound && !pnode->m_manual_connection && !pnode->fFeeler && !pnode->fDisconnect && !pnode->m_addr_fetch && pnode->fSuccessfullyConnected) {
17711771
++nOutbound;
17721772
}
17731773
}
@@ -1782,7 +1782,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
17821782
{
17831783
for (int64_t nLoop = 0;; nLoop++)
17841784
{
1785-
ProcessOneShot();
1785+
ProcessAddrFetch();
17861786
for (const std::string& strAddr : connect)
17871787
{
17881788
CAddress addr(CService(), NODE_NONE);
@@ -1805,7 +1805,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
18051805
int64_t nNextFeeler = PoissonNextSend(nStart*1000*1000, FEELER_INTERVAL);
18061806
while (!interruptNet)
18071807
{
1808-
ProcessOneShot();
1808+
ProcessAddrFetch();
18091809

18101810
if (!interruptNet.sleep_for(std::chrono::milliseconds(500)))
18111811
return;
@@ -2039,7 +2039,7 @@ void CConnman::ThreadOpenAddedConnections()
20392039
}
20402040

20412041
// if successful, this moves the passed grant to the constructed node
2042-
void CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound, const char *pszDest, bool fOneShot, bool fFeeler, bool manual_connection, bool block_relay_only)
2042+
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)
20432043
{
20442044
//
20452045
// Initiate outbound network connection
@@ -2064,8 +2064,8 @@ void CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFai
20642064
return;
20652065
if (grantOutbound)
20662066
grantOutbound->MoveTo(pnode->grantOutbound);
2067-
if (fOneShot)
2068-
pnode->fOneShot = true;
2067+
if (m_addr_fetch)
2068+
pnode->m_addr_fetch = true;
20692069
if (fFeeler)
20702070
pnode->fFeeler = true;
20712071
if (manual_connection)
@@ -2337,7 +2337,7 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
23372337
}
23382338

23392339
for (const auto& strDest : connOptions.vSeedNodes) {
2340-
AddOneShot(strDest);
2340+
AddAddrFetch(strDest);
23412341
}
23422342

23432343
if (clientInterface) {

src/net.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ class CConnman
197197
bool GetNetworkActive() const { return fNetworkActive; };
198198
bool GetUseAddrmanOutgoing() const { return m_use_addrman_outgoing; };
199199
void SetNetworkActive(bool active);
200-
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);
200+
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);
201201
bool CheckIncomingNonce(uint64_t nonce);
202202

203203
bool ForNode(NodeId id, std::function<bool(CNode* pnode)> func);
@@ -340,8 +340,8 @@ class CConnman
340340
bool Bind(const CService& addr, unsigned int flags, NetPermissionFlags permissions);
341341
bool InitBinds(const std::vector<CService>& binds, const std::vector<NetWhitebindPermissions>& whiteBinds);
342342
void ThreadOpenAddedConnections();
343-
void AddOneShot(const std::string& strDest);
344-
void ProcessOneShot();
343+
void AddAddrFetch(const std::string& strDest);
344+
void ProcessAddrFetch();
345345
void ThreadOpenConnections(std::vector<std::string> connect);
346346
void ThreadMessageHandler();
347347
void AcceptConnection(const ListenSocket& hListenSocket);
@@ -405,8 +405,8 @@ class CConnman
405405
std::atomic<bool> fNetworkActive{true};
406406
bool fAddressesInitialized{false};
407407
CAddrMan addrman;
408-
std::deque<std::string> vOneShots GUARDED_BY(cs_vOneShots);
409-
RecursiveMutex cs_vOneShots;
408+
std::deque<std::string> m_addr_fetches GUARDED_BY(m_addr_fetches_mutex);
409+
RecursiveMutex m_addr_fetches_mutex;
410410
std::vector<std::string> vAddedNodes GUARDED_BY(cs_vAddedNodes);
411411
RecursiveMutex cs_vAddedNodes;
412412
std::vector<CNode*> vNodes GUARDED_BY(cs_vNodes);
@@ -765,7 +765,7 @@ class CNode
765765
// This boolean is unusued in actual processing, only present for backward compatibility at RPC/QT level
766766
bool m_legacyWhitelisted{false};
767767
bool fFeeler{false}; // If true this node is being used as a short lived feeler.
768-
bool fOneShot{false};
768+
bool m_addr_fetch{false};
769769
bool m_manual_connection{false};
770770
bool fClient{false}; // set by version message
771771
bool m_limited_node{false}; //after BIP159, set by version message

src/net_processing.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ static void UpdatePreferredDownload(const CNode& node, CNodeState* state) EXCLUS
473473
nPreferredDownload -= state->fPreferredDownload;
474474

475475
// Whether this node should be marked as a preferred download node.
476-
state->fPreferredDownload = (!node.fInbound || node.HasPermission(PF_NOBAN)) && !node.fOneShot && !node.fClient;
476+
state->fPreferredDownload = (!node.fInbound || node.HasPermission(PF_NOBAN)) && !node.m_addr_fetch && !node.fClient;
477477

478478
nPreferredDownload += state->fPreferredDownload;
479479
}
@@ -831,7 +831,7 @@ void UpdateLastBlockAnnounceTime(NodeId node, int64_t time_in_seconds)
831831
// one-shots.
832832
static bool IsOutboundDisconnectionCandidate(const CNode& node)
833833
{
834-
return !(node.fInbound || node.m_manual_connection || node.fFeeler || node.fOneShot);
834+
return !(node.fInbound || node.m_manual_connection || node.fFeeler || node.m_addr_fetch);
835835
}
836836

837837
void PeerLogicValidation::InitializeNode(CNode *pnode) {
@@ -2584,7 +2584,7 @@ void ProcessMessage(
25842584
connman.AddNewAddresses(vAddrOk, pfrom.addr, 2 * 60 * 60);
25852585
if (vAddr.size() < 1000)
25862586
pfrom.fGetAddr = false;
2587-
if (pfrom.fOneShot)
2587+
if (pfrom.m_addr_fetch)
25882588
pfrom.fDisconnect = true;
25892589
return;
25902590
}
@@ -4097,7 +4097,7 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
40974097
// Start block sync
40984098
if (pindexBestHeader == nullptr)
40994099
pindexBestHeader = ::ChainActive().Tip();
4100-
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.
4100+
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.
41014101
if (!state.fSyncStarted && !pto->fClient && !fImporting && !fReindex) {
41024102
// Only actively request headers from a single peer, unless we're close to today.
41034103
if ((nSyncStarted == 0 && fFetch) || pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) {

0 commit comments

Comments
 (0)