2020-09-03 14:04:04 +00:00
|
|
|
package netmap
|
|
|
|
|
|
|
|
import (
|
2021-05-18 08:12:51 +00:00
|
|
|
"fmt"
|
|
|
|
|
2020-10-26 14:46:15 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
2020-09-03 14:04:04 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
|
|
|
)
|
|
|
|
|
|
|
|
type AddPeer struct {
|
|
|
|
node []byte
|
|
|
|
}
|
|
|
|
|
|
|
|
// MorphEvent implements Neo:Morph Event interface.
|
|
|
|
func (AddPeer) MorphEvent() {}
|
|
|
|
|
|
|
|
func (s AddPeer) Node() []byte {
|
|
|
|
return s.node
|
|
|
|
}
|
|
|
|
|
2020-10-26 14:46:15 +00:00
|
|
|
func ParseAddPeer(prms []stackitem.Item) (event.Event, error) {
|
2020-09-03 14:04:04 +00:00
|
|
|
var (
|
|
|
|
ev AddPeer
|
|
|
|
err error
|
|
|
|
)
|
|
|
|
|
|
|
|
if ln := len(prms); ln != 1 {
|
|
|
|
return nil, event.WrongNumberOfParameters(1, ln)
|
|
|
|
}
|
|
|
|
|
2020-10-26 14:46:15 +00:00
|
|
|
ev.node, err = client.BytesFromStackItem(prms[0])
|
2020-09-03 14:04:04 +00:00
|
|
|
if err != nil {
|
2021-05-18 08:12:51 +00:00
|
|
|
return nil, fmt.Errorf("could not get integer epoch number: %w", err)
|
2020-09-03 14:04:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ev, nil
|
|
|
|
}
|