Skip to content

Commit

Permalink
Merge pull request #245 from kcalvinalvin/2025-01-21-prevent-runtime-…
Browse files Browse the repository at this point in the history
…error

netsync: fix bug in peer selection logic
  • Loading branch information
kcalvinalvin authored Jan 21, 2025
2 parents 2d4bb72 + 5939535 commit 0138821
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions netsync/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -1091,9 +1091,15 @@ func (sm *SyncManager) fetchUtreexoHeaders(peer *peerpkg.Peer) {
return
}

// Can't fetch if both are nil.
if peer == nil && sm.syncPeer == nil {
log.Warnf("fetchUtreexoHeader called with syncPeer and peer as nil")
return
}

// Default to the syncPeer unless we're given a peer by the caller.
reqPeer := sm.syncPeer
if reqPeer == nil {
if peer != nil {
reqPeer = peer
}

Expand Down Expand Up @@ -1134,9 +1140,15 @@ func (sm *SyncManager) fetchHeaderBlocks(peer *peerpkg.Peer) {
return
}

// Can't fetch if both are nil.
if peer == nil && sm.syncPeer == nil {
log.Warnf("fetchHeaderBlocks called with syncPeer and peer as nil")
return
}

// Default to the syncPeer unless we're given a peer by the caller.
reqPeer := sm.syncPeer
if reqPeer == nil {
if peer != nil {
reqPeer = peer
}

Expand Down

0 comments on commit 0138821

Please sign in to comment.