Skip to content

Commit

Permalink
feat: apply PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
joanestebanr committed Oct 29, 2024
1 parent 0bb0e39 commit 8c14a55
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
6 changes: 3 additions & 3 deletions aggsender/block_notifier_polling.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ func (b *BlockNotifierPolling) String() string {
return res
}

func (b *BlockNotifierPolling) Start(ctx context.Context) {
go b.start(ctx)
func (b *BlockNotifierPolling) StartAsync(ctx context.Context) {
go b.Start(ctx)
}

func (b *BlockNotifierPolling) start(ctx context.Context) {
func (b *BlockNotifierPolling) Start(ctx context.Context) {
ticker := time.NewTimer(b.config.CheckNewBlockInterval)
defer ticker.Stop()

Expand Down
2 changes: 1 addition & 1 deletion aggsender/block_notifier_polling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestExploratoryBlockNotifierPolling(t *testing.T) {
BlockFinalityType: etherman.LatestBlock,
}, log.WithFields("test", "test"), nil)
require.NoError(t, errSut)
sut.Start(context.Background())
sut.StartAsync(context.Background())
ch := sut.Subscribe("test")
for {
select {
Expand Down
8 changes: 1 addition & 7 deletions aggsender/epoch_notifier_per_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,10 @@ package aggsender
import (
"context"
"fmt"
"time"

"github.com/0xPolygon/cdk/aggsender/types"
)

const (
// EthereumBlockSpeed is the speed of the Ethereum to generate a blocks
EthereumBlockSpeed = time.Second * 15
)

type ConfigEpochNotifierPerBlock struct {
StartingEpochBlock uint64
NumBlockPerEpoch uint
Expand Down Expand Up @@ -68,7 +62,7 @@ func (e *EpochNotifierPerBlock) String() string {
e.Config.StartingEpochBlock, e.Config.NumBlockPerEpoch, e.Config.NotifyPendingBlocksBeforeEndEpoch)
}

func (e *EpochNotifierPerBlock) Start(ctx context.Context) {
func (e *EpochNotifierPerBlock) StartAsync(ctx context.Context) {
eventNewBlockChannel := e.blockNotifier.Subscribe("EpochNotifierPerBlock")
go e.start(ctx, eventNewBlockChannel)
}
Expand Down
2 changes: 1 addition & 1 deletion aggsender/epoch_notifier_per_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestNotifyEpoch(t *testing.T) {
ch := testData.sut.Subscribe("test")
chBlocks := make(chan types.EventNewBlock)
testData.blockNotifierMock.EXPECT().Subscribe(mock.Anything).Return(chBlocks)
testData.sut.Start(testData.ctx)
testData.sut.StartAsync(testData.ctx)
chBlocks <- types.EventNewBlock{BlockNumber: 109, BlockFinalityType: etherman.LatestBlock}
epochEvent := <-ch
require.Equal(t, uint64(11), epochEvent.Epoch)
Expand Down

0 comments on commit 8c14a55

Please sign in to comment.