Skip to content

Commit

Permalink
go tendermint: don't try to access the block before block 1
Browse files Browse the repository at this point in the history
  • Loading branch information
pro-wh committed Aug 21, 2019
1 parent e0d0326 commit fed43d3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions go/tendermint/abci/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,17 @@ func (s *ApplicationState) EpochChanged(timeSource epochtime.Backend) (bool, epo
blockHeight := s.BlockHeight()
if blockHeight == 0 {
return false, epochtime.EpochInvalid
} else if blockHeight == 1 {
// There is no block before the first block. For historic reasons, this is defined as not
// having had a transition.
currentEpoch, err := timeSource.GetEpoch(s.ctx, blockHeight)
if err != nil {
s.logger.Error("EpochChanged: failed to get current epoch",
"err", err,
)
return false, epochtime.EpochInvalid
}
return false, currentEpoch
}

previousEpoch, err := timeSource.GetEpoch(s.ctx, blockHeight-1)
Expand Down

0 comments on commit fed43d3

Please sign in to comment.