Skip to content

Commit

Permalink
Add check for nil map (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipsu522 authored May 4, 2023
1 parent 400e0d6 commit ebd8ff2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/p2p/peermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,9 @@ func (m *PeerManager) Add(address NodeAddress) (bool, error) {
}

// else add the new address
if len(peer.AddressInfo) == 0 {
peer.AddressInfo = make(map[NodeAddress]*peerAddressInfo)
}
peer.AddressInfo[address] = &peerAddressInfo{Address: address}
m.logger.Info(fmt.Sprintf("Adding new peer %s with address %s to peer store\n", peer.ID, address.String()))
if err := m.store.Set(peer); err != nil {
Expand Down

0 comments on commit ebd8ff2

Please sign in to comment.