mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-26 15:42:21 +08:00
bitswap: fewer allocations in bitswap sessions
Also, don't call time.Now in a loop. License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user