Skip to content

Commit

Permalink
Remove fat context from activation builder
Browse files Browse the repository at this point in the history
  • Loading branch information
fasmat committed Feb 4, 2025
1 parent 4aa7f1a commit b6620b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
21 changes: 8 additions & 13 deletions activation/activation.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ type Builder struct {
layerClock layerClock
syncer syncer
logger *zap.Logger
parentCtx context.Context
poets []PoetService
poetCfg PoetConfig
poetRetryInterval time.Duration
Expand Down Expand Up @@ -139,14 +138,6 @@ func WithPoetRetryInterval(interval time.Duration) BuilderOption {
}
}

// WithContext modifies parent context for background job.
func WithContext(ctx context.Context) BuilderOption {
return func(b *Builder) {
// TODO(mafa): fix this
b.parentCtx = ctx // nolint:fatcontext
}
}

// WithPoetConfig sets the poet config.
func WithPoetConfig(c PoetConfig) BuilderOption {
return func(b *Builder) {
Expand Down Expand Up @@ -192,7 +183,6 @@ func NewBuilder(
opts ...BuilderOption,
) *Builder {
b := &Builder{
parentCtx: context.Background(),
signers: make(map[types.NodeID]*signing.EdSigner),
conf: conf,
db: db,
Expand Down Expand Up @@ -228,7 +218,13 @@ func (b *Builder) Register(sig *signing.EdSigner) {
b.postStates.Set(sig.NodeID(), types.PostStateIdle)

if b.stop != nil {
b.startID(b.parentCtx, sig)
ctx, stop := context.WithCancel(context.Background())
prevStop := b.stop
b.stop = func() {
prevStop()
stop()
}
b.startID(ctx, sig)
}
}

Expand Down Expand Up @@ -268,9 +264,8 @@ func (b *Builder) StartSmeshing(coinbase types.Address) error {
}

b.coinbaseAccount = coinbase
ctx, stop := context.WithCancel(b.parentCtx)
ctx, stop := context.WithCancel(context.Background())
b.stop = stop

for _, sig := range b.signers {
b.startID(ctx, sig)
}
Expand Down
1 change: 0 additions & 1 deletion node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,6 @@ func (app *App) initServices(ctx context.Context) error {
app.clock,
syncer,
app.addLogger(ATXBuilderLogger, lg).Zap(),
activation.WithContext(ctx),
activation.WithPoetConfig(app.Config.POET),
// TODO(dshulyak) makes no sense. how we ended using it?
activation.WithPoetRetryInterval(app.Config.HARE3.PreroundDelay),
Expand Down

0 comments on commit b6620b8

Please sign in to comment.