/
hooks.go
49 lines (39 loc) · 1.99 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
package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
// Wrapper struct
type Hooks struct {
k Keeper
}
// Create new gravity 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) {
// 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.SetLastUnBondingBlockHeight(ctx, uint64(ctx.BlockHeight()))
}
func (h Hooks) BeforeDelegationCreated(_ sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) {
}
func (h Hooks) AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress) {}
func (h Hooks) BeforeValidatorModified(_ sdk.Context, _ sdk.ValAddress) {}
func (h Hooks) AfterValidatorBonded(_ sdk.Context, _ sdk.ConsAddress, _ sdk.ValAddress) {}
func (h Hooks) BeforeDelegationRemoved(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress) {}
func (h Hooks) AfterValidatorRemoved(ctx sdk.Context, _ sdk.ConsAddress, valAddr sdk.ValAddress) {}
func (h Hooks) BeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, fraction sdk.Dec) {}
func (h Hooks) BeforeDelegationSharesModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) {
}
func (h Hooks) AfterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) {
}