Skip to content

Commit

Permalink
fix: fixing lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikelle committed Nov 8, 2024
1 parent 3232ebf commit 210b718
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 22 deletions.
4 changes: 0 additions & 4 deletions cl/ethclient/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,3 @@ func latency(chain string, endpoint string) func() {
func incError(chain, endpoint string) {
errorCount.WithLabelValues(chain, endpoint).Inc()
}

func spanName(endpoint string) string {
return "ethclient/" + endpoint
}
16 changes: 0 additions & 16 deletions cl/redisapp/blockbuilder/blockbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/primev/mev-commit/cl/redisapp/types"
"github.com/primev/mev-commit/cl/redisapp/util"
"github.com/vmihailenco/msgpack/v5"
"golang.org/x/exp/rand"
)

const maxAttempts = 3
Expand Down Expand Up @@ -321,21 +320,6 @@ func isSyncing(status engine.PayloadStatusV1) bool {
return status.Status == engine.SYNCING || status.Status == engine.ACCEPTED
}

// temp function for testing
func sometimesFails() error {
rand.Seed(uint64(time.Now().UnixNano()))

chance := rand.Intn(5) // 0, 1, 2, 3, 4

if chance == 0 {
// Fail 1 out of 5 times (when chance == 0)
return errors.New("failed: 1 in 5 chance")
}

// Otherwise succeed
return nil
}

func (bb *BlockBuilder) FinalizeBlock(ctx context.Context, payloadIDStr, executionPayloadStr, msgID string) error {
if payloadIDStr == "" || executionPayloadStr == "" {
return errors.New("PayloadID or ExecutionPayload is missing in build state")
Expand Down
6 changes: 5 additions & 1 deletion cl/redisapp/leaderfollower/leaderfollower.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,11 @@ func (lfm *LeaderFollowerManager) leaderWork(ctx context.Context) error {
// if has messages to process, return to wait for the signal to be a leader
if isHaveMessagesToProcess {
lfm.logger.Info("Leader: State is not synchronized, waiting for follower to catch up")
lfm.leaderProc.Stop()
err := lfm.leaderProc.Stop()
if err != nil {
lfm.logger.Error("Leader: Failed to stop leader election", "error", err)
return err
}
return nil
}

Expand Down
5 changes: 4 additions & 1 deletion cl/redisapp/rapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ func (app *MevCommitChain) Stop() {
// Cancel the context to signal all goroutines to stop
app.cancel()
app.stateManager.Stop()
app.lfm.WaitForGoroutinesToStop()
err := app.lfm.WaitForGoroutinesToStop()
if err != nil {
app.logger.Error("Error waiting for goroutines to stop", "error", err)
}
app.logger.Info("MevCommitChain stopped gracefully")
}

0 comments on commit 210b718

Please sign in to comment.