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

Method get

onchain/eth_get.go:17–60  ·  view source on GitHub ↗
(f getFunc)

Source from the content-addressed store, hash-verified

15type getFunc func(ctx context.Context) (chan interface{}, chan error)
16
17func (e *ethAdaptor) get(f getFunc) (result interface{}, err error) {
18 if !e.isConnecting() {
19 err = errors.New("not connecting to geth")
20 return
21 }
22 var valList []chan interface{}
23 var errList []chan error
24 for _, ctx := range e.ctxes {
25 select {
26 case <-ctx.Done():
27 default:
28 opCtx, opCancel := context.WithTimeout(ctx, e.getTimeout)
29 defer opCancel()
30 outc, errc := f(opCtx)
31 valList = append(valList, outc)
32 errList = append(errList, errc)
33 }
34 }
35 outc := first(e.ctx, merge(e.ctx, valList...))
36 errc := mergeError(e.ctx, errList...)
37 var ok bool
38 select {
39 case result = <-outc:
40 case <-e.ctx.Done():
41 return nil, errors.Errorf(" : %w", e.ctx.Err())
42 }
43 for {
44 select {
45 case err, ok = <-errc:
46 if !ok {
47 return
48 }
49 if strings.Contains(err.Error(), "use of closed network connection") {
50 var oError *OnchainError
51 if errors.As(err, &oError) {
52 e.cancels[oError.Idx]()
53 }
54 }
55 continue
56 case <-e.ctx.Done():
57 return nil, errors.Errorf(" : %w", e.ctx.Err())
58 }
59 }
60}
61
62// GroupToPick returns the groupToPick value
63func (e *ethAdaptor) GroupToPick() (result uint64, err error) {

Callers 15

GroupToPickMethod · 0.95
GroupSizeMethod · 0.95
GetWorkingGroupSizeMethod · 0.95
LastUpdatedBlockMethod · 0.95
NumPendingGroupsMethod · 0.95
NumPendingNodesMethod · 0.95
BootstrapEndBlkMethod · 0.95
GroupPubKeyMethod · 0.95

Calls 6

isConnectingMethod · 0.95
firstFunction · 0.85
mergeErrorFunction · 0.85
mergeFunction · 0.70
NewMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected