forked from TrueCloudLab/frostfs-node
[#627] ir: Read addresses of contracts from the client wrappers
After recent changes morph client wrappers provide contract address getter. It can be used to compose notification parsers and handlers. Use `ContractAddress` method in constructors of notification parsers and handlers. Remove no longer used script hash parameters of event processors. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
d6c0307431
commit
8fc1505351
5 changed files with 112 additions and 138 deletions
|
@ -4,7 +4,6 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
neofscontract "github.com/nspcc-dev/neofs-node/pkg/morph/client/neofs/wrapper"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||
balanceEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/balance"
|
||||
|
@ -25,22 +24,20 @@ type (
|
|||
|
||||
// Processor of events produced by balance contract in morph chain.
|
||||
Processor struct {
|
||||
log *zap.Logger
|
||||
pool *ants.Pool
|
||||
neofsClient *neofscontract.ClientWrapper
|
||||
balanceContract util.Uint160
|
||||
alphabetState AlphabetState
|
||||
converter PrecisionConverter
|
||||
log *zap.Logger
|
||||
pool *ants.Pool
|
||||
neofsClient *neofscontract.ClientWrapper
|
||||
alphabetState AlphabetState
|
||||
converter PrecisionConverter
|
||||
}
|
||||
|
||||
// Params of the processor constructor.
|
||||
Params struct {
|
||||
Log *zap.Logger
|
||||
PoolSize int
|
||||
NeoFSClient *neofscontract.ClientWrapper
|
||||
BalanceContract util.Uint160
|
||||
AlphabetState AlphabetState
|
||||
Converter PrecisionConverter
|
||||
Log *zap.Logger
|
||||
PoolSize int
|
||||
NeoFSClient *neofscontract.ClientWrapper
|
||||
AlphabetState AlphabetState
|
||||
Converter PrecisionConverter
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -67,12 +64,11 @@ func New(p *Params) (*Processor, error) {
|
|||
}
|
||||
|
||||
return &Processor{
|
||||
log: p.Log,
|
||||
pool: pool,
|
||||
neofsClient: p.NeoFSClient,
|
||||
balanceContract: p.BalanceContract,
|
||||
alphabetState: p.AlphabetState,
|
||||
converter: p.Converter,
|
||||
log: p.Log,
|
||||
pool: pool,
|
||||
neofsClient: p.NeoFSClient,
|
||||
alphabetState: p.AlphabetState,
|
||||
converter: p.Converter,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -83,7 +79,7 @@ func (bp *Processor) ListenerNotificationParsers() []event.NotificationParserInf
|
|||
// new lock event
|
||||
lock := event.NotificationParserInfo{}
|
||||
lock.SetType(lockNotification)
|
||||
lock.SetScriptHash(bp.balanceContract)
|
||||
lock.SetScriptHash(bp.neofsClient.ContractAddress())
|
||||
lock.SetParser(balanceEvent.ParseLock)
|
||||
parsers = append(parsers, lock)
|
||||
|
||||
|
@ -97,7 +93,7 @@ func (bp *Processor) ListenerNotificationHandlers() []event.NotificationHandlerI
|
|||
// lock handler
|
||||
lock := event.NotificationHandlerInfo{}
|
||||
lock.SetType(lockNotification)
|
||||
lock.SetScriptHash(bp.balanceContract)
|
||||
lock.SetScriptHash(bp.neofsClient.ContractAddress())
|
||||
lock.SetHandler(bp.handleLock)
|
||||
handlers = append(handlers, lock)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue