Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes FinalizedBlockNumber and SafeBlockNumber from SyncProgressMap #411

Merged
merged 2 commits into from
Feb 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions arbitrum/apibackend.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ func CreateFallbackClient(fallbackClientUrl string, fallbackClientTimeout time.D

type SyncProgressBackend interface {
SyncProgressMap() map[string]interface{}
SafeBlockNumber(ctx context.Context) (uint64, error)
FinalizedBlockNumber(ctx context.Context) (uint64, error)
BlockMetadataByNumber(blockNum uint64) (common.BlockMetadata, error)
}

Expand Down Expand Up @@ -407,13 +405,23 @@ func (a *APIBackend) blockNumberToUint(ctx context.Context, number rpc.BlockNumb
if a.sync == nil {
return 0, errors.New("block number not supported: object not set")
}
return a.sync.SafeBlockNumber(ctx)

currentSafeBlock := a.BlockChain().CurrentSafeBlock()
if currentSafeBlock == nil {
return 0, errors.New("safe block not found")
}
return currentSafeBlock.Number.Uint64(), nil
}
if number == rpc.FinalizedBlockNumber {
if a.sync == nil {
return 0, errors.New("block number not supported: object not set")
}
return a.sync.FinalizedBlockNumber(ctx)

currentFinalizedBlock := a.BlockChain().CurrentFinalBlock()
if currentFinalizedBlock == nil {
return 0, errors.New("finalized block not found")
}
return currentFinalizedBlock.Number.Uint64(), nil
}
if number < 0 {
return 0, errors.New("block number not supported")
Expand Down