diff --git a/internal/rpcserver/interface.go b/internal/rpcserver/interface.go index 17bafa419b..304ad83909 100644 --- a/internal/rpcserver/interface.go +++ b/internal/rpcserver/interface.go @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2023 The Decred developers +// Copyright (c) 2019-2024 The Decred developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. @@ -113,8 +113,7 @@ type ConnManager interface { // ConnectedPeers returns an array consisting of all connected peers. ConnectedPeers() []Peer - // PersistentPeers returns an array consisting of all the persistent - // peers. + // PersistentPeers returns an array consisting of all the persistent peers. PersistentPeers() []Peer // BroadcastMessage sends the provided message to all currently @@ -130,9 +129,6 @@ type ConnManager interface { // the passed transactions to all connected peers. RelayTransactions(txns []*dcrutil.Tx) - // AddedNodeInfo returns information describing persistent (added) nodes. - AddedNodeInfo() []Peer - // Lookup defines the DNS lookup function to be used. Lookup(host string) ([]net.IP, error) } diff --git a/internal/rpcserver/rpcserver.go b/internal/rpcserver/rpcserver.go index 37b4c4fe05..6a9c52330d 100644 --- a/internal/rpcserver/rpcserver.go +++ b/internal/rpcserver/rpcserver.go @@ -1,5 +1,5 @@ // Copyright (c) 2013-2016 The btcsuite developers -// Copyright (c) 2015-2023 The Decred developers +// Copyright (c) 2015-2024 The Decred developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. @@ -1795,7 +1795,7 @@ func handleGetAddedNodeInfo(_ context.Context, s *Server, cmd interface{}) (inte // Retrieve a list of persistent (added) peers from the Decred server // and filter the list of peers per the specified address (if any). - peers := s.cfg.ConnMgr.AddedNodeInfo() + peers := s.cfg.ConnMgr.PersistentPeers() if c.Node != nil { found := false for i, peer := range peers { diff --git a/internal/rpcserver/rpcserverhandlers_test.go b/internal/rpcserver/rpcserverhandlers_test.go index d228a3ede3..2e6f36dcd9 100644 --- a/internal/rpcserver/rpcserverhandlers_test.go +++ b/internal/rpcserver/rpcserverhandlers_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2023 The Decred developers +// Copyright (c) 2020-2024 The Decred developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. @@ -802,7 +802,6 @@ type testConnManager struct { netTotalSent uint64 connectedPeers []Peer persistentPeers []Peer - addedNodeInfo []Peer lookup func(host string) ([]net.IP, error) } @@ -870,11 +869,6 @@ func (c *testConnManager) AddRebroadcastInventory(iv *wire.InvVect, data interfa // inventory vectors for all of the passed transactions to all connected peers. func (c *testConnManager) RelayTransactions(txns []*dcrutil.Tx) {} -// AddedNodeInfo returns a mocked slice of persistent (added) peers. -func (c *testConnManager) AddedNodeInfo() []Peer { - return c.addedNodeInfo -} - // Lookup defines a mocked DNS lookup function to be used. func (c *testConnManager) Lookup(host string) ([]net.IP, error) { return c.lookup(host) @@ -1704,12 +1698,6 @@ func defaultMockConnManager() *testConnManager { testPeer3, testPeer4, }, - addedNodeInfo: []Peer{ - testPeer1, - testPeer2, - testPeer3, - testPeer4, - }, lookup: func(host string) ([]net.IP, error) { if host == "mydomain.org" { return []net.IP{net.ParseIP("127.0.0.211")}, nil diff --git a/rpcadaptors.go b/rpcadaptors.go index 643f9f802e..3477929cf4 100644 --- a/rpcadaptors.go +++ b/rpcadaptors.go @@ -1,5 +1,5 @@ // Copyright (c) 2017 The btcsuite developers -// Copyright (c) 2015-2022 The Decred developers +// Copyright (c) 2015-2024 The Decred developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. @@ -247,7 +247,7 @@ func (cm *rpcConnManager) PersistentPeers() []rpcserver.Peer { cm.server.query <- getAddedNodesMsg{reply: replyChan} serverPeers := <-replyChan - // Convert to generic peers. + // Convert to RPC server peers. peers := make([]rpcserver.Peer, 0, len(serverPeers)) for _, sp := range serverPeers { peers = append(peers, (*rpcPeer)(sp)) @@ -282,22 +282,6 @@ func (cm *rpcConnManager) RelayTransactions(txns []*dcrutil.Tx) { cm.server.relayTransactions(txns) } -// AddedNodeInfo returns information describing persistent (added) nodes. -// -// This function is safe for concurrent access and is part of the -// rpcserver.ConnManager interface implementation. -func (cm *rpcConnManager) AddedNodeInfo() []rpcserver.Peer { - serverPeers := cm.server.AddedNodeInfo() - - // Convert to RPC server peers. - peers := make([]rpcserver.Peer, 0, len(serverPeers)) - for _, sp := range serverPeers { - peers = append(peers, (*rpcPeer)(sp)) - } - - return peers -} - // Lookup defines the DNS lookup function to be used. // // This function is safe for concurrent access and is part of the diff --git a/server.go b/server.go index 0f4d6c16c9..bc41ea29fc 100644 --- a/server.go +++ b/server.go @@ -1,5 +1,5 @@ // Copyright (c) 2013-2016 The btcsuite developers -// Copyright (c) 2015-2023 The Decred developers +// Copyright (c) 2015-2024 The Decred developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. @@ -2550,18 +2550,6 @@ func (s *server) OutboundGroupCount(key string) int { } } -// AddedNodeInfo returns an array of dcrjson.GetAddedNodeInfoResult structures -// describing the persistent (added) nodes. -func (s *server) AddedNodeInfo() []*serverPeer { - replyChan := make(chan []*serverPeer) - select { - case <-s.quit: - return nil - case s.query <- getAddedNodesMsg{reply: replyChan}: - return <-replyChan - } -} - // AddBytesSent adds the passed number of bytes to the total bytes sent counter // for the server. It is safe for concurrent access. func (s *server) AddBytesSent(bytesSent uint64) {