commands/bitswap: use cmds.EmitOnce in single value
License: MIT Signed-off-by: Overbool <overbool.xu@gmail.com>
Overbool committed
Oct 30, 2018 at 10:15 UTC
73fef489f5655b19678c442814d6093443ee635b
1 file changed
+4
-7
core/commands/bitswap.go
+4
-7
@@ -59,21 +59,18 @@ Print out all blocks currently on the bitswap wantlist for the local peer.`,
59
}
60
61
pstr, found := req.Options[peerOptionName].(string)
62
- if err != nil {
63
- return err
64
- }
62
if found {
63
pid, err := peer.IDB58Decode(pstr)
64
if err != nil {
65
return err
66
}
67
if pid == nd.Identity {
71
- return res.Emit(&KeyList{bs.GetWantlist()})
68
+ return cmds.EmitOnce(res, &KeyList{bs.GetWantlist()})
69
}
70
74
- return res.Emit(&KeyList{bs.WantlistForPeer(pid)})
71
+ return cmds.EmitOnce(res, &KeyList{bs.WantlistForPeer(pid)})
72
}
76
- return res.Emit(&KeyList{bs.GetWantlist()})
73
+ return cmds.EmitOnce(res, &KeyList{bs.GetWantlist()})
74
},
75
Encoders: cmds.EncoderMap{
76
cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *KeyList) error {
@@ -175,7 +172,7 @@ prints the ledger associated with a given peer.
172
if err != nil {
173
return err
174
}
178
- return res.Emit(bs.LedgerForPeer(partner))
175
+ return cmds.EmitOnce(res, bs.LedgerForPeer(partner))
176
},
177
Encoders: cmds.EncoderMap{
178
cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *decision.Receipt) error {