quick out addPAth
This commit is contained in:
@@ -88,7 +88,7 @@ func (p *PeerCache) LaunchPeerExecution(peerID string, dataID string,
|
||||
// If the peer is not reachable, add the execution to the failed executions list
|
||||
pexec := &PeerExecution{
|
||||
Method: method.String(),
|
||||
Url: p.urlFormat((mypeer.Url)+meth, dt),
|
||||
Url: p.urlFormat((mypeer.Url)+"/"+dt.API()+meth, dt),
|
||||
Body: body,
|
||||
DataType: dt.EnumIndex(),
|
||||
DataID: dataID,
|
||||
@@ -98,11 +98,11 @@ func (p *PeerCache) LaunchPeerExecution(peerID string, dataID string,
|
||||
return nil, errors.New("peer is not reachable")
|
||||
} else {
|
||||
// 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
|
||||
mypeer.FailedExecution = []PeerExecution{} // Reset the failed executions list
|
||||
mypeer.GetAccessor(nil).UpdateOne(mypeer, peerID) // Update the peer in the db
|
||||
for _, v := range tmp { // Retry the failed executions
|
||||
url = p.urlFormat((mypeer.Url)+"/"+dt.API()+meth, dt) // Format the URL
|
||||
tmp := mypeer.FailedExecution // Get the failed executions list
|
||||
mypeer.FailedExecution = []PeerExecution{} // Reset the failed executions list
|
||||
mypeer.GetAccessor(nil).UpdateOne(mypeer, peerID) // Update the peer in the db
|
||||
for _, v := range tmp { // Retry the failed executions
|
||||
go p.exec(v.Url, tools.ToMethod(v.Method), v.Body, caller)
|
||||
}
|
||||
}
|
||||
@@ -113,7 +113,6 @@ 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", url, method, body)
|
||||
if method == tools.POST { // Execute the POST method if it's a POST method
|
||||
b, err = caller.CallPost(url, "", body)
|
||||
}
|
||||
@@ -128,7 +127,6 @@ func (p *PeerCache) exec(url string, method tools.METHOD, body map[string]interf
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println("response", m["error"], m["error"] != "<nil>")
|
||||
if e, ok := m["error"]; ok && e != "<nil>" { // Check if there is an error in the response
|
||||
return errors.New(fmt.Sprintf("%v", m["error"]))
|
||||
}
|
||||
|
Reference in New Issue
Block a user