]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Use smaller parameter type
authorMatt Joiner <anacrolix@gmail.com>
Thu, 8 Dec 2022 03:04:42 +0000 (14:04 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 8 Dec 2022 03:04:42 +0000 (14:04 +1100)
tracker/server.go

index e19b816a4cff56c2fda37249b6d506c8d5a51bbe..dc95bce6841c4dc4adc77def60046ad12b524df3 100644 (file)
@@ -110,7 +110,7 @@ func (me *AnnounceHandler) Serve(
        if !op.Ok && len(peers) <= 1 {
                op.Value, op.Ok = me.ongoingUpstreamAugmentations[infoHash]
                if !op.Ok {
-                       op.Set(me.augmentPeersFromUpstream(req))
+                       op.Set(me.augmentPeersFromUpstream(req.InfoHash))
                        generics.MakeMapIfNilAndSet(&me.ongoingUpstreamAugmentations, infoHash, op.Value)
                }
        }
@@ -130,10 +130,10 @@ func (me *AnnounceHandler) Serve(
        return
 }
 
-func (me *AnnounceHandler) augmentPeersFromUpstream(req AnnounceRequest) augmentationOperation {
+func (me *AnnounceHandler) augmentPeersFromUpstream(infoHash [20]byte) augmentationOperation {
        announceCtx, cancel := context.WithTimeout(context.Background(), time.Minute)
        subReq := AnnounceRequest{
-               InfoHash: req.InfoHash,
+               InfoHash: infoHash,
                PeerId:   me.UpstreamAnnouncePeerId,
                Event:    None,
                Key:      0,
@@ -168,7 +168,7 @@ func (me *AnnounceHandler) augmentPeersFromUpstream(req AnnounceRequest) augment
                                continue
                        }
                        trackReq := AnnounceRequest{
-                               InfoHash: req.InfoHash,
+                               InfoHash: infoHash,
                                Event:    Started,
                                Port:     uint16(peer.Port),
                        }
@@ -179,7 +179,7 @@ func (me *AnnounceHandler) augmentPeersFromUpstream(req AnnounceRequest) augment
                        }
                }
                me.mu.Lock()
-               delete(me.ongoingUpstreamAugmentations, req.InfoHash)
+               delete(me.ongoingUpstreamAugmentations, infoHash)
                me.mu.Unlock()
        }()
        curPeersChan := make(chan map[PeerInfo]struct{})