From f9b63c5f8c61836411efb20147882f4ee3c5e90a Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Wed, 2 Feb 2022 11:36:08 +0100 Subject: [PATCH] add idxProvHost to StorageProvider --- node/builder_miner.go | 1 + node/modules/storageminer.go | 2 ++ node/modules/storageminer_idxprov.go | 21 ++++++++++++++++++--- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/node/builder_miner.go b/node/builder_miner.go index de22ef8aa..e45e8d19a 100644 --- a/node/builder_miner.go +++ b/node/builder_miner.go @@ -168,6 +168,7 @@ func ConfigStorageMiner(c interface{}) Option { Override(new(dtypes.ProviderTransferNetwork), modules.NewProviderTransferNetwork), Override(new(dtypes.ProviderTransport), modules.NewProviderTransport), Override(new(dtypes.ProviderDataTransfer), modules.NewProviderDataTransfer), + Override(new(*modules.IdxProvHost), modules.IndexerProviderHost(cfg.IndexerProvider)), Override(new(provider.Interface), modules.IndexerProvider(cfg.IndexerProvider)), Override(new(*storedask.StoredAsk), modules.NewStorageAsk), Override(new(dtypes.StorageDealFilter), modules.BasicDealFilter(cfg.Dealmaking, nil)), diff --git a/node/modules/storageminer.go b/node/modules/storageminer.go index 2a6b61b69..34b27d9d7 100644 --- a/node/modules/storageminer.go +++ b/node/modules/storageminer.go @@ -591,6 +591,7 @@ func StorageProvider(minerAddress dtypes.MinerAddress, df dtypes.StorageDealFilter, dsw *dagstore.Wrapper, fullnodeApi v1api.FullNode, + idxProvHost *IdxProvHost, ) (storagemarket.StorageProvider, error) { net := smnet.NewFromLibp2pHost(h) @@ -622,6 +623,7 @@ func StorageProvider(minerAddress dtypes.MinerAddress, address.Address(minerAddress), storedAsk, fullnodeApi, + idxProvHost.Host, opt, ) } diff --git a/node/modules/storageminer_idxprov.go b/node/modules/storageminer_idxprov.go index 8a0d21057..b200d23eb 100644 --- a/node/modules/storageminer_idxprov.go +++ b/node/modules/storageminer_idxprov.go @@ -48,10 +48,12 @@ type IdxProv struct { peerstore.Peerstore } -func IndexerProvider(cfg config.IndexerProviderConfig) func(params IdxProv, marketHost host.Host) (provider.Interface, error) { - return func(args IdxProv, marketHost host.Host) (provider.Interface, error) { - ipds := namespace.Wrap(args.Datastore, datastore.NewKey("/indexer-provider")) +type IdxProvHost struct { + host.Host +} +func IndexerProviderHost(cfg config.IndexerProviderConfig) func(IdxProv) (*IdxProvHost, error) { + return func(args IdxProv) (*IdxProvHost, error) { pkey := args.Peerstore.PrivKey(args.PeerID) if pkey == nil { return nil, fmt.Errorf("missing private key for node ID: %s", args.PeerID.Pretty()) @@ -62,6 +64,19 @@ func IndexerProvider(cfg config.IndexerProviderConfig) func(params IdxProv, mark return nil, xerrors.Errorf("creating indexer provider host: %w", err) } + return &IdxProvHost{h}, nil + } +} + +func IndexerProvider(cfg config.IndexerProviderConfig) func(params IdxProv, marketHost host.Host, h *IdxProvHost) (provider.Interface, error) { + return func(args IdxProv, marketHost host.Host, h *IdxProvHost) (provider.Interface, error) { + ipds := namespace.Wrap(args.Datastore, datastore.NewKey("/indexer-provider")) + + pkey := args.Peerstore.PrivKey(args.PeerID) + if pkey == nil { + return nil, fmt.Errorf("missing private key for node ID: %s", args.PeerID.Pretty()) + } + dt, err := newIndexerProviderDataTransfer(cfg, args.MetricsCtx, args.Lifecycle, args.Repo, h, ipds) if err != nil { return nil, err