2020-08-11 12:04:46 +00:00
|
|
|
package invoke
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
|
|
|
// ContainerParams for container put invocation.
|
|
|
|
ContainerParams struct {
|
|
|
|
Key *keys.PublicKey
|
|
|
|
Container []byte
|
|
|
|
Signature []byte
|
|
|
|
}
|
2020-09-02 16:04:29 +00:00
|
|
|
|
2021-04-29 13:39:09 +00:00
|
|
|
// RemoveContainerParams for container delete invocation.
|
2020-09-02 16:04:29 +00:00
|
|
|
RemoveContainerParams struct {
|
|
|
|
ContainerID []byte
|
|
|
|
Signature []byte
|
|
|
|
}
|
2020-08-11 12:04:46 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2020-09-02 16:04:29 +00:00
|
|
|
putContainerMethod = "put"
|
|
|
|
deleteContainerMethod = "delete"
|
2020-08-11 12:04:46 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// RegisterContainer invokes Put method.
|
2021-04-29 13:39:09 +00:00
|
|
|
func RegisterContainer(cli *client.Client, con util.Uint160, fee SideFeeProvider, p *ContainerParams) error {
|
2020-08-11 12:04:46 +00:00
|
|
|
if cli == nil {
|
|
|
|
return client.ErrNilClient
|
|
|
|
}
|
|
|
|
|
2021-05-21 07:39:21 +00:00
|
|
|
return cli.NotaryInvoke(con, fee.SideChainFee(), putContainerMethod,
|
2020-08-11 12:04:46 +00:00
|
|
|
p.Container,
|
|
|
|
p.Signature,
|
|
|
|
p.Key.Bytes(),
|
|
|
|
)
|
|
|
|
}
|
2020-09-02 16:04:29 +00:00
|
|
|
|
2021-04-29 13:39:09 +00:00
|
|
|
// RemoveContainer invokes Delete method.
|
|
|
|
func RemoveContainer(cli *client.Client, con util.Uint160, fee SideFeeProvider, p *RemoveContainerParams) error {
|
2020-09-02 16:04:29 +00:00
|
|
|
if cli == nil {
|
|
|
|
return client.ErrNilClient
|
|
|
|
}
|
|
|
|
|
2021-05-21 07:39:21 +00:00
|
|
|
return cli.NotaryInvoke(con, fee.SideChainFee(), deleteContainerMethod,
|
2020-09-02 16:04:29 +00:00
|
|
|
p.ContainerID,
|
|
|
|
p.Signature,
|
|
|
|
)
|
|
|
|
}
|