2020-10-19 19:35:34 +00:00
|
|
|
package policies
|
|
|
|
|
2021-02-22 23:20:57 +00:00
|
|
|
import types "github.com/prysmaticlabs/eth2-types"
|
2021-02-09 10:05:22 +00:00
|
|
|
|
2020-10-19 19:35:34 +00:00
|
|
|
// AfterNthEpoch runs for every epoch after the provided epoch.
|
2021-02-09 10:05:22 +00:00
|
|
|
func AfterNthEpoch(afterEpoch types.Epoch) func(epoch types.Epoch) bool {
|
|
|
|
return func(currentEpoch types.Epoch) bool {
|
2020-10-19 19:35:34 +00:00
|
|
|
return currentEpoch > afterEpoch
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// AllEpochs runs for all epochs.
|
2021-02-09 10:05:22 +00:00
|
|
|
func AllEpochs(_ types.Epoch) bool {
|
2020-10-19 19:35:34 +00:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OnEpoch runs only for the provided epoch.
|
2021-02-09 10:05:22 +00:00
|
|
|
func OnEpoch(epoch types.Epoch) func(types.Epoch) bool {
|
|
|
|
return func(currentEpoch types.Epoch) bool {
|
2020-10-19 19:35:34 +00:00
|
|
|
return currentEpoch == epoch
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// BetweenEpochs runs for every epoch that is between the provided epochs.
|
2021-02-09 10:05:22 +00:00
|
|
|
func BetweenEpochs(fromEpoch, toEpoch types.Epoch) func(types.Epoch) bool {
|
|
|
|
return func(currentEpoch types.Epoch) bool {
|
2020-10-19 19:35:34 +00:00
|
|
|
return fromEpoch < currentEpoch && currentEpoch < toEpoch
|
|
|
|
}
|
|
|
|
}
|