Skip to content

Commit

Permalink
core/commands: remove 'ipfs dht' commands, except 'query'
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Feb 1, 2024
1 parent 2f62ff6 commit e2fbffd
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 206 deletions.
5 changes: 0 additions & 5 deletions core/commands/commands_test.go
Expand Up @@ -117,11 +117,6 @@ func TestCommands(t *testing.T) {
"/dag/resolve",
"/dag/stat",
"/dht",
"/dht/findpeer",
"/dht/findprovs",
"/dht/get",
"/dht/provide",
"/dht/put",
"/dht/query",
"/routing",
"/routing/put",
Expand Down
57 changes: 1 addition & 56 deletions core/commands/dht.go
Expand Up @@ -21,65 +21,10 @@ var DhtCmd = &cmds.Command{
},

Subcommands: map[string]*cmds.Command{
"query": queryDhtCmd,
"findprovs": findProvidersDhtCmd,
"findpeer": findPeerDhtCmd,
"get": getValueDhtCmd,
"put": putValueDhtCmd,
"provide": provideRefDhtCmd,
"query": queryDhtCmd,
},
}

var findProvidersDhtCmd = &cmds.Command{
Helptext: findProvidersRoutingCmd.Helptext,
Arguments: findProvidersRoutingCmd.Arguments,
Options: findProvidersRoutingCmd.Options,
Run: findProvidersRoutingCmd.Run,
Encoders: findProvidersRoutingCmd.Encoders,
Type: findProvidersRoutingCmd.Type,
Status: cmds.Deprecated,
}

var findPeerDhtCmd = &cmds.Command{
Helptext: findPeerRoutingCmd.Helptext,
Arguments: findPeerRoutingCmd.Arguments,
Options: findPeerRoutingCmd.Options,
Run: findPeerRoutingCmd.Run,
Encoders: findPeerRoutingCmd.Encoders,
Type: findPeerRoutingCmd.Type,
Status: cmds.Deprecated,
}

var getValueDhtCmd = &cmds.Command{
Helptext: getValueRoutingCmd.Helptext,
Arguments: getValueRoutingCmd.Arguments,
Options: getValueRoutingCmd.Options,
Run: getValueRoutingCmd.Run,
Encoders: getValueRoutingCmd.Encoders,
Type: getValueRoutingCmd.Type,
Status: cmds.Deprecated,
}

var putValueDhtCmd = &cmds.Command{
Helptext: putValueRoutingCmd.Helptext,
Arguments: putValueRoutingCmd.Arguments,
Options: putValueRoutingCmd.Options,
Run: putValueRoutingCmd.Run,
Encoders: putValueRoutingCmd.Encoders,
Type: putValueRoutingCmd.Type,
Status: cmds.Deprecated,
}

var provideRefDhtCmd = &cmds.Command{
Helptext: provideRefRoutingCmd.Helptext,
Arguments: provideRefRoutingCmd.Arguments,
Options: provideRefRoutingCmd.Options,
Run: provideRefRoutingCmd.Run,
Encoders: provideRefRoutingCmd.Encoders,
Type: provideRefRoutingCmd.Type,
Status: cmds.Deprecated,
}

// kademlia extends the routing interface with a command to get the peers closest to the target
type kademlia interface {
routing.Routing
Expand Down
7 changes: 6 additions & 1 deletion docs/changelogs/v0.27.md
Expand Up @@ -9,6 +9,7 @@
- [Gateway: support for `/api/v0` is deprecated](#gateway-support-for-apiv0-is-deprecated)
- [IPNS resolver cache's TTL can now be configured](#ipns-resolver-caches-ttl-can-now-be-configured)
- [RPC client: deprecated DHT API, added Routing API](#rpc-client-deprecated-dht-api-added-routing-api)
- [Deprecated DHT commands removed from `/api/v0/dht`](#deprecated-dht-commands-removed-from-apiv0dht)
- [📝 Changelog](#-changelog)
- [👨‍👩‍👧‍👦 Contributors](#-contributors)

Expand All @@ -28,10 +29,14 @@ You can now configure the upper-bound of a cached IPNS entry's Time-To-Live via

#### RPC client: deprecated DHT API, added Routing API

The RPC client now includes a Routing API to match the available commands in `/api/v0/routing`. In addition, the DHT API has been marked as deprecated.
The RPC client now includes a Routing API to match the available commands in `/api/v0/routing`. In addition, the DHT API has been marked as deprecated.

In the next version, all DHT deprecated methods will be removed from the Go RPC client.

#### Deprecated DHT commands removed from `/api/v0/dht`

All the DHT commands that were deprecated were finally removed from `/api/v0/dht`. You can now use them via `/api/v0/routing`.

### 📝 Changelog

### 👨‍👩‍👧‍👦 Contributors
4 changes: 2 additions & 2 deletions docs/file-transfer.md
Expand Up @@ -68,7 +68,7 @@ pitfalls that people run into)
### Checking providers
When requesting content on ipfs, nodes search the DHT for 'provider records' to
see who has what content. Let's manually do that on node B to make sure that
node B is able to determine that node A has the data. Run `ipfs dht findprovs
node B is able to determine that node A has the data. Run `ipfs routing findprovs
<hash>`. We expect to see the peer ID of node A printed out. If this command
returns nothing (or returns IDs that are not node A), then no record of A
having the data exists on the network. This can happen if the data is added
Expand All @@ -85,7 +85,7 @@ In the case where node B simply cannot form a connection to node A, despite
knowing that it needs to, the likely culprit is a bad NAT. When node B learns
that it needs to connect to node A, it checks the DHT for addresses for node A,
and then starts trying to connect to them. We can check those addresses by
running `ipfs dht findpeer <node A peerID>` on node B. This command should
running `ipfs routing findpeer <node A peerID>` on node B. This command should
return a list of addresses for node A. If it doesn't return any addresses, then
you should try running the manual providing command from the previous steps.
Example output of addresses might look something like this:
Expand Down
2 changes: 0 additions & 2 deletions test/cli/basic_commands_test.go
Expand Up @@ -154,7 +154,6 @@ func TestCommandDocsWidth(t *testing.T) {
"ipfs pin remote rm": true,
"ipfs pin remote ls": true,
"ipfs pin verify": true,
"ipfs dht get": true,
"ipfs pin remote service add": true,
"ipfs pin update": true,
"ipfs pin rm": true,
Expand All @@ -167,7 +166,6 @@ func TestCommandDocsWidth(t *testing.T) {
"ipfs name": true,
"ipfs object patch append-data": true,
"ipfs object patch set-data": true,
"ipfs dht put": true,
"ipfs diag profile": true,
"ipfs diag cmds": true,
"ipfs swarm addrs local": true,
Expand Down
137 changes: 0 additions & 137 deletions test/cli/dht_legacy_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion test/cli/dht_opt_prov_test.go
Expand Up @@ -22,7 +22,7 @@ func TestDHTOptimisticProvide(t *testing.T) {
nodes.StartDaemons().Connect()

hash := nodes[0].IPFSAddStr(testutils.RandomStr(100))
nodes[0].IPFS("dht", "provide", hash)
nodes[0].IPFS("routing", "provide", hash)

res := nodes[1].IPFS("routing", "findprovs", "--num-providers=1", hash)
assert.Equal(t, nodes[0].PeerID().String(), res.Stdout.Trimmed())
Expand Down
4 changes: 2 additions & 2 deletions test/sharness/lib/test-lib.sh
Expand Up @@ -512,7 +512,7 @@ port_from_maddr() {

findprovs_empty() {
test_expect_success 'findprovs '$1' succeeds' '
ipfsi 1 dht findprovs -n 1 '$1' > findprovsOut
ipfsi 1 routing findprovs -n 1 '$1' > findprovsOut
'

test_expect_success "findprovs $1 output is empty" '
Expand All @@ -522,7 +522,7 @@ findprovs_empty() {

findprovs_expect() {
test_expect_success 'findprovs '$1' succeeds' '
ipfsi 1 dht findprovs -n 1 '$1' > findprovsOut &&
ipfsi 1 routing findprovs -n 1 '$1' > findprovsOut &&
echo '$2' > expected
'

Expand Down

0 comments on commit e2fbffd

Please sign in to comment.