* Err: transaction failed Err: insufficient funds for gas * price + value ->Fail request and send back error to requester to handle the error Err: failed to retrieve account nonce Err: use of closed network connection ->Switch to other geth to set again */
(req *request)
| 33 | ->Switch to other geth to set again |
| 34 | */ |
| 35 | func (e *ethAdaptor) handleReq(req *request) { |
| 36 | var tx *types.Transaction |
| 37 | var err error |
| 38 | var idx int |
| 39 | var ctx context.Context |
| 40 | L: |
| 41 | for idx, ctx = range e.ctxes { |
| 42 | select { |
| 43 | case <-req.opCtx.Done(): |
| 44 | return |
| 45 | case <-ctx.Done(): |
| 46 | continue |
| 47 | default: |
| 48 | tx, err = req.f(ctx) |
| 49 | if err != nil { |
| 50 | if strings.Contains(err.Error(), "transaction failed") || |
| 51 | strings.Contains(err.Error(), "insufficient funds for gas * price + value") { |
| 52 | break L |
| 53 | } |
| 54 | if strings.Contains(err.Error(), "failed to retrieve account nonce") || |
| 55 | strings.Contains(err.Error(), "use of closed network connection") { |
| 56 | var oError *OnchainError |
| 57 | if errors.As(err, &oError) { |
| 58 | e.cancels[oError.Idx]() |
| 59 | } |
| 60 | } |
| 61 | continue |
| 62 | } |
| 63 | break L |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | resp := &response{idx, tx, err} |
| 68 | go func() { |
| 69 | defer close(req.reply) |
| 70 | select { |
| 71 | case req.reply <- resp: |
| 72 | case <-req.opCtx.Done(): |
| 73 | } |
| 74 | }() |
| 75 | } |
| 76 | |
| 77 | func (e *ethAdaptor) waitForReply(req *request) (err error) { |
| 78 | for { |