mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-17 13:07:54 +02:00
Merge e69cbac628 into merged_master (Bitcoin PR bitcoin/bitcoin#22896)
This commit is contained in:
commit
b1a459ed3e
1 changed files with 10 additions and 12 deletions
22
src/net.cpp
22
src/net.cpp
|
|
@ -192,8 +192,8 @@ CAddress GetLocalAddress(const CNetAddr *paddrPeer, ServiceFlags nLocalServices)
|
|||
static int GetnScore(const CService& addr)
|
||||
{
|
||||
LOCK(cs_mapLocalHost);
|
||||
if (mapLocalHost.count(addr) == 0) return 0;
|
||||
return mapLocalHost[addr].nScore;
|
||||
const auto it = mapLocalHost.find(addr);
|
||||
return (it != mapLocalHost.end()) ? it->second.nScore : 0;
|
||||
}
|
||||
|
||||
// Is our peer's addrLocal potentially useful as an external IP source?
|
||||
|
|
@ -245,10 +245,10 @@ bool AddLocal(const CService& addr, int nScore)
|
|||
|
||||
{
|
||||
LOCK(cs_mapLocalHost);
|
||||
bool fAlready = mapLocalHost.count(addr) > 0;
|
||||
LocalServiceInfo &info = mapLocalHost[addr];
|
||||
if (!fAlready || nScore >= info.nScore) {
|
||||
info.nScore = nScore + (fAlready ? 1 : 0);
|
||||
const auto [it, is_newly_added] = mapLocalHost.emplace(addr, LocalServiceInfo());
|
||||
LocalServiceInfo &info = it->second;
|
||||
if (is_newly_added || nScore >= info.nScore) {
|
||||
info.nScore = nScore + (is_newly_added ? 0 : 1);
|
||||
info.nPort = addr.GetPort();
|
||||
}
|
||||
}
|
||||
|
|
@ -290,12 +290,10 @@ bool IsReachable(const CNetAddr &addr)
|
|||
/** vote for a local address */
|
||||
bool SeenLocal(const CService& addr)
|
||||
{
|
||||
{
|
||||
LOCK(cs_mapLocalHost);
|
||||
if (mapLocalHost.count(addr) == 0)
|
||||
return false;
|
||||
mapLocalHost[addr].nScore++;
|
||||
}
|
||||
LOCK(cs_mapLocalHost);
|
||||
const auto it = mapLocalHost.find(addr);
|
||||
if (it == mapLocalHost.end()) return false;
|
||||
++it->second.nScore;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue