From 73fef489f5655b19678c442814d6093443ee635b Mon Sep 17 00:00:00 2001 From: Overbool Date: Tue, 30 Oct 2018 10:15:26 +0800 Subject: [PATCH] commands/bitswap: use cmds.EmitOnce in single value License: MIT Signed-off-by: Overbool --- core/commands/bitswap.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/core/commands/bitswap.go b/core/commands/bitswap.go index ce8515519..1a6a21781 100644 --- a/core/commands/bitswap.go +++ b/core/commands/bitswap.go @@ -59,21 +59,18 @@ Print out all blocks currently on the bitswap wantlist for the local peer.`, } pstr, found := req.Options[peerOptionName].(string) - if err != nil { - return err - } if found { pid, err := peer.IDB58Decode(pstr) if err != nil { return err } if pid == nd.Identity { - return res.Emit(&KeyList{bs.GetWantlist()}) + return cmds.EmitOnce(res, &KeyList{bs.GetWantlist()}) } - return res.Emit(&KeyList{bs.WantlistForPeer(pid)}) + return cmds.EmitOnce(res, &KeyList{bs.WantlistForPeer(pid)}) } - return res.Emit(&KeyList{bs.GetWantlist()}) + return cmds.EmitOnce(res, &KeyList{bs.GetWantlist()}) }, Encoders: cmds.EncoderMap{ 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. if err != nil { return err } - return res.Emit(bs.LedgerForPeer(partner)) + return cmds.EmitOnce(res, bs.LedgerForPeer(partner)) }, Encoders: cmds.EncoderMap{ cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *decision.Receipt) error {