Skip to content

Commit fa8f589

Browse files
committed
renaming as per feedback (2)
1 parent bc48950 commit fa8f589

File tree

4 files changed

+18
-26
lines changed

4 files changed

+18
-26
lines changed

block/components.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import (
2222
"github.com/evstack/ev-node/types"
2323
)
2424

25-
// BlockComponents represents the block-related components
26-
type BlockComponents struct {
25+
// Components represents the block-related components
26+
type Components struct {
2727
Executor *executing.Executor
2828
Syncer *syncing.Syncer
2929
Submitter *submitting.Submitter
@@ -34,7 +34,7 @@ type BlockComponents struct {
3434
}
3535

3636
// GetLastState returns the current blockchain state
37-
func (bc *BlockComponents) GetLastState() types.State {
37+
func (bc *Components) GetLastState() types.State {
3838
if bc.Executor != nil {
3939
return bc.Executor.GetLastState()
4040
}
@@ -45,7 +45,7 @@ func (bc *BlockComponents) GetLastState() types.State {
4545
}
4646

4747
// Start starts all components and monitors for critical errors
48-
func (bc *BlockComponents) Start(ctx context.Context) error {
48+
func (bc *Components) Start(ctx context.Context) error {
4949
ctxWithCancel, cancel := context.WithCancel(ctx)
5050

5151
// error monitoring goroutine
@@ -89,7 +89,7 @@ func (bc *BlockComponents) Start(ctx context.Context) error {
8989
}
9090

9191
// Stop stops all components
92-
func (bc *BlockComponents) Stop() error {
92+
func (bc *Components) Stop() error {
9393
var errs error
9494
if bc.Executor != nil {
9595
if err := bc.Executor.Stop(); err != nil {
@@ -129,7 +129,7 @@ func NewSyncComponents(
129129
logger zerolog.Logger,
130130
metrics *Metrics,
131131
blockOpts BlockOptions,
132-
) (*BlockComponents, error) {
132+
) (*Components, error) {
133133
cacheManager, err := cache.NewManager(config, store, logger)
134134
if err != nil {
135135
return nil, fmt.Errorf("failed to create cache manager: %w", err)
@@ -168,7 +168,7 @@ func NewSyncComponents(
168168
errorCh,
169169
)
170170

171-
return &BlockComponents{
171+
return &Components{
172172
Syncer: syncer,
173173
Submitter: submitter,
174174
Cache: cacheManager,
@@ -192,7 +192,7 @@ func NewAggregatorComponents(
192192
logger zerolog.Logger,
193193
metrics *Metrics,
194194
blockOpts BlockOptions,
195-
) (*BlockComponents, error) {
195+
) (*Components, error) {
196196
cacheManager, err := cache.NewManager(config, store, logger)
197197
if err != nil {
198198
return nil, fmt.Errorf("failed to create cache manager: %w", err)
@@ -235,7 +235,7 @@ func NewAggregatorComponents(
235235
errorCh,
236236
)
237237

238-
return &BlockComponents{
238+
return &Components{
239239
Executor: executor,
240240
Submitter: submitter,
241241
Cache: cacheManager,

block/components_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestBlockComponents_ExecutionClientFailure_StopsNode(t *testing.T) {
3232
criticalError := errors.New("execution client connection lost")
3333

3434
// Create BlockComponents with error channel
35-
bc := &BlockComponents{
35+
bc := &Components{
3636
errorCh: errorCh,
3737
}
3838

@@ -57,7 +57,7 @@ func TestBlockComponents_GetLastState(t *testing.T) {
5757

5858
t.Run("Empty state", func(t *testing.T) {
5959
// When neither is present, return empty state
60-
bc := &BlockComponents{}
60+
bc := &Components{}
6161

6262
result := bc.GetLastState()
6363
assert.Equal(t, uint64(0), result.LastBlockHeight)
@@ -66,7 +66,7 @@ func TestBlockComponents_GetLastState(t *testing.T) {
6666

6767
func TestBlockComponents_StartStop_Lifecycle(t *testing.T) {
6868
// Simple lifecycle test without creating full components
69-
bc := &BlockComponents{
69+
bc := &Components{
7070
errorCh: make(chan error, 1),
7171
}
7272

block/internal/executing/executor.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ func (e *Executor) produceBlock() error {
361361

362362
e.logger.Debug().Uint64("height", newHeight).Msg("producing block")
363363

364-
// Check pending limits
364+
// check pending limits
365365
if e.config.Node.MaxPendingHeadersAndData > 0 {
366366
pendingHeaders := e.cache.NumPendingHeaders()
367367
pendingData := e.cache.NumPendingData()
@@ -376,7 +376,7 @@ func (e *Executor) produceBlock() error {
376376
}
377377
}
378378

379-
// Get batch from sequencer
379+
// get batch from sequencer
380380
batchData, err := e.retrieveBatch(e.ctx)
381381
if errors.Is(err, common.ErrNoBatch) {
382382
e.logger.Debug().Msg("no batch available")
@@ -387,55 +387,47 @@ func (e *Executor) produceBlock() error {
387387
return fmt.Errorf("failed to retrieve batch: %w", err)
388388
}
389389

390-
// Create block
391390
header, data, err := e.createBlock(e.ctx, newHeight, batchData)
392391
if err != nil {
393392
return fmt.Errorf("failed to create block: %w", err)
394393
}
395394

396-
// Apply block to get new state
397395
newState, err := e.applyBlock(e.ctx, header.Header, data)
398396
if err != nil {
399397
return fmt.Errorf("failed to apply block: %w", err)
400398
}
401399

402-
// Sign the header
403400
signature, err := e.signHeader(header.Header)
404401
if err != nil {
405402
return fmt.Errorf("failed to sign header: %w", err)
406403
}
407404
header.Signature = signature
408405

409-
// Validate block
410406
if err := e.validateBlock(currentState, header, data); err != nil {
411407
return fmt.Errorf("failed to validate block: %w", err)
412408
}
413409

414-
// Save block
415410
if err := e.store.SaveBlockData(e.ctx, header, data, &signature); err != nil {
416411
return fmt.Errorf("failed to save block: %w", err)
417412
}
418413

419-
// Update store height
420414
if err := e.store.SetHeight(e.ctx, newHeight); err != nil {
421415
return fmt.Errorf("failed to update store height: %w", err)
422416
}
423417

424-
// Update state
425418
if err := e.updateState(e.ctx, newState); err != nil {
426419
return fmt.Errorf("failed to update state: %w", err)
427420
}
428421

429-
// Broadcast header and data to P2P network
422+
// broadcast header and data to P2P network
430423
g, ctx := errgroup.WithContext(e.ctx)
431424
g.Go(func() error { return e.headerBroadcaster.WriteToStoreAndBroadcast(ctx, header) })
432425
g.Go(func() error { return e.dataBroadcaster.WriteToStoreAndBroadcast(ctx, data) })
433426
if err := g.Wait(); err != nil {
434427
e.logger.Error().Err(err).Msg("failed to broadcast header and/data")
435-
// Don't fail block production on broadcast error
428+
// don't fail block production on broadcast error
436429
}
437430

438-
// Record metrics
439431
e.recordBlockMetrics(data)
440432

441433
e.logger.Info().

node/full.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ type FullNode struct {
5959
hSyncService *evsync.HeaderSyncService
6060
dSyncService *evsync.DataSyncService
6161
Store store.Store
62-
blockComponents *block.BlockComponents
62+
blockComponents *block.Components
6363

6464
prometheusSrv *http.Server
6565
pprofSrv *http.Server
@@ -97,7 +97,7 @@ func newFullNode(
9797
return nil, err
9898
}
9999

100-
var blockComponents *block.BlockComponents
100+
var blockComponents *block.Components
101101
if nodeConfig.Node.Aggregator {
102102
blockComponents, err = block.NewAggregatorComponents(
103103
nodeConfig,

0 commit comments

Comments
 (0)