From 4bac045288bead814b1f73b5f2b9f8faaff5a4dd Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 8 Apr 2020 17:27:21 -0700 Subject: [PATCH] fix: remove local provider check It doesn't actually work. Blocks are stored under /blocks and have been since 2015. Furthermore, this is just wrong. We shouldn't go digging through the datastore to see if we happen to have the block. If we want something like this, we should include a blockstore in the provider manager. --- handlers.go | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/handlers.go b/handlers.go index 3dc709792..4c991fc13 100644 --- a/handlers.go +++ b/handlers.go @@ -316,20 +316,8 @@ func (dht *IpfsDHT) handleGetProviders(ctx context.Context, p peer.ID, pmes *pb. resp := pb.NewMessage(pmes.GetType(), pmes.GetKey(), pmes.GetClusterLevel()) - // check if we have this value, to add ourselves as provider. - has, err := dht.datastore.Has(convertToDsKey(key)) - if err != nil && err != ds.ErrNotFound { - // FIXME: This doesn't work reliably. If we want this check, we - // need a _blockstore_. - logger.Errorw("error checking datastore for block", "key", key, "error", err) - has = false - } - // setup providers providers := dht.ProviderManager.GetProviders(ctx, key) - if has { - providers = append(providers, dht.self) - } if len(providers) > 0 { // TODO: pstore.PeerInfos should move to core (=> peerstore.AddrInfos).