erigon-pulse/common/chan.go
ledgerwatch f7fc4d66ec
Move tests 5 (#2069)
* Remove silkworm and reader builders

* Switch tests

* Stop from hanging

* Update tests to 9.0.0

* Move tests back

* Moving code around

* Fix lint

* More fixes

* Intermediate

* Fix compile

* Fix compile errors

* Compile errors

* Fix lint

* Comment out more printing

* More simplifications

* Compile fixes

* Compile fix

* More replacements

* More fixes

* More muddling through

* lint

* Exclude dao split test

* Restore sidechains after unwind

* Errors in senders stage, stopped in bodies stage

* Fix compile

* Fix compile

* Fix tests

* More fixes

* More fixes

* Code cleanup

Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
Co-authored-by: alex.sharov <AskAlexSharov@gmail.com>
2021-06-05 11:00:21 +01:00

31 lines
398 B
Go

package common
import "errors"
var ErrStopped = errors.New("stopped")
var ErrUnwind = errors.New("unwound")
func Stopped(ch <-chan struct{}) error {
if ch == nil {
return nil
}
select {
case <-ch:
return ErrStopped
default:
}
return nil
}
func SafeClose(ch chan struct{}) {
if ch == nil {
return
}
select {
case <-ch:
// Channel was already closed
default:
close(ch)
}
}