diff --git a/models/peer/peer_cache.go b/models/peer/peer_cache.go index 4baeaec..9719d14 100644 --- a/models/peer/peer_cache.go +++ b/models/peer/peer_cache.go @@ -33,10 +33,10 @@ type PeerCache struct { Executions []*PeerExecution } -func (p *PeerCache) urlFormat(url string) string { +func (p *PeerCache) urlFormat(url string, dt utils.DataType) string { if strings.Contains(url, "localhost") || strings.Contains(url, "127.0.0.1") { - url = strings.ReplaceAll(url, "localhost", utils.PEER.API()) - url = strings.ReplaceAll(url, "127.0.0.1", utils.PEER.API()) + url = strings.ReplaceAll(url, "localhost", dt.API()) + url = strings.ReplaceAll(url, "127.0.0.1", dt.API()) r := regexp.MustCompile("(:[0-9]+)") t := r.FindString(url) if t != "" { @@ -65,11 +65,9 @@ func (p *PeerCache) checkPeerStatus(peerID string, caller *tools.HTTPCaller) boo if meth == "" { return false } - url := p.urlFormat(res.(*Peer).Url + meth) + url := p.urlFormat(res.(*Peer).Url+meth, utils.PEER) fmt.Println("checkPeerStatus AFT 4", url) state := api.CheckRemotePeer(url) - fmt.Println("checkPeerStatus AFT 4", state, tools.DEAD) - return state != tools.DEAD } @@ -81,13 +79,10 @@ func (p *PeerCache) GetAccessor(caller *tools.HTTPCaller) utils.Accessor { func (p *PeerCache) LaunchPeerExecution(peerID string, isMySelf bool, dataID string, url string, dt utils.DataType, method tools.METHOD, body map[string]interface{}, caller *tools.HTTPCaller) (*PeerExecution, error) { - fmt.Println("LaunchPeerExecution", url, strings.Contains(url, "localhost") || strings.Contains(url, "127.0.0.1")) - url = p.urlFormat(url) - fmt.Println("LaunchPeerExecution AFT", url, dt.API()) + url = p.urlFormat(url, dt) var err error b := []byte{} methods := caller.URLS[dt.String()] - fmt.Println("LaunchPeerExecution AFT 2", methods) if _, ok := methods[method]; !ok { return nil, errors.New("no path found") }