Skip to content

Commit

Permalink
go/control/GetStatus: include the latest epoch
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrus committed Mar 4, 2021
1 parent dde272f commit a48fd73
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions .changelog/3743.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go/control/GetStatus: include the latest epoch
2 changes: 2 additions & 0 deletions go/consensus/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ type Status struct { // nolint: maligned
LatestHash []byte `json:"latest_hash"`
// LatestTime is the timestamp of the latest block.
LatestTime time.Time `json:"latest_time"`
// LatestEpoch is the epoch of the latest block.
LatestEpoch beacon.EpochTime `json:"latest_epoch"`
// LatestStateRoot is the Merkle root of the consensus state tree.
LatestStateRoot mkvsNode.Root `json:"latest_state_root"`

Expand Down
5 changes: 5 additions & 0 deletions go/consensus/tendermint/full/full.go
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,11 @@ func (t *fullService) GetStatus(ctx context.Context) (*consensusAPI.Status, erro
status.LatestHash = latestBlk.Hash
status.LatestTime = latestBlk.Time
status.LatestStateRoot = latestBlk.StateRoot
epoch, err := t.beacon.GetEpoch(ctx, status.LatestHeight)
if err != nil {
return nil, fmt.Errorf("failed to fetch epoch: %w", err)
}
status.LatestEpoch = epoch
case consensusAPI.ErrNoCommittedBlocks:
// No committed blocks yet.
default:
Expand Down

0 comments on commit a48fd73

Please sign in to comment.