Improve peer hints for pin remote add (#8143)
* improve peer hints in pin.origins
Brian Strauch committed
Jun 25, 2021 at 10:10 UTC
5ad04176b1b5cb42eb76e2a63c4054276c28f5dd
1 file changed
+9
-3
core/commands/pin/remotepin.go
+9
-3
@@ -167,13 +167,19 @@ NOTE: a comma-separated notation is supported in CLI for convenience:
167
}
168
169
// Prepare Pin.origins
170
- // Add own multiaddrs to the 'origins' array, so Pinning Service can
171
- // use that as a hint and connect back to us (if possible)
170
+ // If CID in blockstore, add own multiaddrs to the 'origins' array
171
+ // so pinning service can use that as a hint and connect back to us.
172
node, err := cmdenv.GetNode(env)
173
if err != nil {
174
return err
175
}
176
- if node.PeerHost != nil {
176
+
177
+ isInBlockstore, err := node.Blockstore.Has(rp.Cid())
178
+ if err != nil {
179
+ return err
180
+ }
181
+
182
+ if isInBlockstore && node.PeerHost != nil {
183
addrs, err := peer.AddrInfoToP2pAddrs(host.InfoFromHost(node.PeerHost))
184
if err != nil {
185
return err