You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
320 B
18 lines
320 B
2 years ago
|
package selector
|
||
|
|
||
|
import "context"
|
||
|
|
||
|
type peerKey struct {
|
||
|
}
|
||
|
type Peer struct {
|
||
|
Node
|
||
|
}
|
||
|
|
||
|
func NewPeerContext(ctx context.Context, node *Peer) context.Context {
|
||
|
return context.WithValue(ctx, peerKey{}, node)
|
||
|
}
|
||
|
func FromPeerContext(ctx context.Context) (p *Peer, ok bool) {
|
||
|
p, ok = ctx.Value(peerKey{}).(*Peer)
|
||
|
return
|
||
|
}
|