Skip to content

Commit d7c5033

Browse files
committed
feat(store): add MinerMeta to context
1 parent b0e0e0f commit d7c5033

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package miner
2+
3+
import "context"
4+
5+
type MinerMeta struct {
6+
ID uint64 // minerID
7+
}
8+
9+
type minerKey struct{}
10+
11+
// NewContext creates a new context with MinerMeta attached.
12+
func NewContext(ctx context.Context, p *MinerMeta) context.Context {
13+
return context.WithValue(ctx, minerKey{}, p)
14+
}
15+
16+
// FromContext returns the MinerMeta in ctx if it exists.
17+
func FromContext(ctx context.Context) (miner *MinerMeta, ok bool) {
18+
miner, ok = ctx.Value(minerKey{}).(*MinerMeta)
19+
return
20+
}

manager-plugin/objstore/objstore.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,11 @@ type Store interface {
8585
InstanceInfo(ctx context.Context) (InstanceInfo, error)
8686

8787
// Get returns an io.ReadCloser object for reading the file corresponding to the resourceName from this store.
88-
// the resourceName value looks like this:
89-
// - "cache/sc-02-data-tree-r-last.dat"
88+
// the resourceName value looks like these:
89+
// - "cache/s-t010001-1/sc-02-data-tree-r-last-0.dat"
90+
// - "update-cache/s-t010001-1/sc-02-data-tree-r-last-0.dat"
91+
// - "sealed/s-t010001-101"
92+
// - "update/s-t010001-101"
9093
Get(ctx context.Context, resourceName string) (io.ReadCloser, error)
9194
// Del removes the file corresponding to given resourceName from this store
9295
Del(ctx context.Context, resourceName string) error

0 commit comments

Comments
 (0)