From dff188c46985a4db71239bab0fb49194115527f7 Mon Sep 17 00:00:00 2001 From: Will Scott Date: Mon, 9 Aug 2021 22:55:11 -0700 Subject: [PATCH] Add a WithReifier method to allow easier derivation of different pathing semantics This commit was moved from ipfs/go-fetcher@b24de2cb27b4008c031e886138a6f348ecaffd16 --- fetcher/impl/blockservice/fetcher.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fetcher/impl/blockservice/fetcher.go b/fetcher/impl/blockservice/fetcher.go index b0ee9f417..237f3f955 100644 --- a/fetcher/impl/blockservice/fetcher.go +++ b/fetcher/impl/blockservice/fetcher.go @@ -50,6 +50,16 @@ func (fc FetcherConfig) NewSession(ctx context.Context) fetcher.Fetcher { return &fetcherSession{linkSystem: ls, protoChooser: protoChooser} } +// WithReifier derives a different fetcher factory from the same source but +// with a chosen NodeReifier for pathing semantics. +func (fc FetcherConfig) WithReifier(nr ipld.NodeReifier) fetcher.Factory { + return FetcherConfig{ + blockService: fc.blockService, + NodeReifier: nr, + PrototypeChooser: fc.PrototypeChooser, + } +} + // interface check var _ fetcher.Factory = FetcherConfig{}