[#302] pkg/reputation: Convert nil PeerID
to nil message
Document that `PeerID.ToV2` method return `nil` when called on `nil`. Document that `PeerIDFromV2` function return `nil` when called on `nil`. Write corresponding unit tests. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
c00cdd407d
commit
d4327ec018
2 changed files with 23 additions and 2 deletions
|
@ -17,6 +17,8 @@ func NewPeerID() *PeerID {
|
|||
}
|
||||
|
||||
// PeerIDFromV2 converts NeoFS API v2 reputation.PeerID message to PeerID.
|
||||
//
|
||||
// Nil reputation.PeerID converts to nil.
|
||||
func PeerIDFromV2(id *reputation.PeerID) *PeerID {
|
||||
return (*PeerID)(id)
|
||||
}
|
||||
|
@ -28,6 +30,8 @@ func (x *PeerID) SetPublicKey(v [crypto.PublicKeyCompressedSize]byte) {
|
|||
}
|
||||
|
||||
// ToV2 converts PeerID to NeoFS API v2 reputation.PeerID message.
|
||||
//
|
||||
// Nil PeerID converts to nil.
|
||||
func (x *PeerID) ToV2() *reputation.PeerID {
|
||||
return (*reputation.PeerID)(x)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue