Skip to content

Commit

Permalink
Fix les server handler for registered peers
Browse files Browse the repository at this point in the history
  • Loading branch information
gastonponti committed Jul 12, 2021
1 parent 19ed236 commit 981b360
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions les/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,21 @@ func (s *serverSet) register(peer *clientPeer) error {
return nil
}

func (s *serverSet) unregister(peer *clientPeer) error {
s.lock.Lock()
defer s.lock.Unlock()

if s.closed {
return errClosed
}
if _, exist := s.set[peer.id]; !exist {
return errNotRegistered
}
delete(s.set, peer.id)
peer.Peer.Disconnect(p2p.DiscQuitting)
return nil
}

func (s *serverSet) close() {
s.lock.Lock()
defer s.lock.Unlock()
Expand Down
1 change: 1 addition & 0 deletions les/server_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ func (h *serverHandler) handle(p *clientPeer) error {
}
// connected to another server, no messages expected, just wait for disconnection
_, err := p.rw.ReadMsg()
h.server.serverset.unregister(p)
return err
}
// Reject light clients if server is not synced.
Expand Down

0 comments on commit 981b360

Please sign in to comment.