diff --git a/client/accounting.go b/client/accounting.go index ed83cf0..71dd030 100644 --- a/client/accounting.go +++ b/client/accounting.go @@ -52,10 +52,7 @@ func (x ResBalanceGet) Amount() accounting.Decimal { // Return statuses: // - global (see Client docs). func (c *Client) BalanceGet(ctx context.Context, prm PrmBalanceGet) (*ResBalanceGet, error) { - switch { - case ctx == nil: - return nil, errorMissingContext - case !prm.accountSet: + if !prm.accountSet { return nil, errorAccountNotSet } diff --git a/client/common.go b/client/common.go index c743249..e051058 100644 --- a/client/common.go +++ b/client/common.go @@ -73,7 +73,6 @@ func writeXHeadersToMeta(xHeaders []string, h *v2session.RequestMetaHeader) { // error messages. var ( - errorMissingContext = errors.New("missing context") errorMissingContainer = errors.New("missing container") errorMissingObject = errors.New("missing object") errorAccountNotSet = errors.New("account not set") diff --git a/client/container_delete.go b/client/container_delete.go index adb55c2..07cee4f 100644 --- a/client/container_delete.go +++ b/client/container_delete.go @@ -72,10 +72,7 @@ type ResContainerDelete struct { // - global (see Client docs). func (c *Client) ContainerDelete(ctx context.Context, prm PrmContainerDelete) (*ResContainerDelete, error) { // check parameters - switch { - case ctx == nil: - return nil, errorMissingContext - case !prm.idSet: + if !prm.idSet { return nil, errorMissingContainer } diff --git a/client/container_eacl.go b/client/container_eacl.go index ed5a39f..8ea388d 100644 --- a/client/container_eacl.go +++ b/client/container_eacl.go @@ -55,10 +55,7 @@ func (x ResContainerEACL) Table() eacl.Table { // - *apistatus.EACLNotFound. func (c *Client) ContainerEACL(ctx context.Context, prm PrmContainerEACL) (*ResContainerEACL, error) { // check parameters - switch { - case ctx == nil: - return nil, errorMissingContext - case !prm.idSet: + if !prm.idSet { return nil, errorMissingContainer } diff --git a/client/container_get.go b/client/container_get.go index 6d1779d..0cbad88 100644 --- a/client/container_get.go +++ b/client/container_get.go @@ -57,10 +57,7 @@ func (x ResContainerGet) Container() container.Container { // - global (see Client docs); // - *apistatus.ContainerNotFound. func (c *Client) ContainerGet(ctx context.Context, prm PrmContainerGet) (*ResContainerGet, error) { - switch { - case ctx == nil: - return nil, errorMissingContext - case !prm.idSet: + if !prm.idSet { return nil, errorMissingContainer } diff --git a/client/container_list.go b/client/container_list.go index f01def1..85b4c37 100644 --- a/client/container_list.go +++ b/client/container_list.go @@ -56,10 +56,7 @@ func (x ResContainerList) Containers() []cid.ID { // - global (see Client docs). func (c *Client) ContainerList(ctx context.Context, prm PrmContainerList) (*ResContainerList, error) { // check parameters - switch { - case ctx == nil: - return nil, errorMissingContext - case !prm.ownerSet: + if !prm.ownerSet { return nil, errorAccountNotSet } diff --git a/client/container_put.go b/client/container_put.go index 47ee4b6..83896b8 100644 --- a/client/container_put.go +++ b/client/container_put.go @@ -82,10 +82,7 @@ func (x ResContainerPut) ID() cid.ID { // nolint: funlen func (c *Client) ContainerPut(ctx context.Context, prm PrmContainerPut) (*ResContainerPut, error) { // check parameters - switch { - case ctx == nil: - return nil, errorMissingContext - case !prm.cnrSet: + if !prm.cnrSet { return nil, errorMissingContainer } diff --git a/client/container_set_eacl.go b/client/container_set_eacl.go index 0b7eed3..d0266f1 100644 --- a/client/container_set_eacl.go +++ b/client/container_set_eacl.go @@ -74,10 +74,7 @@ type ResContainerSetEACL struct { // - global (see Client docs). func (c *Client) ContainerSetEACL(ctx context.Context, prm PrmContainerSetEACL) (*ResContainerSetEACL, error) { // check parameters - switch { - case ctx == nil: - return nil, errorMissingContext - case !prm.tableSet: + if !prm.tableSet { return nil, errorEACLTableNotSet } diff --git a/client/container_space.go b/client/container_space.go index 0513d5f..2b7bdc8 100644 --- a/client/container_space.go +++ b/client/container_space.go @@ -49,10 +49,7 @@ type ResAnnounceSpace struct { // - global (see Client docs). func (c *Client) ContainerAnnounceUsedSpace(ctx context.Context, prm PrmAnnounceSpace) (*ResAnnounceSpace, error) { // check parameters - switch { - case ctx == nil: - return nil, errorMissingContext - case len(prm.announcements) == 0: + if len(prm.announcements) == 0 { return nil, errorMissingAnnouncements } diff --git a/client/netmap.go b/client/netmap.go index a4abb0b..3fb57b8 100644 --- a/client/netmap.go +++ b/client/netmap.go @@ -56,11 +56,6 @@ func (x ResEndpointInfo) NodeInfo() netmap.NodeInfo { // Return statuses: // - global (see Client docs). func (c *Client) EndpointInfo(ctx context.Context, prm PrmEndpointInfo) (*ResEndpointInfo, error) { - // check context - if ctx == nil { - return nil, errorMissingContext - } - // form request var req v2netmap.LocalNodeInfoRequest @@ -153,11 +148,6 @@ func (x ResNetworkInfo) Info() netmap.NetworkInfo { // Return statuses: // - global (see Client docs). func (c *Client) NetworkInfo(ctx context.Context, prm PrmNetworkInfo) (*ResNetworkInfo, error) { - // check context - if ctx == nil { - return nil, errorMissingContext - } - // form request var req v2netmap.NetworkInfoRequest diff --git a/client/object_delete.go b/client/object_delete.go index e7fee89..873cf3d 100644 --- a/client/object_delete.go +++ b/client/object_delete.go @@ -125,8 +125,6 @@ func (x ResObjectDelete) Tombstone() oid.ID { // - *apistatus.SessionTokenExpired. func (c *Client) ObjectDelete(ctx context.Context, prm PrmObjectDelete) (*ResObjectDelete, error) { switch { - case ctx == nil: - return nil, errorMissingContext case prm.addr.GetContainerID() == nil: return nil, errorMissingContainer case prm.addr.GetObjectID() == nil: diff --git a/client/object_get.go b/client/object_get.go index 2ae2219..02de74a 100644 --- a/client/object_get.go +++ b/client/object_get.go @@ -301,8 +301,6 @@ func (x *ObjectReader) Read(p []byte) (int, error) { func (c *Client) ObjectGetInit(ctx context.Context, prm PrmObjectGet) (*ObjectReader, error) { // check parameters switch { - case ctx == nil: - return nil, errorMissingContext case prm.addr.GetContainerID() == nil: return nil, errorMissingContainer case prm.addr.GetObjectID() == nil: @@ -416,8 +414,6 @@ func (x *ResObjectHead) ReadHeader(dst *object.Object) bool { // - *apistatus.SessionTokenExpired. func (c *Client) ObjectHead(ctx context.Context, prm PrmObjectHead) (*ResObjectHead, error) { switch { - case ctx == nil: - return nil, errorMissingContext case prm.addr.GetContainerID() == nil: return nil, errorMissingContainer case prm.addr.GetObjectID() == nil: @@ -668,8 +664,6 @@ func (x *ObjectRangeReader) Read(p []byte) (int, error) { func (c *Client) ObjectRangeInit(ctx context.Context, prm PrmObjectRange) (*ObjectRangeReader, error) { // check parameters switch { - case ctx == nil: - return nil, errorMissingContext case prm.addr.GetContainerID() == nil: return nil, errorMissingContainer case prm.addr.GetObjectID() == nil: diff --git a/client/object_hash.go b/client/object_hash.go index 3bad781..6df0d7a 100644 --- a/client/object_hash.go +++ b/client/object_hash.go @@ -166,8 +166,6 @@ func (x ResObjectHash) Checksums() [][]byte { // - *apistatus.SessionTokenExpired. func (c *Client) ObjectHash(ctx context.Context, prm PrmObjectHash) (*ResObjectHash, error) { switch { - case ctx == nil: - return nil, errorMissingContext case prm.addr.GetContainerID() == nil: return nil, errorMissingContainer case prm.addr.GetObjectID() == nil: diff --git a/client/object_put.go b/client/object_put.go index 5995683..3486907 100644 --- a/client/object_put.go +++ b/client/object_put.go @@ -245,11 +245,6 @@ func (x *ObjectWriter) Close() (*ResObjectPut, error) { // Returns an error if parameters are set incorrectly. // Context is required and must not be nil. It is used for network communication. func (c *Client) ObjectPutInit(ctx context.Context, prm PrmObjectPutInit) (*ObjectWriter, error) { - // check parameters - if ctx == nil { - return nil, errorMissingContext - } - var w ObjectWriter ctx, cancel := context.WithCancel(ctx) diff --git a/client/object_search.go b/client/object_search.go index 127b5b8..95c18ab 100644 --- a/client/object_search.go +++ b/client/object_search.go @@ -222,10 +222,7 @@ func (x *ObjectListReader) Close() (*ResObjectSearch, error) { // Context is required and must not be nil. It is used for network communication. func (c *Client) ObjectSearchInit(ctx context.Context, prm PrmObjectSearch) (*ObjectListReader, error) { // check parameters - switch { - case ctx == nil: - return nil, errorMissingContext - case !prm.cnrSet: + if !prm.cnrSet { return nil, errorMissingContainer } diff --git a/client/reputation.go b/client/reputation.go index ae22fd1..f35cea3 100644 --- a/client/reputation.go +++ b/client/reputation.go @@ -53,8 +53,6 @@ type ResAnnounceLocalTrust struct { func (c *Client) AnnounceLocalTrust(ctx context.Context, prm PrmAnnounceLocalTrust) (*ResAnnounceLocalTrust, error) { // check parameters switch { - case ctx == nil: - return nil, errorMissingContext case prm.epoch == 0: return nil, errorZeroEpoch case len(prm.trusts) == 0: @@ -154,8 +152,6 @@ type ResAnnounceIntermediateTrust struct { func (c *Client) AnnounceIntermediateTrust(ctx context.Context, prm PrmAnnounceIntermediateTrust) (*ResAnnounceIntermediateTrust, error) { // check parameters switch { - case ctx == nil: - return nil, errorMissingContext case prm.epoch == 0: return nil, errorZeroEpoch case !prm.trustSet: diff --git a/client/session.go b/client/session.go index e05ca44..554d3a5 100644 --- a/client/session.go +++ b/client/session.go @@ -78,11 +78,6 @@ func (x ResSessionCreate) PublicKey() []byte { // Return statuses: // - global (see Client docs). func (c *Client) SessionCreate(ctx context.Context, prm PrmSessionCreate) (*ResSessionCreate, error) { - // check context - if ctx == nil { - return nil, errorMissingContext - } - ownerKey := c.prm.key.PublicKey if prm.keySet { ownerKey = prm.key.PublicKey