light modification
This commit is contained in:
parent
d1f6331ff8
commit
305f260503
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user