Commit 5b77b660 authored by Steven Allen's avatar Steven Allen

bitswap: fewer allocations in bitswap sessions

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

License: MIT
Signed-off-by: default avatarSteven Allen <steven@stebalien.com>
parent 3b80bf49
...@@ -199,11 +199,12 @@ func (s *Session) run(ctx context.Context) { ...@@ -199,11 +199,12 @@ func (s *Session) run(ctx context.Context) {
s.cancel(keys) s.cancel(keys)
case <-s.tick.C: case <-s.tick.C:
var live []*cid.Cid live := make([]*cid.Cid, 0, len(s.liveWants))
now := time.Now()
for c := range s.liveWants { for c := range s.liveWants {
cs, _ := cid.Cast([]byte(c)) cs, _ := cid.Cast([]byte(c))
live = append(live, cs) live = append(live, cs)
s.liveWants[c] = time.Now() s.liveWants[c] = now
} }
// Broadcast these keys to everyone we're connected to // Broadcast these keys to everyone we're connected to
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment