From 3b8079ca87ad75d1d73e1a3bea9c5bdf4d8f18bd Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 19 Nov 2024 10:08:46 +0100 Subject: [PATCH] hard stuff --- models/peer/peer_cache.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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