Documentation ¶
Index ¶
- Constants
- Variables
- func ActiveChangeQueueKey(changeID uint64) []byte
- func ChangeKey(changeID uint64) []byte
- func GetChangeIDBytes(changeID uint64) (changeIDBz []byte)
- func GetChangeIDFromBytes(bz []byte) (changeID uint64)
- func ParamKeyTable() params.KeyTable
- func RegisterChangeTypeCodec(o interface{}, name string)
- func RegisterCodec(cdc *codec.Codec)
- func ValidChangeStatus(status ChangeStatus) bool
- func ValidateGenesis(data GenesisState) error
- type Change
- type ChangeQueue
- type ChangeStatus
- func (status ChangeStatus) Format(s fmt.State, verb rune)
- func (status ChangeStatus) Marshal() ([]byte, error)
- func (status ChangeStatus) MarshalJSON() ([]byte, error)
- func (status ChangeStatus) String() string
- func (status *ChangeStatus) Unmarshal(data []byte) error
- func (status *ChangeStatus) UnmarshalJSON(data []byte) error
- type Changes
- type GenesisState
- type MsgApprove
- type MsgSubmitChange
- type ParamSubspace
- type Params
- type QueryChangeParams
- type QueryChangesParams
- type TallyParams
- type VotingParams
Constants ¶
const ( EventTypeSync = "sync" EventTypeActiveChange = "active_change" AttributeKeyChangeResult = "change_result" AttributeKeyChangeID = "change_id" AttributeValueChangePassed = "change_passed" // met vote quorum AttributeValueChangeFailed = "change_failed" // error on change handler ActionSubmitChange = "submit_change" )
Governance module event types
const ( // ModuleName is the name of the module ModuleName = "sync" // StoreKey is the store key string for sync StoreKey = ModuleName // RouterKey is the message route for sync RouterKey = ModuleName // QuerierRoute is the querier route for sync QuerierRoute = ModuleName // DefaultParamspace default name for parameter store DefaultParamspace = ModuleName )
const ( TypeMsgApprove = "approve_change" TypeMsgSubmitChange = "submit_change" ConfirmParamProposal = "confirm_param_proposal" UpdateSidechainAddr = "update_sidechain_addr" SyncDelegator = "sync_delegator" SyncValidator = "sync_validator" Subscribe = "subscribe" InitGuardRequest = "init_guard_request" GuardTrigger = "guard_trigger" GuardProof = "guard_proof" )
Sync message types and routes
const ( QueryParams = "params" QueryChange = "change" QueryChanges = "changes" QueryActiveChanges = "activeChanges" ParamVoting = "voting" ParamTallying = "tallying" )
query endpoints supported by the sync Querier
const (
DefaultPeriod time.Duration = 15 * time.Second // 15 seconds
)
Default period for voting
const DefaultStartingChangeID uint64 = 1
DefaultStartingChangeID is 1
Variables ¶
var ( ErrUnknownChange = sdkerrors.Register(ModuleName, 1, "unknown change") ErrDoubleVote = sdkerrors.Register(ModuleName, 2, "double vote") ErrInvalidChangeType = sdkerrors.Register(ModuleName, 3, "invalid change type") ErrInvalidChangeData = sdkerrors.Register(ModuleName, 4, "invalid change data") ErrInvalidGenesis = sdkerrors.Register(ModuleName, 5, "invalid genesis state") )
x/sync module sentinel errors
var ( ChangesKeyPrefix = []byte{0x00} ActiveChangeQueuePrefix = []byte{0x01} ChangeIDKey = []byte{0x03} )
var ( ParamStoreKeyVotingParams = []byte("votingparams") ParamStoreKeyTallyParams = []byte("tallyparams") )
Parameter store key
var (
DefaultThreshold = sdk.NewDecWithPrec(668, 3)
)
Default sync params
var ModuleCdc = codec.New()
module codec
Functions ¶
func ActiveChangeQueueKey ¶
ActiveChangeQueueKey returns the key for a changeID in the activeChangeQueue
func GetChangeIDBytes ¶
GetChangeIDBytes returns the byte representation of the changeID
func GetChangeIDFromBytes ¶
GetChangeIDFromBytes returns changeID in uint64 format from a byte array
func ParamKeyTable ¶
ParamKeyTable - Key declaration for parameters
func RegisterChangeTypeCodec ¶
func RegisterChangeTypeCodec(o interface{}, name string)
RegisterChangeTypeCodec registers an external change content type defined in another module for the internal ModuleCdc. This allows the MsgSubmitChange to be correctly Amino encoded and decoded.
func RegisterCodec ¶
RegisterCodec registers all the necessary types and interfaces for sync.
func ValidChangeStatus ¶
func ValidChangeStatus(status ChangeStatus) bool
ValidChangeStatus returns true if the change status is valid and false otherwise.
func ValidateGenesis ¶
func ValidateGenesis(data GenesisState) error
ValidateGenesis checks if parameters are within valid ranges
Types ¶
type Change ¶
type Change struct { ID uint64 `json:"id" yaml:"id"` // ID of the change Type string `json:"type" yaml:"type"` Data []byte `json:"data" yaml:"data"` BlockNum uint64 `json:"block_num" yaml:"block_num"` // Claimed mainchain block number when the infomation was queried Initiator sdk.AccAddress `json:"initiator" yaml:"initiator"` Voters []sdk.ValAddress `json:"voters" yaml:"voters"` Status ChangeStatus `json:"change_status" yaml:"change_status"` // Status of the Change {Pending, Active, Passed, Rejected} SubmitTime time.Time `json:"submit_time" yaml:"submit_time"` // Time of the block where TxGovSubmitChange was included VotingEndTime time.Time `json:"voting_end_time" yaml:"voting_end_time"` // Time that the VotingPeriod for this change will end and votes will be tallied Rewardable bool `json:"rewardable" yaml:"rewardable"` }
Change defines a struct used by the sync module to allow for voting on network changes.
type ChangeStatus ¶
type ChangeStatus byte
ChangeStatus is a type alias that represents a change status as a byte
const ( StatusNil ChangeStatus = 0x00 StatusActive ChangeStatus = 0x01 StatusPassed ChangeStatus = 0x02 StatusFailed ChangeStatus = 0x03 )
Valid Change statuses
func ChangeStatusFromString ¶
func ChangeStatusFromString(str string) (ChangeStatus, error)
ChangeStatusFromString turns a string into a ChangeStatus
func (ChangeStatus) Format ¶
func (status ChangeStatus) Format(s fmt.State, verb rune)
Format implements the fmt.Formatter interface. nolint: errcheck
func (ChangeStatus) Marshal ¶
func (status ChangeStatus) Marshal() ([]byte, error)
Marshal needed for protobuf compatibility
func (ChangeStatus) MarshalJSON ¶
func (status ChangeStatus) MarshalJSON() ([]byte, error)
MarshalJSON Marshals to JSON using string representation of the status
func (ChangeStatus) String ¶
func (status ChangeStatus) String() string
String implements the Stringer interface.
func (*ChangeStatus) Unmarshal ¶
func (status *ChangeStatus) Unmarshal(data []byte) error
Unmarshal needed for protobuf compatibility
func (*ChangeStatus) UnmarshalJSON ¶
func (status *ChangeStatus) UnmarshalJSON(data []byte) error
UnmarshalJSON Unmarshals from JSON assuming Bech32 encoding
type GenesisState ¶
type GenesisState struct { StartingChangeID uint64 `json:"starting_change_id" yaml:"starting_change_id"` Changes Changes `json:"changes" yaml:"changes"` VotingParams VotingParams `json:"voting_params" yaml:"voting_params"` TallyParams TallyParams `json:"tally_params" yaml:"tally_params"` }
GenesisState - all staking state that must be provided at genesis
func DefaultGenesisState ¶
func DefaultGenesisState() GenesisState
DefaultGenesisState defines the default sync genesis state
func NewGenesisState ¶
func NewGenesisState(startingChangeID uint64, vp VotingParams, tp TallyParams) GenesisState
NewGenesisState creates a new genesis state for the sync module
func (GenesisState) Equal ¶
func (data GenesisState) Equal(data2 GenesisState) bool
Equal checks whether two sync GenesisState structs are equivalent
func (GenesisState) IsEmpty ¶
func (data GenesisState) IsEmpty() bool
IsEmpty returns true if a GenesisState is empty
type MsgApprove ¶
type MsgApprove struct { ChangeID uint64 `json:"change_id" yaml:"change_id"` // ID of the change Sender sdk.AccAddress `json:"sender" yaml:"sender"` // Address of the sender }
MsgApprove defines a message to cast a vote
func NewMsgApprove ¶
func NewMsgApprove(changeID uint64, sender sdk.AccAddress) MsgApprove
NewMsgApprove creates a message to cast a vote on an active change
func (MsgApprove) GetSignBytes ¶
func (msg MsgApprove) GetSignBytes() []byte
GetSignBytes implements Msg
func (MsgApprove) GetSigners ¶
func (msg MsgApprove) GetSigners() []sdk.AccAddress
GetSigners implements Msg
func (MsgApprove) String ¶
func (msg MsgApprove) String() string
String implements the Stringer interface
func (MsgApprove) ValidateBasic ¶
func (msg MsgApprove) ValidateBasic() error
ValidateBasic implements Msg
type MsgSubmitChange ¶
type MsgSubmitChange struct { ChangeType string `json:"change_type" yaml:"change_type"` Data []byte `json:"data" yaml:"data"` // The serialized information to sync BlockNum uint64 `json:"block_num" yaml:"block_num"` // Claimed mainchain block number when the infomation was queried Sender sdk.AccAddress `json:"sender" yaml:"sender"` // Address of the sender }
MsgSubmitChange defines a message to create a sync change
func NewMsgSubmitChange ¶
func NewMsgSubmitChange(changeType string, data []byte, blockNum uint64, sender sdk.AccAddress) MsgSubmitChange
NewMsgSubmitChange creates a new MsgSubmitChange instance
func (MsgSubmitChange) GetSignBytes ¶
func (msg MsgSubmitChange) GetSignBytes() []byte
GetSignBytes implements Msg
func (MsgSubmitChange) GetSigners ¶
func (msg MsgSubmitChange) GetSigners() []sdk.AccAddress
GetSigners implements Msg
func (MsgSubmitChange) String ¶
func (msg MsgSubmitChange) String() string
String implements the Stringer interface
func (MsgSubmitChange) ValidateBasic ¶
func (msg MsgSubmitChange) ValidateBasic() error
ValidateBasic implements Msg
type ParamSubspace ¶
type ParamSubspace interface { Get(ctx sdk.Context, key []byte, ptr interface{}) Set(ctx sdk.Context, key []byte, param interface{}) }
ParamSubspace defines the expected Subspace interface for parameters (noalias)
type Params ¶
type Params struct { VotingParams VotingParams `json:"voting_params" yaml:"voting_params"` TallyParams TallyParams `json:"tally_params" yaml:"tally_params"` }
Params returns all of the sync params
func NewParams ¶
func NewParams(vp VotingParams, tp TallyParams) Params
NewParams creates a new sync Params instance
type QueryChangeParams ¶
type QueryChangeParams struct {
ID uint64
}
QueryChangeParams Params for queries: - 'custom/sync/change' - 'custom/sync/deposits' - 'custom/sync/tally'
func NewQueryChangeParams ¶
func NewQueryChangeParams(changeID uint64) QueryChangeParams
NewQueryChangeParams creates a new instance of QueryChangeParams
type QueryChangesParams ¶
type QueryChangesParams struct { Page int Limit int Voter sdk.AccAddress ChangeStatus ChangeStatus }
QueryChangesParams Params for query 'custom/sync/changes'
func NewQueryChangesParams ¶
func NewQueryChangesParams(page, limit int, status ChangeStatus) QueryChangesParams
NewQueryChangesParams creates a new instance of QueryChangesParams
type TallyParams ¶
type TallyParams struct {
Threshold sdk.Dec `json:"threshold,omitempty" yaml:"threshold,omitempty"` // Minimum proportion of Yes votes for change to pass. Initial value: 0.668
}
TallyParams defines the params around Tallying votes in sync
func DefaultTallyParams ¶
func DefaultTallyParams() TallyParams
DefaultTallyParams default parameters for tallying
func NewTallyParams ¶
func NewTallyParams(threshold sdk.Dec) TallyParams
NewTallyParams creates a new TallyParams object
func (TallyParams) String ¶
func (tp TallyParams) String() string
String implements stringer insterface
type VotingParams ¶
type VotingParams struct {
VotingPeriod time.Duration `json:"voting_period,omitempty" yaml:"voting_period,omitempty"` // Length of the voting period.
}
VotingParams defines the params around Voting in sync
func DefaultVotingParams ¶
func DefaultVotingParams() VotingParams
DefaultVotingParams default parameters for voting
func NewVotingParams ¶
func NewVotingParams(votingPeriod time.Duration) VotingParams
NewVotingParams creates a new VotingParams object
func (VotingParams) String ¶
func (vp VotingParams) String() string
String implements stringer interface