From bc12fb53be238deb89e027f82493d00d0e85887c Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 21 Jan 2025 11:11:18 +0100 Subject: [PATCH] light modification --- models/peer/peer_cache.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/models/peer/peer_cache.go b/models/peer/peer_cache.go index e877686..e69dd3c 100644 --- a/models/peer/peer_cache.go +++ b/models/peer/peer_cache.go @@ -57,24 +57,28 @@ func (p *PeerCache) urlFormat(url string, dt tools.DataType) string { func (p *PeerCache) checkPeerStatus(peerID string, appName string, caller *tools.HTTPCaller) (*Peer, bool) { api := tools.API{} access := NewShallowAccessor() - res, code, _ := access.LoadOne(peerID) // Load the peer from db - if code != 200 { // no peer no party + res, code, err := access.LoadOne(peerID) // Load the peer from db + fmt.Println("Checking peer status", res, code, err) + if code != 200 { // no peer no party return nil, false } methods := caller.URLS[tools.PEER] // Get the methods url of the peer + fmt.Println("Checking peer status 2", methods) if methods == nil { return res.(*Peer), false } meth := methods[tools.POST] // Get the POST method to check status + fmt.Println("Checking peer status 3", meth) if meth == "" { return res.(*Peer), false } url := p.urlFormat(res.(*Peer).Url, tools.PEER) + meth // Format the URL fmt.Println("Checking peer status on", url, "...") state, services := api.CheckRemotePeer(url) - fmt.Println("Checking peer status on", url, state, services) // Check the status of the peer - res.(*Peer).ServicesState = services // Update the services states of the peer - access.UpdateOne(res, peerID) // Update the peer in the db + fmt.Println("Checking peer status on", url, state, services) // Check the status of the peer + res.(*Peer).ServicesState = services // Update the services states of the peer + access.UpdateOne(res, peerID) // Update the peer in the db + fmt.Println("Checking peer status 4", state, state != tools.DEAD, services[appName]) return res.(*Peer), state != tools.DEAD && services[appName] == 0 // Return the peer and its status }