[#1636] ir: Listen balance contract in balance processor

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2022-07-28 18:04:07 +03:00 committed by fyrchik
parent 8162b27264
commit 71fd86f220
3 changed files with 8 additions and 2 deletions

View file

@ -46,6 +46,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)

View file

@ -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,
}) })

View file

@ -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)