-
Notifications
You must be signed in to change notification settings - Fork 0
/
slashing.go
30 lines (27 loc) · 1.04 KB
/
slashing.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
package emitter
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/slashing"
)
// handleEventSlash implements emitter handler for Slashing event.
func (app *App) handleEventSlash(event EvMap) {
if raw, ok := event[slashing.EventTypeSlash+"."+slashing.AttributeKeyJailed]; ok && len(raw) == 1 {
consAddress, _ := sdk.ConsAddressFromBech32(raw[0])
validator, _ := app.StakingKeeper.GetValidatorByConsAddr(app.DeliverContext, consAddress)
app.Write("UPDATE_VALIDATOR", JsDict{
"operator_address": validator.OperatorAddress.String(),
"tokens": validator.Tokens.Uint64(),
"jailed": validator.Jailed,
})
}
}
// handleMsgUnjail implements emitter handler for MsgUnjail.
func (app *App) handleMsgUnjail(
txHash []byte, msg slashing.MsgUnjail, evMap EvMap, extra JsDict,
) {
validator, _ := app.StakingKeeper.GetValidator(app.DeliverContext, msg.ValidatorAddr)
app.Write("UPDATE_VALIDATOR", JsDict{
"operator_address": msg.ValidatorAddr.String(),
"jailed": validator.Jailed,
})
}