-
Notifications
You must be signed in to change notification settings - Fork 0
/
hooks.go
51 lines (41 loc) · 1.44 KB
/
hooks.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package types
import sdk "github.com/cosmos/cosmos-sdk/types"
type IncentiveHooks interface {
AfterCreateGauge(ctx sdk.Context, gaugeId uint64)
AfterAddToGauge(ctx sdk.Context, gaugeId uint64)
AfterStartDistribution(ctx sdk.Context, gaugeId uint64)
AfterFinishDistribution(ctx sdk.Context, gaugeId uint64)
AfterEpochDistribution(ctx sdk.Context)
}
var _ IncentiveHooks = MultiIncentiveHooks{}
// MultiIncentiveHooks combines multiple incentive hooks. All hook functions are run in array sequence.
type MultiIncentiveHooks []IncentiveHooks
// NewMultiIncentiveHooks combines multiple incentive hooks into a single IncentiveHooks array.
func NewMultiIncentiveHooks(hooks ...IncentiveHooks) MultiIncentiveHooks {
return hooks
}
func (h MultiIncentiveHooks) AfterCreateGauge(ctx sdk.Context, gaugeId uint64) {
for i := range h {
h[i].AfterCreateGauge(ctx, gaugeId)
}
}
func (h MultiIncentiveHooks) AfterAddToGauge(ctx sdk.Context, gaugeId uint64) {
for i := range h {
h[i].AfterAddToGauge(ctx, gaugeId)
}
}
func (h MultiIncentiveHooks) AfterStartDistribution(ctx sdk.Context, gaugeId uint64) {
for i := range h {
h[i].AfterStartDistribution(ctx, gaugeId)
}
}
func (h MultiIncentiveHooks) AfterFinishDistribution(ctx sdk.Context, gaugeId uint64) {
for i := range h {
h[i].AfterFinishDistribution(ctx, gaugeId)
}
}
func (h MultiIncentiveHooks) AfterEpochDistribution(ctx sdk.Context) {
for i := range h {
h[i].AfterEpochDistribution(ctx)
}
}