Documentation
¶
Index ¶
- func CountVotes(votes []string) int
- func ParseBitArray(bitArray string) (pattern string, voted int64, total int64, percent float64)
- func ParseHeightRoundStep(hrs string) (height int64, round int, step int, err error)
- type ConsensusResponse
- type HeightVote
- type ProposerInfo
- type PubKey
- type RoundState
- type State
- type Validator
- type ValidatorStatus
- type ValidatorsResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountVotes ¶
CountVotes counts the number of non-nil votes in a vote array
func ParseBitArray ¶
ParseBitArray extracts the bit pattern and percentages from the bit array string Format: "BA{99:xx_xx_x_...} 63976000/106137430 = 0.60"
Types ¶
type ConsensusResponse ¶
type ConsensusResponse struct {
JSONRPC string `json:"jsonrpc"`
ID int `json:"id"`
Result struct {
RoundState RoundState `json:"round_state"`
} `json:"result"`
}
ConsensusResponse represents the JSON-RPC response from /consensus_state
type HeightVote ¶
type HeightVote struct {
Round int `json:"round"`
Prevotes []string `json:"prevotes"`
PrevotesBitArray string `json:"prevotes_bit_array"`
Precommits []string `json:"precommits"`
PrecommitsBitArray string `json:"precommits_bit_array"`
}
HeightVote contains vote information for a round
type ProposerInfo ¶
ProposerInfo contains proposer details
type RoundState ¶
type RoundState struct {
HeightRoundStep string `json:"height/round/step"`
StartTime time.Time `json:"start_time"`
ProposalBlockHash string `json:"proposal_block_hash"`
LockedBlockHash string `json:"locked_block_hash"`
ValidBlockHash string `json:"valid_block_hash"`
HeightVoteSet []HeightVote `json:"height_vote_set"`
Proposer ProposerInfo `json:"proposer"`
}
RoundState contains the consensus round information
type State ¶
type State struct {
Height int64
Round int
Step int
StartTime time.Time
Elapsed time.Duration
ProposerAddress string
ProposerIndex int
// Vote stats
TotalValidators int
TotalVotingPower int64
// Prevote stats
PrevoteCount int
PrevotePower int64
PrevotePercent float64
PrevoteBitArray string
// Precommit stats
PrecommitCount int
PrecommitPower int64
PrecommitPercent float64
PrecommitBitArray string
// Validator list with vote status
Validators []ValidatorStatus
// Error state
Error error
}
State represents the parsed consensus state for display
func ParseConsensusState ¶
func ParseConsensusState(resp *ConsensusResponse, validators []Validator) (*State, error)
ParseConsensusState converts raw consensus data into a State struct
type Validator ¶
type Validator struct {
Address string `json:"address"`
PubKey PubKey `json:"pub_key"`
VotingPower string `json:"voting_power"`
ProposerPriority string `json:"proposer_priority"`
}
Validator represents a validator in the set
type ValidatorStatus ¶
type ValidatorStatus struct {
Index int
Address string
PubKey string // Base64 encoded consensus pubkey for moniker lookup
VotingPower int64
Prevoted bool
Precommited bool
IsProposer bool
}
ValidatorStatus represents a validator's current voting status
type ValidatorsResponse ¶
type ValidatorsResponse struct {
JSONRPC string `json:"jsonrpc"`
ID int `json:"id"`
Result struct {
BlockHeight string `json:"block_height"`
Validators []Validator `json:"validators"`
Count string `json:"count"`
Total string `json:"total"`
} `json:"result"`
}
ValidatorsResponse represents the JSON-RPC response from /validators