diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-06-13 19:30:04 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-06-13 19:34:17 +0200 |
commit | be9711e597071c813bdd72c2866c547f117e4865 (patch) | |
tree | f965abcecc43584d8f9f9a42629df169fdcc249e /src/addrman.cpp | |
parent | 44c1b1c9bb54082625c7ad76af25473abf79f866 (diff) | |
parent | ecd7fd37c888f8ebc64cf3d92272975b37ae54ca (diff) | |
download | bitcoin-be9711e597071c813bdd72c2866c547f117e4865.tar.xz |
Merge #7749: Enforce expected outbound services
ecd7fd3 Introduce REQUIRED_SERVICES constant (Pieter Wuille)
ee06e04 Introduce enum ServiceFlags for service flags (Pieter Wuille)
15bf863 Don't require services in -addnode (Pieter Wuille)
5e7ab16 Only store and connect to NODE_NETWORK nodes (Pieter Wuille)
fc83f18 Verify that outbound connections have expected services (Pieter Wuille)
3764dec Keep addrman's nService bits consistent with outbound observations (Pieter Wuille)
Diffstat (limited to 'src/addrman.cpp')
-rw-r--r-- | src/addrman.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/addrman.cpp b/src/addrman.cpp index 00f6fe99e0..cebb1c8e5e 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -263,7 +263,7 @@ bool CAddrMan::Add_(const CAddress& addr, const CNetAddr& source, int64_t nTimeP pinfo->nTime = std::max((int64_t)0, addr.nTime - nTimePenalty); // add services - pinfo->nServices |= addr.nServices; + pinfo->nServices = ServiceFlags(pinfo->nServices | addr.nServices); // do not update if no new information is present if (!addr.nTime || (pinfo->nTime && addr.nTime <= pinfo->nTime)) @@ -502,6 +502,24 @@ void CAddrMan::Connected_(const CService& addr, int64_t nTime) info.nTime = nTime; } +void CAddrMan::SetServices_(const CService& addr, ServiceFlags nServices) +{ + CAddrInfo* pinfo = Find(addr); + + // if not found, bail out + if (!pinfo) + return; + + CAddrInfo& info = *pinfo; + + // check whether we are talking about the exact same CService (including same port) + if (info != addr) + return; + + // update info + info.nServices = nServices; +} + int CAddrMan::RandomInt(int nMax){ return GetRandInt(nMax); } |