forked from TrueCloudLab/frostfs-node
[#971] *: Add notification TX hash to neofs/netmap morph client calls
Add hash of the TX that generated notification to neofs/netmap event structures. Adapt all neofs/netmap wrapper calls to new structures. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
c25f5a86ae
commit
bad739258e
19 changed files with 220 additions and 60 deletions
|
@ -17,6 +17,11 @@ type Lock struct {
|
|||
lock util.Uint160
|
||||
amount int64 // Fixed16
|
||||
until int64
|
||||
|
||||
// txHash is used in notary environmental
|
||||
// for calculating unique but same for
|
||||
// all notification receivers values.
|
||||
txHash util.Uint256
|
||||
}
|
||||
|
||||
// MorphEvent implements Neo:Morph Event interface.
|
||||
|
@ -34,9 +39,13 @@ func (l Lock) LockAccount() util.Uint160 { return l.lock }
|
|||
// Amount of the locked assets.
|
||||
func (l Lock) Amount() int64 { return l.amount }
|
||||
|
||||
// Until is a epoch before locked account exists.
|
||||
// Until is an epoch before locked account exists.
|
||||
func (l Lock) Until() int64 { return l.until }
|
||||
|
||||
// TxHash returns hash of the TX with lock
|
||||
// notification.
|
||||
func (l Lock) TxHash() util.Uint256 { return l.txHash }
|
||||
|
||||
// ParseLock from notification into lock structure.
|
||||
func ParseLock(e *subscriptions.NotificationEvent) (event.Event, error) {
|
||||
var (
|
||||
|
@ -93,5 +102,7 @@ func ParseLock(e *subscriptions.NotificationEvent) (event.Event, error) {
|
|||
return nil, fmt.Errorf("could not get lock deadline: %w", err)
|
||||
}
|
||||
|
||||
ev.txHash = e.Container
|
||||
|
||||
return ev, nil
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||
)
|
||||
|
@ -12,6 +13,17 @@ type Config struct {
|
|||
key []byte
|
||||
value []byte
|
||||
id []byte
|
||||
|
||||
// txHash is used in notary environmental
|
||||
// for calculating unique but same for
|
||||
// all notification receivers values.
|
||||
txHash util.Uint256
|
||||
}
|
||||
|
||||
// TxHash returns hash of the TX with new epoch
|
||||
// notification.
|
||||
func (u Config) TxHash() util.Uint256 {
|
||||
return u.txHash
|
||||
}
|
||||
|
||||
// MorphEvent implements Neo:Morph Event interface.
|
||||
|
@ -56,5 +68,7 @@ func ParseConfig(e *subscriptions.NotificationEvent) (event.Event, error) {
|
|||
return nil, fmt.Errorf("could not get config value: %w", err)
|
||||
}
|
||||
|
||||
ev.txHash = e.Container
|
||||
|
||||
return ev, nil
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||
)
|
||||
|
@ -11,6 +12,11 @@ import (
|
|||
// NewEpoch is a new epoch Neo:Morph event.
|
||||
type NewEpoch struct {
|
||||
num uint64
|
||||
|
||||
// txHash is used in notary environmental
|
||||
// for calculating unique but same for
|
||||
// all notification receivers values.
|
||||
txHash util.Uint256
|
||||
}
|
||||
|
||||
// MorphEvent implements Neo:Morph Event interface.
|
||||
|
@ -21,6 +27,12 @@ func (s NewEpoch) EpochNumber() uint64 {
|
|||
return s.num
|
||||
}
|
||||
|
||||
// TxHash returns hash of the TX with new epoch
|
||||
// notification.
|
||||
func (s NewEpoch) TxHash() util.Uint256 {
|
||||
return s.txHash
|
||||
}
|
||||
|
||||
// ParseNewEpoch is a parser of new epoch notification event.
|
||||
//
|
||||
// Result is type of NewEpoch.
|
||||
|
@ -40,6 +52,7 @@ func ParseNewEpoch(e *subscriptions.NotificationEvent) (event.Event, error) {
|
|||
}
|
||||
|
||||
return NewEpoch{
|
||||
num: uint64(prmEpochNum),
|
||||
num: uint64(prmEpochNum),
|
||||
txHash: e.Container,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/network/payload"
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/netmap"
|
||||
v2netmap "github.com/nspcc-dev/neofs-api-go/v2/netmap"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||
|
|
|
@ -5,12 +5,18 @@ import (
|
|||
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/native/noderoles"
|
||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||
)
|
||||
|
||||
// Designate represents designation event of the mainnet RoleManagement contract.
|
||||
type Designate struct {
|
||||
Role noderoles.Role
|
||||
|
||||
// TxHash is used in notary environmental
|
||||
// for calculating unique but same for
|
||||
// all notification receivers values.
|
||||
TxHash util.Uint256
|
||||
}
|
||||
|
||||
// MorphEvent implements Neo:Morph Event interface.
|
||||
|
@ -32,5 +38,8 @@ func ParseDesignate(e *subscriptions.NotificationEvent) (event.Event, error) {
|
|||
return nil, fmt.Errorf("invalid stackitem type: %w", err)
|
||||
}
|
||||
|
||||
return Designate{Role: noderoles.Role(bi.Int64())}, nil
|
||||
return Designate{
|
||||
Role: noderoles.Role(bi.Int64()),
|
||||
TxHash: e.Container,
|
||||
}, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue