From 76882b81355b13d3e281c8d16c89fc24e4b78761 Mon Sep 17 00:00:00 2001 From: colinlyguo Date: Wed, 22 May 2024 00:19:27 +0800 Subject: [PATCH] no waiting --- rollup/cmd/rollup_relayer/app/app.go | 52 ++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/rollup/cmd/rollup_relayer/app/app.go b/rollup/cmd/rollup_relayer/app/app.go index 547be11d1b..88674c8677 100644 --- a/rollup/cmd/rollup_relayer/app/app.go +++ b/rollup/cmd/rollup_relayer/app/app.go @@ -106,13 +106,51 @@ func action(ctx *cli.Context) error { l2watcher.TryFetchRunningMissingBlocks(number) }) - go utils.Loop(subCtx, 2*time.Second, chunkProposer.TryProposeChunk) - - go utils.Loop(subCtx, 10*time.Second, batchProposer.TryProposeBatch) - - go utils.Loop(subCtx, 2*time.Second, l2relayer.ProcessPendingBatches) - - go utils.Loop(subCtx, 15*time.Second, l2relayer.ProcessCommittedBatches) + go func(ctx context.Context) { + for { + select { + case <-ctx.Done(): + return + default: + chunkProposer.TryProposeChunk() + } + } + }(subCtx) + + go func(ctx context.Context) { + for { + select { + case <-ctx.Done(): + return + default: + batchProposer.TryProposeBatch() + } + } + }(subCtx) + + go func(ctx context.Context) { + for { + select { + case <-ctx.Done(): + return + default: + l2relayer.ProcessPendingBatches() + time.Sleep(2 * time.Second) + } + } + }(subCtx) + + go func(ctx context.Context) { + for { + select { + case <-ctx.Done(): + return + default: + l2relayer.ProcessCommittedBatches() + time.Sleep(15 * time.Second) + } + } + }(subCtx) // Finish start all rollup relayer functions. log.Info("Start rollup-relayer successfully", "version", version.Version)