Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check if epoch is negative in GetTipsetByHeight()/ 检查epoch 是否是负数在GetTipsetByHeight()方法 #6008

Merged
Merged
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
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