]> Sergey Matveev's repositories - btrtrc.git/commitdiff
gofumpt
authorMatt Joiner <anacrolix@gmail.com>
Sat, 18 Feb 2023 07:35:22 +0000 (18:35 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Sat, 18 Feb 2023 07:35:22 +0000 (18:35 +1100)
client_test.go
cmd/torrent/download.go
metainfo/piece-length.go
misc.go
request-strategy/order.go
storage/mmap.go
tracker/http/client.go
webtorrent/tracker-client.go
webtorrent/transport_test.go

index 65182d58be84bfe5a880ab2071f2525e5dfee851..03851ae88d8712c4293545604ab97e7935f273e3 100644 (file)
@@ -808,7 +808,7 @@ func TestBadPeerIpPort(t *testing.T) {
                        true,
                        func(cl *Client) {
                                cl.ipBlockList = iplist.New([]iplist.Range{
-                                       iplist.Range{First: net.ParseIP("10.0.0.1"), Last: net.ParseIP("10.0.0.255")},
+                                       {First: net.ParseIP("10.0.0.1"), Last: net.ParseIP("10.0.0.255")},
                                })
                        },
                },
@@ -845,5 +845,4 @@ func TestBadPeerIpPort(t *testing.T) {
                        require.Equal(t, tc.expectedOk, cl.badPeerIPPort(tc.ip, tc.port))
                })
        }
-
 }
index 1f2fbc89ff7c1ae57004afb595908c07509d9a13..0ec4b99088250bc37cae52daf60c9791155519bc 100644 (file)
@@ -221,7 +221,7 @@ func waitForPieces(ctx context.Context, t *torrent.Torrent, beginIndex, endIndex
 }
 
 func writeMetainfoToFile(mi metainfo.MetaInfo, path string) error {
-       f, err := os.OpenFile(path, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0640)
+       f, err := os.OpenFile(path, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0o640)
        if err != nil {
                return err
        }
index 9835dc5b2fbeae4c287abe5803fccd5b932ba8f3..183b4d86ff4196626c75cff62b3c878f98c1871c 100644 (file)
 package metainfo
 
 // For more context on why these numbers, see http://wiki.vuze.com/w/Torrent_Piece_Size
-const minimumPieceLength = 16 * 1024
-const targetPieceCountLog2 = 10
-const targetPieceCountMin = 1 << targetPieceCountLog2
+const (
+       minimumPieceLength   = 16 * 1024
+       targetPieceCountLog2 = 10
+       targetPieceCountMin  = 1 << targetPieceCountLog2
+)
 
 // Target piece count should be < targetPieceCountMax
 const targetPieceCountMax = targetPieceCountMin << 1
diff --git a/misc.go b/misc.go
index 99345fe70f5fdf26f8c00494ed31055a0df1faff..7d3007ecee74eb92f58eee434dfb9431a86f9098 100644 (file)
--- a/misc.go
+++ b/misc.go
@@ -115,7 +115,8 @@ func connLessTrusted(l, r *Peer) bool {
 
 func connIsIpv6(nc interface {
        LocalAddr() net.Addr
-}) bool {
+},
+) bool {
        ra := nc.LocalAddr()
        rip := addrIpOrNil(ra)
        return rip.To4() == nil && rip.To16() != nil
index b009a10882e84eb9a235345b64f70cd2f2631f15..6c134be1d333e19ff43f523da1c4d485dde5bbed 100644 (file)
@@ -66,7 +66,7 @@ func GetRequestablePieces(
                lastItem.Set(_i)
 
                ih := _i.key.InfoHash
-               var t = input.Torrent(ih)
+               t := input.Torrent(ih)
                pieceLength := t.PieceLength()
                if storageLeft != nil {
                        if *storageLeft < pieceLength {
index a9d922ac20146b2fa11db8c4ea2497f210e7d73a..00b2721c1199767d5f9982d2f243820a6fb325a4 100644 (file)
@@ -71,6 +71,7 @@ func (ts *mmapTorrentStorage) Close() error {
        }
        return nil
 }
+
 func (ts *mmapTorrentStorage) Flush() error {
        errs := ts.span.Flush()
        if len(errs) > 0 {
index 1716b44c8a80781540ee1f0ecf827ebbb84c6216..c6b06fc10dcc5a3f47c89d27a2a84c5a75229d01 100644 (file)
@@ -13,8 +13,10 @@ type Client struct {
        url_ *url.URL
 }
 
-type ProxyFunc func(*http.Request) (*url.URL, error)
-type DialContextFunc func(ctx context.Context, network, addr string) (net.Conn, error)
+type (
+       ProxyFunc       func(*http.Request) (*url.URL, error)
+       DialContextFunc func(ctx context.Context, network, addr string) (net.Conn, error)
+)
 
 type NewClientOpts struct {
        Proxy          ProxyFunc
index 60cd852773e524c8d9d130b16c9fc5005e43c32c..97b9b6211aa744bd09a19d8cc5527ee671f2f578 100644 (file)
@@ -233,14 +233,16 @@ func (tc *TrackerClient) Announce(event tracker.AnnounceEvent, infoHash [20]byte
                return fmt.Errorf("creating offer: %w", err)
        }
 
-       err = tc.announce(event, infoHash, []outboundOffer{{
-               offerId: offerIDBinary,
-               outboundOfferValue: outboundOfferValue{
-                       originalOffer:  offer,
-                       peerConnection: pc,
-                       infoHash:       infoHash,
-                       dataChannel:    dc,
-               }},
+       err = tc.announce(event, infoHash, []outboundOffer{
+               {
+                       offerId: offerIDBinary,
+                       outboundOfferValue: outboundOfferValue{
+                               originalOffer:  offer,
+                               peerConnection: pc,
+                               infoHash:       infoHash,
+                               dataChannel:    dc,
+                       },
+               },
        })
        if err != nil {
                dc.Close()
index b993487dd5d6373775b1ef2617bb49b4d03b47aa..c17328e8dd410a352436a014d19175f8d52be6a1 100644 (file)
@@ -1,10 +1,11 @@
 package webtorrent
 
 import (
+       "testing"
+
        "github.com/anacrolix/log"
        qt "github.com/frankban/quicktest"
        "github.com/pion/webrtc/v3"
-       "testing"
 )
 
 func TestClosingPeerConnectionDoesNotCloseUnopenedDataChannel(t *testing.T) {