forked from TrueCloudLab/frostfs-node
[#168] node: Refactor node config
Resolve containedctx linter for cfg Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
8426d25f4b
commit
a7c79c773a
20 changed files with 93 additions and 83 deletions
|
@ -108,7 +108,7 @@ func initMorphComponents(c *cfg) {
|
|||
c.cfgNetmap.wrapper = wrap
|
||||
}
|
||||
|
||||
func makeAndWaitNotaryDeposit(c *cfg) {
|
||||
func makeAndWaitNotaryDeposit(ctx context.Context, c *cfg) {
|
||||
// skip notary deposit in non-notary environments
|
||||
if !c.cfgMorph.notaryEnabled {
|
||||
return
|
||||
|
@ -125,7 +125,7 @@ func makeAndWaitNotaryDeposit(c *cfg) {
|
|||
return
|
||||
}
|
||||
|
||||
err = waitNotaryDeposit(c, tx)
|
||||
err = waitNotaryDeposit(ctx, c, tx)
|
||||
fatalOnErr(err)
|
||||
}
|
||||
|
||||
|
@ -154,11 +154,11 @@ var (
|
|||
errNotaryDepositTimeout = errors.New("notary deposit tx has not appeared in the network")
|
||||
)
|
||||
|
||||
func waitNotaryDeposit(c *cfg, tx util.Uint256) error {
|
||||
func waitNotaryDeposit(ctx context.Context, c *cfg, tx util.Uint256) error {
|
||||
for i := 0; i < notaryDepositRetriesAmount; i++ {
|
||||
select {
|
||||
case <-c.ctx.Done():
|
||||
return c.ctx.Err()
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
default:
|
||||
}
|
||||
|
||||
|
@ -171,7 +171,7 @@ func waitNotaryDeposit(c *cfg, tx util.Uint256) error {
|
|||
return errNotaryDepositFail
|
||||
}
|
||||
|
||||
err = c.cfgMorph.client.Wait(c.ctx, 1)
|
||||
err = c.cfgMorph.client.Wait(ctx, 1)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not wait for one block in chain: %w", err)
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ func waitNotaryDeposit(c *cfg, tx util.Uint256) error {
|
|||
return errNotaryDepositTimeout
|
||||
}
|
||||
|
||||
func listenMorphNotifications(c *cfg) {
|
||||
func listenMorphNotifications(ctx context.Context, c *cfg) {
|
||||
// listenerPoolCap is a capacity of a
|
||||
// worker pool inside the listener. It
|
||||
// is used to prevent blocking in neo-go:
|
||||
|
@ -200,7 +200,7 @@ func listenMorphNotifications(c *cfg) {
|
|||
c.log.Warn("can't get last processed side chain block number", zap.String("error", err.Error()))
|
||||
}
|
||||
|
||||
subs, err = subscriber.New(c.ctx, &subscriber.Params{
|
||||
subs, err = subscriber.New(ctx, &subscriber.Params{
|
||||
Log: c.log,
|
||||
StartFromBlock: fromSideChainBlock,
|
||||
Client: c.cfgMorph.client,
|
||||
|
@ -214,9 +214,9 @@ func listenMorphNotifications(c *cfg) {
|
|||
})
|
||||
fatalOnErr(err)
|
||||
|
||||
c.workers = append(c.workers, newWorkerFromFunc(func(ctx context.Context) {
|
||||
runAndLog(c, "morph notification", false, func(c *cfg) {
|
||||
lis.ListenWithError(ctx, c.internalErr)
|
||||
c.workers = append(c.workers, newWorkerFromFunc(func(wCtx context.Context) {
|
||||
runAndLog(wCtx, c, "morph notification", false, func(lCtx context.Context, c *cfg) {
|
||||
lis.ListenWithError(lCtx, c.internalErr)
|
||||
})
|
||||
}))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue