Skip to content

Commit

Permalink
Merge pull request #6008 from filecoin-project/opt/elvindu/check-epoc…
Browse files Browse the repository at this point in the history
…h-negative-GetTipsetByHeight

check if epoch is negative in GetTipsetByHeight()/ 检查epoch 是否是负数在GetTipsetByHeight()方法
  • Loading branch information
simlecode authored Jun 6, 2023
2 parents b5b9834 + c2b12a4 commit 48bdd30
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/chain/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,14 @@ func (store *Store) GetTipSet(ctx context.Context, key types.TipSetKey) (*types.
}

// GetTipSetByHeight looks back for a tipset at the specified epoch.
// If there are no blocks at the specified epoch, a tipset at an earlier epoch
// will be returned.
// In the case that the given height is a null round, the 'prev' flag
// selects the tipset before the null round if true, and the tipset following
// the null round if false.
func (store *Store) GetTipSetByHeight(ctx context.Context, ts *types.TipSet, h abi.ChainEpoch, prev bool) (*types.TipSet, error) {
if h < 0 {
return nil, fmt.Errorf("height %d is negative", h)
}

if ts == nil {
ts = store.head
}
Expand Down

0 comments on commit 48bdd30

Please sign in to comment.