-
Notifications
You must be signed in to change notification settings - Fork 0
/
module.go
executable file
·106 lines (86 loc) · 3.36 KB
/
module.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package slashing
import (
"encoding/json"
staking "github.com/ci123chain/ci123chain/pkg/staking/keeper"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
abci "github.com/tendermint/tendermint/abci/types"
tmtypes "github.com/tendermint/tendermint/types"
"github.com/ci123chain/ci123chain/pkg/abci/codec"
codectypes "github.com/ci123chain/ci123chain/pkg/abci/codec/types"
sdk "github.com/ci123chain/ci123chain/pkg/abci/types"
"github.com/ci123chain/ci123chain/pkg/abci/types/module"
client "github.com/ci123chain/ci123chain/pkg/client/context"
"github.com/ci123chain/ci123chain/pkg/slashing/keeper"
"github.com/ci123chain/ci123chain/pkg/slashing/types"
)
var (
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
)
// AppModuleBasic defines the basic application module used by the slashing module.
type AppModuleBasic struct {
cdc *codec.Codec
}
var _ module.AppModuleBasic = AppModuleBasic{}
// Name returns the slashing module's name.
func (AppModuleBasic) Name() string {
return types.ModuleName
}
// DefaultGenesis returns default genesis state as raw bytes for the slashing
// module.
func (am AppModuleBasic) DefaultGenesis(validators []tmtypes.GenesisValidator) json.RawMessage {
return types.SlashingCodec.MustMarshalJSON(types.DefaultGenesisState())
}
func (AppModuleBasic) RegisterCodec(codec *codec.Codec) {
types.RegisterCodec(codec)
}
func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
return
}
func (am AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {}
//____________________________________________________________________________
// AppModule implements an application module for the slashing module.
type AppModule struct {
AppModuleBasic
Keeper keeper.Keeper
AccountKeeper types.AccountKeeper
StakingKeeper staking.StakingKeeper
}
// NewAppModule creates a new AppModule object
func NewAppModule(cdc *codec.Codec, keeper keeper.Keeper, ak types.AccountKeeper, sk staking.StakingKeeper) AppModule {
return AppModule{
AppModuleBasic: AppModuleBasic{cdc: cdc},
Keeper: keeper,
AccountKeeper: ak,
StakingKeeper: sk,
}
}
// Name returns the slashing module's name.
func (AppModule) Name() string {
return types.ModuleName
}
// InitGenesis performs genesis initialization for the slashing module. It returns
// no validator updates.
func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate {
var genesisState types.GenesisState
types.SlashingCodec.MustUnmarshalJSON(data, &genesisState)
InitGenesis(ctx, am.Keeper, am.StakingKeeper, &genesisState)
return []abci.ValidatorUpdate{}
}
// ExportGenesis returns the exported genesis state as raw bytes for the slashing
// module.
func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage {
gs := ExportGenesis(ctx, am.Keeper)
return types.SlashingCodec.MustMarshalJSON(gs)
}
// BeginBlock returns the begin blocker for the slashing module.
func (am AppModule) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) {
BeginBlocker(ctx, req, am.Keeper)
}
// EndBlock returns the end blocker for the slashing module. It returns no validator
// updates.
func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
return []abci.ValidatorUpdate{}
}
func (am AppModule) RegisterServices(cfg module.Configurator) {
}