()
| 562 | return |
| 563 | } |
| 564 | func (e *ethAdaptor) Balance() (result *big.Float, err error) { |
| 565 | if !e.isConnecting() { |
| 566 | err = errors.New("not connecting to geth") |
| 567 | } |
| 568 | clients := e.clients |
| 569 | f := func(ctx context.Context) (chan interface{}, chan error) { |
| 570 | outc := make(chan interface{}) |
| 571 | errc := make(chan error) |
| 572 | go func() { |
| 573 | defer close(outc) |
| 574 | defer close(errc) |
| 575 | idx := getIndex(ctx) |
| 576 | if idx == -1 { |
| 577 | err = errors.New("no client index in context") |
| 578 | } else { |
| 579 | if val, err := GetBalance(clients[idx], e.key); err != nil { |
| 580 | replyError(ctx, errc, &OnchainError{err: errors.Errorf("get err : %w", err), Idx: idx}) |
| 581 | } else { |
| 582 | utils.ReportResult(ctx, outc, val) |
| 583 | } |
| 584 | } |
| 585 | }() |
| 586 | return outc, errc |
| 587 | } |
| 588 | var r interface{} |
| 589 | if r, err = e.get(f); err != nil { |
| 590 | return |
| 591 | } |
| 592 | if v, ok := r.(*big.Float); ok { |
| 593 | result = v |
| 594 | } else { |
| 595 | err = errors.New("casting error") |
| 596 | } |
| 597 | return |
| 598 | } |
| 599 | func (e *ethAdaptor) CurrentBlock() (result uint64, err error) { |
| 600 | if !e.isConnecting() { |
| 601 | err = errors.New("not connecting to geth") |
nothing calls this directly
no test coverage detected