Skip to content

Commit

Permalink
Fix Panics in P2P Service (#5442)
Browse files Browse the repository at this point in the history
* fix panics
* Merge branch 'master' into smallFixes
* Merge refs/heads/master into smallFixes
* Merge refs/heads/master into smallFixes
  • Loading branch information
nisdas committed Apr 15, 2020
1 parent 046a00a commit 144f37e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions beacon-chain/p2p/peers/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ func (p *Status) SubscribedToSubnet(index uint64) []peer.ID {
peers := make([]peer.ID, 0)
for pid, status := range p.status {
// look at active peers
if status.peerState == PeerConnecting || status.peerState == PeerConnected &&
status.metaData != nil {
connectedStatus := status.peerState == PeerConnecting || status.peerState == PeerConnected
if connectedStatus && status.metaData != nil && status.metaData.Attnets != nil {
indices := retrieveIndicesFromBitfield(status.metaData.Attnets)
for _, idx := range indices {
if idx == index {
Expand Down
4 changes: 4 additions & 0 deletions beacon-chain/p2p/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ func (s *Service) RefreshENR(epoch uint64) {
// with those peers.
func (s *Service) FindPeersWithSubnet(index uint64) (bool, error) {
nodes := make([]*enode.Node, searchLimit)
if s.dv5Listener == nil {
// return if discovery isn't set
return false, nil
}
num := s.dv5Listener.ReadRandomNodes(nodes)
exists := false
for _, node := range nodes[:num] {
Expand Down

0 comments on commit 144f37e

Please sign in to comment.