From 9bb973b9f383505598eb9cc3e04f4271edce863e Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Thu, 28 Jul 2022 18:04:07 +0300 Subject: [PATCH] [#1636] ir: Listen balance contract in balance processor Signed-off-by: Alex Vanin --- CHANGELOG.md | 1 + pkg/innerring/innerring.go | 1 + pkg/innerring/processors/balance/processor.go | 8 ++++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fac0588..a0568313 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ Changelog for NeoFS Node - `neofs-adm` now registers candidates during initialization in a single transaction (#1608) ### Fixed +- Invalid smart contract address in balance contract listener (#1636) - Shard now can start in degraded mode if the metabase is unavailable (#1559) - Shard can now be disabled completely on init failure (#1559) diff --git a/pkg/innerring/innerring.go b/pkg/innerring/innerring.go index 74b6aa24..d843e355 100644 --- a/pkg/innerring/innerring.go +++ b/pkg/innerring/innerring.go @@ -749,6 +749,7 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper, errChan chan<- Log: log, PoolSize: cfg.GetInt("workers.balance"), NeoFSClient: neofsCli, + BalanceSC: server.contracts.balance, AlphabetState: server, Converter: &server.precision, }) diff --git a/pkg/innerring/processors/balance/processor.go b/pkg/innerring/processors/balance/processor.go index 7784d214..f2e984d3 100644 --- a/pkg/innerring/processors/balance/processor.go +++ b/pkg/innerring/processors/balance/processor.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" + "github.com/nspcc-dev/neo-go/pkg/util" neofscontract "github.com/nspcc-dev/neofs-node/pkg/morph/client/neofs" "github.com/nspcc-dev/neofs-node/pkg/morph/event" balanceEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/balance" @@ -27,6 +28,7 @@ type ( log *zap.Logger pool *ants.Pool neofsClient *neofscontract.Client + balanceSC util.Uint160 alphabetState AlphabetState converter PrecisionConverter } @@ -36,6 +38,7 @@ type ( Log *zap.Logger PoolSize int NeoFSClient *neofscontract.Client + BalanceSC util.Uint160 AlphabetState AlphabetState Converter PrecisionConverter } @@ -67,6 +70,7 @@ func New(p *Params) (*Processor, error) { log: p.Log, pool: pool, neofsClient: p.NeoFSClient, + balanceSC: p.BalanceSC, alphabetState: p.AlphabetState, converter: p.Converter, }, nil @@ -79,7 +83,7 @@ func (bp *Processor) ListenerNotificationParsers() []event.NotificationParserInf // new lock event lock := event.NotificationParserInfo{} lock.SetType(lockNotification) - lock.SetScriptHash(bp.neofsClient.ContractAddress()) + lock.SetScriptHash(bp.balanceSC) lock.SetParser(balanceEvent.ParseLock) parsers = append(parsers, lock) @@ -93,7 +97,7 @@ func (bp *Processor) ListenerNotificationHandlers() []event.NotificationHandlerI // lock handler lock := event.NotificationHandlerInfo{} lock.SetType(lockNotification) - lock.SetScriptHash(bp.neofsClient.ContractAddress()) + lock.SetScriptHash(bp.balanceSC) lock.SetHandler(bp.handleLock) handlers = append(handlers, lock)