Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
colinlyguo committed Sep 19, 2024
1 parent e124dce commit dc03c12
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions rollup/rollup_sync_service/rollup_sync_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const (

// RollupSyncService collects ScrollChain batch commit/revert/finalize events and stores metadata into db.
type RollupSyncService struct {
originalCtx context.Context
ctx context.Context
cancel context.CancelFunc
client *L1Client
Expand Down Expand Up @@ -99,10 +100,11 @@ func NewRollupSyncService(ctx context.Context, genesisConfig *params.ChainConfig
latestProcessedBlock = *block
}

ctx, cancel := context.WithCancel(ctx)
serviceCtx, cancel := context.WithCancel(ctx)

service := RollupSyncService{
ctx: ctx,
originalCtx: ctx,
ctx: serviceCtx,
cancel: cancel,
client: client,
db: db,
Expand Down Expand Up @@ -161,6 +163,9 @@ func (s *RollupSyncService) Stop() {
func (s *RollupSyncService) ResetToHeight(height uint64) {
s.Stop()

newCtx, newCancel := context.WithCancel(s.originalCtx)
s.ctx = newCtx
s.cancel = newCancel
s.latestProcessedBlock = height

rawdb.WriteRollupEventSyncedL1BlockNumber(s.db, height)
Expand Down
9 changes: 7 additions & 2 deletions rollup/sync_service/sync_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ var (

// SyncService collects all L1 messages and stores them in a local database.
type SyncService struct {
originalCtx context.Context
ctx context.Context
cancel context.CancelFunc
client *BridgeClient
Expand Down Expand Up @@ -76,10 +77,11 @@ func NewSyncService(ctx context.Context, genesisConfig *params.ChainConfig, node
latestProcessedBlock = *block
}

ctx, cancel := context.WithCancel(ctx)
serviceCtx, cancel := context.WithCancel(ctx)

service := SyncService{
ctx: ctx,
originalCtx: ctx,
ctx: serviceCtx,
cancel: cancel,
client: client,
db: db,
Expand Down Expand Up @@ -143,6 +145,9 @@ func (s *SyncService) Stop() {
func (s *SyncService) ResetToHeight(height uint64) {
s.Stop()

newCtx, newCancel := context.WithCancel(s.originalCtx)
s.ctx = newCtx
s.cancel = newCancel
s.latestProcessedBlock = height

rawdb.WriteSyncedL1BlockNumber(s.db, height)
Expand Down

0 comments on commit dc03c12

Please sign in to comment.