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

Function merge

onchain/eth_helpers.go:55–83  ·  view source on GitHub ↗
(ctx context.Context, cs ...chan interface{})

Source from the content-addressed store, hash-verified

53}
54
55func merge(ctx context.Context, cs ...chan interface{}) chan interface{} {
56 var wg sync.WaitGroup
57 out := make(chan interface{})
58
59 // Start an output goroutine for each input channel in cs. output
60 // copies values from c to out until c is closed, then calls wg.Done.
61 output := func(c <-chan interface{}) {
62 for n := range c {
63 select {
64 case <-ctx.Done():
65 return
66 case out <- n:
67 }
68 }
69 wg.Done()
70 }
71 wg.Add(len(cs))
72 for _, c := range cs {
73 go output(c)
74 }
75
76 // Start a goroutine to close out once all the output goroutines are
77 // done. This must start after the wg.Add call.
78 go func() {
79 wg.Wait()
80 close(out)
81 }()
82 return out
83}
84
85func mergeError(ctx context.Context, cs ...chan error) chan error {
86 var wg sync.WaitGroup

Callers 2

SubscribeEventMethod · 0.70
getMethod · 0.70

Calls 1

AddMethod · 0.45

Tested by

no test coverage detected