From 305f2605030d1b39d4067bf83a5247440419c3b2 Mon Sep 17 00:00:00 2001 From: mr Date: Mon, 20 Jan 2025 15:35:09 +0100 Subject: [PATCH] light modification --- models/peer/peer_cache.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/models/peer/peer_cache.go b/models/peer/peer_cache.go index 6482400..3b590d5 100644 --- a/models/peer/peer_cache.go +++ b/models/peer/peer_cache.go @@ -93,6 +93,7 @@ func (p *PeerCache) LaunchPeerExecution(peerID string, dataID string, // Check the status of the peer 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 + fmt.Println("Peer is not reachable") pexec := &PeerExecution{ Method: method.String(), Url: p.urlFormat((mypeer.Url)+meth, dt), @@ -104,6 +105,7 @@ func (p *PeerCache) LaunchPeerExecution(peerID string, dataID string, NewShallowAccessor().UpdateOne(mypeer, peerID) // Update the peer in the db return nil, errors.New("peer is not reachable") } else { + fmt.Println("Peer is reachable") if mypeer == nil { return nil, errors.New("peer not found") } @@ -124,6 +126,7 @@ func (p *PeerCache) LaunchPeerExecution(peerID string, dataID string, func (p *PeerCache) exec(url string, method tools.METHOD, body map[string]interface{}, caller *tools.HTTPCaller) error { var b []byte var err error + fmt.Println("Executing", method, "on", url, "with", body) if method == tools.POST { // Execute the POST method if it's a POST method b, err = caller.CallPost(url, "", body) } @@ -133,8 +136,11 @@ func (p *PeerCache) exec(url string, method tools.METHOD, body map[string]interf if method == tools.DELETE { // Execute the DELETE method if it's a DELETE method b, err = caller.CallDelete(url, "") } + if err != nil { + return err + } var m map[string]interface{} - json.Unmarshal(b, &m) + err = json.Unmarshal(b, &m) if err != nil { return err }