lotus/blockstore/context.go

22 lines
547 B
Go
Raw Normal View History

2022-02-04 14:07:58 +00:00
package blockstore
import (
"context"
)
type hotViewKey struct{}
var hotView = hotViewKey{}
// WithHotView constructs a new context with an option that provides a hint to the blockstore
// (e.g. the splitstore) that the object (and its ipld references) should be kept hot.
func WithHotView(ctx context.Context) context.Context {
return context.WithValue(ctx, hotView, struct{}{})
}
2022-02-14 14:03:17 +00:00
// IsHotView returns true if the hot view option is set in the context
func IsHotView(ctx context.Context) bool {
2022-02-04 14:07:58 +00:00
v := ctx.Value(hotView)
return v != nil
}