mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-17 16:37:59 +08:00
commands/bitswap: use cmds.EmitOnce in single value
License: MIT Signed-off-by: Overbool <overbool.xu@gmail.com>
This commit is contained in:
@ -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 {
|
||||
|
Reference in New Issue
Block a user