types

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2020 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
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
)
View Source
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"
)

Governance message types and routes

View Source
const (
	QueryParams        = "params"
	QueryChange        = "change"
	QueryChanges       = "changes"
	QueryActiveChanges = "activeChanges"

	ParamVoting   = "voting"
	ParamTallying = "tallying"
)

query endpoints supported by the sync Querier

View Source
const (
	DefaultPeriod time.Duration = 15 * time.Second // 15 seconds
)

Default period for voting

View Source
const DefaultStartingChangeID uint64 = 1

DefaultStartingChangeID is 1

Variables

View Source
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

View Source
var (
	ChangesKeyPrefix        = []byte{0x00}
	ActiveChangeQueuePrefix = []byte{0x01}
	ChangeIDKey             = []byte{0x03}
)
View Source
var (
	ParamStoreKeyVotingParams = []byte("votingparams")
	ParamStoreKeyTallyParams  = []byte("tallyparams")
)

Parameter store key

View Source
var (
	DefaultThreshold = sdk.NewDecWithPrec(668, 3)
)

Default sync params

View Source
var ModuleCdc = codec.New()

module codec

Functions

func ActiveChangeQueueKey

func ActiveChangeQueueKey(changeID uint64) []byte

ActiveChangeQueueKey returns the key for a changeID in the activeChangeQueue

func ChangeKey

func ChangeKey(changeID uint64) []byte

ChangeKey gets a specific change from the store

func GetChangeIDBytes

func GetChangeIDBytes(changeID uint64) (changeIDBz []byte)

GetChangeIDBytes returns the byte representation of the changeID

func GetChangeIDFromBytes

func GetChangeIDFromBytes(bz []byte) (changeID uint64)

GetChangeIDFromBytes returns changeID in uint64 format from a byte array

func ParamKeyTable

func ParamKeyTable() params.KeyTable

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

func RegisterCodec(cdc *codec.Codec)

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"`
	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.

func NewChange

func NewChange(id uint64, changeType string, data []byte, submitTime, votingEndTime time.Time, initiatorAddr sdk.AccAddress) Change

NewChange creates a new Change instance

func (Change) String

func (c Change) String() string

String implements stringer interface

type ChangeQueue

type ChangeQueue []uint64

ChangeQueue defines a queue for change ids

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 Changes

type Changes []Change

Changes is an array of change

func (Changes) String

func (changes Changes) String() string

String implements stringer interface

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) Route

func (msg MsgApprove) Route() string

Route implements Msg

func (MsgApprove) String

func (msg MsgApprove) String() string

String implements the Stringer interface

func (MsgApprove) Type

func (msg MsgApprove) Type() string

Type implements Msg

func (MsgApprove) ValidateBasic

func (msg MsgApprove) ValidateBasic() error

ValidateBasic implements Msg

type MsgSubmitChange

type MsgSubmitChange struct {
	ChangeType string         `json:"changeType" yaml:"changeType"`
	Data       []byte         `json:"data" yaml:"data"`     //  Initial deposit paid by sender. Must be strictly positive
	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, 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) Route

func (msg MsgSubmitChange) Route() string

Route implements Msg

func (MsgSubmitChange) String

func (msg MsgSubmitChange) String() string

String implements the Stringer interface

func (MsgSubmitChange) Type

func (msg MsgSubmitChange) Type() string

Type implements Msg

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 DefaultParams

func DefaultParams() Params

DefaultParams default sync params

func NewParams

func NewParams(vp VotingParams, tp TallyParams) Params

NewParams creates a new sync Params instance

func (Params) String

func (gp Params) String() string

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

Jump to

Keyboard shortcuts

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