network: drop now useless addrReq queue from the server
Just broadcast a high-priority message to everyone.
This commit is contained in:
parent
f2ffffddb7
commit
99dfdc19e7
2 changed files with 1 additions and 16 deletions
|
@ -61,7 +61,6 @@ type (
|
||||||
lock sync.RWMutex
|
lock sync.RWMutex
|
||||||
peers map[Peer]bool
|
peers map[Peer]bool
|
||||||
|
|
||||||
addrReq chan *Message
|
|
||||||
register chan Peer
|
register chan Peer
|
||||||
unregister chan peerDrop
|
unregister chan peerDrop
|
||||||
quit chan struct{}
|
quit chan struct{}
|
||||||
|
@ -97,7 +96,6 @@ func NewServer(config ServerConfig, chain core.Blockchainer, log *zap.Logger) *S
|
||||||
bQueue: newBlockQueue(maxBlockBatch, chain, log),
|
bQueue: newBlockQueue(maxBlockBatch, chain, log),
|
||||||
id: randomID(),
|
id: randomID(),
|
||||||
quit: make(chan struct{}),
|
quit: make(chan struct{}),
|
||||||
addrReq: make(chan *Message, config.MinPeers),
|
|
||||||
register: make(chan Peer),
|
register: make(chan Peer),
|
||||||
unregister: make(chan peerDrop),
|
unregister: make(chan peerDrop),
|
||||||
peers: make(map[Peer]bool),
|
peers: make(map[Peer]bool),
|
||||||
|
@ -203,13 +201,7 @@ func (s *Server) run() {
|
||||||
s.discovery.RequestRemote(s.AttemptConnPeers)
|
s.discovery.RequestRemote(s.AttemptConnPeers)
|
||||||
}
|
}
|
||||||
if s.discovery.PoolCount() < minPoolCount {
|
if s.discovery.PoolCount() < minPoolCount {
|
||||||
select {
|
s.broadcastHPMessage(s.MkMsg(CMDGetAddr, payload.NewNullPayload()))
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
case <-s.quit:
|
case <-s.quit:
|
||||||
|
|
|
@ -198,13 +198,6 @@ func (p *TCPPeer) StartProtocol() {
|
||||||
select {
|
select {
|
||||||
case <-p.done:
|
case <-p.done:
|
||||||
return
|
return
|
||||||
case m := <-p.server.addrReq:
|
|
||||||
var pkt []byte
|
|
||||||
|
|
||||||
pkt, err = m.Bytes()
|
|
||||||
if err == nil {
|
|
||||||
err = p.EnqueueHPPacket(pkt)
|
|
||||||
}
|
|
||||||
case <-timer.C:
|
case <-timer.C:
|
||||||
// Try to sync in headers and block with the peer if his block height is higher then ours.
|
// 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() {
|
if p.LastBlockIndex() > p.server.chain.BlockHeight() {
|
||||||
|
|
Loading…
Reference in a new issue