Skip to content

Commit

Permalink
object: Declare header length limit
Browse files Browse the repository at this point in the history
It was added to the protocol within
nspcc-dev/neofs-api#262. Also provide
`Object.HeaderLen` method.

Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
  • Loading branch information
cthulhu-rider committed Feb 27, 2024
1 parent e292150 commit c12635b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions client/object_put.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ func (x *DefaultObjectWriter) GetResult() ResObjectPut {
}

// ObjectPutInit initiates writing an object through a remote server using NeoFS API protocol.
// Header length is limited to [object.MaxHeaderLen].
//
// The call only opens the transmission channel, explicit recording is done using the [ObjectWriter].
// Exactly one return value is non-nil. Resulting writer must be finally closed.
Expand Down
4 changes: 4 additions & 0 deletions object/fmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import (
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
)

// MaxHeaderLen is a maximum allowed length of binary object header to be
// created via NeoFS API protocol.
const MaxHeaderLen = 16 << 10

var (
errCheckSumMismatch = errors.New("payload checksum mismatch")
errCheckSumNotSet = errors.New("payload checksum is not set")
Expand Down
5 changes: 5 additions & 0 deletions object/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -843,3 +843,8 @@ func formatCheck(v2 *object.Object) error {

return nil
}

// HeaderLen returns length of the binary header.
func (o *Object) HeaderLen() int {
return (*object.Object)(o).GetHeader().StableSize()
}
3 changes: 2 additions & 1 deletion object/slicer/slicer.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ var (
type ObjectWriter interface {
// ObjectPutInit initializes and returns a stream of writable data associated
// with the object according to its header. Provided header includes at least
// container, owner and object ID fields.
// container, owner and object ID fields. Header length is limited to
// [object.MaxHeaderLen].
//
// Signer is required and must not be nil. The operation is executed on behalf of
// the account corresponding to the specified Signer, which is taken into account, in particular, for access control.
Expand Down
1 change: 1 addition & 0 deletions pool/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func (p *Pool) actualSigner(signer user.Signer) user.Signer {
}

// ObjectPutInit initiates writing an object through a remote server using NeoFS API protocol.
// Header length is limited to [object.MaxHeaderLen].
//
// Operation is executed within a session automatically created by [Pool] unless parameters explicitly override session settings.
//
Expand Down

0 comments on commit c12635b

Please sign in to comment.