1
0
mirror of https://github.com/fluencelabs/tendermint synced 2025-06-25 18:51:39 +00:00
Files
DOCKER
Godeps
INSTALL
account
alert
binary
blockchain
cmd
common
config
consensus
crawler
db
events
logger
mempool
merkle
node
p2p
permission
process
rpc
client
core
types
accounts.go
blocks.go
config.go
consensus.go
log.go
mempool.go
names.go
net.go
pipe.go
routes.go
txs.go
core_client
server
test
types
scripts
state
types
vm
.gitignore
LICENSE.md
Makefile
README.md
Vagrantfile
tendermint/rpc/core/consensus.go

41 lines
1.4 KiB
Go
Raw Normal View History

package core
import (
"github.com/tendermint/tendermint/binary"
cm "github.com/tendermint/tendermint/consensus"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
2015-04-01 17:30:16 -07:00
sm "github.com/tendermint/tendermint/state"
)
func ListValidators() (*ctypes.ResponseListValidators, error) {
var blockHeight int
var bondedValidators []*sm.Validator
var unbondingValidators []*sm.Validator
state := consensusState.GetState()
blockHeight = state.LastBlockHeight
state.BondedValidators.Iterate(func(index int, val *sm.Validator) bool {
bondedValidators = append(bondedValidators, val)
return false
})
state.UnbondingValidators.Iterate(func(index int, val *sm.Validator) bool {
unbondingValidators = append(unbondingValidators, val)
return false
})
return &ctypes.ResponseListValidators{blockHeight, bondedValidators, unbondingValidators}, nil
}
func DumpConsensusState() (*ctypes.ResponseDumpConsensusState, error) {
roundState := consensusState.GetRoundState()
peerRoundStates := []string{}
for _, peer := range p2pSwitch.Peers().List() {
// TODO: clean this up?
peerState := peer.Data.Get(cm.PeerStateKey).(*cm.PeerState)
peerRoundState := peerState.GetRoundState()
peerRoundStateStr := peer.Key + ":" + string(binary.JSONBytes(peerRoundState))
peerRoundStates = append(peerRoundStates, peerRoundStateStr)
}
return &ctypes.ResponseDumpConsensusState{roundState.String(), peerRoundStates}, nil
}