Documentation ¶
Index ¶
- Constants
- Variables
- func ErrAddressNotAuthorised() sdk.Error
- func ErrAlreadySlashed() sdk.Error
- func ErrInvalidArgument(id uint64) sdk.Error
- func ErrInvalidCreator(address sdk.AccAddress) sdk.Error
- func ErrInvalidSlashReason(because string) sdk.Error
- func ErrInvalidStake(id uint64) sdk.Error
- func ErrMaxSlashCountReached(id uint64) sdk.Error
- func ErrNotEnoughEarnedStake(address sdk.AccAddress) sdk.Error
- func ErrSlashNotFound(id uint64) sdk.Error
- func InitGenesis(ctx sdk.Context, keeper Keeper, data GenesisState)
- func NewHandler(keeper Keeper) sdk.Handler
- func NewQuerier(keeper Keeper) sdk.Querier
- func ParamKeyTable() params.KeyTable
- func RegisterCodec(cdc *codec.Codec)
- func ValidateGenesis(data GenesisState) error
- type AppModule
- func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock)
- func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate
- func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage
- func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate
- func (am AppModule) NewHandler() sdk.Handler
- func (am AppModule) NewQuerierHandler() sdk.Querier
- func (AppModule) QuerierRoute() string
- func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry)
- func (AppModule) Route() string
- type AppModuleBasic
- func (AppModuleBasic) DefaultGenesis() json.RawMessage
- func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command
- func (AppModuleBasic) GetTxCmd(_ *codec.Codec) *cobra.Command
- func (AppModuleBasic) Name() string
- func (AppModuleBasic) RegisterCodec(cdc *codec.Codec)
- func (AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router)
- func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error
- type GenesisState
- type Keeper
- func (k Keeper) AddAdmin(ctx sdk.Context, admin, creator sdk.AccAddress) (err sdk.Error)
- func (k Keeper) ArgumentSlasherSlashes(ctx sdk.Context, slasher sdk.AccAddress, argumentID uint64) []Slash
- func (k Keeper) ArgumentSlashes(ctx sdk.Context, argumentID uint64) []Slash
- func (k Keeper) CreateSlash(ctx sdk.Context, argumentID uint64, slashType SlashType, ...) (slash Slash, results []PunishmentResult, err sdk.Error)
- func (k Keeper) GetParams(ctx sdk.Context) Params
- func (k Keeper) IterateArgumentSlasherSlashes(ctx sdk.Context, argumentID uint64, address sdk.AccAddress, cb slashCallback)
- func (k Keeper) IterateArgumentSlashes(ctx sdk.Context, argumentID uint64, cb slashCallback)
- func (k Keeper) Logger(ctx sdk.Context) log.Logger
- func (k Keeper) RemoveAdmin(ctx sdk.Context, admin, remover sdk.AccAddress) (err sdk.Error)
- func (k Keeper) SetParams(ctx sdk.Context, params Params)
- func (k Keeper) Slash(ctx sdk.Context, id uint64) (slash Slash, err sdk.Error)
- func (k Keeper) Slashes(ctx sdk.Context) (slashes []Slash)
- func (k Keeper) UpdateParams(ctx sdk.Context, updater sdk.AccAddress, updates Params, ...) sdk.Error
- type MsgAddAdmin
- type MsgRemoveAdmin
- type MsgSlashArgument
- type MsgUpdateParams
- type Params
- type PunishmentResult
- type PunishmentResultType
- type QueryArgumentSlasherSlashesParams
- type QueryArgumentSlashesParams
- type QuerySlashParams
- type Slash
- type SlashReason
- type SlashType
- type Slashes
Constants ¶
const ( DefaultCodespace sdk.CodespaceType = ModuleName ErrorCodeSlashNotFound sdk.CodeType = 501 ErrorCodeInvalidStake sdk.CodeType = 502 ErrorCodeInvalidArgument sdk.CodeType = 503 ErrorCodeMaxSlashCountReached sdk.CodeType = 504 ErrorCodeInvalidCreator sdk.CodeType = 505 ErrorCodeNotEnoughEarnedStake sdk.CodeType = 506 ErrorCodeAlreadySlashed sdk.CodeType = 507 ErrorCodeInvalidSlashReason sdk.CodeType = 508 ErrorCodeAddressNotAuthorised sdk.CodeType = 509 )
Slashing errors reserve 500 ~ 599.
const ( // TypeMsgSlashArgument represents the type of the message for creating new community TypeMsgSlashArgument = "slash_argument" // TypeMsgAddAdmin represents the type of message for adding a new admin TypeMsgAddAdmin = "add_admin" // TypeMsgRemoveAdmin represents the type of message for removeing an admin TypeMsgRemoveAdmin = "remove_admin" // TypeMsgUpdateParams represents the type of TypeMsgUpdateParams = "update_params" )
const ( QuerySlash = "slash" QuerySlashes = "slashes" QueryArgumentSlashes = "argument_slashes" QueryArgumentSlasherSlashes = "argument_slasher_slashes" QueryParams = "params" )
query endpoints supported by the truchain Querier
const ( StoreKey = ModuleName RouterKey = ModuleName QuerierRoute = ModuleName DefaultParamspace = ModuleName AttributeKeyMinSlashCountKey = "min-slash-count" AttributeKeySlashResults = "slash-results" )
Defines slashing module constants
const ModuleName = "truslashing"
ModuleName is the name of this module
Variables ¶
var ( WithCommunityID = exported.WithCommunityID ToModuleAccount = exported.ToModuleAccount FromModuleAccount = exported.FromModuleAccount )
nolint
var ( SlashesKeyPrefix = []byte{0x00} SlashIDKey = []byte{0x01} SlashCountPrefix = []byte{0x02} CreatorSlashesPrefix = []byte{0x10} ArgumentSlashesPrefix = []byte{0x11} ArgumentCreatorPrefix = []byte{0x12} )
Keys for slashing store Items are stored with the following key: values
- 0x00<slashID>: Slash{} - 0x01: nextSlashID - 0x02<argumentID>: slashCount
- 0x10<creator><slashID>: slashID - 0x11<argumentID><slashID>: slashID - 0x12<argumentID><slashCreator><slashID>: slashID
var ( KeyMinSlashCount = []byte("minStakeSlashCount") KeySlashMagnitude = []byte("slashMagnitude") KeySlashMinStake = []byte("slashMinStake") KeySlashAdmins = []byte("slashAdmins") KeyMaxDetailedReasonLength = []byte("maxDetailedReasonLength") )
Keys for params
var ModuleCodec *codec.Codec
ModuleCodec encodes module codec
var SlashReasonName = []string{ SlashReasonLogicOrEvidenceAbsent: "No clear logic or evidence", SlashReasonIssueNotAddressed: "Doesn't address the issue", SlashReasonFocusedOnPerson: "Focuses on the person", SlashNoOriginalThought: "No original thought", SlashReasonPlagiarism: "Plagiarism", SlashReasonOther: "Other", SlashReasonHarassment: "Harassment", SlashReasonSpam: "Spam", SlashReasonOffensiveContent: "Offensive Content", }
SlashReasonName is the reason for the slash
Functions ¶
func ErrAddressNotAuthorised ¶
ErrAddressNotAuthorised throws an error when the address is not admin
func ErrAlreadySlashed ¶
ErrAlreadySlashed throws an error when the creator has already slashed the stake previously
func ErrInvalidArgument ¶
ErrInvalidArgument throws an error when the argument is invalid
func ErrInvalidCreator ¶
func ErrInvalidCreator(address sdk.AccAddress) sdk.Error
ErrInvalidCreator throws an error when the creator is not an admin
func ErrInvalidSlashReason ¶
ErrInvalidSlashReason throws an error when the slash reason is not valid
func ErrInvalidStake ¶
ErrInvalidStake throws an error when the stake is invalid
func ErrMaxSlashCountReached ¶
ErrMaxSlashCountReached throws an error when the max slash count on a stake is reached
func ErrNotEnoughEarnedStake ¶
func ErrNotEnoughEarnedStake(address sdk.AccAddress) sdk.Error
ErrNotEnoughEarnedStake throws an error when the creator is not an admin
func ErrSlashNotFound ¶
ErrSlashNotFound throws an error when the searched slash is not found
func InitGenesis ¶
func InitGenesis(ctx sdk.Context, keeper Keeper, data GenesisState)
InitGenesis initializes slashing state from genesis file
func NewHandler ¶
NewHandler creates a new handler for slashing module
func RegisterCodec ¶
RegisterCodec registers all the necessary types and interfaces for the module
func ValidateGenesis ¶
func ValidateGenesis(data GenesisState) error
ValidateGenesis validates the genesis state data
Types ¶
type AppModule ¶
type AppModule struct { AppModuleBasic // contains filtered or unexported fields }
AppModule defines external data for the module ----------------------------------------------------------------------------
func NewAppModule ¶
NewAppModule creates a NewAppModule object
func (AppModule) BeginBlock ¶
func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock)
BeginBlock returns the begin blocker for the supply module.
func (AppModule) EndBlock ¶
func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate
EndBlock returns the end blocker for the supply module. It returns no validator updates.
func (AppModule) ExportGenesis ¶
func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage
ExportGenesis enforces exporting this module's data to a genesis file
func (AppModule) InitGenesis ¶
func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate
InitGenesis enforces the creation of the genesis state for the slashing module
func (AppModule) NewHandler ¶
NewHandler creates the handler for the slashing module
func (AppModule) NewQuerierHandler ¶
NewQuerierHandler creates a new querier handler
func (AppModule) QuerierRoute ¶
QuerierRoute defines the querier route
func (AppModule) RegisterInvariants ¶
func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry)
RegisterInvariants enforces registering of invariants
type AppModuleBasic ¶
type AppModuleBasic struct{}
AppModuleBasic defines the internal data for the module ----------------------------------------------------------------------------
func (AppModuleBasic) DefaultGenesis ¶
func (AppModuleBasic) DefaultGenesis() json.RawMessage
DefaultGenesis creates the default genesis state for testing
func (AppModuleBasic) GetQueryCmd ¶
func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command
GetQueryCmd returns no root query command for the slashing module.
func (AppModuleBasic) GetTxCmd ¶
func (AppModuleBasic) GetTxCmd(_ *codec.Codec) *cobra.Command
GetTxCmd returns the root tx command for the slashing module.
func (AppModuleBasic) RegisterCodec ¶
func (AppModuleBasic) RegisterCodec(cdc *codec.Codec)
RegisterCodec registers the types needed for amino encoding/decoding
func (AppModuleBasic) RegisterRESTRoutes ¶
func (AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router)
RegisterRESTRoutes registers the REST routes for the slashing module.
func (AppModuleBasic) ValidateGenesis ¶
func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error
ValidateGenesis validates the genesis state
type GenesisState ¶
GenesisState defines genesis data for the module
func DefaultGenesisState ¶
func DefaultGenesisState() GenesisState
DefaultGenesisState returns a default genesis state
func ExportGenesis ¶
func ExportGenesis(ctx sdk.Context, keeper Keeper) GenesisState
ExportGenesis exports the genesis state
func NewGenesisState ¶
func NewGenesisState() GenesisState
NewGenesisState creates a new genesis state.
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
Keeper is the model object for the package slashing module
func NewKeeper ¶
func NewKeeper( storeKey sdk.StoreKey, paramStore params.Subspace, codec *codec.Codec, bankKeeper bank.Keeper, stakingKeeper staking.Keeper, accountKeeper account.Keeper, claimKeeper claim.Keeper, ) Keeper
NewKeeper creates a new keeper of the slashing Keeper
func (Keeper) ArgumentSlasherSlashes ¶
func (Keeper) ArgumentSlashes ¶
func (Keeper) CreateSlash ¶
func (k Keeper) CreateSlash(ctx sdk.Context, argumentID uint64, slashType SlashType, slashReason SlashReason, slashDetailedReason string, creator sdk.AccAddress) (slash Slash, results []PunishmentResult, err sdk.Error)
CreateSlash creates a new slash on an argument (mark as "Unhelpful" in app)
func (Keeper) IterateArgumentSlasherSlashes ¶
func (Keeper) IterateArgumentSlashes ¶
func (Keeper) RemoveAdmin ¶
RemoveAdmin removes an admin
type MsgAddAdmin ¶
type MsgAddAdmin struct { Admin sdk.AccAddress `json:"admin"` Creator sdk.AccAddress `json:"creator"` }
MsgAddAdmin defines the message to add a new admin
func NewMsgAddAdmin ¶
func NewMsgAddAdmin(admin, creator sdk.AccAddress) MsgAddAdmin
NewMsgAddAdmin returns the messages to add a new admin
func (MsgAddAdmin) GetSignBytes ¶
func (msg MsgAddAdmin) GetSignBytes() []byte
GetSignBytes implements Msg
func (MsgAddAdmin) GetSigners ¶
func (msg MsgAddAdmin) GetSigners() []sdk.AccAddress
GetSigners implements Msg. Returns the creator as the signer.
func (MsgAddAdmin) ValidateBasic ¶
func (msg MsgAddAdmin) ValidateBasic() sdk.Error
ValidateBasic implements Msg
type MsgRemoveAdmin ¶
type MsgRemoveAdmin struct { Admin sdk.AccAddress `json:"admin"` Remover sdk.AccAddress `json:"remover"` }
MsgRemoveAdmin defines the message to remove an admin
func NewMsgRemoveAdmin ¶
func NewMsgRemoveAdmin(admin, remover sdk.AccAddress) MsgRemoveAdmin
NewMsgRemoveAdmin returns the messages to remove an admin
func (MsgRemoveAdmin) GetSignBytes ¶
func (msg MsgRemoveAdmin) GetSignBytes() []byte
GetSignBytes implements Msg
func (MsgRemoveAdmin) GetSigners ¶
func (msg MsgRemoveAdmin) GetSigners() []sdk.AccAddress
GetSigners implements Msg. Returns the remover as the signer.
func (MsgRemoveAdmin) ValidateBasic ¶
func (msg MsgRemoveAdmin) ValidateBasic() sdk.Error
ValidateBasic implements Msg
type MsgSlashArgument ¶
type MsgSlashArgument struct { ArgumentID uint64 `json:"argument_id"` SlashType SlashType `json:"slash_type"` SlashReason SlashReason `json:"slash_reason"` SlashDetailedReason string `json:"slash_detailed_reason,omitempty"` Creator sdk.AccAddress `json:"creator"` }
MsgSlashArgument defines the message to slash an argument
func NewMsgSlashArgument ¶
func NewMsgSlashArgument(argumentID uint64, slashType SlashType, slashReason SlashReason, slashDetailedReason string, creator sdk.AccAddress) MsgSlashArgument
NewMsgSlashArgument returns the messages to slash an argument
func (MsgSlashArgument) GetSignBytes ¶
func (msg MsgSlashArgument) GetSignBytes() []byte
GetSignBytes implements Msg
func (MsgSlashArgument) GetSigners ¶
func (msg MsgSlashArgument) GetSigners() []sdk.AccAddress
GetSigners implements Msg. Returns the creator as the signer.
func (MsgSlashArgument) ValidateBasic ¶
func (msg MsgSlashArgument) ValidateBasic() sdk.Error
ValidateBasic implements Msg
type MsgUpdateParams ¶
type MsgUpdateParams struct { Updates Params `json:"updates"` UpdatedFields []string `json:"updated_fields"` Updater sdk.AccAddress `json:"updater"` }
MsgUpdateParams defines the message to remove an admin
func NewMsgUpdateParams ¶
func NewMsgUpdateParams(updates Params, updatedFields []string, updater sdk.AccAddress) MsgUpdateParams
NewMsgUpdateParams returns the message to update the params
func (MsgUpdateParams) GetSignBytes ¶
func (msg MsgUpdateParams) GetSignBytes() []byte
GetSignBytes implements Msg
func (MsgUpdateParams) GetSigners ¶
func (msg MsgUpdateParams) GetSigners() []sdk.AccAddress
GetSigners implements Msg. Returns the remover as the signer.
func (MsgUpdateParams) ValidateBasic ¶
func (msg MsgUpdateParams) ValidateBasic() sdk.Error
ValidateBasic implements Msg
type Params ¶
type Params struct { MinSlashCount int `json:"min_slash_count"` SlashMagnitude int `json:"slash_magnitude"` SlashMinStake sdk.Coin `json:"slash_min_stake"` SlashAdmins []sdk.AccAddress `json:"slash_admins"` MaxDetailedReasonLength int `json:"max_detailed_reason_length"` }
Params holds parameters for Slashing
func (*Params) ParamSetPairs ¶
func (p *Params) ParamSetPairs() params.ParamSetPairs
ParamSetPairs implements params.ParamSet
type PunishmentResult ¶
type PunishmentResult struct { Type PunishmentResultType `json:"type"` AppAccAddress sdk.AccAddress `json:"address"` Coin sdk.Coin `json:"coin"` }
type PunishmentResultType ¶
type PunishmentResultType int
const ( PunishmentInterestSlashed PunishmentResultType = iota PunishmentStakeSlashed PunishmentCuratorRewarded PunishmentJailed )
type QueryArgumentSlasherSlashesParams ¶
type QueryArgumentSlasherSlashesParams struct { ArgumentID uint64 `json:"argument_id"` Slasher sdk.AccAddress `json:"slasher"` }
QueryArgumentSlashesParams are params for querying slashes by argument id and slasher
type QueryArgumentSlashesParams ¶
type QueryArgumentSlashesParams struct {
ArgumentID uint64 `json:"argument_id"`
}
QueryArgumentSlashesParams are params for querying slashes by argument id
type QuerySlashParams ¶
type QuerySlashParams struct {
ID uint64 `json:"id"`
}
QuerySlashParams are params for querying slashes by id queries
type Slash ¶
type Slash struct { ID uint64 ArgumentID uint64 Type SlashType Reason SlashReason DetailedReason string Creator sdk.AccAddress CreatedTime time.Time }
Slash stores data about a slashing
type SlashReason ¶
type SlashReason int
SlashReason enum
const ( // SlashReasonLogicOrEvidenceAbsent represents the reason when no clear logic or evidence is present SlashReasonLogicOrEvidenceAbsent SlashReason = iota // SlashReasonIssueNotAddressed represents the reason when the issue at hand is not addressed SlashReasonIssueNotAddressed // SlashReasonFocusedOnPerson represents the reason when the argument is focused on the person, not the idea SlashReasonFocusedOnPerson // SlashNoOriginalThought represents the reasons when a thought isn't original; SlashNoOriginalThought // SlashReasonPlagiarism represents the reason when the argument is plagiarised SlashReasonPlagiarism // SlashReasonOther represents the reason that is any other than the above SlashReasonOther // SlashReasonHarassment ... SlashReasonHarassment // SlashReasonSpam ... SlashReasonSpam // SlashReasonOffensiveContent ... SlashReasonOffensiveContent )
func (SlashReason) String ¶
func (r SlashReason) String() string