forked from TrueCloudLab/frostfs-node
[#971] *: Add notification TX hash to neofsid morph client calls
Add hash of the TX that generated notification to neofsid event structures. Adapt all neofsid wrapper calls to new structures. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
404c62c5c4
commit
822d73fb02
5 changed files with 37 additions and 3 deletions
|
@ -8,6 +8,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
|
neofsid "github.com/nspcc-dev/neofs-node/pkg/morph/client/neofsid/wrapper"
|
||||||
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/session"
|
"github.com/nspcc-dev/neofs-sdk-go/session"
|
||||||
|
@ -65,7 +66,10 @@ func (cp *Processor) checkKeyOwnership(ownerIDSrc ownerIDSource, key *keys.Publi
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
ownerKeys, err := cp.idClient.AccountKeys(ownerIDSrc.OwnerID())
|
prm := neofsid.AccountKeysPrm{}
|
||||||
|
prm.SetID(ownerIDSrc.OwnerID())
|
||||||
|
|
||||||
|
ownerKeys, err := cp.idClient.AccountKeys(prm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not received owner keys %s: %w", ownerIDSrc.OwnerID(), err)
|
return fmt.Errorf("could not received owner keys %s: %w", ownerIDSrc.OwnerID(), err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/network/payload"
|
"github.com/nspcc-dev/neo-go/pkg/network/payload"
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/refs"
|
"github.com/nspcc-dev/neofs-api-go/v2/refs"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/core/container"
|
"github.com/nspcc-dev/neofs-node/pkg/core/container"
|
||||||
|
neofsid "github.com/nspcc-dev/neofs-node/pkg/morph/client/neofsid/wrapper"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||||
containerEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/container"
|
containerEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/container"
|
||||||
containerSDK "github.com/nspcc-dev/neofs-sdk-go/container"
|
containerSDK "github.com/nspcc-dev/neofs-sdk-go/container"
|
||||||
|
@ -198,8 +199,11 @@ func (cp *Processor) checkDeleteContainer(e *containerEvent.Delete) error {
|
||||||
|
|
||||||
checkKeys = keys.PublicKeys{key}
|
checkKeys = keys.PublicKeys{key}
|
||||||
} else {
|
} else {
|
||||||
|
prm := neofsid.AccountKeysPrm{}
|
||||||
|
prm.SetID(cnr.OwnerID())
|
||||||
|
|
||||||
// receive all owner keys from NeoFS ID contract
|
// receive all owner keys from NeoFS ID contract
|
||||||
checkKeys, err = cp.idClient.AccountKeys(cnr.OwnerID())
|
checkKeys, err = cp.idClient.AccountKeys(prm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not received owner keys %s: %w", cnr.OwnerID(), err)
|
return fmt.Errorf("could not received owner keys %s: %w", cnr.OwnerID(), err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@ import (
|
||||||
"crypto/elliptic"
|
"crypto/elliptic"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
neofsid "github.com/nspcc-dev/neofs-node/pkg/morph/client/neofsid/wrapper"
|
||||||
|
|
||||||
"github.com/mr-tron/base58"
|
"github.com/mr-tron/base58"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||||
|
@ -15,6 +17,7 @@ import (
|
||||||
type bindCommon interface {
|
type bindCommon interface {
|
||||||
User() []byte
|
User() []byte
|
||||||
Keys() [][]byte
|
Keys() [][]byte
|
||||||
|
TxHash() util.Uint256
|
||||||
}
|
}
|
||||||
|
|
||||||
func (np *Processor) processBind(e bindCommon) {
|
func (np *Processor) processBind(e bindCommon) {
|
||||||
|
@ -93,7 +96,14 @@ func (np *Processor) approveBindCommon(e *bindCommonContext) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = np.neofsIDClient.ManageKeys(wallet, e.Keys(), e.bind)
|
prm := neofsid.ManageKeysPrm{}
|
||||||
|
|
||||||
|
prm.SetOwnerID(wallet)
|
||||||
|
prm.SetKeys(e.Keys())
|
||||||
|
prm.SetAdd(e.bind)
|
||||||
|
prm.SetHash(e.bindCommon.TxHash())
|
||||||
|
|
||||||
|
err = np.neofsIDClient.ManageKeys(prm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
var typ string
|
var typ string
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||||
|
@ -16,6 +17,17 @@ type Bind struct {
|
||||||
type bindCommon struct {
|
type bindCommon struct {
|
||||||
user []byte
|
user []byte
|
||||||
keys [][]byte
|
keys [][]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 (b bindCommon) TxHash() util.Uint256 {
|
||||||
|
return b.txHash
|
||||||
}
|
}
|
||||||
|
|
||||||
// MorphEvent implements Neo:Morph Event interface.
|
// MorphEvent implements Neo:Morph Event interface.
|
||||||
|
@ -41,6 +53,8 @@ func ParseBind(e *subscriptions.NotificationEvent) (event.Event, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ev.txHash = e.Container
|
||||||
|
|
||||||
return ev, nil
|
return ev, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,5 +27,7 @@ func ParseUnbind(e *subscriptions.NotificationEvent) (event.Event, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ev.txHash = e.Container
|
||||||
|
|
||||||
return ev, nil
|
return ev, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue