mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-10 15:07:24 +00:00
* Update docs references from master to main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update DOCS_README to reflect current reality Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update vuepress config with current versions and updated discussions link Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update generated docs versions Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update docs build to use temp folder instead of home Signed-off-by: Thane Thomson <connect@thanethomson.com> * Document build-docs Makefile target Signed-off-by: Thane Thomson <connect@thanethomson.com> * Add serve-docs Makefile target to serve local build of docs Signed-off-by: Thane Thomson <connect@thanethomson.com> * Ensure 404 page is copied during docs build Signed-off-by: Thane Thomson <connect@thanethomson.com> * Redirect /master/ to /main/ Signed-off-by: Thane Thomson <connect@thanethomson.com> * Attempt to resolve #7908 Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update OpenAPI references from master to main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update CHANGELOG references from master to main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update Docker readme references from master to main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update UPGRADING references from master to main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update package-specific documentation references from master to main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update spec references from master to main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update all code comment references to docs site from master to main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Build v0.34.x as "latest" Signed-off-by: Thane Thomson <connect@thanethomson.com> * Explicitly mark v0.34 docs as latest in version selector Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update all links from docs.tendermint.com/main to docs.tendermint.com/latest Signed-off-by: Thane Thomson <connect@thanethomson.com> * ci: Redeploy docs on pushes to v0.34.x Signed-off-by: Thane Thomson <connect@thanethomson.com> * Temporarily copy spec directory into docs while building Signed-off-by: Thane Thomson <connect@thanethomson.com> * Add nav link to main and clearly mark as unstable Signed-off-by: Thane Thomson <connect@thanethomson.com> * Revert to only publishing docs in nav for v0.34 and v0.33 with no latest Signed-off-by: Thane Thomson <connect@thanethomson.com> * Link to docs.tendermint.com/v0.34 from RFCs Signed-off-by: Thane Thomson <connect@thanethomson.com> * Rather just use main for all docs.tendermint.com references on main branch Signed-off-by: Thane Thomson <connect@thanethomson.com> * Rename GitHub tree links from master to main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update link for ABCI Rust client Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update github links from master to main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update badges in root readme Signed-off-by: Thane Thomson <connect@thanethomson.com> * Remove codecov badge since we do not use it any more Signed-off-by: Thane Thomson <connect@thanethomson.com> * Remove Java and Kotlin tutorials Signed-off-by: Thane Thomson <connect@thanethomson.com> * Remove specs from docs build Signed-off-by: Thane Thomson <connect@thanethomson.com> * Migrate spec links to GitHub repo from docs site Signed-off-by: Thane Thomson <connect@thanethomson.com> * Remove references to non-existent PEX reactor spec Signed-off-by: Thane Thomson <connect@thanethomson.com> * Fix linting badge in README Signed-off-by: Thane Thomson <connect@thanethomson.com> Signed-off-by: Thane Thomson <connect@thanethomson.com>
109 lines
3.5 KiB
Go
109 lines
3.5 KiB
Go
package core
|
|
|
|
import (
|
|
cm "github.com/tendermint/tendermint/consensus"
|
|
tmmath "github.com/tendermint/tendermint/libs/math"
|
|
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
|
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
|
|
"github.com/tendermint/tendermint/types"
|
|
)
|
|
|
|
// Validators gets the validator set at the given block height.
|
|
//
|
|
// If no height is provided, it will fetch the latest validator set. Note the
|
|
// validators are sorted by their voting power - this is the canonical order
|
|
// for the validators in the set as used in computing their Merkle root.
|
|
//
|
|
// More: https://docs.tendermint.com/main/rpc/#/Info/validators
|
|
func Validators(ctx *rpctypes.Context, heightPtr *int64, pagePtr, perPagePtr *int) (*ctypes.ResultValidators, error) {
|
|
// The latest validator that we know is the NextValidator of the last block.
|
|
height, err := getHeight(latestUncommittedHeight(), heightPtr)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
validators, err := env.StateStore.LoadValidators(height)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
totalCount := len(validators.Validators)
|
|
perPage := validatePerPage(perPagePtr)
|
|
page, err := validatePage(pagePtr, perPage, totalCount)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
skipCount := validateSkipCount(page, perPage)
|
|
|
|
v := validators.Validators[skipCount : skipCount+tmmath.MinInt(perPage, totalCount-skipCount)]
|
|
|
|
return &ctypes.ResultValidators{
|
|
BlockHeight: height,
|
|
Validators: v,
|
|
Count: len(v),
|
|
Total: totalCount}, nil
|
|
}
|
|
|
|
// DumpConsensusState dumps consensus state.
|
|
// UNSTABLE
|
|
// More: https://docs.tendermint.com/main/rpc/#/Info/dump_consensus_state
|
|
func DumpConsensusState(ctx *rpctypes.Context) (*ctypes.ResultDumpConsensusState, error) {
|
|
// Get Peer consensus states.
|
|
peers := env.P2PPeers.Peers().List()
|
|
peerStates := make([]ctypes.PeerStateInfo, len(peers))
|
|
for i, peer := range peers {
|
|
peerState, ok := peer.Get(types.PeerStateKey).(*cm.PeerState)
|
|
if !ok { // peer does not have a state yet
|
|
continue
|
|
}
|
|
peerStateJSON, err := peerState.ToJSON()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
peerStates[i] = ctypes.PeerStateInfo{
|
|
// Peer basic info.
|
|
NodeAddress: peer.SocketAddr().String(),
|
|
// Peer consensus state.
|
|
PeerState: peerStateJSON,
|
|
}
|
|
}
|
|
// Get self round state.
|
|
roundState, err := env.ConsensusState.GetRoundStateJSON()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &ctypes.ResultDumpConsensusState{
|
|
RoundState: roundState,
|
|
Peers: peerStates}, nil
|
|
}
|
|
|
|
// ConsensusState returns a concise summary of the consensus state.
|
|
// UNSTABLE
|
|
// More: https://docs.tendermint.com/main/rpc/#/Info/consensus_state
|
|
func ConsensusState(ctx *rpctypes.Context) (*ctypes.ResultConsensusState, error) {
|
|
// Get self round state.
|
|
bz, err := env.ConsensusState.GetRoundStateSimpleJSON()
|
|
return &ctypes.ResultConsensusState{RoundState: bz}, err
|
|
}
|
|
|
|
// ConsensusParams gets the consensus parameters at the given block height.
|
|
// If no height is provided, it will fetch the latest consensus params.
|
|
// More: https://docs.tendermint.com/main/rpc/#/Info/consensus_params
|
|
func ConsensusParams(ctx *rpctypes.Context, heightPtr *int64) (*ctypes.ResultConsensusParams, error) {
|
|
// The latest consensus params that we know is the consensus params after the
|
|
// last block.
|
|
height, err := getHeight(latestUncommittedHeight(), heightPtr)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
consensusParams, err := env.StateStore.LoadConsensusParams(height)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &ctypes.ResultConsensusParams{
|
|
BlockHeight: height,
|
|
ConsensusParams: consensusParams}, nil
|
|
}
|