Compare commits
11 commits
master
...
support/v0
Author | SHA1 | Date | |
---|---|---|---|
|
1b5a45a7d8 | ||
|
1e6662d486 | ||
|
384a857cc2 | ||
|
4963fd8266 | ||
|
9bfe113d06 | ||
|
426e4f2f09 | ||
|
1d38cbec67 | ||
|
a46f20064c | ||
|
7570677e3b | ||
|
1ebf89687d | ||
|
9bb973b9f3 |
58 changed files with 319 additions and 181 deletions
18
CHANGELOG.md
18
CHANGELOG.md
|
@ -1,21 +1,24 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
Changelog for NeoFS Node
|
Changelog for NeoFS Node
|
||||||
|
|
||||||
## [Unreleased]
|
## [0.30.2] - 2022-08-01
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
- `EACL_NOT_FOUND` status code support (#1645).
|
||||||
|
|
||||||
### Changed
|
## [0.30.1] - 2022-07-29
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
- `GetRange` operation now works correctly with objects stored in write-cache (#1638)
|
||||||
- Losing request context in eACL response checks (#1595)
|
- Losing request context in eACL response checks (#1595)
|
||||||
|
- Wrong balance contract in innerring processor (#1636)
|
||||||
### Removed
|
- `neofs-adm` now sets groups in manifest for all contracts properly (#1631)
|
||||||
|
|
||||||
### Updated
|
### Updated
|
||||||
|
|
||||||
### Updating from v0.30.0
|
- `neo-go` to `v0.99.1`
|
||||||
|
- `neofs-sdk-go` to `v1.0.0-rc.6`
|
||||||
|
|
||||||
## [0.30.0] - 2022-07-22 - Saengildo (생일도, 生日島)
|
## [0.30.0] - 2022-07-22 - Saengildo (생일도, 生日島)
|
||||||
|
|
||||||
|
@ -37,6 +40,7 @@ Changelog for NeoFS Node
|
||||||
- `neofs-adm` now registers candidates during initialization in a single transaction (#1608)
|
- `neofs-adm` now registers candidates during initialization in a single transaction (#1608)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
- Invalid smart contract address in balance contract listener (#1636)
|
||||||
|
|
||||||
- Shard now can start in degraded mode if the metabase is unavailable (#1559)
|
- Shard now can start in degraded mode if the metabase is unavailable (#1559)
|
||||||
- Shard can now be disabled completely on init failure (#1559)
|
- Shard can now be disabled completely on init failure (#1559)
|
||||||
|
@ -1183,7 +1187,9 @@ NeoFS-API v2.0 support and updated brand-new storage node application.
|
||||||
|
|
||||||
First public review release.
|
First public review release.
|
||||||
|
|
||||||
[Unreleased]: https://github.com/nspcc-dev/neofs-node/compare/v0.30.0...master
|
[Unreleased]: https://github.com/nspcc-dev/neofs-node/compare/v0.30.2...support/v0.30
|
||||||
|
[0.30.2]: https://github.com/nspcc-dev/neofs-node/compare/v0.30.1...v0.30.2
|
||||||
|
[0.30.1]: https://github.com/nspcc-dev/neofs-node/compare/v0.30.0...v0.30.1
|
||||||
[0.30.0]: https://github.com/nspcc-dev/neofs-node/compare/v0.29.0...v0.30.0
|
[0.30.0]: https://github.com/nspcc-dev/neofs-node/compare/v0.29.0...v0.30.0
|
||||||
[0.29.0]: https://github.com/nspcc-dev/neofs-node/compare/v0.28.3...v0.29.0
|
[0.29.0]: https://github.com/nspcc-dev/neofs-node/compare/v0.28.3...v0.29.0
|
||||||
[0.28.3]: https://github.com/nspcc-dev/neofs-node/compare/v0.28.2...v0.28.3
|
[0.28.3]: https://github.com/nspcc-dev/neofs-node/compare/v0.28.2...v0.28.3
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
v0.30.0
|
v0.30.2
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
"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/rpc/client"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/vmstate"
|
"github.com/nspcc-dev/neo-go/pkg/vm/vmstate"
|
||||||
|
@ -363,7 +363,7 @@ loop:
|
||||||
// If sysFee is -1, it is calculated automatically. If tryGroup is false,
|
// If sysFee is -1, it is calculated automatically. If tryGroup is false,
|
||||||
// global scope is used for the signer (useful when working with native contracts).
|
// global scope is used for the signer (useful when working with native contracts).
|
||||||
func (c *initializeContext) sendCommitteeTx(script []byte, sysFee int64, tryGroup bool) error {
|
func (c *initializeContext) sendCommitteeTx(script []byte, sysFee int64, tryGroup bool) error {
|
||||||
tx, err := c.Client.CreateTxFromScript(script, c.CommitteeAcc, sysFee, 0, []client.SignerAccount{{
|
tx, err := c.Client.CreateTxFromScript(script, c.CommitteeAcc, sysFee, 0, []rpcclient.SignerAccount{{
|
||||||
Signer: c.getSigner(tryGroup),
|
Signer: c.getSigner(tryGroup),
|
||||||
Account: c.CommitteeAcc,
|
Account: c.CommitteeAcc,
|
||||||
}})
|
}})
|
||||||
|
@ -377,7 +377,7 @@ func (c *initializeContext) sendCommitteeTx(script []byte, sysFee int64, tryGrou
|
||||||
// sendSingleTx creates transaction signed by a simple account and pushes in onto the chain.
|
// sendSingleTx creates transaction signed by a simple account and pushes in onto the chain.
|
||||||
// It neither waits until tx persists nor checks the execution result.
|
// It neither waits until tx persists nor checks the execution result.
|
||||||
func (c *initializeContext) sendSingleTx(script []byte, sysFee int64, acc *wallet.Account) error {
|
func (c *initializeContext) sendSingleTx(script []byte, sysFee int64, acc *wallet.Account) error {
|
||||||
tx, err := c.Client.CreateTxFromScript(script, acc, sysFee, 0, []client.SignerAccount{{
|
tx, err := c.Client.CreateTxFromScript(script, acc, sysFee, 0, []rpcclient.SignerAccount{{
|
||||||
Signer: transaction.Signer{
|
Signer: transaction.Signer{
|
||||||
Account: acc.Contract.ScriptHash(),
|
Account: acc.Contract.ScriptHash(),
|
||||||
Scopes: transaction.CalledByEntry,
|
Scopes: transaction.CalledByEntry,
|
||||||
|
|
|
@ -17,7 +17,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
io2 "github.com/nspcc-dev/neo-go/pkg/io"
|
io2 "github.com/nspcc-dev/neo-go/pkg/io"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
||||||
|
@ -133,7 +133,7 @@ func (c *initializeContext) deployNNS(method string) error {
|
||||||
return fmt.Errorf("can't deploy NNS contract: %s", res.FaultException)
|
return fmt.Errorf("can't deploy NNS contract: %s", res.FaultException)
|
||||||
}
|
}
|
||||||
|
|
||||||
tx, err := c.Client.CreateTxFromScript(res.Script, c.CommitteeAcc, res.GasConsumed, 0, []client.SignerAccount{{
|
tx, err := c.Client.CreateTxFromScript(res.Script, c.CommitteeAcc, res.GasConsumed, 0, []rpcclient.SignerAccount{{
|
||||||
Signer: signer,
|
Signer: signer,
|
||||||
Account: c.CommitteeAcc,
|
Account: c.CommitteeAcc,
|
||||||
}})
|
}})
|
||||||
|
@ -166,16 +166,17 @@ func (c *initializeContext) updateContracts() error {
|
||||||
// Update script size for a single-node committee is close to the maximum allowed size of 65535.
|
// Update script size for a single-node committee is close to the maximum allowed size of 65535.
|
||||||
// Because of this we want to reuse alphabet contract NEF and manifest for different updates.
|
// Because of this we want to reuse alphabet contract NEF and manifest for different updates.
|
||||||
// The generated script is as following.
|
// The generated script is as following.
|
||||||
// 1. Initialize static slots for alphabet NEF and manifest.
|
// 1. Initialize static slot for alphabet NEF.
|
||||||
// 2. Store NEF and manifest into static slots.
|
// 2. Store NEF into the static slot.
|
||||||
// 3. Push parameters for each alphabet contract on stack.
|
// 3. Push parameters for each alphabet contract on stack.
|
||||||
// 4. For each alphabet contract, invoke `update` using parameters on stack and
|
// 4. Add contract group to the manifest.
|
||||||
// NEF and manifest from step 2.
|
// 5. For each alphabet contract, invoke `update` using parameters on stack and
|
||||||
// 5. Update other contracts as usual.
|
// NEF from step 2 and manifest from step 4.
|
||||||
emit.Instruction(w.BinWriter, opcode.INITSSLOT, []byte{2})
|
emit.Instruction(w.BinWriter, opcode.INITSSLOT, []byte{1})
|
||||||
emit.Bytes(w.BinWriter, alphaCs.RawManifest)
|
|
||||||
emit.Bytes(w.BinWriter, alphaCs.RawNEF)
|
emit.Bytes(w.BinWriter, alphaCs.RawNEF)
|
||||||
emit.Opcodes(w.BinWriter, opcode.STSFLD0, opcode.STSFLD1)
|
emit.Opcodes(w.BinWriter, opcode.STSFLD0)
|
||||||
|
|
||||||
|
baseGroups := alphaCs.Manifest.Groups
|
||||||
|
|
||||||
// alphabet contracts should be deployed by individual nodes to get different hashes.
|
// alphabet contracts should be deployed by individual nodes to get different hashes.
|
||||||
for i, acc := range c.Accounts {
|
for i, acc := range c.Accounts {
|
||||||
|
@ -188,7 +189,15 @@ func (c *initializeContext) updateContracts() error {
|
||||||
|
|
||||||
params := c.getAlphabetDeployItems(i, len(c.Wallets))
|
params := c.getAlphabetDeployItems(i, len(c.Wallets))
|
||||||
emit.Array(w.BinWriter, params...)
|
emit.Array(w.BinWriter, params...)
|
||||||
emit.Opcodes(w.BinWriter, opcode.LDSFLD1, opcode.LDSFLD0)
|
|
||||||
|
alphaCs.Manifest.Groups = baseGroups
|
||||||
|
err = c.addManifestGroup(ctrHash, alphaCs)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("can't sign manifest group: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
emit.Bytes(w.BinWriter, alphaCs.RawManifest)
|
||||||
|
emit.Opcodes(w.BinWriter, opcode.LDSFLD0)
|
||||||
emit.Int(w.BinWriter, 3)
|
emit.Int(w.BinWriter, 3)
|
||||||
emit.Opcodes(w.BinWriter, opcode.PACK)
|
emit.Opcodes(w.BinWriter, opcode.PACK)
|
||||||
emit.AppCallNoArgs(w.BinWriter, ctrHash, updateMethodName, callflag.All)
|
emit.AppCallNoArgs(w.BinWriter, ctrHash, updateMethodName, callflag.All)
|
||||||
|
@ -205,10 +214,11 @@ func (c *initializeContext) updateContracts() error {
|
||||||
return fmt.Errorf("can't update alphabet contracts: %s", res.FaultException)
|
return fmt.Errorf("can't update alphabet contracts: %s", res.FaultException)
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Reset()
|
if err := c.sendCommitteeTx(res.Script, res.GasConsumed, false); err != nil {
|
||||||
totalGasCost += res.GasConsumed
|
return err
|
||||||
w.WriteBytes(res.Script)
|
}
|
||||||
|
|
||||||
|
w.Reset()
|
||||||
for _, ctrName := range contractList {
|
for _, ctrName := range contractList {
|
||||||
cs := c.getContract(ctrName)
|
cs := c.getContract(ctrName)
|
||||||
|
|
||||||
|
@ -223,7 +233,7 @@ func (c *initializeContext) updateContracts() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = c.addManifestGroup(ctrHash, alphaCs)
|
err = c.addManifestGroup(ctrHash, cs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("can't sign manifest group: %v", err)
|
return fmt.Errorf("can't sign manifest group: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"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/io"
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
||||||
|
@ -238,7 +238,7 @@ var errNNSIsAvailableInvalid = errors.New("`isAvailable`: invalid response")
|
||||||
|
|
||||||
func nnsIsAvailable(c Client, nnsHash util.Uint160, name string) (bool, error) {
|
func nnsIsAvailable(c Client, nnsHash util.Uint160, name string) (bool, error) {
|
||||||
switch ct := c.(type) {
|
switch ct := c.(type) {
|
||||||
case *client.Client:
|
case *rpcclient.Client:
|
||||||
return ct.NNSIsAvailable(nnsHash, name)
|
return ct.NNSIsAvailable(nnsHash, name)
|
||||||
default:
|
default:
|
||||||
res, err := invokeFunction(c, nnsHash, "isAvailable", []interface{}{name}, nil)
|
res, err := invokeFunction(c, nnsHash, "isAvailable", []interface{}{name}, nil)
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
||||||
|
@ -52,12 +52,12 @@ func (c *initializeContext) registerCandidates() error {
|
||||||
panic(fmt.Sprintf("BUG: %v", w.Err))
|
panic(fmt.Sprintf("BUG: %v", w.Err))
|
||||||
}
|
}
|
||||||
|
|
||||||
signers := []client.SignerAccount{{
|
signers := []rpcclient.SignerAccount{{
|
||||||
Signer: c.getSigner(false),
|
Signer: c.getSigner(false),
|
||||||
Account: c.CommitteeAcc,
|
Account: c.CommitteeAcc,
|
||||||
}}
|
}}
|
||||||
for i := range c.Accounts {
|
for i := range c.Accounts {
|
||||||
signers = append(signers, client.SignerAccount{
|
signers = append(signers, rpcclient.SignerAccount{
|
||||||
Signer: transaction.Signer{
|
Signer: transaction.Signer{
|
||||||
Account: c.Accounts[i].Contract.ScriptHash(),
|
Account: c.Accounts[i].Contract.ScriptHash(),
|
||||||
Scopes: transaction.CustomContracts,
|
Scopes: transaction.CustomContracts,
|
||||||
|
@ -120,7 +120,7 @@ var errGetPriceInvalid = errors.New("`getRegisterPrice`: invalid response")
|
||||||
|
|
||||||
func (c *initializeContext) getCandidateRegisterPrice() (int64, error) {
|
func (c *initializeContext) getCandidateRegisterPrice() (int64, error) {
|
||||||
switch ct := c.Client.(type) {
|
switch ct := c.Client.(type) {
|
||||||
case *client.Client:
|
case *rpcclient.Client:
|
||||||
return ct.GetCandidateRegisterPrice()
|
return ct.GetCandidateRegisterPrice()
|
||||||
default:
|
default:
|
||||||
neoHash := c.nativeHash(nativenames.Neo)
|
neoHash := c.nativeHash(nativenames.Neo)
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
||||||
scContext "github.com/nspcc-dev/neo-go/pkg/smartcontract/context"
|
scContext "github.com/nspcc-dev/neo-go/pkg/smartcontract/context"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
||||||
|
@ -35,11 +35,11 @@ func (c *initializeContext) transferFunds() error {
|
||||||
gasHash := c.nativeHash(nativenames.Gas)
|
gasHash := c.nativeHash(nativenames.Gas)
|
||||||
neoHash := c.nativeHash(nativenames.Neo)
|
neoHash := c.nativeHash(nativenames.Neo)
|
||||||
|
|
||||||
var transfers []client.TransferTarget
|
var transfers []rpcclient.TransferTarget
|
||||||
for _, acc := range c.Accounts {
|
for _, acc := range c.Accounts {
|
||||||
to := acc.Contract.ScriptHash()
|
to := acc.Contract.ScriptHash()
|
||||||
transfers = append(transfers,
|
transfers = append(transfers,
|
||||||
client.TransferTarget{
|
rpcclient.TransferTarget{
|
||||||
Token: gasHash,
|
Token: gasHash,
|
||||||
Address: to,
|
Address: to,
|
||||||
Amount: initialAlphabetGASAmount,
|
Amount: initialAlphabetGASAmount,
|
||||||
|
@ -49,19 +49,19 @@ func (c *initializeContext) transferFunds() error {
|
||||||
|
|
||||||
// It is convenient to have all funds at the committee account.
|
// It is convenient to have all funds at the committee account.
|
||||||
transfers = append(transfers,
|
transfers = append(transfers,
|
||||||
client.TransferTarget{
|
rpcclient.TransferTarget{
|
||||||
Token: gasHash,
|
Token: gasHash,
|
||||||
Address: c.CommitteeAcc.Contract.ScriptHash(),
|
Address: c.CommitteeAcc.Contract.ScriptHash(),
|
||||||
Amount: (gasInitialTotalSupply - initialAlphabetGASAmount*int64(len(c.Wallets))) / 2,
|
Amount: (gasInitialTotalSupply - initialAlphabetGASAmount*int64(len(c.Wallets))) / 2,
|
||||||
},
|
},
|
||||||
client.TransferTarget{
|
rpcclient.TransferTarget{
|
||||||
Token: neoHash,
|
Token: neoHash,
|
||||||
Address: c.CommitteeAcc.Contract.ScriptHash(),
|
Address: c.CommitteeAcc.Contract.ScriptHash(),
|
||||||
Amount: native.NEOTotalSupply,
|
Amount: native.NEOTotalSupply,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
tx, err := createNEP17MultiTransferTx(c.Client, c.ConsensusAcc, 0, transfers, []client.SignerAccount{{
|
tx, err := createNEP17MultiTransferTx(c.Client, c.ConsensusAcc, 0, transfers, []rpcclient.SignerAccount{{
|
||||||
Signer: transaction.Signer{
|
Signer: transaction.Signer{
|
||||||
Account: c.ConsensusAcc.Contract.ScriptHash(),
|
Account: c.ConsensusAcc.Contract.ScriptHash(),
|
||||||
Scopes: transaction.CalledByEntry,
|
Scopes: transaction.CalledByEntry,
|
||||||
|
@ -143,7 +143,7 @@ func (c *initializeContext) transferGASToProxy() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
tx, err := createNEP17MultiTransferTx(c.Client, c.CommitteeAcc, 0, []client.TransferTarget{{
|
tx, err := createNEP17MultiTransferTx(c.Client, c.CommitteeAcc, 0, []rpcclient.TransferTarget{{
|
||||||
Token: gasHash,
|
Token: gasHash,
|
||||||
Address: proxyCs.Hash,
|
Address: proxyCs.Hash,
|
||||||
Amount: initialProxyGASAmount,
|
Amount: initialProxyGASAmount,
|
||||||
|
@ -160,7 +160,7 @@ func (c *initializeContext) transferGASToProxy() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func createNEP17MultiTransferTx(c Client, acc *wallet.Account, netFee int64,
|
func createNEP17MultiTransferTx(c Client, acc *wallet.Account, netFee int64,
|
||||||
recipients []client.TransferTarget, cosigners []client.SignerAccount) (*transaction.Transaction, error) {
|
recipients []rpcclient.TransferTarget, cosigners []rpcclient.SignerAccount) (*transaction.Transaction, error) {
|
||||||
from := acc.Contract.ScriptHash()
|
from := acc.Contract.ScriptHash()
|
||||||
|
|
||||||
w := io.NewBufBinWriter()
|
w := io.NewBufBinWriter()
|
||||||
|
@ -172,7 +172,7 @@ func createNEP17MultiTransferTx(c Client, acc *wallet.Account, netFee int64,
|
||||||
if w.Err != nil {
|
if w.Err != nil {
|
||||||
return nil, fmt.Errorf("failed to create transfer script: %w", w.Err)
|
return nil, fmt.Errorf("failed to create transfer script: %w", w.Err)
|
||||||
}
|
}
|
||||||
return c.CreateTxFromScript(w.Bytes(), acc, -1, netFee, append([]client.SignerAccount{{
|
return c.CreateTxFromScript(w.Bytes(), acc, -1, netFee, append([]rpcclient.SignerAccount{{
|
||||||
Signer: transaction.Signer{
|
Signer: transaction.Signer{
|
||||||
Account: from,
|
Account: from,
|
||||||
Scopes: transaction.CalledByEntry,
|
Scopes: transaction.CalledByEntry,
|
||||||
|
|
|
@ -21,9 +21,9 @@ import (
|
||||||
"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/fixedn"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/network/payload"
|
"github.com/nspcc-dev/neo-go/pkg/network/payload"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger"
|
||||||
|
@ -125,7 +125,7 @@ func (l *localClient) GetApplicationLog(h util.Uint256, t *trigger.Type) (*resul
|
||||||
return &a, nil
|
return &a, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *localClient) CreateTxFromScript(script []byte, acc *wallet.Account, sysFee int64, netFee int64, cosigners []client.SignerAccount) (*transaction.Transaction, error) {
|
func (l *localClient) CreateTxFromScript(script []byte, acc *wallet.Account, sysFee int64, netFee int64, cosigners []rpcclient.SignerAccount) (*transaction.Transaction, error) {
|
||||||
signers, accounts, err := getSigners(acc, cosigners)
|
signers, accounts, err := getSigners(acc, cosigners)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to construct tx signers: %w", err)
|
return nil, fmt.Errorf("failed to construct tx signers: %w", err)
|
||||||
|
@ -173,7 +173,7 @@ func (l *localClient) SignAndPushP2PNotaryRequest(_ *transaction.Transaction, _
|
||||||
panic("unexpected call")
|
panic("unexpected call")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *localClient) SignAndPushInvocationTx(_ []byte, _ *wallet.Account, _ int64, _ fixedn.Fixed8, _ []client.SignerAccount) (util.Uint256, error) {
|
func (l *localClient) SignAndPushInvocationTx(_ []byte, _ *wallet.Account, _ int64, _ fixedn.Fixed8, _ []rpcclient.SignerAccount) (util.Uint256, error) {
|
||||||
// not used by `morph init` command
|
// not used by `morph init` command
|
||||||
panic("unexpected call")
|
panic("unexpected call")
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@ func (l *localClient) AddNetworkFee(tx *transaction.Transaction, extraFee int64,
|
||||||
// will be placed at the start of the list.
|
// will be placed at the start of the list.
|
||||||
// Copied from neo-go with minor corrections:
|
// Copied from neo-go with minor corrections:
|
||||||
// https://github.com/nspcc-dev/neo-go/blob/6ff11baa1b9e4c71ef0d1de43b92a8c541ca732c/pkg/rpc/client/rpc.go#L735
|
// https://github.com/nspcc-dev/neo-go/blob/6ff11baa1b9e4c71ef0d1de43b92a8c541ca732c/pkg/rpc/client/rpc.go#L735
|
||||||
func getSigners(sender *wallet.Account, cosigners []client.SignerAccount) ([]transaction.Signer, []*wallet.Account, error) {
|
func getSigners(sender *wallet.Account, cosigners []rpcclient.SignerAccount) ([]transaction.Signer, []*wallet.Account, error) {
|
||||||
var (
|
var (
|
||||||
signers []transaction.Signer
|
signers []transaction.Signer
|
||||||
accounts []*wallet.Account
|
accounts []*wallet.Account
|
||||||
|
|
|
@ -11,9 +11,9 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
"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/fixedn"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/network/payload"
|
"github.com/nspcc-dev/neo-go/pkg/network/payload"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
||||||
|
@ -30,14 +30,14 @@ type Client interface {
|
||||||
GetNativeContracts() ([]state.NativeContract, error)
|
GetNativeContracts() ([]state.NativeContract, error)
|
||||||
GetNetwork() (netmode.Magic, error)
|
GetNetwork() (netmode.Magic, error)
|
||||||
GetApplicationLog(util.Uint256, *trigger.Type) (*result.ApplicationLog, error)
|
GetApplicationLog(util.Uint256, *trigger.Type) (*result.ApplicationLog, error)
|
||||||
CreateTxFromScript([]byte, *wallet.Account, int64, int64, []client.SignerAccount) (*transaction.Transaction, error)
|
CreateTxFromScript([]byte, *wallet.Account, int64, int64, []rpcclient.SignerAccount) (*transaction.Transaction, error)
|
||||||
NEP17BalanceOf(util.Uint160, util.Uint160) (int64, error)
|
NEP17BalanceOf(util.Uint160, util.Uint160) (int64, error)
|
||||||
InvokeScript([]byte, []transaction.Signer) (*result.Invoke, error)
|
InvokeScript([]byte, []transaction.Signer) (*result.Invoke, error)
|
||||||
SendRawTransaction(*transaction.Transaction) (util.Uint256, error)
|
SendRawTransaction(*transaction.Transaction) (util.Uint256, error)
|
||||||
GetCommittee() (keys.PublicKeys, error)
|
GetCommittee() (keys.PublicKeys, error)
|
||||||
CalculateNotaryFee(uint8) (int64, error)
|
CalculateNotaryFee(uint8) (int64, error)
|
||||||
AddNetworkFee(*transaction.Transaction, int64, ...*wallet.Account) error
|
AddNetworkFee(*transaction.Transaction, int64, ...*wallet.Account) error
|
||||||
SignAndPushInvocationTx([]byte, *wallet.Account, int64, fixedn.Fixed8, []client.SignerAccount) (util.Uint256, error)
|
SignAndPushInvocationTx([]byte, *wallet.Account, int64, fixedn.Fixed8, []rpcclient.SignerAccount) (util.Uint256, error)
|
||||||
SignAndPushP2PNotaryRequest(*transaction.Transaction, []byte, int64, int64, uint32, *wallet.Account) (*payload.P2PNotaryRequest, error)
|
SignAndPushP2PNotaryRequest(*transaction.Transaction, []byte, int64, int64, uint32, *wallet.Account) (*payload.P2PNotaryRequest, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ func getN3Client(v *viper.Viper) (Client, error) {
|
||||||
if endpoint == "" {
|
if endpoint == "" {
|
||||||
return nil, errors.New("missing endpoint")
|
return nil, errors.New("missing endpoint")
|
||||||
}
|
}
|
||||||
c, err := client.New(ctx, endpoint, client.Options{
|
c, err := rpcclient.New(ctx, endpoint, rpcclient.Options{
|
||||||
MaxConnsPerHost: maxConnsPerHost,
|
MaxConnsPerHost: maxConnsPerHost,
|
||||||
RequestTimeout: requestTimeout,
|
RequestTimeout: requestTimeout,
|
||||||
})
|
})
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"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"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
|
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
|
||||||
|
@ -113,7 +113,7 @@ func depositNotary(cmd *cobra.Command, _ []string) error {
|
||||||
return fmt.Errorf("BUG: invalid transfer arguments: %w", bw.Err)
|
return fmt.Errorf("BUG: invalid transfer arguments: %w", bw.Err)
|
||||||
}
|
}
|
||||||
|
|
||||||
tx, err := c.CreateTxFromScript(bw.Bytes(), acc, -1, 0, []client.SignerAccount{{
|
tx, err := c.CreateTxFromScript(bw.Bytes(), acc, -1, 0, []rpcclient.SignerAccount{{
|
||||||
Signer: transaction.Signer{
|
Signer: transaction.Signer{
|
||||||
Account: acc.Contract.ScriptHash(),
|
Account: acc.Contract.ScriptHash(),
|
||||||
Scopes: transaction.Global,
|
Scopes: transaction.Global,
|
||||||
|
|
|
@ -12,8 +12,8 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
neogocli "github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
|
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
|
||||||
|
@ -851,7 +851,7 @@ func invokeNonNotary(c Client, key keys.PrivateKey, method string, args ...inter
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
cosignerAcc := []neogocli.SignerAccount{
|
cosignerAcc := []rpcclient.SignerAccount{
|
||||||
{
|
{
|
||||||
Signer: cosigner[0],
|
Signer: cosigner[0],
|
||||||
Account: acc,
|
Account: acc,
|
||||||
|
|
|
@ -24,7 +24,7 @@ import (
|
||||||
"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"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
|
@ -394,8 +394,8 @@ loop:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func initClient(rpc []string) *client.Client {
|
func initClient(rpc []string) *rpcclient.Client {
|
||||||
var c *client.Client
|
var c *rpcclient.Client
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
shuffled := make([]string, len(rpc))
|
shuffled := make([]string, len(rpc))
|
||||||
|
@ -403,7 +403,7 @@ func initClient(rpc []string) *client.Client {
|
||||||
rand.Shuffle(len(shuffled), func(i, j int) { shuffled[i], shuffled[j] = shuffled[j], shuffled[i] })
|
rand.Shuffle(len(shuffled), func(i, j int) { shuffled[i], shuffled[j] = shuffled[j], shuffled[i] })
|
||||||
|
|
||||||
for _, endpoint := range shuffled {
|
for _, endpoint := range shuffled {
|
||||||
c, err = client.New(context.Background(), "https://"+endpoint, client.Options{
|
c, err = rpcclient.New(context.Background(), "https://"+endpoint, rpcclient.Options{
|
||||||
DialTimeout: time.Second * 2,
|
DialTimeout: time.Second * 2,
|
||||||
RequestTimeout: time.Second * 5,
|
RequestTimeout: time.Second * 5,
|
||||||
})
|
})
|
||||||
|
|
8
go.mod
8
go.mod
|
@ -15,11 +15,11 @@ require (
|
||||||
github.com/multiformats/go-multiaddr v0.4.0
|
github.com/multiformats/go-multiaddr v0.4.0
|
||||||
github.com/nats-io/nats.go v1.13.1-0.20220308171302-2f2f6968e98d
|
github.com/nats-io/nats.go v1.13.1-0.20220308171302-2f2f6968e98d
|
||||||
github.com/nspcc-dev/hrw v1.0.9
|
github.com/nspcc-dev/hrw v1.0.9
|
||||||
github.com/nspcc-dev/neo-go v0.99.1-pre.0.20220714084516-54849ef3e58e
|
github.com/nspcc-dev/neo-go v0.99.1
|
||||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220713145417-4f184498bc42 // indirect
|
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220727202624-6c7a401f776a // indirect
|
||||||
github.com/nspcc-dev/neofs-api-go/v2 v2.13.0
|
github.com/nspcc-dev/neofs-api-go/v2 v2.13.1
|
||||||
github.com/nspcc-dev/neofs-contract v0.15.3
|
github.com/nspcc-dev/neofs-contract v0.15.3
|
||||||
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.5.0.20220725101411-90f1cc7a1a77
|
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.6.0.20220801165707-7a99cc916c8e
|
||||||
github.com/nspcc-dev/tzhash v1.6.1
|
github.com/nspcc-dev/tzhash v1.6.1
|
||||||
github.com/panjf2000/ants/v2 v2.4.0
|
github.com/panjf2000/ants/v2 v2.4.0
|
||||||
github.com/paulmach/orb v0.2.2
|
github.com/paulmach/orb v0.2.2
|
||||||
|
|
BIN
go.sum
BIN
go.sum
Binary file not shown.
|
@ -43,10 +43,6 @@ func IsErrNotFound(err error) bool {
|
||||||
return errors.As(err, new(apistatus.ContainerNotFound))
|
return errors.As(err, new(apistatus.ContainerNotFound))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrEACLNotFound is returned by eACL storage implementations when
|
|
||||||
// the requested eACL table is not in the storage.
|
|
||||||
var ErrEACLNotFound = errors.New("extended ACL table is not set for this container")
|
|
||||||
|
|
||||||
// EACL groups information about the NeoFS container's extended ACL stored in
|
// EACL groups information about the NeoFS container's extended ACL stored in
|
||||||
// the NeoFS network.
|
// the NeoFS network.
|
||||||
type EACL struct {
|
type EACL struct {
|
||||||
|
|
|
@ -749,6 +749,7 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper, errChan chan<-
|
||||||
Log: log,
|
Log: log,
|
||||||
PoolSize: cfg.GetInt("workers.balance"),
|
PoolSize: cfg.GetInt("workers.balance"),
|
||||||
NeoFSClient: neofsCli,
|
NeoFSClient: neofsCli,
|
||||||
|
BalanceSC: server.contracts.balance,
|
||||||
AlphabetState: server,
|
AlphabetState: server,
|
||||||
Converter: &server.precision,
|
Converter: &server.precision,
|
||||||
})
|
})
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
neofscontract "github.com/nspcc-dev/neofs-node/pkg/morph/client/neofs"
|
neofscontract "github.com/nspcc-dev/neofs-node/pkg/morph/client/neofs"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||||
balanceEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/balance"
|
balanceEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/balance"
|
||||||
|
@ -27,6 +28,7 @@ type (
|
||||||
log *zap.Logger
|
log *zap.Logger
|
||||||
pool *ants.Pool
|
pool *ants.Pool
|
||||||
neofsClient *neofscontract.Client
|
neofsClient *neofscontract.Client
|
||||||
|
balanceSC util.Uint160
|
||||||
alphabetState AlphabetState
|
alphabetState AlphabetState
|
||||||
converter PrecisionConverter
|
converter PrecisionConverter
|
||||||
}
|
}
|
||||||
|
@ -36,6 +38,7 @@ type (
|
||||||
Log *zap.Logger
|
Log *zap.Logger
|
||||||
PoolSize int
|
PoolSize int
|
||||||
NeoFSClient *neofscontract.Client
|
NeoFSClient *neofscontract.Client
|
||||||
|
BalanceSC util.Uint160
|
||||||
AlphabetState AlphabetState
|
AlphabetState AlphabetState
|
||||||
Converter PrecisionConverter
|
Converter PrecisionConverter
|
||||||
}
|
}
|
||||||
|
@ -67,6 +70,7 @@ func New(p *Params) (*Processor, error) {
|
||||||
log: p.Log,
|
log: p.Log,
|
||||||
pool: pool,
|
pool: pool,
|
||||||
neofsClient: p.NeoFSClient,
|
neofsClient: p.NeoFSClient,
|
||||||
|
balanceSC: p.BalanceSC,
|
||||||
alphabetState: p.AlphabetState,
|
alphabetState: p.AlphabetState,
|
||||||
converter: p.Converter,
|
converter: p.Converter,
|
||||||
}, nil
|
}, nil
|
||||||
|
@ -79,7 +83,7 @@ func (bp *Processor) ListenerNotificationParsers() []event.NotificationParserInf
|
||||||
// new lock event
|
// new lock event
|
||||||
lock := event.NotificationParserInfo{}
|
lock := event.NotificationParserInfo{}
|
||||||
lock.SetType(lockNotification)
|
lock.SetType(lockNotification)
|
||||||
lock.SetScriptHash(bp.neofsClient.ContractAddress())
|
lock.SetScriptHash(bp.balanceSC)
|
||||||
lock.SetParser(balanceEvent.ParseLock)
|
lock.SetParser(balanceEvent.ParseLock)
|
||||||
parsers = append(parsers, lock)
|
parsers = append(parsers, lock)
|
||||||
|
|
||||||
|
@ -93,7 +97,7 @@ func (bp *Processor) ListenerNotificationHandlers() []event.NotificationHandlerI
|
||||||
// lock handler
|
// lock handler
|
||||||
lock := event.NotificationHandlerInfo{}
|
lock := event.NotificationHandlerInfo{}
|
||||||
lock.SetType(lockNotification)
|
lock.SetType(lockNotification)
|
||||||
lock.SetScriptHash(bp.neofsClient.ContractAddress())
|
lock.SetScriptHash(bp.balanceSC)
|
||||||
lock.SetHandler(bp.handleLock)
|
lock.SetHandler(bp.handleLock)
|
||||||
handlers = append(handlers, lock)
|
handlers = append(handlers, lock)
|
||||||
|
|
||||||
|
|
|
@ -628,7 +628,7 @@ func (b *blobovniczas) getObjectRange(blz *blobovnicza.Blobovnicza, prm GetRange
|
||||||
to := from + prm.rng.GetLength()
|
to := from + prm.rng.GetLength()
|
||||||
payload := obj.Payload()
|
payload := obj.Payload()
|
||||||
|
|
||||||
if uint64(len(payload)) < to {
|
if pLen := uint64(len(payload)); to < from || pLen < from || pLen < to {
|
||||||
var errOutOfRange apistatus.ObjectOutOfRange
|
var errOutOfRange apistatus.ObjectOutOfRange
|
||||||
|
|
||||||
return GetRangeSmallRes{}, errOutOfRange
|
return GetRangeSmallRes{}, errOutOfRange
|
||||||
|
|
|
@ -54,7 +54,7 @@ func (b *BlobStor) GetRangeBig(prm GetRangeBigPrm) (GetRangeBigRes, error) {
|
||||||
payload := obj.Payload()
|
payload := obj.Payload()
|
||||||
ln, off := prm.rng.GetLength(), prm.rng.GetOffset()
|
ln, off := prm.rng.GetLength(), prm.rng.GetOffset()
|
||||||
|
|
||||||
if pLen := uint64(len(payload)); pLen < ln+off {
|
if pLen := uint64(len(payload)); ln+off < off || pLen < off || pLen < ln+off {
|
||||||
var errOutOfRange apistatus.ObjectOutOfRange
|
var errOutOfRange apistatus.ObjectOutOfRange
|
||||||
|
|
||||||
return GetRangeBigRes{}, errOutOfRange
|
return GetRangeBigRes{}, errOutOfRange
|
||||||
|
|
|
@ -87,8 +87,12 @@ func (s *Shard) Get(prm GetPrm) (GetRes, error) {
|
||||||
return res.Object(), nil
|
return res.Object(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wc := func(c writecache.Cache) (*objectSDK.Object, error) {
|
||||||
|
return c.Get(prm.addr)
|
||||||
|
}
|
||||||
|
|
||||||
skipMeta := prm.skipMeta || s.GetMode().NoMetabase()
|
skipMeta := prm.skipMeta || s.GetMode().NoMetabase()
|
||||||
obj, hasMeta, err := s.fetchObjectData(prm.addr, skipMeta, big, small)
|
obj, hasMeta, err := s.fetchObjectData(prm.addr, skipMeta, big, small, wc)
|
||||||
|
|
||||||
return GetRes{
|
return GetRes{
|
||||||
obj: obj,
|
obj: obj,
|
||||||
|
@ -97,16 +101,16 @@ func (s *Shard) Get(prm GetPrm) (GetRes, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetchObjectData looks through writeCache and blobStor to find object.
|
// fetchObjectData looks through writeCache and blobStor to find object.
|
||||||
func (s *Shard) fetchObjectData(addr oid.Address, skipMeta bool, big, small storFetcher) (*objectSDK.Object, bool, error) {
|
func (s *Shard) fetchObjectData(addr oid.Address, skipMeta bool, big, small storFetcher, wc func(w writecache.Cache) (*objectSDK.Object, error)) (*objectSDK.Object, bool, error) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
res *objectSDK.Object
|
res *objectSDK.Object
|
||||||
)
|
)
|
||||||
|
|
||||||
if s.hasWriteCache() {
|
if s.hasWriteCache() {
|
||||||
res, err = s.writeCache.Get(addr)
|
res, err := wc(s.writeCache)
|
||||||
if err == nil {
|
if err == nil || IsErrOutOfRange(err) {
|
||||||
return res, false, nil
|
return res, false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if writecache.IsErrNotFound(err) {
|
if writecache.IsErrNotFound(err) {
|
||||||
|
|
|
@ -3,6 +3,8 @@ package shard
|
||||||
import (
|
import (
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza"
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor"
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor"
|
||||||
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/writecache"
|
||||||
|
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/object"
|
"github.com/nspcc-dev/neofs-sdk-go/object"
|
||||||
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
||||||
)
|
)
|
||||||
|
@ -102,8 +104,26 @@ func (s *Shard) GetRange(prm RngPrm) (RngRes, error) {
|
||||||
return obj, nil
|
return obj, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wc := func(c writecache.Cache) (*object.Object, error) {
|
||||||
|
res, err := c.Get(prm.addr)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
payload := res.Payload()
|
||||||
|
from := rng.GetOffset()
|
||||||
|
to := from + rng.GetLength()
|
||||||
|
if pLen := uint64(len(payload)); to < from || pLen < from || pLen < to {
|
||||||
|
return nil, apistatus.ObjectOutOfRange{}
|
||||||
|
}
|
||||||
|
|
||||||
|
obj := object.New()
|
||||||
|
obj.SetPayload(payload[from:to])
|
||||||
|
return obj, nil
|
||||||
|
}
|
||||||
|
|
||||||
skipMeta := prm.skipMeta || s.GetMode().NoMetabase()
|
skipMeta := prm.skipMeta || s.GetMode().NoMetabase()
|
||||||
obj, hasMeta, err := s.fetchObjectData(prm.addr, skipMeta, big, small)
|
obj, hasMeta, err := s.fetchObjectData(prm.addr, skipMeta, big, small, wc)
|
||||||
|
|
||||||
return RngRes{
|
return RngRes{
|
||||||
obj: obj,
|
obj: obj,
|
||||||
|
|
97
pkg/local_object_storage/shard/range_test.go
Normal file
97
pkg/local_object_storage/shard/range_test.go
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
package shard_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"math"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/util/slice"
|
||||||
|
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||||
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor"
|
||||||
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
|
||||||
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/writecache"
|
||||||
|
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
|
||||||
|
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestShard_GetRange(t *testing.T) {
|
||||||
|
t.Run("without write cache", func(t *testing.T) {
|
||||||
|
testShardGetRange(t, false)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("with write cache", func(t *testing.T) {
|
||||||
|
testShardGetRange(t, true)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func testShardGetRange(t *testing.T, hasWriteCache bool) {
|
||||||
|
type testCase struct {
|
||||||
|
hasErr bool
|
||||||
|
name string
|
||||||
|
payloadSize int
|
||||||
|
rng *objectSDK.Range
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
writeCacheMaxSize = 1024
|
||||||
|
smallObjectSize = 2048
|
||||||
|
)
|
||||||
|
|
||||||
|
newRange := func(off, ln uint64) *objectSDK.Range {
|
||||||
|
rng := objectSDK.NewRange()
|
||||||
|
rng.SetOffset(off)
|
||||||
|
rng.SetLength(ln)
|
||||||
|
return rng
|
||||||
|
}
|
||||||
|
|
||||||
|
testCases := []testCase{
|
||||||
|
{false, "small object, good", 1024, newRange(11, 123)},
|
||||||
|
{true, "small object, out of range, big len", 1024, newRange(10, 1020)},
|
||||||
|
{true, "small object, out of range, big offset", 1024, newRange(1025, math.MaxUint64-10)},
|
||||||
|
{false, "big object, good", 2048, newRange(11, 123)},
|
||||||
|
{true, "big object, out of range, big len", 2048, newRange(100, 2000)},
|
||||||
|
{true, "big object, out of range, big offset", 2048, newRange(2048, math.MaxUint64-10)},
|
||||||
|
}
|
||||||
|
|
||||||
|
if hasWriteCache {
|
||||||
|
testCases = append(testCases,
|
||||||
|
testCase{false, "object in write-cache, good", 100, newRange(2, 18)},
|
||||||
|
testCase{true, "object in write-cache, out of range, big len", 100, newRange(4, 99)},
|
||||||
|
testCase{true, "object in write-cache, out of range, big offset", 100, newRange(101, math.MaxUint64-10)})
|
||||||
|
}
|
||||||
|
|
||||||
|
sh := newCustomShard(t, t.TempDir(), hasWriteCache,
|
||||||
|
[]writecache.Option{writecache.WithMaxMemSize(0), writecache.WithMaxObjectSize(writeCacheMaxSize)},
|
||||||
|
[]blobstor.Option{blobstor.WithSmallSizeLimit(smallObjectSize)})
|
||||||
|
defer releaseShard(sh, t)
|
||||||
|
|
||||||
|
for _, tc := range testCases {
|
||||||
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
obj := generateObject(t)
|
||||||
|
addAttribute(obj, "foo", "bar")
|
||||||
|
addPayload(obj, tc.payloadSize)
|
||||||
|
|
||||||
|
addr := object.AddressOf(obj)
|
||||||
|
payload := slice.Copy(obj.Payload())
|
||||||
|
|
||||||
|
var putPrm shard.PutPrm
|
||||||
|
putPrm.SetObject(obj)
|
||||||
|
|
||||||
|
_, err := sh.Put(putPrm)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
var rngPrm shard.RngPrm
|
||||||
|
rngPrm.SetAddress(addr)
|
||||||
|
rngPrm.SetRange(tc.rng.GetOffset(), tc.rng.GetLength())
|
||||||
|
|
||||||
|
res, err := sh.GetRange(rngPrm)
|
||||||
|
if tc.hasErr {
|
||||||
|
require.ErrorAs(t, err, &apistatus.ObjectOutOfRange{})
|
||||||
|
} else {
|
||||||
|
require.Equal(t,
|
||||||
|
payload[tc.rng.GetOffset():tc.rng.GetOffset()+tc.rng.GetLength()],
|
||||||
|
res.Object().Payload())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,7 +14,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
"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/fixedn"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
||||||
sc "github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
sc "github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
|
@ -44,7 +44,7 @@ type Client struct {
|
||||||
|
|
||||||
logger *logger.Logger // logging component
|
logger *logger.Logger // logging component
|
||||||
|
|
||||||
client *client.WSClient // neo-go websocket client
|
client *rpcclient.WSClient // neo-go websocket client
|
||||||
|
|
||||||
acc *wallet.Account // neo account
|
acc *wallet.Account // neo account
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ type Client struct {
|
||||||
switchLock *sync.RWMutex
|
switchLock *sync.RWMutex
|
||||||
|
|
||||||
// channel for ws notifications
|
// channel for ws notifications
|
||||||
notifications chan client.Notification
|
notifications chan rpcclient.Notification
|
||||||
|
|
||||||
// channel for internal stop
|
// channel for internal stop
|
||||||
closeChan chan struct{}
|
closeChan chan struct{}
|
||||||
|
@ -194,7 +194,7 @@ func (c *Client) Invoke(contract util.Uint160, fee fixedn.Fixed8, method string,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
cosignerAcc := []client.SignerAccount{
|
cosignerAcc := []rpcclient.SignerAccount{
|
||||||
{
|
{
|
||||||
Signer: cosigner[0],
|
Signer: cosigner[0],
|
||||||
Account: c.acc,
|
Account: c.acc,
|
||||||
|
@ -569,7 +569,7 @@ func (c *Client) IsValidScript(script []byte, signers []transaction.Signer) (res
|
||||||
// notification from the connected RPC node.
|
// notification from the connected RPC node.
|
||||||
// Channel is closed when connection to the RPC node has been
|
// Channel is closed when connection to the RPC node has been
|
||||||
// lost without the possibility of recovery.
|
// lost without the possibility of recovery.
|
||||||
func (c *Client) NotificationChannel() <-chan client.Notification {
|
func (c *Client) NotificationChannel() <-chan rpcclient.Notification {
|
||||||
return c.notifications
|
return c.notifications
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
lru "github.com/hashicorp/golang-lru"
|
lru "github.com/hashicorp/golang-lru"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
"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/rpc/client"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
|
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
|
||||||
|
@ -38,7 +38,7 @@ type cfg struct {
|
||||||
|
|
||||||
endpoints []Endpoint
|
endpoints []Endpoint
|
||||||
|
|
||||||
singleCli *client.WSClient // neo-go client for single client mode
|
singleCli *rpcclient.WSClient // neo-go client for single client mode
|
||||||
|
|
||||||
inactiveModeCb Callback
|
inactiveModeCb Callback
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ func New(key *keys.PrivateKey, opts ...Option) (*Client, error) {
|
||||||
signer: cfg.signer,
|
signer: cfg.signer,
|
||||||
cfg: *cfg,
|
cfg: *cfg,
|
||||||
switchLock: &sync.RWMutex{},
|
switchLock: &sync.RWMutex{},
|
||||||
notifications: make(chan client.Notification),
|
notifications: make(chan rpcclient.Notification),
|
||||||
subscribedEvents: make(map[util.Uint160]string),
|
subscribedEvents: make(map[util.Uint160]string),
|
||||||
subscribedNotaryEvents: make(map[util.Uint160]string),
|
subscribedNotaryEvents: make(map[util.Uint160]string),
|
||||||
closeChan: make(chan struct{}),
|
closeChan: make(chan struct{}),
|
||||||
|
@ -136,11 +136,11 @@ func New(key *keys.PrivateKey, opts ...Option) (*Client, error) {
|
||||||
return cli, nil
|
return cli, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func newWSClient(cfg cfg, endpoint string) (*client.WSClient, error) {
|
func newWSClient(cfg cfg, endpoint string) (*rpcclient.WSClient, error) {
|
||||||
return client.NewWS(
|
return rpcclient.NewWS(
|
||||||
cfg.ctx,
|
cfg.ctx,
|
||||||
endpoint,
|
endpoint,
|
||||||
client.Options{DialTimeout: cfg.dialTimeout},
|
rpcclient.Options{DialTimeout: cfg.dialTimeout},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ func WithEndpoints(endpoints ...Endpoint) Option {
|
||||||
// to use it for requests.
|
// to use it for requests.
|
||||||
//
|
//
|
||||||
// Passed client must already be initialized.
|
// Passed client must already be initialized.
|
||||||
func WithSingleClient(cli *client.WSClient) Option {
|
func WithSingleClient(cli *rpcclient.WSClient) Option {
|
||||||
return func(c *cfg) {
|
return func(c *cfg) {
|
||||||
c.singleCli = cli
|
c.singleCli = cli
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"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"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||||
|
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
|
||||||
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/eacl"
|
"github.com/nspcc-dev/neofs-sdk-go/eacl"
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/session"
|
"github.com/nspcc-dev/neofs-sdk-go/session"
|
||||||
|
@ -14,6 +15,8 @@ import (
|
||||||
|
|
||||||
// GetEACL reads the extended ACL table from NeoFS system
|
// GetEACL reads the extended ACL table from NeoFS system
|
||||||
// through Container contract call.
|
// through Container contract call.
|
||||||
|
//
|
||||||
|
// Returns apistatus.EACLNotFound if eACL table is missing in the contract.
|
||||||
func (c *Client) GetEACL(cnr cid.ID) (*container.EACL, error) {
|
func (c *Client) GetEACL(cnr cid.ID) (*container.EACL, error) {
|
||||||
binCnr := make([]byte, sha256.Size)
|
binCnr := make([]byte, sha256.Size)
|
||||||
cnr.Encode(binCnr)
|
cnr.Encode(binCnr)
|
||||||
|
@ -52,7 +55,9 @@ func (c *Client) GetEACL(cnr cid.ID) (*container.EACL, error) {
|
||||||
// The absence of a signature in the response can be taken as an eACL absence criterion,
|
// The absence of a signature in the response can be taken as an eACL absence criterion,
|
||||||
// since unsigned table cannot be approved in the storage by design.
|
// since unsigned table cannot be approved in the storage by design.
|
||||||
if len(sig) == 0 {
|
if len(sig) == 0 {
|
||||||
return nil, container.ErrEACLNotFound
|
var errEACLNotFound apistatus.EACLNotFound
|
||||||
|
|
||||||
|
return nil, errEACLNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
pub, err := client.BytesFromStackItem(arr[2])
|
pub, err := client.BytesFromStackItem(arr[2])
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
"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/rpc/client"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"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"
|
||||||
|
@ -98,7 +98,7 @@ func (c *Client) NNSHash() (util.Uint160, error) {
|
||||||
return *nnsHash, nil
|
return *nnsHash, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func nnsResolveItem(c *client.WSClient, nnsHash util.Uint160, domain string) (stackitem.Item, error) {
|
func nnsResolveItem(c *rpcclient.WSClient, nnsHash util.Uint160, domain string) (stackitem.Item, error) {
|
||||||
found, err := exists(c, nnsHash, domain)
|
found, err := exists(c, nnsHash, domain)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not check presence in NNS contract for %s: %w", domain, err)
|
return nil, fmt.Errorf("could not check presence in NNS contract for %s: %w", domain, err)
|
||||||
|
@ -130,7 +130,7 @@ func nnsResolveItem(c *client.WSClient, nnsHash util.Uint160, domain string) (st
|
||||||
return result.Stack[0], nil
|
return result.Stack[0], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func nnsResolve(c *client.WSClient, nnsHash util.Uint160, domain string) (util.Uint160, error) {
|
func nnsResolve(c *rpcclient.WSClient, nnsHash util.Uint160, domain string) (util.Uint160, error) {
|
||||||
res, err := nnsResolveItem(c, nnsHash, domain)
|
res, err := nnsResolveItem(c, nnsHash, domain)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return util.Uint160{}, err
|
return util.Uint160{}, err
|
||||||
|
@ -152,7 +152,7 @@ func nnsResolve(c *client.WSClient, nnsHash util.Uint160, domain string) (util.U
|
||||||
return util.Uint160DecodeStringLE(string(bs))
|
return util.Uint160DecodeStringLE(string(bs))
|
||||||
}
|
}
|
||||||
|
|
||||||
func exists(c *client.WSClient, nnsHash util.Uint160, domain string) (bool, error) {
|
func exists(c *rpcclient.WSClient, nnsHash util.Uint160, domain string) (bool, error) {
|
||||||
result, err := c.InvokeFunction(nnsHash, "isAvailable", []smartcontract.Parameter{
|
result, err := c.InvokeFunction(nnsHash, "isAvailable", []smartcontract.Parameter{
|
||||||
{
|
{
|
||||||
Type: smartcontract.StringType,
|
Type: smartcontract.StringType,
|
||||||
|
|
|
@ -3,7 +3,7 @@ package balance
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"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/client"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||||
|
@ -46,7 +46,7 @@ func (l Lock) Until() int64 { return l.until }
|
||||||
func (l Lock) TxHash() util.Uint256 { return l.txHash }
|
func (l Lock) TxHash() util.Uint256 { return l.txHash }
|
||||||
|
|
||||||
// ParseLock from notification into lock structure.
|
// ParseLock from notification into lock structure.
|
||||||
func ParseLock(e *subscriptions.NotificationEvent) (event.Event, error) {
|
func ParseLock(e *state.ContainedNotificationEvent) (event.Event, error) {
|
||||||
var (
|
var (
|
||||||
ev Lock
|
ev Lock
|
||||||
err error
|
err error
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"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/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/event"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||||
|
@ -102,8 +101,8 @@ func TestParseLock(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func createNotifyEventFromItems(items []stackitem.Item) *subscriptions.NotificationEvent {
|
func createNotifyEventFromItems(items []stackitem.Item) *state.ContainedNotificationEvent {
|
||||||
return &subscriptions.NotificationEvent{
|
return &state.ContainedNotificationEvent{
|
||||||
NotificationEvent: state.NotificationEvent{
|
NotificationEvent: state.NotificationEvent{
|
||||||
Item: stackitem.NewArray(items),
|
Item: stackitem.NewArray(items),
|
||||||
},
|
},
|
||||||
|
|
|
@ -3,8 +3,8 @@ package container
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/network/payload"
|
"github.com/nspcc-dev/neo-go/pkg/network/payload"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
|
||||||
"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"
|
||||||
)
|
)
|
||||||
|
@ -46,7 +46,7 @@ const expectedItemNumDelete = 3
|
||||||
// ParseDelete from notification into container event structure.
|
// ParseDelete from notification into container event structure.
|
||||||
//
|
//
|
||||||
// Expects 3 stack items.
|
// Expects 3 stack items.
|
||||||
func ParseDelete(e *subscriptions.NotificationEvent) (event.Event, error) {
|
func ParseDelete(e *state.ContainedNotificationEvent) (event.Event, error) {
|
||||||
var (
|
var (
|
||||||
ev Delete
|
ev Delete
|
||||||
err error
|
err error
|
||||||
|
|
|
@ -3,8 +3,8 @@ package container
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/network/payload"
|
"github.com/nspcc-dev/neo-go/pkg/network/payload"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
|
||||||
"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"
|
||||||
)
|
)
|
||||||
|
@ -58,7 +58,7 @@ const expectedItemNumEACL = 4
|
||||||
// ParseSetEACL parses SetEACL notification event from list of stack items.
|
// ParseSetEACL parses SetEACL notification event from list of stack items.
|
||||||
//
|
//
|
||||||
// Expects 4 stack items.
|
// Expects 4 stack items.
|
||||||
func ParseSetEACL(e *subscriptions.NotificationEvent) (event.Event, error) {
|
func ParseSetEACL(e *state.ContainedNotificationEvent) (event.Event, error) {
|
||||||
var (
|
var (
|
||||||
ev SetEACL
|
ev SetEACL
|
||||||
err error
|
err error
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
|
||||||
"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/event"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -86,8 +85,8 @@ func TestParseEACL(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func createNotifyEventFromItems(items []stackitem.Item) *subscriptions.NotificationEvent {
|
func createNotifyEventFromItems(items []stackitem.Item) *state.ContainedNotificationEvent {
|
||||||
return &subscriptions.NotificationEvent{
|
return &state.ContainedNotificationEvent{
|
||||||
NotificationEvent: state.NotificationEvent{
|
NotificationEvent: state.NotificationEvent{
|
||||||
Item: stackitem.NewArray(items),
|
Item: stackitem.NewArray(items),
|
||||||
},
|
},
|
||||||
|
|
|
@ -3,7 +3,7 @@ package container
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"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"
|
||||||
|
@ -34,7 +34,7 @@ func (s StartEstimation) Epoch() uint64 { return s.epoch }
|
||||||
func (s StopEstimation) Epoch() uint64 { return s.epoch }
|
func (s StopEstimation) Epoch() uint64 { return s.epoch }
|
||||||
|
|
||||||
// ParseStartEstimation from notification into container event structure.
|
// ParseStartEstimation from notification into container event structure.
|
||||||
func ParseStartEstimation(e *subscriptions.NotificationEvent) (event.Event, error) {
|
func ParseStartEstimation(e *state.ContainedNotificationEvent) (event.Event, error) {
|
||||||
params, err := event.ParseStackArray(e)
|
params, err := event.ParseStackArray(e)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not parse stack items from notify event: %w", err)
|
return nil, fmt.Errorf("could not parse stack items from notify event: %w", err)
|
||||||
|
@ -49,7 +49,7 @@ func ParseStartEstimation(e *subscriptions.NotificationEvent) (event.Event, erro
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseStopEstimation from notification into container event structure.
|
// ParseStopEstimation from notification into container event structure.
|
||||||
func ParseStopEstimation(e *subscriptions.NotificationEvent) (event.Event, error) {
|
func ParseStopEstimation(e *state.ContainedNotificationEvent) (event.Event, error) {
|
||||||
params, err := event.ParseStackArray(e)
|
params, err := event.ParseStackArray(e)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not parse stack items from notify event: %w", err)
|
return nil, fmt.Errorf("could not parse stack items from notify event: %w", err)
|
||||||
|
|
|
@ -3,8 +3,8 @@ package container
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/network/payload"
|
"github.com/nspcc-dev/neo-go/pkg/network/payload"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
|
||||||
"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"
|
||||||
)
|
)
|
||||||
|
@ -65,7 +65,7 @@ func (x PutNamed) Zone() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParsePut from notification into container event structure.
|
// ParsePut from notification into container event structure.
|
||||||
func ParsePut(e *subscriptions.NotificationEvent) (event.Event, error) {
|
func ParsePut(e *state.ContainedNotificationEvent) (event.Event, error) {
|
||||||
var (
|
var (
|
||||||
ev Put
|
ev Put
|
||||||
err error
|
err error
|
||||||
|
|
|
@ -7,7 +7,8 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/block"
|
"github.com/nspcc-dev/neo-go/pkg/core/block"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"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/client"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/subscriber"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/subscriber"
|
||||||
|
@ -189,11 +190,11 @@ func (l *listener) listen(ctx context.Context, intError chan<- error) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *listener) listenLoop(ctx context.Context, chEvent <-chan *subscriptions.NotificationEvent, intErr chan<- error) {
|
func (l *listener) listenLoop(ctx context.Context, chEvent <-chan *state.ContainedNotificationEvent, intErr chan<- error) {
|
||||||
var (
|
var (
|
||||||
blockChan <-chan *block.Block
|
blockChan <-chan *block.Block
|
||||||
|
|
||||||
notaryChan <-chan *subscriptions.NotaryRequestEvent
|
notaryChan <-chan *result.NotaryRequestEvent
|
||||||
|
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
@ -294,7 +295,7 @@ loop:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *listener) parseAndHandleNotification(notifyEvent *subscriptions.NotificationEvent) {
|
func (l *listener) parseAndHandleNotification(notifyEvent *state.ContainedNotificationEvent) {
|
||||||
log := l.log.With(
|
log := l.log.With(
|
||||||
zap.String("script hash LE", notifyEvent.ScriptHash.StringLE()),
|
zap.String("script hash LE", notifyEvent.ScriptHash.StringLE()),
|
||||||
)
|
)
|
||||||
|
@ -349,7 +350,7 @@ func (l *listener) parseAndHandleNotification(notifyEvent *subscriptions.Notific
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *listener) parseAndHandleNotary(nr *subscriptions.NotaryRequestEvent) {
|
func (l *listener) parseAndHandleNotary(nr *result.NotaryRequestEvent) {
|
||||||
// prepare the notary event
|
// prepare the notary event
|
||||||
notaryEvent, err := l.notaryEventsPreparator.Prepare(nr.NotaryRequest)
|
notaryEvent, err := l.notaryEventsPreparator.Prepare(nr.NotaryRequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -3,7 +3,7 @@ package neofs
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"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"
|
||||||
|
@ -37,7 +37,7 @@ func (b bindCommon) Keys() [][]byte { return b.keys }
|
||||||
|
|
||||||
func (b bindCommon) User() []byte { return b.user }
|
func (b bindCommon) User() []byte { return b.user }
|
||||||
|
|
||||||
func ParseBind(e *subscriptions.NotificationEvent) (event.Event, error) {
|
func ParseBind(e *state.ContainedNotificationEvent) (event.Event, error) {
|
||||||
var (
|
var (
|
||||||
ev Bind
|
ev Bind
|
||||||
err error
|
err error
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
|
||||||
"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/event"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -64,8 +63,8 @@ func TestParseBind(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func createNotifyEventFromItems(items []stackitem.Item) *subscriptions.NotificationEvent {
|
func createNotifyEventFromItems(items []stackitem.Item) *state.ContainedNotificationEvent {
|
||||||
return &subscriptions.NotificationEvent{
|
return &state.ContainedNotificationEvent{
|
||||||
NotificationEvent: state.NotificationEvent{
|
NotificationEvent: state.NotificationEvent{
|
||||||
Item: stackitem.NewArray(items),
|
Item: stackitem.NewArray(items),
|
||||||
},
|
},
|
||||||
|
|
|
@ -3,7 +3,7 @@ package neofs
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"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/client"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||||
|
@ -33,7 +33,7 @@ func (c Cheque) Amount() int64 { return c.amount }
|
||||||
func (c Cheque) LockAccount() util.Uint160 { return c.lock }
|
func (c Cheque) LockAccount() util.Uint160 { return c.lock }
|
||||||
|
|
||||||
// ParseCheque from notification into cheque structure.
|
// ParseCheque from notification into cheque structure.
|
||||||
func ParseCheque(e *subscriptions.NotificationEvent) (event.Event, error) {
|
func ParseCheque(e *state.ContainedNotificationEvent) (event.Event, error) {
|
||||||
var (
|
var (
|
||||||
ev Cheque
|
ev Cheque
|
||||||
err error
|
err error
|
||||||
|
|
|
@ -3,7 +3,7 @@ package neofs
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"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/client"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||||
|
@ -35,7 +35,7 @@ func (u Config) Key() []byte { return u.key }
|
||||||
|
|
||||||
func (u Config) Value() []byte { return u.value }
|
func (u Config) Value() []byte { return u.value }
|
||||||
|
|
||||||
func ParseConfig(e *subscriptions.NotificationEvent) (event.Event, error) {
|
func ParseConfig(e *state.ContainedNotificationEvent) (event.Event, error) {
|
||||||
var (
|
var (
|
||||||
ev Config
|
ev Config
|
||||||
err error
|
err error
|
||||||
|
|
|
@ -3,7 +3,7 @@ package neofs
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"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/client"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||||
|
@ -33,7 +33,7 @@ func (d Deposit) To() util.Uint160 { return d.to }
|
||||||
func (d Deposit) Amount() int64 { return d.amount }
|
func (d Deposit) Amount() int64 { return d.amount }
|
||||||
|
|
||||||
// ParseDeposit notification into deposit structure.
|
// ParseDeposit notification into deposit structure.
|
||||||
func ParseDeposit(e *subscriptions.NotificationEvent) (event.Event, error) {
|
func ParseDeposit(e *state.ContainedNotificationEvent) (event.Event, error) {
|
||||||
var ev Deposit
|
var ev Deposit
|
||||||
|
|
||||||
params, err := event.ParseStackArray(e)
|
params, err := event.ParseStackArray(e)
|
||||||
|
|
|
@ -3,7 +3,7 @@ package neofs
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ type Unbind struct {
|
||||||
bindCommon
|
bindCommon
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseUnbind(e *subscriptions.NotificationEvent) (event.Event, error) {
|
func ParseUnbind(e *state.ContainedNotificationEvent) (event.Event, error) {
|
||||||
var (
|
var (
|
||||||
ev Unbind
|
ev Unbind
|
||||||
err error
|
err error
|
||||||
|
|
|
@ -3,7 +3,7 @@ package neofs
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"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/client"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||||
|
@ -29,7 +29,7 @@ func (w Withdraw) User() util.Uint160 { return w.user }
|
||||||
func (w Withdraw) Amount() int64 { return w.amount }
|
func (w Withdraw) Amount() int64 { return w.amount }
|
||||||
|
|
||||||
// ParseWithdraw notification into withdraw structure.
|
// ParseWithdraw notification into withdraw structure.
|
||||||
func ParseWithdraw(e *subscriptions.NotificationEvent) (event.Event, error) {
|
func ParseWithdraw(e *state.ContainedNotificationEvent) (event.Event, error) {
|
||||||
var ev Withdraw
|
var ev Withdraw
|
||||||
|
|
||||||
params, err := event.ParseStackArray(e)
|
params, err := event.ParseStackArray(e)
|
||||||
|
|
|
@ -3,8 +3,8 @@ package netmap
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/network/payload"
|
"github.com/nspcc-dev/neo-go/pkg/network/payload"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
|
||||||
"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"
|
||||||
)
|
)
|
||||||
|
@ -32,7 +32,7 @@ func (s AddPeer) NotaryRequest() *payload.P2PNotaryRequest {
|
||||||
|
|
||||||
const expectedItemNumAddPeer = 1
|
const expectedItemNumAddPeer = 1
|
||||||
|
|
||||||
func ParseAddPeer(e *subscriptions.NotificationEvent) (event.Event, error) {
|
func ParseAddPeer(e *state.ContainedNotificationEvent) (event.Event, error) {
|
||||||
var (
|
var (
|
||||||
ev AddPeer
|
ev AddPeer
|
||||||
err error
|
err error
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
|
||||||
"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/event"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -43,8 +42,8 @@ func TestParseAddPeer(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func createNotifyEventFromItems(items []stackitem.Item) *subscriptions.NotificationEvent {
|
func createNotifyEventFromItems(items []stackitem.Item) *state.ContainedNotificationEvent {
|
||||||
return &subscriptions.NotificationEvent{
|
return &state.ContainedNotificationEvent{
|
||||||
NotificationEvent: state.NotificationEvent{
|
NotificationEvent: state.NotificationEvent{
|
||||||
Item: stackitem.NewArray(items),
|
Item: stackitem.NewArray(items),
|
||||||
},
|
},
|
||||||
|
|
|
@ -3,7 +3,7 @@ package netmap
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"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/client"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||||
|
@ -36,7 +36,7 @@ func (s NewEpoch) TxHash() util.Uint256 {
|
||||||
// ParseNewEpoch is a parser of new epoch notification event.
|
// ParseNewEpoch is a parser of new epoch notification event.
|
||||||
//
|
//
|
||||||
// Result is type of NewEpoch.
|
// Result is type of NewEpoch.
|
||||||
func ParseNewEpoch(e *subscriptions.NotificationEvent) (event.Event, error) {
|
func ParseNewEpoch(e *state.ContainedNotificationEvent) (event.Event, error) {
|
||||||
params, err := event.ParseStackArray(e)
|
params, err := event.ParseStackArray(e)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not parse stack items from notify event: %w", err)
|
return nil, fmt.Errorf("could not parse stack items from notify event: %w", err)
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"crypto/elliptic"
|
"crypto/elliptic"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"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/network/payload"
|
"github.com/nspcc-dev/neo-go/pkg/network/payload"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
|
||||||
"github.com/nspcc-dev/neofs-contract/netmap"
|
"github.com/nspcc-dev/neofs-contract/netmap"
|
||||||
"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"
|
||||||
|
@ -41,7 +41,7 @@ func (s UpdatePeer) NotaryRequest() *payload.P2PNotaryRequest {
|
||||||
|
|
||||||
const expectedItemNumUpdatePeer = 2
|
const expectedItemNumUpdatePeer = 2
|
||||||
|
|
||||||
func ParseUpdatePeer(e *subscriptions.NotificationEvent) (event.Event, error) {
|
func ParseUpdatePeer(e *state.ContainedNotificationEvent) (event.Event, error) {
|
||||||
var (
|
var (
|
||||||
ev UpdatePeer
|
ev UpdatePeer
|
||||||
err error
|
err error
|
||||||
|
|
|
@ -3,13 +3,13 @@ package event
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/network/payload"
|
"github.com/nspcc-dev/neo-go/pkg/network/payload"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// NotificationParser is a function that constructs Event
|
// NotificationParser is a function that constructs Event
|
||||||
// from the StackItem list.
|
// from the StackItem list.
|
||||||
type NotificationParser func(*subscriptions.NotificationEvent) (Event, error)
|
type NotificationParser func(*state.ContainedNotificationEvent) (Event, error)
|
||||||
|
|
||||||
// NotificationParserInfo is a structure that groups
|
// NotificationParserInfo is a structure that groups
|
||||||
// the parameters of particular contract
|
// the parameters of particular contract
|
||||||
|
|
|
@ -3,8 +3,8 @@ package reputation
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/network/payload"
|
"github.com/nspcc-dev/neo-go/pkg/network/payload"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
|
||||||
"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"
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/reputation"
|
"github.com/nspcc-dev/neofs-sdk-go/reputation"
|
||||||
|
@ -49,7 +49,7 @@ func (p Put) NotaryRequest() *payload.P2PNotaryRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParsePut from notification into reputation event structure.
|
// ParsePut from notification into reputation event structure.
|
||||||
func ParsePut(e *subscriptions.NotificationEvent) (event.Event, error) {
|
func ParsePut(e *state.ContainedNotificationEvent) (event.Event, error) {
|
||||||
var (
|
var (
|
||||||
ev Put
|
ev Put
|
||||||
err error
|
err error
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
|
||||||
"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/event"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/reputation"
|
"github.com/nspcc-dev/neofs-sdk-go/reputation"
|
||||||
|
@ -84,8 +83,8 @@ func TestParsePut(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func createNotifyEventFromItems(items []stackitem.Item) *subscriptions.NotificationEvent {
|
func createNotifyEventFromItems(items []stackitem.Item) *state.ContainedNotificationEvent {
|
||||||
return &subscriptions.NotificationEvent{
|
return &state.ContainedNotificationEvent{
|
||||||
NotificationEvent: state.NotificationEvent{
|
NotificationEvent: state.NotificationEvent{
|
||||||
Item: stackitem.NewArray(items),
|
Item: stackitem.NewArray(items),
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/native/noderoles"
|
"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/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||||
)
|
)
|
||||||
|
@ -23,7 +23,7 @@ type Designate struct {
|
||||||
func (Designate) MorphEvent() {}
|
func (Designate) MorphEvent() {}
|
||||||
|
|
||||||
// ParseDesignate from notification into container event structure.
|
// ParseDesignate from notification into container event structure.
|
||||||
func ParseDesignate(e *subscriptions.NotificationEvent) (event.Event, error) {
|
func ParseDesignate(e *state.ContainedNotificationEvent) (event.Event, error) {
|
||||||
params, err := event.ParseStackArray(e)
|
params, err := event.ParseStackArray(e)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not parse stack items from notify event: %w", err)
|
return nil, fmt.Errorf("could not parse stack items from notify event: %w", err)
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/native/noderoles"
|
"github.com/nspcc-dev/neo-go/pkg/core/native/noderoles"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
@ -28,8 +27,8 @@ func TestParseRoleUpdate(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func createNotifyEventFromItems(items []stackitem.Item) *subscriptions.NotificationEvent {
|
func createNotifyEventFromItems(items []stackitem.Item) *state.ContainedNotificationEvent {
|
||||||
return &subscriptions.NotificationEvent{
|
return &state.ContainedNotificationEvent{
|
||||||
NotificationEvent: state.NotificationEvent{
|
NotificationEvent: state.NotificationEvent{
|
||||||
Item: stackitem.NewArray(items),
|
Item: stackitem.NewArray(items),
|
||||||
},
|
},
|
||||||
|
|
|
@ -3,7 +3,7 @@ package subnetevents
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"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/client"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||||
|
@ -34,7 +34,7 @@ func (x Delete) TxHash() util.Uint256 {
|
||||||
// by the appropriate method of the Subnet contract.
|
// by the appropriate method of the Subnet contract.
|
||||||
//
|
//
|
||||||
// Resulting event is of Delete type.
|
// Resulting event is of Delete type.
|
||||||
func ParseDelete(e *subscriptions.NotificationEvent) (event.Event, error) {
|
func ParseDelete(e *state.ContainedNotificationEvent) (event.Event, error) {
|
||||||
var (
|
var (
|
||||||
ev Delete
|
ev Delete
|
||||||
err error
|
err error
|
||||||
|
|
|
@ -3,9 +3,9 @@ package subnetevents
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/network/payload"
|
"github.com/nspcc-dev/neo-go/pkg/network/payload"
|
||||||
"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/util"
|
||||||
"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"
|
||||||
|
@ -65,7 +65,7 @@ const itemNumPut = 3
|
||||||
// by the appropriate method of the subnet contract.
|
// by the appropriate method of the subnet contract.
|
||||||
//
|
//
|
||||||
// Resulting event is of Put type.
|
// Resulting event is of Put type.
|
||||||
func ParsePut(e *subscriptions.NotificationEvent) (event.Event, error) {
|
func ParsePut(e *state.ContainedNotificationEvent) (event.Event, error) {
|
||||||
var (
|
var (
|
||||||
put Put
|
put Put
|
||||||
err error
|
err error
|
||||||
|
|
|
@ -3,7 +3,7 @@ package subnetevents
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"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/client"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||||
|
@ -38,7 +38,7 @@ const expectedItemNumRemoveNode = 2
|
||||||
// ParseRemoveNode parses notification into subnet event structure.
|
// ParseRemoveNode parses notification into subnet event structure.
|
||||||
//
|
//
|
||||||
// Expects 2 stack items.
|
// Expects 2 stack items.
|
||||||
func ParseRemoveNode(e *subscriptions.NotificationEvent) (event.Event, error) {
|
func ParseRemoveNode(e *state.ContainedNotificationEvent) (event.Event, error) {
|
||||||
var (
|
var (
|
||||||
ev RemoveNode
|
ev RemoveNode
|
||||||
err error
|
err error
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"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/rpc/response/result/subscriptions"
|
|
||||||
"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/event/subnet"
|
. "github.com/nspcc-dev/neofs-node/pkg/morph/event/subnet"
|
||||||
subnetid "github.com/nspcc-dev/neofs-sdk-go/subnet/id"
|
subnetid "github.com/nspcc-dev/neofs-sdk-go/subnet/id"
|
||||||
|
@ -48,8 +47,8 @@ func TestParseRemoveNode(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func createNotifyEventFromItems(items []stackitem.Item) *subscriptions.NotificationEvent {
|
func createNotifyEventFromItems(items []stackitem.Item) *state.ContainedNotificationEvent {
|
||||||
return &subscriptions.NotificationEvent{
|
return &state.ContainedNotificationEvent{
|
||||||
NotificationEvent: state.NotificationEvent{
|
NotificationEvent: state.NotificationEvent{
|
||||||
Item: stackitem.NewArray(items),
|
Item: stackitem.NewArray(items),
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/mempoolevent"
|
"github.com/nspcc-dev/neo-go/pkg/core/mempoolevent"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"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"
|
||||||
|
@ -99,7 +99,7 @@ var errEmptyStackArray = errors.New("stack item array is empty")
|
||||||
|
|
||||||
// ParseStackArray parses stack array from raw notification
|
// ParseStackArray parses stack array from raw notification
|
||||||
// event received from neo-go RPC node.
|
// event received from neo-go RPC node.
|
||||||
func ParseStackArray(event *subscriptions.NotificationEvent) ([]stackitem.Item, error) {
|
func ParseStackArray(event *state.ContainedNotificationEvent) ([]stackitem.Item, error) {
|
||||||
arr, err := client.ArrayFromStackItem(event.Item)
|
arr, err := client.ArrayFromStackItem(event.Item)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("stack item is not an array type: %w", err)
|
return nil, fmt.Errorf("stack item is not an array type: %w", err)
|
||||||
|
|
|
@ -7,8 +7,9 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/block"
|
"github.com/nspcc-dev/neo-go/pkg/core/block"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions"
|
"github.com/nspcc-dev/neo-go/pkg/neorpc"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"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/client"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
@ -17,10 +18,10 @@ import (
|
||||||
type (
|
type (
|
||||||
// Subscriber is an interface of the NotificationEvent listener.
|
// Subscriber is an interface of the NotificationEvent listener.
|
||||||
Subscriber interface {
|
Subscriber interface {
|
||||||
SubscribeForNotification(...util.Uint160) (<-chan *subscriptions.NotificationEvent, error)
|
SubscribeForNotification(...util.Uint160) (<-chan *state.ContainedNotificationEvent, error)
|
||||||
UnsubscribeForNotification()
|
UnsubscribeForNotification()
|
||||||
BlockNotifications() (<-chan *block.Block, error)
|
BlockNotifications() (<-chan *block.Block, error)
|
||||||
SubscribeForNotaryRequests(mainTXSigner util.Uint160) (<-chan *subscriptions.NotaryRequestEvent, error)
|
SubscribeForNotaryRequests(mainTXSigner util.Uint160) (<-chan *result.NotaryRequestEvent, error)
|
||||||
Close()
|
Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,11 +30,11 @@ type (
|
||||||
log *zap.Logger
|
log *zap.Logger
|
||||||
client *client.Client
|
client *client.Client
|
||||||
|
|
||||||
notifyChan chan *subscriptions.NotificationEvent
|
notifyChan chan *state.ContainedNotificationEvent
|
||||||
|
|
||||||
blockChan chan *block.Block
|
blockChan chan *block.Block
|
||||||
|
|
||||||
notaryChan chan *subscriptions.NotaryRequestEvent
|
notaryChan chan *result.NotaryRequestEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
// Params is a group of Subscriber constructor parameters.
|
// Params is a group of Subscriber constructor parameters.
|
||||||
|
@ -52,7 +53,7 @@ var (
|
||||||
errNilClient = errors.New("chain/subscriber: client was not provided to the constructor")
|
errNilClient = errors.New("chain/subscriber: client was not provided to the constructor")
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *subscriber) SubscribeForNotification(contracts ...util.Uint160) (<-chan *subscriptions.NotificationEvent, error) {
|
func (s *subscriber) SubscribeForNotification(contracts ...util.Uint160) (<-chan *state.ContainedNotificationEvent, error) {
|
||||||
s.Lock()
|
s.Lock()
|
||||||
defer s.Unlock()
|
defer s.Unlock()
|
||||||
|
|
||||||
|
@ -97,7 +98,7 @@ func (s *subscriber) BlockNotifications() (<-chan *block.Block, error) {
|
||||||
return s.blockChan, nil
|
return s.blockChan, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *subscriber) SubscribeForNotaryRequests(mainTXSigner util.Uint160) (<-chan *subscriptions.NotaryRequestEvent, error) {
|
func (s *subscriber) SubscribeForNotaryRequests(mainTXSigner util.Uint160) (<-chan *result.NotaryRequestEvent, error) {
|
||||||
if err := s.client.SubscribeForNotaryRequests(mainTXSigner); err != nil {
|
if err := s.client.SubscribeForNotaryRequests(mainTXSigner); err != nil {
|
||||||
return nil, fmt.Errorf("could not subscribe for notary request events: %w", err)
|
return nil, fmt.Errorf("could not subscribe for notary request events: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -123,8 +124,8 @@ func (s *subscriber) routeNotifications(ctx context.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch notification.Type {
|
switch notification.Type {
|
||||||
case response.NotificationEventID:
|
case neorpc.NotificationEventID:
|
||||||
notifyEvent, ok := notification.Value.(*subscriptions.NotificationEvent)
|
notifyEvent, ok := notification.Value.(*state.ContainedNotificationEvent)
|
||||||
if !ok {
|
if !ok {
|
||||||
s.log.Error("can't cast notify event value to the notify struct",
|
s.log.Error("can't cast notify event value to the notify struct",
|
||||||
zap.String("received type", fmt.Sprintf("%T", notification.Value)),
|
zap.String("received type", fmt.Sprintf("%T", notification.Value)),
|
||||||
|
@ -133,7 +134,7 @@ func (s *subscriber) routeNotifications(ctx context.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
s.notifyChan <- notifyEvent
|
s.notifyChan <- notifyEvent
|
||||||
case response.BlockEventID:
|
case neorpc.BlockEventID:
|
||||||
b, ok := notification.Value.(*block.Block)
|
b, ok := notification.Value.(*block.Block)
|
||||||
if !ok {
|
if !ok {
|
||||||
s.log.Error("can't cast block event value to block",
|
s.log.Error("can't cast block event value to block",
|
||||||
|
@ -143,8 +144,8 @@ func (s *subscriber) routeNotifications(ctx context.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
s.blockChan <- b
|
s.blockChan <- b
|
||||||
case response.NotaryRequestEventID:
|
case neorpc.NotaryRequestEventID:
|
||||||
notaryRequest, ok := notification.Value.(*subscriptions.NotaryRequestEvent)
|
notaryRequest, ok := notification.Value.(*result.NotaryRequestEvent)
|
||||||
if !ok {
|
if !ok {
|
||||||
s.log.Error("can't cast notify event value to the notary request struct",
|
s.log.Error("can't cast notify event value to the notary request struct",
|
||||||
zap.String("received type", fmt.Sprintf("%T", notification.Value)),
|
zap.String("received type", fmt.Sprintf("%T", notification.Value)),
|
||||||
|
@ -182,9 +183,9 @@ func New(ctx context.Context, p *Params) (Subscriber, error) {
|
||||||
RWMutex: new(sync.RWMutex),
|
RWMutex: new(sync.RWMutex),
|
||||||
log: p.Log,
|
log: p.Log,
|
||||||
client: p.Client,
|
client: p.Client,
|
||||||
notifyChan: make(chan *subscriptions.NotificationEvent),
|
notifyChan: make(chan *state.ContainedNotificationEvent),
|
||||||
blockChan: make(chan *block.Block),
|
blockChan: make(chan *block.Block),
|
||||||
notaryChan: make(chan *subscriptions.NotaryRequestEvent),
|
notaryChan: make(chan *result.NotaryRequestEvent),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Worker listens all events from neo-go websocket and puts them
|
// Worker listens all events from neo-go websocket and puts them
|
||||||
|
|
|
@ -7,13 +7,13 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/core/container"
|
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
|
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/services/object/acl/eacl"
|
"github.com/nspcc-dev/neofs-node/pkg/services/object/acl/eacl"
|
||||||
eaclV2 "github.com/nspcc-dev/neofs-node/pkg/services/object/acl/eacl/v2"
|
eaclV2 "github.com/nspcc-dev/neofs-node/pkg/services/object/acl/eacl/v2"
|
||||||
v2 "github.com/nspcc-dev/neofs-node/pkg/services/object/acl/v2"
|
v2 "github.com/nspcc-dev/neofs-node/pkg/services/object/acl/v2"
|
||||||
bearerSDK "github.com/nspcc-dev/neofs-sdk-go/bearer"
|
bearerSDK "github.com/nspcc-dev/neofs-sdk-go/bearer"
|
||||||
|
"github.com/nspcc-dev/neofs-sdk-go/client"
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/container/acl"
|
"github.com/nspcc-dev/neofs-sdk-go/container/acl"
|
||||||
neofsecdsa "github.com/nspcc-dev/neofs-sdk-go/crypto/ecdsa"
|
neofsecdsa "github.com/nspcc-dev/neofs-sdk-go/crypto/ecdsa"
|
||||||
eaclSDK "github.com/nspcc-dev/neofs-sdk-go/eacl"
|
eaclSDK "github.com/nspcc-dev/neofs-sdk-go/eacl"
|
||||||
|
@ -136,7 +136,7 @@ func (c *Checker) CheckEACL(msg interface{}, reqInfo v2.RequestInfo) error {
|
||||||
if bearerTok == nil {
|
if bearerTok == nil {
|
||||||
eaclInfo, err := c.eaclSrc.GetEACL(cnr)
|
eaclInfo, err := c.eaclSrc.GetEACL(cnr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, container.ErrEACLNotFound) {
|
if client.IsErrEACLNotFound(err) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -13,7 +13,7 @@ type Source interface {
|
||||||
//
|
//
|
||||||
// GetEACL must return exactly one non-nil value.
|
// GetEACL must return exactly one non-nil value.
|
||||||
//
|
//
|
||||||
// Must return pkg/core/container.ErrEACLNotFound if requested
|
// Must return apistatus.ErrEACLNotFound if requested
|
||||||
// eACL table is not in source.
|
// eACL table is not in source.
|
||||||
GetEACL(cid.ID) (*containercore.EACL, error)
|
GetEACL(cid.ID) (*containercore.EACL, error)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue