Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
goran-ethernal committed Jun 20, 2024
1 parent 8af612c commit f38610e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions synchronizer/batches.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ type BatchSynchronizer struct {
self common.Address
db db.DB
committee map[common.Address]etherman.DataCommitteeMember
lock sync.Mutex
comiteeLock sync.Mutex
syncLock sync.Mutex
reorgs <-chan BlockReorg
sequencer SequencerTracker
rpcClientFactory client.Factory
Expand Down Expand Up @@ -75,8 +76,8 @@ func NewBatchSynchronizer(
}

func (bs *BatchSynchronizer) resolveCommittee() error {
bs.lock.Lock()
defer bs.lock.Unlock()
bs.comiteeLock.Lock()
defer bs.comiteeLock.Unlock()

committee := make(map[common.Address]etherman.DataCommitteeMember)
current, err := bs.client.GetCurrentDataCommittee()
Expand Down Expand Up @@ -110,6 +111,9 @@ func (bs *BatchSynchronizer) handleReorgs(ctx context.Context) {
for {
select {
case r := <-bs.reorgs:
bs.syncLock.Lock()
defer bs.syncLock.Unlock()

latest, err := getStartBlock(ctx, bs.db)
if err != nil {
log.Errorf("could not determine latest processed block: %v", err)
Expand Down Expand Up @@ -147,6 +151,9 @@ func (bs *BatchSynchronizer) produceEvents(ctx context.Context) {

// Start an iterator from last block processed, picking off SequenceBatches events
func (bs *BatchSynchronizer) filterEvents(ctx context.Context) error {
bs.syncLock.Lock()
defer bs.syncLock.Unlock()

start, err := getStartBlock(ctx, bs.db)
if err != nil {
return err
Expand Down

0 comments on commit f38610e

Please sign in to comment.