[#152] Add ID field to update state event

NeoFS contract produces event with three arguments:
  - update ID,
  - config key,
  - config value.

Update ID is a unique shared by inner ring holders
byte sequence that is used to update NeoFS runtime
configuration.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2020-11-05 16:26:28 +03:00 committed by Alex Vanin
parent 49da96d006
commit 7c1776a281
2 changed files with 27 additions and 5 deletions

View file

@ -10,11 +10,14 @@ import (
type Config struct {
key []byte
value []byte
id []byte
}
// MorphEvent implements Neo:Morph Event interface.
func (Config) MorphEvent() {}
func (u Config) ID() []byte { return u.id }
func (u Config) Key() []byte { return u.key }
func (u Config) Value() []byte { return u.value }
@ -25,18 +28,24 @@ func ParseConfig(params []stackitem.Item) (event.Event, error) {
err error
)
if ln := len(params); ln != 2 {
return nil, event.WrongNumberOfParameters(2, ln)
if ln := len(params); ln != 3 {
return nil, event.WrongNumberOfParameters(3, ln)
}
// parse id
ev.id, err = client.BytesFromStackItem(params[0])
if err != nil {
return nil, errors.Wrap(err, "could not get config update id")
}
// parse key
ev.key, err = client.BytesFromStackItem(params[0])
ev.key, err = client.BytesFromStackItem(params[1])
if err != nil {
return nil, errors.Wrap(err, "could not get config key")
}
// parse value
ev.value, err = client.BytesFromStackItem(params[1])
ev.value, err = client.BytesFromStackItem(params[2])
if err != nil {
return nil, errors.Wrap(err, "could not get config value")
}