mirror of
https://github.com/tendermint/tendermint.git
synced 2025-12-23 14:25:19 +00:00
* Ignore generated/copied RPC docs Signed-off-by: Thane Thomson <connect@thanethomson.com> * Sync vuepress config with main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Sync docs package-lock.json with main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Sync docs redirects with main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Sync docs versions with main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update OpenAPI version to v0.34 Signed-off-by: Thane Thomson <connect@thanethomson.com> * Sync DOCS_README with main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update all v0.34.x docs references from master to main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update v0.34 OpenAPI references from master to main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update repo doc links from master to main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update code comment references from master to main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update repo root doc links from master to main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update repo root doc links for docs.tendermint.com 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> * Add nav link to main and clearly mark as unstable Signed-off-by: Thane Thomson <connect@thanethomson.com> * Direct all docs.tendermint.com links to v0.34 on v0.34.x Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update all relevant links on v0.34.x branch to be v0.34-specific Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update changelog refs to docs.tendermint.com Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update remaining GH master link to main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Sync docs build and nav config with main 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> Signed-off-by: Thane Thomson <connect@thanethomson.com>
86 lines
2.6 KiB
Go
86 lines
2.6 KiB
Go
package core
|
|
|
|
import (
|
|
"time"
|
|
|
|
tmbytes "github.com/tendermint/tendermint/libs/bytes"
|
|
"github.com/tendermint/tendermint/p2p"
|
|
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
|
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
|
|
"github.com/tendermint/tendermint/types"
|
|
)
|
|
|
|
// Status returns Tendermint status including node info, pubkey, latest block
|
|
// hash, app hash, block height and time.
|
|
// More: https://docs.tendermint.com/v0.34/rpc/#/Info/status
|
|
func Status(ctx *rpctypes.Context) (*ctypes.ResultStatus, error) {
|
|
var (
|
|
earliestBlockHeight int64
|
|
earliestBlockHash tmbytes.HexBytes
|
|
earliestAppHash tmbytes.HexBytes
|
|
earliestBlockTimeNano int64
|
|
)
|
|
|
|
if earliestBlockMeta := env.BlockStore.LoadBaseMeta(); earliestBlockMeta != nil {
|
|
earliestBlockHeight = earliestBlockMeta.Header.Height
|
|
earliestAppHash = earliestBlockMeta.Header.AppHash
|
|
earliestBlockHash = earliestBlockMeta.BlockID.Hash
|
|
earliestBlockTimeNano = earliestBlockMeta.Header.Time.UnixNano()
|
|
}
|
|
|
|
var (
|
|
latestBlockHash tmbytes.HexBytes
|
|
latestAppHash tmbytes.HexBytes
|
|
latestBlockTimeNano int64
|
|
|
|
latestHeight = env.BlockStore.Height()
|
|
)
|
|
|
|
if latestHeight != 0 {
|
|
if latestBlockMeta := env.BlockStore.LoadBlockMeta(latestHeight); latestBlockMeta != nil {
|
|
latestBlockHash = latestBlockMeta.BlockID.Hash
|
|
latestAppHash = latestBlockMeta.Header.AppHash
|
|
latestBlockTimeNano = latestBlockMeta.Header.Time.UnixNano()
|
|
}
|
|
}
|
|
|
|
// Return the very last voting power, not the voting power of this validator
|
|
// during the last block.
|
|
var votingPower int64
|
|
if val := validatorAtHeight(latestUncommittedHeight()); val != nil {
|
|
votingPower = val.VotingPower
|
|
}
|
|
|
|
result := &ctypes.ResultStatus{
|
|
NodeInfo: env.P2PTransport.NodeInfo().(p2p.DefaultNodeInfo),
|
|
SyncInfo: ctypes.SyncInfo{
|
|
LatestBlockHash: latestBlockHash,
|
|
LatestAppHash: latestAppHash,
|
|
LatestBlockHeight: latestHeight,
|
|
LatestBlockTime: time.Unix(0, latestBlockTimeNano),
|
|
EarliestBlockHash: earliestBlockHash,
|
|
EarliestAppHash: earliestAppHash,
|
|
EarliestBlockHeight: earliestBlockHeight,
|
|
EarliestBlockTime: time.Unix(0, earliestBlockTimeNano),
|
|
CatchingUp: env.ConsensusReactor.WaitSync(),
|
|
},
|
|
ValidatorInfo: ctypes.ValidatorInfo{
|
|
Address: env.PubKey.Address(),
|
|
PubKey: env.PubKey,
|
|
VotingPower: votingPower,
|
|
},
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
func validatorAtHeight(h int64) *types.Validator {
|
|
vals, err := env.StateStore.LoadValidators(h)
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
privValAddress := env.PubKey.Address()
|
|
_, val := vals.GetByAddress(privValAddress)
|
|
return val
|
|
}
|