提交 81a67338 作者: Brian Tiger Chow

fix(bitswap) remove peerstore

上级 b31f7281
...@@ -18,7 +18,6 @@ func NewSessionGenerator( ...@@ -18,7 +18,6 @@ func NewSessionGenerator(
net tn.Network) SessionGenerator { net tn.Network) SessionGenerator {
ctx, cancel := context.WithCancel(context.TODO()) ctx, cancel := context.WithCancel(context.TODO())
return SessionGenerator{ return SessionGenerator{
ps: peer.NewPeerstore(),
net: net, net: net,
seq: 0, seq: 0,
ctx: ctx, // TODO take ctx as param to Next, Instances ctx: ctx, // TODO take ctx as param to Next, Instances
...@@ -30,7 +29,6 @@ func NewSessionGenerator( ...@@ -30,7 +29,6 @@ func NewSessionGenerator(
type SessionGenerator struct { type SessionGenerator struct {
seq int seq int
net tn.Network net tn.Network
ps peer.Peerstore
ctx context.Context ctx context.Context
cancel context.CancelFunc cancel context.CancelFunc
} }
...@@ -42,7 +40,7 @@ func (g *SessionGenerator) Close() error { ...@@ -42,7 +40,7 @@ func (g *SessionGenerator) Close() error {
func (g *SessionGenerator) Next() Instance { func (g *SessionGenerator) Next() Instance {
g.seq++ g.seq++
return session(g.ctx, g.net, g.ps, peer.ID(g.seq)) return session(g.ctx, g.net, peer.ID(g.seq))
} }
func (g *SessionGenerator) Instances(n int) []Instance { func (g *SessionGenerator) Instances(n int) []Instance {
...@@ -75,7 +73,7 @@ func (i *Instance) SetBlockstoreLatency(t time.Duration) time.Duration { ...@@ -75,7 +73,7 @@ func (i *Instance) SetBlockstoreLatency(t time.Duration) time.Duration {
// NB: It's easy make mistakes by providing the same peer ID to two different // NB: It's easy make mistakes by providing the same peer ID to two different
// sessions. To safeguard, use the SessionGenerator to generate sessions. It's // sessions. To safeguard, use the SessionGenerator to generate sessions. It's
// just a much better idea. // just a much better idea.
func session(ctx context.Context, net tn.Network, ps peer.Peerstore, p peer.ID) Instance { func session(ctx context.Context, net tn.Network, p peer.ID) Instance {
adapter := net.Adapter(p) adapter := net.Adapter(p)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论