mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-18 17:29:27 +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)
|
pstr, found := req.Options[peerOptionName].(string)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if found {
|
if found {
|
||||||
pid, err := peer.IDB58Decode(pstr)
|
pid, err := peer.IDB58Decode(pstr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if pid == nd.Identity {
|
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{
|
Encoders: cmds.EncoderMap{
|
||||||
cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *KeyList) error {
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return res.Emit(bs.LedgerForPeer(partner))
|
return cmds.EmitOnce(res, bs.LedgerForPeer(partner))
|
||||||
},
|
},
|
||||||
Encoders: cmds.EncoderMap{
|
Encoders: cmds.EncoderMap{
|
||||||
cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *decision.Receipt) error {
|
cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *decision.Receipt) error {
|
||||||
|
Reference in New Issue
Block a user