Try to reconnect ethereum RPC in case of network failure

This commit is contained in:
Martin Boehm 2019-06-10 13:48:46 +02:00
parent d26995a1e4
commit 34e5599362
2 changed files with 5 additions and 4 deletions

View File

@ -1097,6 +1097,7 @@ func (w *Worker) GetSystemInfo(internal bool) (*SystemInfo, error) {
ci, err := w.chain.GetChainInfo()
var backendError string
if err != nil {
glog.Error("GetChainInfo error ", err)
backendError = errors.Annotatef(err, "GetChainInfo").Error()
ci = &bchain.ChainInfo{}
// set not in sync in case of backend error

View File

@ -327,13 +327,13 @@ func (b *EthereumRPC) GetSubversion() string {
// GetChainInfo returns information about the connected backend
func (b *EthereumRPC) GetChainInfo() (*bchain.ChainInfo, error) {
ctx, cancel := context.WithTimeout(context.Background(), b.timeout)
defer cancel()
id, err := b.client.NetworkID(ctx)
h, err := b.getBestHeader()
if err != nil {
return nil, err
}
h, err := b.getBestHeader()
ctx, cancel := context.WithTimeout(context.Background(), b.timeout)
defer cancel()
id, err := b.client.NetworkID(ctx)
if err != nil {
return nil, err
}