From 99dfdc19e745e07438d375b411a4f2ae36f50b3a Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 22 Jan 2020 11:28:59 +0300 Subject: [PATCH] network: drop now useless addrReq queue from the server Just broadcast a high-priority message to everyone. --- pkg/network/server.go | 10 +--------- pkg/network/tcp_peer.go | 7 ------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/pkg/network/server.go b/pkg/network/server.go index ad67fd1d6..cb5c8dfed 100644 --- a/pkg/network/server.go +++ b/pkg/network/server.go @@ -61,7 +61,6 @@ type ( lock sync.RWMutex peers map[Peer]bool - addrReq chan *Message register chan Peer unregister chan peerDrop quit chan struct{} @@ -97,7 +96,6 @@ func NewServer(config ServerConfig, chain core.Blockchainer, log *zap.Logger) *S bQueue: newBlockQueue(maxBlockBatch, chain, log), id: randomID(), quit: make(chan struct{}), - addrReq: make(chan *Message, config.MinPeers), register: make(chan Peer), unregister: make(chan peerDrop), peers: make(map[Peer]bool), @@ -203,13 +201,7 @@ func (s *Server) run() { s.discovery.RequestRemote(s.AttemptConnPeers) } if s.discovery.PoolCount() < minPoolCount { - select { - case s.addrReq <- s.MkMsg(CMDGetAddr, payload.NewNullPayload()): - // sent request - default: - // we have one in the queue already that is - // gonna be served by some worker when it's ready - } + s.broadcastHPMessage(s.MkMsg(CMDGetAddr, payload.NewNullPayload())) } select { case <-s.quit: diff --git a/pkg/network/tcp_peer.go b/pkg/network/tcp_peer.go index 9d2964263..096966359 100644 --- a/pkg/network/tcp_peer.go +++ b/pkg/network/tcp_peer.go @@ -198,13 +198,6 @@ func (p *TCPPeer) StartProtocol() { select { case <-p.done: return - case m := <-p.server.addrReq: - var pkt []byte - - pkt, err = m.Bytes() - if err == nil { - err = p.EnqueueHPPacket(pkt) - } case <-timer.C: // Try to sync in headers and block with the peer if his block height is higher then ours. if p.LastBlockIndex() > p.server.chain.BlockHeight() {