diff --git a/models/peer/peer_cache.go b/models/peer/peer_cache.go index 2b01324..50d731f 100644 --- a/models/peer/peer_cache.go +++ b/models/peer/peer_cache.go @@ -91,7 +91,7 @@ func (p *PeerCache) LaunchPeerExecution(peerID string, dataID string, url := "" // Check the status of the peer - if mypeer, ok := p.checkPeerStatus(peerID, dt.API(), caller); !ok { + if mypeer, ok := p.checkPeerStatus(peerID, dt.API(), caller); !ok && mypeer != nil { // If the peer is not reachable, add the execution to the failed executions list pexec := &PeerExecution{ Method: method.String(), @@ -104,6 +104,9 @@ func (p *PeerCache) LaunchPeerExecution(peerID string, dataID string, mypeer.GetAccessor(nil).UpdateOne(mypeer, peerID) // Update the peer in the db return nil, errors.New("peer is not reachable") } else { + if mypeer == nil { + return nil, errors.New("peer not found") + } // If the peer is reachable, launch the execution url = p.urlFormat((mypeer.Url)+meth, dt) // Format the URL tmp := mypeer.FailedExecution // Get the failed executions list