types

package
v0.2.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2022 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AttributeKeyNonce = "nonce"

	ActionPenalty = "penalty"

	AttributeValueGuardFailure = "guard_failure"
	AttributeValueDepositBurn  = "deposit_burn"
)
View Source
const (
	// module name
	ModuleName = "slash"

	// StoreKey to be used when creating the KVStore
	StoreKey = ModuleName
)
View Source
const (
	QueryPenalty        = "penalty"
	QueryPenaltyRequest = "penalty-request"
	QueryParameters     = "parameters"
)
View Source
const (
	DefaultSignedBlocksWindow = 100
)
View Source
const RouterKey = ModuleName // this was defined in your key.go file

Variables

View Source
var (
	PenaltyKeyPrefix = []byte{0x11} // Key prefix for Penalty
	PenaltyNonceKey  = []byte{0x12} // Key for Penalty nonce
)
View Source
var (
	DefaultMinSignedPerWindow        = sdk.NewDecWithPrec(5, 1)
	DefaultSlashFractionDoubleSign   = sdk.NewDec(1).Quo(sdk.NewDec(20))
	DefaultSlashFractionDowntime     = sdk.NewDec(1).Quo(sdk.NewDec(100))
	DefaultSlashFractionGuardFailure = sdk.NewDec(1).Quo(sdk.NewDec(100))
	DefaultFallbackGuardReward       = sdk.NewDec(1).Quo(sdk.NewDec(2))
)

slash params default values

View Source
var (
	KeySignedBlocksWindow        = []byte("SignedBlocksWindow")
	KeyMinSignedPerWindow        = []byte("MinSignedPerWindow")
	KeySlashFractionDoubleSign   = []byte("SlashFractionDoubleSign")
	KeySlashFractionDowntime     = []byte("SlashFractionDowntime")
	KeySlashFractionGuardFailure = []byte("SlashFractionGuardFailure")
	KeyFallbackGuardReward       = []byte("FallbackGuardReward")
)

nolint - Keys for parameter access

View Source
var ModuleCdc = codec.New()

Functions

func GetPenaltyKey

func GetPenaltyKey(nonce uint64) []byte

get penalty key from nonce

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers concrete types on the Amino codec

Types

type AccountAmtPair

type AccountAmtPair struct {
	Account string  `json:"account"`
	Amount  sdk.Int `json:"amount"`
}

func NewAccountAmtPair

func NewAccountAmtPair(account string, amount sdk.Int) AccountAmtPair

func (AccountAmtPair) String

func (amp AccountAmtPair) String() string

type AccountFractionPair

type AccountFractionPair struct {
	Account  string  `json:"account"`
	Fraction sdk.Dec `json:"percent"`
}

func NewAccountFractionPair

func NewAccountFractionPair(account string, fraction sdk.Dec) AccountFractionPair

type MsgSignPenalty

type MsgSignPenalty struct {
	Nonce  uint64         `json:"nonce"`
	Sig    []byte         `json:"sig"`
	Sender sdk.AccAddress `json:"sender"`
}

func NewMsgSignPenalty

func NewMsgSignPenalty(nonce uint64, sig []byte, sender sdk.AccAddress) MsgSignPenalty

func (MsgSignPenalty) GetSignBytes

func (msg MsgSignPenalty) GetSignBytes() []byte

GetSignBytes encodes the message for signing

func (MsgSignPenalty) GetSigners

func (msg MsgSignPenalty) GetSigners() []sdk.AccAddress

GetSigners defines whose signature is required

func (MsgSignPenalty) Route

func (msg MsgSignPenalty) Route() string

Route should return the name of the module

func (MsgSignPenalty) Type

func (msg MsgSignPenalty) Type() string

Type should return the action

func (MsgSignPenalty) ValidateBasic

func (msg MsgSignPenalty) ValidateBasic() error

ValidateBasic runs stateless checks on the message

type Params

type Params struct {
	SignedBlocksWindow        int64   `json:"signed_blocks_window" yaml:"signed_blocks_window"`
	MinSignedPerWindow        sdk.Dec `json:"min_signed_per_window" yaml:"min_signed_per_window"`
	SlashFractionDoubleSign   sdk.Dec `json:"slash_fraction_double_sign" yaml:"slash_fraction_double_sign"`
	SlashFractionDowntime     sdk.Dec `json:"slash_fraction_downtime" yaml:"slash_fraction_downtime"`
	SlashFractionGuardFailure sdk.Dec `json:"slash_fraction_guard_failure" yaml:"slash_fraction_guard_failure"`
	FallbackGuardReward       sdk.Dec `json:"fallback_guard_reward" yaml:"fallback_guard_reward"`
}

Params defines the high level settings for slash

func DefaultParams

func DefaultParams() Params

DefaultParams returns a default set of parameters.

func MustUnmarshalParams

func MustUnmarshalParams(cdc *codec.Codec, value []byte) Params

unmarshal the current slash params value from store key or panic

func NewParams

func NewParams(signedBlocksWindow int64, minSignedPerWindow,
	slashFractionDoubleSign, slashFractionDowntime, slashFractionGuardFailure, fallbackGuardReward sdk.Dec) Params

NewParams creates a new Params instance

func UnmarshalParams

func UnmarshalParams(cdc *codec.Codec, value []byte) (params Params, err error)

unmarshal the current slash params value from store key

func (Params) Equal

func (p Params) Equal(p2 Params) bool

Equal returns a boolean determining if two Param types are identical.

func (*Params) ParamSetPairs

func (p *Params) ParamSetPairs() params.ParamSetPairs

Implements params.ParamSet

func (Params) String

func (p Params) String() string

String returns a human readable string representation of the parameters.

func (Params) Validate

func (p Params) Validate() error

validate a set of params

type Penalty

type Penalty struct {
	Nonce               uint64                `json:"nonce"`
	ValidatorAddr       string                `json:"validator_addr"`
	Reason              string                `json:"reason"`
	PenalizedDelegators []AccountAmtPair      `json:"penalized_delegators"`
	Beneficiaries       []AccountFractionPair `json:"beneficiaries"`
	PenaltyProtoBytes   []byte                `json:"penalty_proto_bytes"`
	Sigs                []common.Sig          `json:"sigs"`
}

func NewPenalty

func NewPenalty(nonce uint64, reason string, validatorAddr string) Penalty

func (*Penalty) AddSig

func (p *Penalty) AddSig(sig []byte, expectedSigner string) error

Add signature to penalty sigs

func (*Penalty) GenerateProtoBytes

func (p *Penalty) GenerateProtoBytes()

func (Penalty) GetPenaltyRequest

func (p Penalty) GetPenaltyRequest() []byte

Generate penaltyRequest msg

func (Penalty) String

func (p Penalty) String() string

implement fmt.Stringer

type QueryPenaltyParams

type QueryPenaltyParams struct {
	Nonce uint64
}

func NewQueryPenaltyParams

func NewQueryPenaltyParams(nonce uint64) QueryPenaltyParams

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL