提交 93151d4c 作者: Steven Allen

bitswap: fewer allocations in bitswap sessions

Also, don't call time.Now in a loop.

License: MIT
Signed-off-by: 's avatarSteven Allen <steven@stebalien.com>
上级 15c73418
......@@ -199,11 +199,12 @@ func (s *Session) run(ctx context.Context) {
s.cancel(keys)
case <-s.tick.C:
var live []*cid.Cid
live := make([]*cid.Cid, 0, len(s.liveWants))
now := time.Now()
for c := range s.liveWants {
cs, _ := cid.Cast([]byte(c))
live = append(live, cs)
s.liveWants[c] = time.Now()
s.liveWants[c] = now
}
// Broadcast these keys to everyone we're connected to
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论