Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Commit

Permalink
Merge pull request #2059 from OpenBazaar/brian.pushtosearch
Browse files Browse the repository at this point in the history
Update to support Tor connections and update command
  • Loading branch information
cpacia authored Apr 21, 2020
2 parents 25a84a4 + 9422da7 commit c252848
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,6 @@ func (n *OpenBazaarNode) SeedNode() error {
}
n.RootHash = rootHash

go func() {
// Ping search endpoint with published hash
peerId, _ := n.GetNodeID()
endpoint := fmt.Sprintf("https://search.ob1.io/ping/%s/%s", peerId.PeerID, rootHash)
log.Infof("Publishing new rootHash to: %s\n", endpoint)
resp, err := http.Get(endpoint)
if err != nil {
log.Errorf("Search Ping did not succeed. %v\n", err)
}
log.Debugf("%s respone: %v", endpoint, resp)
}()

n.seedLock.Unlock()
n.InitalPublishComplete = true
go n.publish(rootHash)
Expand All @@ -195,6 +183,27 @@ func (n *OpenBazaarNode) publish(hash string) {
return
}

go func() {
// Update search endpoint with published hash
peerId, _ := n.GetNodeID()
endpoint := fmt.Sprintf("https://search.ob1.io/update/%s/%s", peerId.PeerID, hash)
log.Infof("Publishing new rootHash to: %s\n", endpoint)

var client *http.Client
if n.TorDialer != nil {
tbTransport := &http.Transport{Dial: n.TorDialer.Dial}
client = &http.Client{Transport: tbTransport, Timeout: time.Second * 30}
} else {
client = &http.Client{Timeout: time.Second * 30}
}

resp, err := client.Get(endpoint)
if err != nil {
log.Errorf("Search update did not succeed. %v\n", err)
}
log.Debugf("%s response: %v", endpoint, resp)
}()

inflightPublishRequests++
err = ipfs.Publish(n.IpfsNode, hash)

Expand Down

0 comments on commit c252848

Please sign in to comment.