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

Commit c252848

Browse files
authored
Merge pull request #2059 from OpenBazaar/brian.pushtosearch
Update to support Tor connections and update command
2 parents 25a84a4 + 9422da7 commit c252848

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

core/core.go

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -158,18 +158,6 @@ func (n *OpenBazaarNode) SeedNode() error {
158158
}
159159
n.RootHash = rootHash
160160

161-
go func() {
162-
// Ping search endpoint with published hash
163-
peerId, _ := n.GetNodeID()
164-
endpoint := fmt.Sprintf("https://search.ob1.io/ping/%s/%s", peerId.PeerID, rootHash)
165-
log.Infof("Publishing new rootHash to: %s\n", endpoint)
166-
resp, err := http.Get(endpoint)
167-
if err != nil {
168-
log.Errorf("Search Ping did not succeed. %v\n", err)
169-
}
170-
log.Debugf("%s respone: %v", endpoint, resp)
171-
}()
172-
173161
n.seedLock.Unlock()
174162
n.InitalPublishComplete = true
175163
go n.publish(rootHash)
@@ -195,6 +183,27 @@ func (n *OpenBazaarNode) publish(hash string) {
195183
return
196184
}
197185

186+
go func() {
187+
// Update search endpoint with published hash
188+
peerId, _ := n.GetNodeID()
189+
endpoint := fmt.Sprintf("https://search.ob1.io/update/%s/%s", peerId.PeerID, hash)
190+
log.Infof("Publishing new rootHash to: %s\n", endpoint)
191+
192+
var client *http.Client
193+
if n.TorDialer != nil {
194+
tbTransport := &http.Transport{Dial: n.TorDialer.Dial}
195+
client = &http.Client{Transport: tbTransport, Timeout: time.Second * 30}
196+
} else {
197+
client = &http.Client{Timeout: time.Second * 30}
198+
}
199+
200+
resp, err := client.Get(endpoint)
201+
if err != nil {
202+
log.Errorf("Search update did not succeed. %v\n", err)
203+
}
204+
log.Debugf("%s response: %v", endpoint, resp)
205+
}()
206+
198207
inflightPublishRequests++
199208
err = ipfs.Publish(n.IpfsNode, hash)
200209

0 commit comments

Comments
 (0)