Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pkg/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ func (a *App) RefreshChainInfo() {
chainInfo, err := a.Aggregator.GetChainInfo()
if err != nil {
a.Logger.Error().Err(err).Msg("Error getting chain validators")
a.State.SetChainInfoError(err)
a.State.SetStatusError(err)
a.DisplayWrapper.SetState(a.State)
return
}

a.State.SetChainInfo(&chainInfo.Result)
a.State.SetChainInfoError(err)
a.State.SetNodeStatus(&chainInfo.Result)
a.State.SetStatusError(err)
a.DisplayWrapper.SetState(a.State)
}

Expand Down
21 changes: 17 additions & 4 deletions pkg/display/all_rounds_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import (
type AllRoundsTableData struct {
tview.TableContentReadOnly

Validators types.ValidatorsWithInfoAndAllRoundVotes
DisableEmojis bool
Transpose bool
Validators types.ValidatorsWithInfoAndAllRoundVotes
CurrentValidatorAddress string
DisableEmojis bool
Transpose bool

cells [][]*tview.TableCell
mutex sync.Mutex
Expand Down Expand Up @@ -63,12 +64,20 @@ func (d *AllRoundsTableData) GetColumnCount() int {
return len(d.cells[0])
}

func (d *AllRoundsTableData) SetValidators(validators types.ValidatorsWithInfoAndAllRoundVotes) {
func (d *AllRoundsTableData) SetValidators(
validators types.ValidatorsWithInfoAndAllRoundVotes,
statusResult *types.TendermintStatusResult,
) {
if d.Validators.Equals(validators) {
return
}

d.Validators = validators

if statusResult != nil {
d.CurrentValidatorAddress = statusResult.ValidatorInfo.Address
}

d.redrawCells()
}

Expand Down Expand Up @@ -124,6 +133,10 @@ func (d *AllRoundsTableData) redrawCells() {
cell.SetBackgroundColor(tcell.ColorForestGreen)
}

if roundVote.Address == d.CurrentValidatorAddress {
cell.SetBackgroundColor(tcell.ColorMediumTurquoise)
}

d.cells[row][column] = cell
}
}
Expand Down
26 changes: 20 additions & 6 deletions pkg/display/last_round_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ import (
type LastRoundTableData struct {
tview.TableContentReadOnly

Validators types.ValidatorsWithInfo
ConsensusError error
ColumnsCount int
DisableEmojis bool
Transpose bool
Validators types.ValidatorsWithInfo
CurrentValidatorAddress string
ConsensusError error
ColumnsCount int
DisableEmojis bool
Transpose bool

cells [][]*tview.TableCell
mutex sync.Mutex
Expand Down Expand Up @@ -76,9 +77,18 @@ func (d *LastRoundTableData) GetColumnCount() int {
return len(d.cells[0])
}

func (d *LastRoundTableData) SetValidators(validators types.ValidatorsWithInfo, consensusError error) {
func (d *LastRoundTableData) SetValidators(
validators types.ValidatorsWithInfo,
consensusError error,
statusResult *types.TendermintStatusResult,
) {
d.Validators = validators
d.ConsensusError = consensusError

if statusResult != nil {
d.CurrentValidatorAddress = statusResult.ValidatorInfo.Address
}

d.redrawData()
}

Expand Down Expand Up @@ -125,6 +135,10 @@ func (d *LastRoundTableData) redrawData() {
cell.SetBackgroundColor(tcell.ColorForestGreen)
}

if index < len(d.Validators) && d.Validators[index].Validator.Address == d.CurrentValidatorAddress {
cell.SetBackgroundColor(tcell.ColorMediumTurquoise)
}

d.cells[row][column] = cell
}
}
Expand Down
11 changes: 9 additions & 2 deletions pkg/display/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,15 @@ func (w *Wrapper) ToggleHelp() {
}

func (w *Wrapper) SetState(state *types.State) {
w.LastRoundTableData.SetValidators(state.GetValidatorsWithInfo(), state.ConsensusStateError)
w.AllRoundsTableData.SetValidators(state.GetValidatorsWithInfoAndAllRoundVotes())
w.LastRoundTableData.SetValidators(
state.GetValidatorsWithInfo(),
state.ConsensusStateError,
state.NodeStatus,
)
w.AllRoundsTableData.SetValidators(
state.GetValidatorsWithInfoAndAllRoundVotes(),
state.NodeStatus,
)

w.ConsensusInfoTextView.Clear()
w.ChainInfoTextView.Clear()
Expand Down
22 changes: 11 additions & 11 deletions pkg/types/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type State struct {
Validators *ValidatorsWithRoundVote
ValidatorsWithAllRoundsVotes *ValidatorsWithAllRoundsVotes
ChainValidators *ChainValidators
ChainInfo *TendermintStatusResult
NodeStatus *TendermintStatusResult
StartTime time.Time
Upgrade *Upgrade
BlockTime time.Duration
Expand All @@ -23,7 +23,7 @@ type State struct {
ValidatorsError error
ChainValidatorsError error
UpgradePlanError error
ChainInfoError error
StatusError error
}

func NewState() *State {
Expand Down Expand Up @@ -70,8 +70,8 @@ func (s *State) SetChainValidators(validators *ChainValidators) {
s.ChainValidators = validators
}

func (s *State) SetChainInfo(info *TendermintStatusResult) {
s.ChainInfo = info
func (s *State) SetNodeStatus(status *TendermintStatusResult) {
s.NodeStatus = status
}

func (s *State) SetUpgrade(upgrade *Upgrade) {
Expand All @@ -94,8 +94,8 @@ func (s *State) SetUpgradePlanError(err error) {
s.UpgradePlanError = err
}

func (s *State) SetChainInfoError(err error) {
s.ChainInfoError = err
func (s *State) SetStatusError(err error) {
s.StatusError = err
}

func (s *State) SerializeConsensus(timezone *time.Location) string {
Expand Down Expand Up @@ -169,11 +169,11 @@ func (s *State) SerializeConsensus(timezone *time.Location) string {
func (s *State) SerializeChainInfo(timezone *time.Location) string {
var sb strings.Builder

if s.ChainInfoError != nil {
sb.WriteString(fmt.Sprintf(" chain info fetch error: %s\n", s.ChainInfoError.Error()))
} else if s.ChainInfo != nil {
sb.WriteString(fmt.Sprintf(" chain name: %s\n", s.ChainInfo.NodeInfo.Network))
sb.WriteString(fmt.Sprintf(" tendermint version: v%s\n", s.ChainInfo.NodeInfo.Version))
if s.StatusError != nil {
sb.WriteString(fmt.Sprintf(" chain info fetch error: %s\n", s.StatusError.Error()))
} else if s.NodeStatus != nil {
sb.WriteString(fmt.Sprintf(" chain name: %s\n", s.NodeStatus.NodeInfo.Network))
sb.WriteString(fmt.Sprintf(" tendermint version: v%s\n", s.NodeStatus.NodeInfo.Version))

if s.BlockTime != 0 {
sb.WriteString(fmt.Sprintf(" avg block time: %s\n", utils.SerializeDuration(s.BlockTime)))
Expand Down
7 changes: 6 additions & 1 deletion pkg/types/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ type TendermintStatusResponse struct {
}

type TendermintStatusResult struct {
NodeInfo TendermintNodeInfo `json:"node_info"`
NodeInfo TendermintNodeInfo `json:"node_info"`
ValidatorInfo TendermintValidatorInfo `json:"validator_info"`
}

type TendermintNodeInfo struct {
Version string `json:"version"`
Network string `json:"network"`
}

type TendermintValidatorInfo struct {
Address string `json:"address"`
}
Loading