Implementing proto.Clone

This commit is contained in:
Evgeniy Kulikov 2020-07-03 09:12:02 +03:00
parent 2456521240
commit d45548c43b
No known key found for this signature in database
GPG key ID: BF6AEE0A2A699BF2
11 changed files with 129 additions and 10 deletions

View file

@ -3,6 +3,7 @@ package container
import (
"bytes"
"github.com/gogo/protobuf/proto"
"github.com/google/uuid"
"github.com/nspcc-dev/neofs-api-go/internal"
"github.com/nspcc-dev/neofs-api-go/refs"
@ -63,6 +64,13 @@ func (m *Container) ID() (CID, error) {
return refs.CIDForBytes(data), nil
}
// Merge used by proto.Clone
func (m *Container) Merge(src proto.Message) {
if tmp, ok := src.(*Container); ok {
*m = *tmp
}
}
// Empty checks that container is empty.
func (m *Container) Empty() bool {
return m.Capacity == 0 || bytes.Equal(m.Salt.Bytes(), emptySalt) || bytes.Equal(m.OwnerID.Bytes(), emptyOwner)