/
hooks.go
50 lines (40 loc) · 1.3 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 {
AfterCreatePot(ctx sdk.Context, potId uint64)
AfterAddToPot(ctx sdk.Context, potId uint64)
AfterStartDistribution(ctx sdk.Context, potId uint64)
AfterFinishDistribution(ctx sdk.Context, potId uint64)
AfterDistribute(ctx sdk.Context, potId 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) AfterCreatePot(ctx sdk.Context, potId uint64) {
for i := range h {
h[i].AfterCreatePot(ctx, potId)
}
}
func (h MultiIncentiveHooks) AfterAddToPot(ctx sdk.Context, potId uint64) {
for i := range h {
h[i].AfterAddToPot(ctx, potId)
}
}
func (h MultiIncentiveHooks) AfterStartDistribution(ctx sdk.Context, potId uint64) {
for i := range h {
h[i].AfterStartDistribution(ctx, potId)
}
}
func (h MultiIncentiveHooks) AfterFinishDistribution(ctx sdk.Context, potId uint64) {
for i := range h {
h[i].AfterFinishDistribution(ctx, potId)
}
}
func (h MultiIncentiveHooks) AfterDistribute(ctx sdk.Context, potId uint64) {
for i := range h {
h[i].AfterDistribute(ctx, potId)
}
}