Skip to content

Commit

Permalink
context.Context as an argument to SyncProgressMap
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoximenes committed Mar 7, 2025
1 parent e819b90 commit ec7e9d0
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions arbitrum/apibackend.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func CreateFallbackClient(fallbackClientUrl string, fallbackClientTimeout time.D
}

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

Expand Down Expand Up @@ -205,17 +205,17 @@ func (a *APIBackend) GetBody(ctx context.Context, hash common.Hash, number rpc.B
}

// General Ethereum API
func (a *APIBackend) SyncProgressMap() map[string]interface{} {
func (a *APIBackend) SyncProgressMap(ctx context.Context) map[string]interface{} {
if a.sync == nil {
res := make(map[string]interface{})
res["error"] = "sync object not set in apibackend"
return res
}
return a.sync.SyncProgressMap()
return a.sync.SyncProgressMap(ctx)
}

func (a *APIBackend) SyncProgress() ethereum.SyncProgress {
progress := a.SyncProgressMap()
progress := a.SyncProgressMap(context.Background())

if len(progress) == 0 {
return ethereum.SyncProgress{}
Expand Down
2 changes: 1 addition & 1 deletion eth/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ func (b *EthAPIBackend) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.S
return b.eth.txPool.SubscribeTransactions(ch, true)
}

func (b *EthAPIBackend) SyncProgressMap() map[string]interface{} {
func (b *EthAPIBackend) SyncProgressMap(ctx context.Context) map[string]interface{} {
progress := b.eth.Downloader().Progress()
return progress.ToMap()
}
Expand Down
4 changes: 2 additions & 2 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ func (api *EthereumAPI) BlobBaseFee(ctx context.Context) *hexutil.Big {
// - highestBlock: block number of the highest block header this node has received from peers
// - pulledStates: number of state entries processed until now
// - knownStates: number of known state entries that still need to be pulled
func (api *EthereumAPI) Syncing() (interface{}, error) {
progress := api.b.SyncProgressMap()
func (api *EthereumAPI) Syncing(ctx context.Context) (interface{}, error) {
progress := api.b.SyncProgressMap(ctx)

if len(progress) == 0 {
return false, nil
Expand Down
2 changes: 1 addition & 1 deletion internal/ethapi/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ func (b testBackend) FallbackClient() types.FallbackClient {
return nil
}

func (b testBackend) SyncProgressMap() map[string]interface{} {
func (b testBackend) SyncProgressMap(ctx context.Context) map[string]interface{} {
return map[string]interface{}{}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/ethapi/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type Backend interface {

// General Ethereum API
SyncProgress() ethereum.SyncProgress
SyncProgressMap() map[string]interface{}
SyncProgressMap(ctx context.Context) map[string]interface{}

SuggestGasTipCap(ctx context.Context) (*big.Int, error)
FeeHistory(ctx context.Context, blockCount uint64, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*big.Int, [][]*big.Int, []*big.Int, []float64, []*big.Int, []float64, error)
Expand Down
2 changes: 1 addition & 1 deletion internal/ethapi/transaction_args_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,6 @@ func (b *backendMock) FallbackClient() types.FallbackClient {
return nil
}

func (b *backendMock) SyncProgressMap() map[string]interface{} {
func (b *backendMock) SyncProgressMap(ctx context.Context) map[string]interface{} {
return nil
}

0 comments on commit ec7e9d0

Please sign in to comment.