631d7b0e07
`Delete` method of latest `Container` contract accepts binary session token as an argument. Provide `DeleteArgs.SetSessionToken` method. Accept session token as a `[]byte` in `Wrapper.Put` method and attach it to `PutArgs`. Marshal session token from `RemovalWitness` in `wrapper.Delete` function and pass it to the method. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
50 lines
1 KiB
Go
50 lines
1 KiB
Go
package container
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
// DeleteArgs groups the arguments
|
|
// of delete container invocation call.
|
|
type DeleteArgs struct {
|
|
cid []byte // container identifier
|
|
|
|
sig []byte // container identifier signature
|
|
|
|
token []byte // binary session token
|
|
}
|
|
|
|
// SetCID sets the container identifier
|
|
// in a binary format.
|
|
func (p *DeleteArgs) SetCID(v []byte) {
|
|
p.cid = v
|
|
}
|
|
|
|
// SetSignature sets the container identifier
|
|
// owner's signature.
|
|
func (p *DeleteArgs) SetSignature(v []byte) {
|
|
p.sig = v
|
|
}
|
|
|
|
// SetSessionToken sets token of the session
|
|
// within which the container was removed
|
|
// in a NeoFS API binary format.
|
|
func (p *DeleteArgs) SetSessionToken(v []byte) {
|
|
p.token = v
|
|
}
|
|
|
|
// Delete invokes the call of delete container
|
|
// method of NeoFS Container contract.
|
|
func (c *Client) Delete(args DeleteArgs) error {
|
|
err := c.client.Invoke(
|
|
c.deleteMethod,
|
|
args.cid,
|
|
args.sig,
|
|
args.token,
|
|
)
|
|
|
|
if err != nil {
|
|
return fmt.Errorf("could not invoke method (%s): %w", c.deleteMethod, err)
|
|
}
|
|
return nil
|
|
}
|