Skip to content

Commit

Permalink
Remove pnodeLocalHost.
Browse files Browse the repository at this point in the history
Mostly a legacy of the long removed pub/sub system
  • Loading branch information
gmaxwell authored and furszy committed Oct 8, 2021
1 parent 8bd8694 commit 8de5486
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 21 deletions.
15 changes: 0 additions & 15 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ bool fListen = true;
RecursiveMutex cs_mapLocalHost;
std::map<CNetAddr, LocalServiceInfo> mapLocalHost;
static bool vfLimited[NET_MAX] = {};
static CNode* pnodeLocalHost = NULL;
std::string strSubVersion;

limitedmap<CInv, int64_t> mapAlreadyAskedFor(MAX_INV_SZ);
Expand Down Expand Up @@ -1971,17 +1970,6 @@ bool CConnman::Start(CScheduler& scheduler, std::string& strNodeError, Options c
semOutbound = std::make_unique<CSemaphore>(std::min((nMaxOutbound + nMaxFeeler), nMaxConnections));
}

if (pnodeLocalHost == nullptr) {
CNetAddr local;
LookupHost("127.0.0.1", local, false);

NodeId id = GetNewNodeId();
uint64_t nonce = GetDeterministicRandomizer(RANDOMIZER_ID_LOCALHOSTNONCE).Write(id).Finalize();

pnodeLocalHost = new CNode(id, nLocalServices, GetBestHeight(), INVALID_SOCKET, CAddress(CService(local, 0), nLocalServices), 0, nonce);
m_msgproc->InitializeNode(pnodeLocalHost);
}

//
// Start threads
//
Expand Down Expand Up @@ -2096,9 +2084,6 @@ void CConnman::Stop()
vNodesDisconnected.clear();
vhListenSocket.clear();
semOutbound.reset();
if(pnodeLocalHost)
DeleteNode(pnodeLocalHost);
pnodeLocalHost = NULL;
}

void CConnman::DeleteNode(CNode* pnode)
Expand Down
4 changes: 2 additions & 2 deletions test/functional/p2p_addr_relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def run_test(self):
msg.addrs = ADDRS
with self.nodes[0].assert_debug_log([
'Added 10 addresses from 127.0.0.1: 0 tried',
'received: addr (301 bytes) peer=1',
'sending addr (301 bytes) peer=2',
'received: addr (301 bytes) peer=0',
'sending addr (301 bytes) peer=1',
]):
addr_source.send_and_ping(msg)
self.nodes[0].setmocktime(int(time.time()) + 30 * 60)
Expand Down
4 changes: 2 additions & 2 deletions test/functional/p2p_addrv2_relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def run_test(self):
msg.addrs = ADDRS
with self.nodes[0].assert_debug_log([
'Added 10 addresses from 127.0.0.1: 0 tried',
'received: addrv2 (131 bytes) peer=1',
'sending addrv2 (131 bytes) peer=2',
'received: addrv2 (131 bytes) peer=0',
'sending addrv2 (131 bytes) peer=1',
]):
addr_source.send_and_ping(msg)
self.nodes[0].setmocktime(int(time.time()) + 30 * 60)
Expand Down
4 changes: 2 additions & 2 deletions test/functional/p2p_invalid_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ def test_addrv2_unrecognized_network(self):

def test_large_inv(self):
conn = self.nodes[0].add_p2p_connection(P2PInterface())
with self.nodes[0].assert_debug_log(['Misbehaving', 'peer=9 (0 -> 20): message inv size() = 50001']):
with self.nodes[0].assert_debug_log(['Misbehaving', 'peer=8 (0 -> 20): message inv size() = 50001']):
msg = messages.msg_inv([messages.CInv(1, 1)] * 50001)
conn.send_and_ping(msg)
with self.nodes[0].assert_debug_log(['Misbehaving', 'peer=9 (20 -> 40): message getdata size() = 50001']):
with self.nodes[0].assert_debug_log(['Misbehaving', 'peer=8 (20 -> 40): message getdata size() = 50001']):
msg = messages.msg_getdata([messages.CInv(1, 1)] * 50001)
conn.send_and_ping(msg)
self.nodes[0].disconnect_p2ps()
Expand Down

0 comments on commit 8de5486

Please sign in to comment.