forked from TrueCloudLab/frostfs-api-go
[#265] pkg/reputation: Implement PeerID and Trust types
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
51d443c6fc
commit
009f704377
5 changed files with 205 additions and 0 deletions
29
pkg/reputation/peer.go
Normal file
29
pkg/reputation/peer.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
package reputation
|
||||
|
||||
// PeerID represents peer ID compatible with NeoFS API v2.
|
||||
type PeerID []byte
|
||||
|
||||
// NewPeerID creates and returns blank PeerID.
|
||||
func NewPeerID() *PeerID {
|
||||
return PeerIDFromV2(nil)
|
||||
}
|
||||
|
||||
// PeerIDFromV2 converts bytes slice to PeerID.
|
||||
func PeerIDFromV2(data []byte) *PeerID {
|
||||
return (*PeerID)(&data)
|
||||
}
|
||||
|
||||
// SetBytes sets bytes of peer ID.
|
||||
func (x *PeerID) SetBytes(v []byte) {
|
||||
*x = v
|
||||
}
|
||||
|
||||
// Bytes returns bytes of peer ID.
|
||||
func (x PeerID) Bytes() []byte {
|
||||
return x
|
||||
}
|
||||
|
||||
// ToV2 converts PeerID to byte slice.
|
||||
func (x PeerID) ToV2() []byte {
|
||||
return x
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue