@cryptotaxi247 / kubo / commits / db45c4d0d

remove bitswap unwant

This command messes with internal state and doesn't even work at the moment. If you don't want a block, you should cancel the request that's trying to fetch it. fixes #5295 License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>

Steven Allen committed Jul 29, 2018 at 11:42 UTC db45c4d0d9ab0b8f9a4f2120f44126cb771edf6c
3 files changed +1 -60
core/commands/bitswap.go
-48
@@ -16,7 +16,6 @@ import (
16 cmds "gx/ipfs/QmPTfgFTo9PFr1PvPKyKoeMgBvYPh6cX3aDP7DHKVbnCbi/go-ipfs-cmds"
17 peer "gx/ipfs/QmQsErDt8Qgw1XrsXf2BpEzDgGWtB1YLsTAARBup5b6B9W/go-libp2p-peer"
18 cmdkit "gx/ipfs/QmSP88ryZkHSRn1fnngAaV2Vcn63WUJzAavnRM9CVdU1Ky/go-ipfs-cmdkit"
19 - cid "gx/ipfs/QmZFbDTY9jfSBms2MchvYM9oYRbAF19K7Pby47yDBfpPrb/go-cid"
19 )
20
21 var BitswapCmd = &cmds.Command{
@@ -28,58 +27,11 @@ var BitswapCmd = &cmds.Command{
27 Subcommands: map[string]*cmds.Command{
28 "stat": bitswapStatCmd,
29 "wantlist": lgc.NewCommand(showWantlistCmd),
31 - "unwant": lgc.NewCommand(unwantCmd),
30 "ledger": lgc.NewCommand(ledgerCmd),
31 "reprovide": lgc.NewCommand(reprovideCmd),
32 },
33 }
34
37 -var unwantCmd = &oldcmds.Command{
38 - Helptext: cmdkit.HelpText{
39 - Tagline: "Remove a given block from your wantlist.",
40 - },
41 - Arguments: []cmdkit.Argument{
42 - cmdkit.StringArg("key", true, true, "Key(s) to remove from your wantlist.").EnableStdin(),
43 - },
44 - Run: func(req oldcmds.Request, res oldcmds.Response) {
45 - nd, err := req.InvocContext().GetNode()
46 - if err != nil {
47 - res.SetError(err, cmdkit.ErrNormal)
48 - return
49 - }
50 -
51 - if !nd.OnlineMode() {
52 - res.SetError(ErrNotOnline, cmdkit.ErrClient)
53 - return
54 - }
55 -
56 - bs, ok := nd.Exchange.(*bitswap.Bitswap)
57 - if !ok {
58 - res.SetError(e.TypeErr(bs, nd.Exchange), cmdkit.ErrNormal)
59 - return
60 - }
61 -
62 - var ks []*cid.Cid
63 - for _, arg := range req.Arguments() {
64 - c, err := cid.Decode(arg)
65 - if err != nil {
66 - res.SetError(err, cmdkit.ErrNormal)
67 - return
68 - }
69 -
70 - ks = append(ks, c)
71 - }
72 -
73 - // TODO: This should maybe find *all* sessions for this request and cancel them?
74 - // (why): in reality, i think this command should be removed. Its
75 - // messing with the internal state of bitswap. You should cancel wants
76 - // by killing the command that caused the want.
77 - bs.CancelWants(ks, 0)
78 -
79 - res.SetOutput(nil)
80 - },
81 -}
82 -
35 var showWantlistCmd = &oldcmds.Command{
36 Helptext: cmdkit.HelpText{
37 Tagline: "Show blocks currently on the wantlist.",
core/commands/commands_test.go
-1
@@ -73,7 +73,6 @@ func TestCommands(t *testing.T) {
73 "/bitswap/ledger",
74 "/bitswap/reprovide",
75 "/bitswap/stat",
76 - "/bitswap/unwant",
76 "/bitswap/wantlist",
77 "/block",
78 "/block/get",
misc/completion/ipfs-completion.bash
+1 -11
@@ -27,7 +27,7 @@ _ipfs_add()
27
28 _ipfs_bitswap()
29 {
30 - ipfs_comp "ledger stat unwant wantlist --help"
30 + ipfs_comp "ledger stat wantlist --help"
31 }
32
33 _ipfs_bitswap_ledger()
@@ -40,21 +40,11 @@ _ipfs_bitswap_stat()
40 _ipfs_help_only
41 }
42
43 -_ipfs_bitswap_unwant()
44 -{
45 - _ipfs_help_only
46 -}
47 -
43 _ipfs_bitswap_wantlist()
44 {
45 ipfs_comp "--peer= --help"
46 }
47
53 -_ipfs_bitswap_unwant()
54 -{
55 - _ipfs_help_only
56 -}
57 -
48 _ipfs_block()
49 {
50 _ipfs_comp "get put rm stat --help"