github.com/Finschia/finschia-sdk@v0.48.1/x/slashing/spec/05_hooks.md (about) 1 <!-- 2 order: 5 3 --> 4 5 # Hooks 6 7 This section contains a description of the module's `hooks`. Hooks are operations that are executed automatically when events are raised. 8 9 ## Staking hooks 10 11 The slashing module implements the `StakingHooks` defined in `x/staking` and are used as record-keeping of validators information. During the app initialization, these hooks should be registered in the staking module struct. 12 13 The following hooks impact the slashing state: 14 15 + `AfterValidatorBonded` creates a `ValidatorSigningInfo` instance as described in the following section. 16 + `AfterValidatorCreated` stores a validator's consensus key. 17 + `AfterValidatorRemoved` removes a validator's consensus key. 18 19 ## Validator Bonded 20 21 Upon successful first-time bonding of a new validator, we create a new `ValidatorSigningInfo` structure for the 22 now-bonded validator. 23 24 ``` 25 onValidatorBonded(address sdk.ValAddress) 26 27 signingInfo, found = GetValidatorSigningInfo(address) 28 if !found { 29 signingInfo = ValidatorSigningInfo { 30 JailedUntil : time.Unix(0, 0), 31 Tombstone : false, 32 MissedBloskCounter : 0, 33 VoterSetCounter : 0, 34 } 35 setValidatorSigningInfo(signingInfo) 36 } 37 38 return 39 ```