Skip to content

Commit

Permalink
fix: don't try to marshal a nil record
Browse files Browse the repository at this point in the history
fixes #939
  • Loading branch information
Stebalien committed May 20, 2020
1 parent aa60461 commit 60fcc56
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions p2p/protocol/identify/id.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,6 @@ func (ids *IDService) getSnapshot() *identifySnapshot {
if !ids.disableSignedPeerRecord {
if cab, ok := peerstore.GetCertifiedAddrBook(ids.Host.Peerstore()); ok {
snapshot.record = cab.GetPeerRecord(ids.Host.ID())
if snapshot.record == nil {
log.Errorf("latest peer record does not exist. identify message incomplete!")
}
}
}
snapshot.addrs = ids.Host.Addrs()
Expand Down Expand Up @@ -465,7 +462,7 @@ func (ids *IDService) populateMessage(
mes.ListenAddrs = append(mes.ListenAddrs, addr.Bytes())
}

if !ids.disableSignedPeerRecord {
if !ids.disableSignedPeerRecord && snapshot.record != nil {
recBytes, err := snapshot.record.Marshal()
if err != nil {
log.Errorf("error marshaling peer record: %v", err)
Expand Down

0 comments on commit 60fcc56

Please sign in to comment.