diff --git a/dht_test.go b/dht_test.go index 6d6b56fe9..4b4726796 100644 --- a/dht_test.go +++ b/dht_test.go @@ -18,23 +18,23 @@ import ( "github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p-core/peerstore" "github.com/libp2p/go-libp2p-core/routing" + ma "github.com/multiformats/go-multiaddr" + "github.com/multiformats/go-multihash" + "github.com/multiformats/go-multistream" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" test "github.com/libp2p/go-libp2p-kad-dht/internal/testing" pb "github.com/libp2p/go-libp2p-kad-dht/pb" - kb "github.com/libp2p/go-libp2p-kbucket" - record "github.com/libp2p/go-libp2p-record" - swarmt "github.com/libp2p/go-libp2p-swarm/testing" - bhost "github.com/libp2p/go-libp2p/p2p/host/basic" "github.com/ipfs/go-cid" detectrace "github.com/ipfs/go-detect-race" u "github.com/ipfs/go-ipfs-util" - ma "github.com/multiformats/go-multiaddr" - "github.com/multiformats/go-multihash" - "github.com/multiformats/go-multistream" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + kb "github.com/libp2p/go-libp2p-kbucket" + record "github.com/libp2p/go-libp2p-record" + swarmt "github.com/libp2p/go-libp2p-swarm/testing" + bhost "github.com/libp2p/go-libp2p/p2p/host/basic" ) var testCaseCids []cid.Cid diff --git a/records.go b/records.go index bba505080..23d6ee7da 100644 --- a/records.go +++ b/records.go @@ -18,6 +18,10 @@ type pubkrs struct { // GetPublicKey gets the public key when given a Peer ID. It will extract from // the Peer ID if inlined or ask the node it belongs to or ask the DHT. func (dht *IpfsDHT) GetPublicKey(ctx context.Context, p peer.ID) (ci.PubKey, error) { + if !dht.enableValues { + return nil, routing.ErrNotSupported + } + logger.Debugf("getPublicKey for: %s", p) // Check locally. Will also try to extract the public key from the peer