@@ -23,16 +23,16 @@ import (
2323type ExecutionClientManager struct {
2424 primaryEcUrl string
2525 fallbackEcUrl string
26- primaryEc * ethclient. Client
27- fallbackEc * ethclient. Client
26+ primaryEc * ethClient
27+ fallbackEc * ethClient
2828 logger log.ColorLogger
2929 primaryReady bool
3030 fallbackReady bool
3131 ignoreSyncCheck bool
3232}
3333
3434// This is a signature for a wrapped ethclient.Client function
35- type ecFunction func (* ethclient. Client ) (interface {}, error )
35+ type ecFunction func (* ethClient ) (interface {}, error )
3636
3737// Creates a new ExecutionClientManager instance based on the Rocket Pool config
3838func NewExecutionClientManager (cfg * config.RocketPoolConfig ) (* ExecutionClientManager , error ) {
@@ -80,8 +80,8 @@ func NewExecutionClientManager(cfg *config.RocketPoolConfig) (*ExecutionClientMa
8080 return & ExecutionClientManager {
8181 primaryEcUrl : primaryEcUrl ,
8282 fallbackEcUrl : fallbackEcUrl ,
83- primaryEc : primaryEc ,
84- fallbackEc : fallbackEc ,
83+ primaryEc : & ethClient { primaryEc } ,
84+ fallbackEc : & ethClient { fallbackEc } ,
8585 logger : log .NewColorLogger (color .FgYellow ),
8686 primaryReady : true ,
8787 fallbackReady : fallbackEc != nil ,
@@ -96,7 +96,7 @@ func NewExecutionClientManager(cfg *config.RocketPoolConfig) (*ExecutionClientMa
9696// CodeAt returns the code of the given account. This is needed to differentiate
9797// between contract internal errors and the local chain being out of sync.
9898func (p * ExecutionClientManager ) CodeAt (ctx context.Context , contract common.Address , blockNumber * big.Int ) ([]byte , error ) {
99- result , err := p .runFunction (func (client * ethclient. Client ) (interface {}, error ) {
99+ result , err := p .runFunction (func (client * ethClient ) (interface {}, error ) {
100100 return client .CodeAt (ctx , contract , blockNumber )
101101 })
102102 if err != nil {
@@ -108,7 +108,7 @@ func (p *ExecutionClientManager) CodeAt(ctx context.Context, contract common.Add
108108// CallContract executes an Ethereum contract call with the specified data as the
109109// input.
110110func (p * ExecutionClientManager ) CallContract (ctx context.Context , call ethereum.CallMsg , blockNumber * big.Int ) ([]byte , error ) {
111- result , err := p .runFunction (func (client * ethclient. Client ) (interface {}, error ) {
111+ result , err := p .runFunction (func (client * ethClient ) (interface {}, error ) {
112112 return client .CallContract (ctx , call , blockNumber )
113113 })
114114 if err != nil {
@@ -123,7 +123,7 @@ func (p *ExecutionClientManager) CallContract(ctx context.Context, call ethereum
123123
124124// HeaderByHash returns the block header with the given hash.
125125func (p * ExecutionClientManager ) HeaderByHash (ctx context.Context , hash common.Hash ) (* types.Header , error ) {
126- result , err := p .runFunction (func (client * ethclient. Client ) (interface {}, error ) {
126+ result , err := p .runFunction (func (client * ethClient ) (interface {}, error ) {
127127 return client .HeaderByHash (ctx , hash )
128128 })
129129 if err != nil {
@@ -135,7 +135,7 @@ func (p *ExecutionClientManager) HeaderByHash(ctx context.Context, hash common.H
135135// HeaderByNumber returns a block header from the current canonical chain. If number is
136136// nil, the latest known header is returned.
137137func (p * ExecutionClientManager ) HeaderByNumber (ctx context.Context , number * big.Int ) (* types.Header , error ) {
138- result , err := p .runFunction (func (client * ethclient. Client ) (interface {}, error ) {
138+ result , err := p .runFunction (func (client * ethClient ) (interface {}, error ) {
139139 return client .HeaderByNumber (ctx , number )
140140 })
141141 if err != nil {
@@ -146,7 +146,7 @@ func (p *ExecutionClientManager) HeaderByNumber(ctx context.Context, number *big
146146
147147// PendingCodeAt returns the code of the given account in the pending state.
148148func (p * ExecutionClientManager ) PendingCodeAt (ctx context.Context , account common.Address ) ([]byte , error ) {
149- result , err := p .runFunction (func (client * ethclient. Client ) (interface {}, error ) {
149+ result , err := p .runFunction (func (client * ethClient ) (interface {}, error ) {
150150 return client .PendingCodeAt (ctx , account )
151151 })
152152 if err != nil {
@@ -157,7 +157,7 @@ func (p *ExecutionClientManager) PendingCodeAt(ctx context.Context, account comm
157157
158158// PendingNonceAt retrieves the current pending nonce associated with an account.
159159func (p * ExecutionClientManager ) PendingNonceAt (ctx context.Context , account common.Address ) (uint64 , error ) {
160- result , err := p .runFunction (func (client * ethclient. Client ) (interface {}, error ) {
160+ result , err := p .runFunction (func (client * ethClient ) (interface {}, error ) {
161161 return client .PendingNonceAt (ctx , account )
162162 })
163163 if err != nil {
@@ -169,7 +169,7 @@ func (p *ExecutionClientManager) PendingNonceAt(ctx context.Context, account com
169169// SuggestGasPrice retrieves the currently suggested gas price to allow a timely
170170// execution of a transaction.
171171func (p * ExecutionClientManager ) SuggestGasPrice (ctx context.Context ) (* big.Int , error ) {
172- result , err := p .runFunction (func (client * ethclient. Client ) (interface {}, error ) {
172+ result , err := p .runFunction (func (client * ethClient ) (interface {}, error ) {
173173 return client .SuggestGasPrice (ctx )
174174 })
175175 if err != nil {
@@ -181,7 +181,7 @@ func (p *ExecutionClientManager) SuggestGasPrice(ctx context.Context) (*big.Int,
181181// SuggestGasTipCap retrieves the currently suggested 1559 priority fee to allow
182182// a timely execution of a transaction.
183183func (p * ExecutionClientManager ) SuggestGasTipCap (ctx context.Context ) (* big.Int , error ) {
184- result , err := p .runFunction (func (client * ethclient. Client ) (interface {}, error ) {
184+ result , err := p .runFunction (func (client * ethClient ) (interface {}, error ) {
185185 return client .SuggestGasTipCap (ctx )
186186 })
187187 if err != nil {
@@ -196,7 +196,7 @@ func (p *ExecutionClientManager) SuggestGasTipCap(ctx context.Context) (*big.Int
196196// transactions may be added or removed by miners, but it should provide a basis
197197// for setting a reasonable default.
198198func (p * ExecutionClientManager ) EstimateGas (ctx context.Context , call ethereum.CallMsg ) (gas uint64 , err error ) {
199- result , err := p .runFunction (func (client * ethclient. Client ) (interface {}, error ) {
199+ result , err := p .runFunction (func (client * ethClient ) (interface {}, error ) {
200200 return client .EstimateGas (ctx , call )
201201 })
202202 if err != nil {
@@ -207,7 +207,7 @@ func (p *ExecutionClientManager) EstimateGas(ctx context.Context, call ethereum.
207207
208208// SendTransaction injects the transaction into the pending pool for execution.
209209func (p * ExecutionClientManager ) SendTransaction (ctx context.Context , tx * types.Transaction ) error {
210- _ , err := p .runFunction (func (client * ethclient. Client ) (interface {}, error ) {
210+ _ , err := p .runFunction (func (client * ethClient ) (interface {}, error ) {
211211 return nil , client .SendTransaction (ctx , tx )
212212 })
213213 return err
@@ -222,7 +222,7 @@ func (p *ExecutionClientManager) SendTransaction(ctx context.Context, tx *types.
222222//
223223// TODO(karalabe): Deprecate when the subscription one can return past data too.
224224func (p * ExecutionClientManager ) FilterLogs (ctx context.Context , query ethereum.FilterQuery ) ([]types.Log , error ) {
225- result , err := p .runFunction (func (client * ethclient. Client ) (interface {}, error ) {
225+ result , err := p .runFunction (func (client * ethClient ) (interface {}, error ) {
226226 return client .FilterLogs (ctx , query )
227227 })
228228 if err != nil {
@@ -234,7 +234,7 @@ func (p *ExecutionClientManager) FilterLogs(ctx context.Context, query ethereum.
234234// SubscribeFilterLogs creates a background log filtering operation, returning
235235// a subscription immediately, which can be used to stream the found events.
236236func (p * ExecutionClientManager ) SubscribeFilterLogs (ctx context.Context , query ethereum.FilterQuery , ch chan <- types.Log ) (ethereum.Subscription , error ) {
237- result , err := p .runFunction (func (client * ethclient. Client ) (interface {}, error ) {
237+ result , err := p .runFunction (func (client * ethClient ) (interface {}, error ) {
238238 return client .SubscribeFilterLogs (ctx , query , ch )
239239 })
240240 if err != nil {
@@ -250,7 +250,7 @@ func (p *ExecutionClientManager) SubscribeFilterLogs(ctx context.Context, query
250250// TransactionReceipt returns the receipt of a transaction by transaction hash.
251251// Note that the receipt is not available for pending transactions.
252252func (p * ExecutionClientManager ) TransactionReceipt (ctx context.Context , txHash common.Hash ) (* types.Receipt , error ) {
253- result , err := p .runFunction (func (client * ethclient. Client ) (interface {}, error ) {
253+ result , err := p .runFunction (func (client * ethClient ) (interface {}, error ) {
254254 return client .TransactionReceipt (ctx , txHash )
255255 })
256256 if err != nil {
@@ -265,7 +265,7 @@ func (p *ExecutionClientManager) TransactionReceipt(ctx context.Context, txHash
265265
266266// BlockNumber returns the most recent block number
267267func (p * ExecutionClientManager ) BlockNumber (ctx context.Context ) (uint64 , error ) {
268- result , err := p .runFunction (func (client * ethclient. Client ) (interface {}, error ) {
268+ result , err := p .runFunction (func (client * ethClient ) (interface {}, error ) {
269269 return client .BlockNumber (ctx )
270270 })
271271 if err != nil {
@@ -277,7 +277,7 @@ func (p *ExecutionClientManager) BlockNumber(ctx context.Context) (uint64, error
277277// BalanceAt returns the wei balance of the given account.
278278// The block number can be nil, in which case the balance is taken from the latest known block.
279279func (p * ExecutionClientManager ) BalanceAt (ctx context.Context , account common.Address , blockNumber * big.Int ) (* big.Int , error ) {
280- result , err := p .runFunction (func (client * ethclient. Client ) (interface {}, error ) {
280+ result , err := p .runFunction (func (client * ethClient ) (interface {}, error ) {
281281 return client .BalanceAt (ctx , account , blockNumber )
282282 })
283283 if err != nil {
@@ -288,7 +288,7 @@ func (p *ExecutionClientManager) BalanceAt(ctx context.Context, account common.A
288288
289289// TransactionByHash returns the transaction with the given hash.
290290func (p * ExecutionClientManager ) TransactionByHash (ctx context.Context , hash common.Hash ) (tx * types.Transaction , isPending bool , err error ) {
291- result , err := p .runFunction (func (client * ethclient. Client ) (interface {}, error ) {
291+ result , err := p .runFunction (func (client * ethClient ) (interface {}, error ) {
292292 tx , isPending , err := client .TransactionByHash (ctx , hash )
293293 result := []interface {}{tx , isPending }
294294 return result , err
@@ -307,7 +307,7 @@ func (p *ExecutionClientManager) TransactionByHash(ctx context.Context, hash com
307307// NonceAt returns the account nonce of the given account.
308308// The block number can be nil, in which case the nonce is taken from the latest known block.
309309func (p * ExecutionClientManager ) NonceAt (ctx context.Context , account common.Address , blockNumber * big.Int ) (uint64 , error ) {
310- result , err := p .runFunction (func (client * ethclient. Client ) (interface {}, error ) {
310+ result , err := p .runFunction (func (client * ethClient ) (interface {}, error ) {
311311 return client .NonceAt (ctx , account , blockNumber )
312312 })
313313 if err != nil {
@@ -319,7 +319,7 @@ func (p *ExecutionClientManager) NonceAt(ctx context.Context, account common.Add
319319// SyncProgress retrieves the current progress of the sync algorithm. If there's
320320// no sync currently running, it returns nil.
321321func (p * ExecutionClientManager ) SyncProgress (ctx context.Context ) (* ethereum.SyncProgress , error ) {
322- result , err := p .runFunction (func (client * ethclient. Client ) (interface {}, error ) {
322+ result , err := p .runFunction (func (client * ethClient ) (interface {}, error ) {
323323 return client .SyncProgress (ctx )
324324 })
325325 if err != nil {
@@ -328,6 +328,16 @@ func (p *ExecutionClientManager) SyncProgress(ctx context.Context) (*ethereum.Sy
328328 return result .(* ethereum.SyncProgress ), err
329329}
330330
331+ func (p * ExecutionClientManager ) LatestBlockTime (ctx context.Context ) (time.Time , error ) {
332+ result , err := p .runFunction (func (client * ethClient ) (interface {}, error ) {
333+ return client .LatestBlockTime (ctx )
334+ })
335+ if err != nil {
336+ return time.Time {}, err
337+ }
338+ return result .(time.Time ), err
339+ }
340+
331341/// ==================
332342/// Internal functions
333343/// ==================
@@ -387,7 +397,7 @@ func getNetworkNameFromId(networkId uint) string {
387397}
388398
389399// Check the client status
390- func checkEcStatus (client * ethclient. Client ) api.ClientStatus {
400+ func checkEcStatus (client * ethClient ) api.ClientStatus {
391401
392402 status := api.ClientStatus {}
393403
0 commit comments