diff --git a/exchange/fx_exchange.go b/exchange/fx_exchange.go index b04d3e3c..714ca787 100644 --- a/exchange/fx_exchange.go +++ b/exchange/fx_exchange.go @@ -95,12 +95,12 @@ func NewFxExchange(h host.Host, ls ipld.LinkSystem, o ...Option) (*FxExchange, e return nil, err } } - if !e.ipniPublishDisabled { - e.pub, err = newIpniPublisher(h, opts) - if err != nil { - return nil, err - } + //if !e.ipniPublishDisabled { + e.pub, err = newIpniPublisher(h, opts) + if err != nil { + return nil, err } + //} return e, nil } @@ -120,14 +120,20 @@ func (e *FxExchange) GetAuthorizedPeers(ctx context.Context) ([]peer.ID, error) return peerList, nil } +func (e *FxExchange) IpniNotifyLink(link ipld.Link) { + log.Debugw("Notifying link to IPNI publisher...", "link", link) + e.pub.notifyReceivedLink(link) + log.Debugw("Successfully notified link to IPNI publisher", "link", link) +} + func (e *FxExchange) Start(ctx context.Context) error { gsn := gsnet.NewFromLibp2pHost(e.h) e.gx = gs.New(ctx, gsn, e.ls) + if err := e.pub.Start(ctx); err != nil { + return err + } if !e.ipniPublishDisabled { - if err := e.pub.Start(ctx); err != nil { - return err - } e.gx.RegisterIncomingBlockHook(func(p peer.ID, responseData graphsync.ResponseData, blockData graphsync.BlockData, hookActions graphsync.IncomingBlockHookActions) { go func(link ipld.Link) { log.Debugw("Notifying link to IPNI publisher...", "link", link) @@ -374,11 +380,11 @@ func (e *FxExchange) authorized(pid peer.ID, action string) bool { } func (e *FxExchange) Shutdown(ctx context.Context) error { - if !e.ipniPublishDisabled { - if err := e.pub.shutdown(); err != nil { - log.Warnw("Failed to shutdown IPNI publisher gracefully", "err", err) - } + //if !e.ipniPublishDisabled { + if err := e.pub.shutdown(); err != nil { + log.Warnw("Failed to shutdown IPNI publisher gracefully", "err", err) } + //} e.c.CloseIdleConnections() return e.s.Shutdown(ctx) } diff --git a/exchange/interface.go b/exchange/interface.go index d4b1c351..012bc51c 100644 --- a/exchange/interface.go +++ b/exchange/interface.go @@ -13,4 +13,5 @@ type Exchange interface { Pull(context.Context, peer.ID, ipld.Link) error SetAuth(context.Context, peer.ID, peer.ID, bool) error Shutdown(context.Context) error + IpniNotifyLink(link ipld.Link) } diff --git a/exchange/noop_exchange.go b/exchange/noop_exchange.go index b4eca218..d8f7a7ab 100644 --- a/exchange/noop_exchange.go +++ b/exchange/noop_exchange.go @@ -35,3 +35,7 @@ func (n NoopExchange) Shutdown(context.Context) error { log.Debug("Shut down noop exchange.") return nil } + +func (n NoopExchange) IpniNotifyLink(l ipld.Link) { + log.Debugw("IpniNotifyLink noop exchange.", "link", l) +} diff --git a/mobile/client.go b/mobile/client.go index 226b5398..61d40da8 100644 --- a/mobile/client.go +++ b/mobile/client.go @@ -185,6 +185,7 @@ func (c *Client) Put(value []byte, codec int64) ([]byte, error) { return nil, err } c.markAsRecentCid(ctx, link.(cidlink.Link)) + c.ex.IpniNotifyLink(link.(cidlink.Link)) return link.(cidlink.Link).Cid.Bytes(), nil }