From: Matt Joiner Date: Thu, 8 Dec 2022 03:04:42 +0000 (+1100) Subject: Use smaller parameter type X-Git-Tag: v1.49.0~7^2~24 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=1028161833bb73c171b9bf5a70d5b6201478b707;p=btrtrc.git Use smaller parameter type --- diff --git a/tracker/server.go b/tracker/server.go index e19b816a..dc95bce6 100644 --- a/tracker/server.go +++ b/tracker/server.go @@ -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{})