-
Notifications
You must be signed in to change notification settings - Fork 285
/
hooks.go
71 lines (56 loc) · 2.1 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
// Hooks is a wrapper struct around Keeper.
type Hooks struct {
k Keeper
}
// Create new QGB hooks
func (k Keeper) Hooks() Hooks {
// if startup is mis-ordered in app.go this hook will halt the chain when
// called. Keep this check to make such a mistake obvious
if k.storeKey == nil {
panic("hooks initialized before GravityKeeper")
}
return Hooks{k}
}
func (h Hooks) AfterValidatorBeginUnbonding(ctx sdk.Context, _ sdk.ConsAddress, _ sdk.ValAddress) error {
// When Validator starts Unbonding, Persist the block height in the store
// Later in endblocker, check if there is at least one validator who started
// unbonding and create a valset request. The reason for creating valset
// requests in endblock is to create only one valset request per block, if
// multiple validators starts unbonding at same block.
// this hook IS called for jailing or unbonding triggered by users but it IS
// NOT called for jailing triggered in the endblocker therefore we call the
// keeper function ourselves there.
h.k.SetLatestUnBondingBlockHeight(ctx, uint64(ctx.BlockHeight()))
return nil
}
func (h Hooks) BeforeDelegationCreated(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress) error {
return nil
}
func (h Hooks) AfterValidatorCreated(_ sdk.Context, _ sdk.ValAddress) error {
return nil
}
func (h Hooks) BeforeValidatorModified(_ sdk.Context, _ sdk.ValAddress) error {
return nil
}
func (h Hooks) AfterValidatorBonded(_ sdk.Context, _ sdk.ConsAddress, _ sdk.ValAddress) error {
return nil
}
func (h Hooks) BeforeDelegationRemoved(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress) error {
return nil
}
func (h Hooks) AfterValidatorRemoved(_ sdk.Context, _ sdk.ConsAddress, _ sdk.ValAddress) error {
return nil
}
func (h Hooks) BeforeValidatorSlashed(_ sdk.Context, _ sdk.ValAddress, _ sdk.Dec) error {
return nil
}
func (h Hooks) BeforeDelegationSharesModified(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress) error {
return nil
}
func (h Hooks) AfterDelegationModified(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress) error {
return nil
}