frostfs-api-go/accounting/withdraw.go

36 lines
1.1 KiB
Go
Raw Permalink Normal View History

2019-11-18 13:34:06 +00:00
package accounting
import (
"encoding/binary"
2020-03-31 07:05:26 +00:00
"github.com/nspcc-dev/neofs-api-go/refs"
2019-11-18 13:34:06 +00:00
)
type (
// MessageID type alias.
MessageID = refs.MessageID
)
// PrepareData prepares bytes representation of PutRequest to satisfy SignedRequest interface.
func (m *PutRequest) PrepareData() ([]byte, error) {
var offset int
// MessageID-len + OwnerID-len + Amount + Height
buf := make([]byte, refs.UUIDSize+refs.OwnerIDSize+binary.MaxVarintLen64+binary.MaxVarintLen64)
offset += copy(buf[offset:], m.MessageID.Bytes())
offset += copy(buf[offset:], m.OwnerID.Bytes())
offset += binary.PutVarint(buf[offset:], m.Amount.Value)
binary.PutUvarint(buf[offset:], m.Height)
return buf, nil
}
// PrepareData prepares bytes representation of DeleteRequest to satisfy SignedRequest interface.
func (m *DeleteRequest) PrepareData() ([]byte, error) {
var offset int
// ID-len + OwnerID-len + MessageID-len
buf := make([]byte, refs.UUIDSize+refs.OwnerIDSize+refs.UUIDSize)
offset += copy(buf[offset:], m.ID.Bytes())
offset += copy(buf[offset:], m.OwnerID.Bytes())
copy(buf[offset:], m.MessageID.Bytes())
return buf, nil
}