/
hooks.go
50 lines (40 loc) · 1.34 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
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)
AfterDistribute(ctx sdk.Context, gaugeId uint64)
}
var _ IncentiveHooks = MultiIncentiveHooks{}
// combine multiple incentive hooks, all hook functions are run in array sequence
type MultiIncentiveHooks []IncentiveHooks
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) AfterDistribute(ctx sdk.Context, gaugeId uint64) {
for i := range h {
h[i].AfterDistribute(ctx, gaugeId)
}
}