MCPcopy Create free account
hub / github.com/DOSNetwork/core / Balance

Method Balance

onchain/eth_get.go:564–598  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

562 return
563}
564func (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}
599func (e *ethAdaptor) CurrentBlock() (result uint64, err error) {
600 if !e.isConnecting() {
601 err = errors.New("not connecting to geth")

Callers

nothing calls this directly

Calls 6

isConnectingMethod · 0.95
getMethod · 0.95
getIndexFunction · 0.85
GetBalanceFunction · 0.85
replyErrorFunction · 0.85
NewMethod · 0.65

Tested by

no test coverage detected