@ -31,7 +31,7 @@ var (
ErrUnknownBlock = fmt . Errorf ( "unknown block" )
ErrUnknownBlock = fmt . Errorf ( "unknown block" )
)
)
// Stats of the syncr honizer
// Stats of the synchr onizer
type Stats struct {
type Stats struct {
Eth struct {
Eth struct {
RefreshPeriod time . Duration
RefreshPeriod time . Duration
@ -347,7 +347,7 @@ func (s *Synchronizer) setSlotCoordinator(slot *common.Slot) error {
}
}
// updateCurrentSlot updates the slot with information of the current slot.
// updateCurrentSlot updates the slot with information of the current slot.
// The information abouth which coordinator is allowed to forge is only updated
// The information about which coordinator is allowed to forge is only updated
// when we are Synced.
// when we are Synced.
// hasBatch is true when the last synced block contained at least one batch.
// hasBatch is true when the last synced block contained at least one batch.
func ( s * Synchronizer ) updateCurrentSlot ( slot * common . Slot , reset bool , hasBatch bool ) error {
func ( s * Synchronizer ) updateCurrentSlot ( slot * common . Slot , reset bool , hasBatch bool ) error {
@ -400,7 +400,7 @@ func (s *Synchronizer) updateCurrentSlot(slot *common.Slot, reset bool, hasBatch
}
}
// updateNextSlot updates the slot with information of the next slot.
// updateNextSlot updates the slot with information of the next slot.
// The information abouth which coordinator is allowed to forge is only updated
// The information about which coordinator is allowed to forge is only updated
// when we are Synced.
// when we are Synced.
func ( s * Synchronizer ) updateNextSlot ( slot * common . Slot ) error {
func ( s * Synchronizer ) updateNextSlot ( slot * common . Slot ) error {
// We want the next block because the current one is already mined
// We want the next block because the current one is already mined
@ -503,9 +503,9 @@ func (s *Synchronizer) resetIntermediateState() error {
return nil
return nil
}
}
// Sync attems to synchronize an ethereum block starting from lastSavedBlock.
// Sync attempt s to synchronize an ethereum block starting from lastSavedBlock.
// If lastSavedBlock is nil, the lastSavedBlock value is obtained from de DB.
// If lastSavedBlock is nil, the lastSavedBlock value is obtained from de DB.
// If a block is synch ed, it will be returned and also stored in the DB. If a
// If a block is synced, it will be returned and also stored in the DB. If a
// reorg is detected, the number of discarded blocks will be returned and no
// reorg is detected, the number of discarded blocks will be returned and no
// synchronization will be made.
// synchronization will be made.
// TODO: Be smart about locking: only lock during the read/write operations
// TODO: Be smart about locking: only lock during the read/write operations
@ -558,7 +558,7 @@ func (s *Synchronizer) Sync(ctx context.Context,
"ethLastBlock" , s . stats . Eth . LastBlock ,
"ethLastBlock" , s . stats . Eth . LastBlock ,
)
)
// Check that the obti aned ethBlock.ParentHash == prevEthBlock.Hash; if not, reorg!
// Check that the obtai ned ethBlock.ParentHash == prevEthBlock.Hash; if not, reorg!
if lastSavedBlock != nil {
if lastSavedBlock != nil {
if lastSavedBlock . Hash != ethBlock . ParentHash {
if lastSavedBlock . Hash != ethBlock . ParentHash {
// Reorg detected
// Reorg detected
@ -578,7 +578,7 @@ func (s *Synchronizer) Sync(ctx context.Context,
// If there was an error during sync, reset to the last block
// If there was an error during sync, reset to the last block
// in the historyDB because the historyDB is written last in
// in the historyDB because the historyDB is written last in
// the Sync method and is the source of consistency. This
// the Sync method and is the source of consistency. This
// allows reseting the stateDB in the case a batch was
// allows resett ing the stateDB in the case a batch was
// processed but the historyDB block was not committed due to an
// processed but the historyDB block was not committed due to an
// error.
// error.
if err != nil {
if err != nil {
@ -818,7 +818,7 @@ func (s *Synchronizer) resetState(block *common.Block) error {
return nil
return nil
}
}
// rollupSync retre ives all the Rollup Smart Contract Data that happened at
// rollupSync retrie ves all the Rollup Smart Contract Data that happened at
// ethBlock.blockNum with ethBlock.Hash.
// ethBlock.blockNum with ethBlock.Hash.
func ( s * Synchronizer ) rollupSync ( ethBlock * common . Block ) ( * common . RollupData , error ) {
func ( s * Synchronizer ) rollupSync ( ethBlock * common . Block ) ( * common . RollupData , error ) {
blockNum := ethBlock . Num
blockNum := ethBlock . Num