Skip to content

Commit

Permalink
main: Retry PoolStatus.GetBalance in case connection dropped
Browse files Browse the repository at this point in the history
  • Loading branch information
shazow committed Dec 11, 2018
1 parent afa25d1 commit b648187
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pool.go
Expand Up @@ -128,7 +128,16 @@ func runPool(options Options) error {
settleHandler = contract.OpSettle

depositGetter = func(ctx context.Context) (*big.Int, error) {
return ethclient.PendingBalanceAt(ctx, contractAddr)
r, err := ethclient.PendingBalanceAt(ctx, contractAddr)
if err != nil {
// Try again in case the connection dropped
logger.Warningf("PoolStatus: ethclient.PendingBalanceAt failed, retrying: %s", err)
r, err = ethclient.PendingBalanceAt(ctx, contractAddr)
}
if err != nil {
logger.Errorf("PoolStatus: ethclient.PendingBalanceAt failed twice: %s", err)
}
return r, err
}
}

Expand Down

0 comments on commit b648187

Please sign in to comment.