forked from TrueCloudLab/frostfs-node
[#973] ir: Listen and process Put/Delete events of Subnet contract
Define notification events, implement parsers. Add morph client of Subnet contract. Listen, verify and approve events in Inner Ring app. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
214c2bd0cb
commit
41eaa1e246
22 changed files with 1278 additions and 12 deletions
57
pkg/morph/client/subnet/get.go
Normal file
57
pkg/morph/client/subnet/get.go
Normal file
|
@ -0,0 +1,57 @@
|
|||
package morphsubnet
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
)
|
||||
|
||||
// GetPrm groups parameters of Get method of Subnet contract.
|
||||
type GetPrm struct {
|
||||
cliPrm client.TestInvokePrm
|
||||
|
||||
args [1]interface{}
|
||||
}
|
||||
|
||||
// SetID sets identifier of the subnet to be read in a binary NeoFS API protocol format.
|
||||
func (x *GetPrm) SetID(id []byte) {
|
||||
x.args[0] = id
|
||||
}
|
||||
|
||||
// GetRes groups resulting values of Get method of Subnet contract.
|
||||
type GetRes struct {
|
||||
info []byte
|
||||
}
|
||||
|
||||
// Info returns information about the subnet in a binary format of NeoFS API protocol.
|
||||
func (x GetRes) Info() []byte {
|
||||
return x.info
|
||||
}
|
||||
|
||||
var errEmptyResponse = errors.New("empty response")
|
||||
|
||||
// Get reads the subnet through the call of the corresponding method of the Subnet contract.
|
||||
func (x *Client) Get(prm GetPrm) (*GetRes, error) {
|
||||
prm.cliPrm.SetMethod("get")
|
||||
prm.cliPrm.SetArgs(prm.args[:]...)
|
||||
|
||||
res, err := x.client.TestInvoke(prm.cliPrm)
|
||||
if err != nil {
|
||||
fmt.Println()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(res) == 0 {
|
||||
return nil, errEmptyResponse
|
||||
}
|
||||
|
||||
data, err := client.BytesFromStackItem(res[0])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &GetRes{
|
||||
info: data,
|
||||
}, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue