client.go | 28 ++++++++++++++-------------- diff --git a/client.go b/client.go index 81a7936b3b48dda103450140f0dde68b378390af..5ae32af67d99042af1451d42f31587be511414e3 100644 --- a/client.go +++ b/client.go @@ -851,6 +851,20 @@ } } func (cl *Client) sendInitialMessages(conn *connection, torrent *Torrent) { + func() { + if conn.fastEnabled() { + if torrent.haveAllPieces() { + conn.Post(pp.Message{Type: pp.HaveAll}) + conn.sentHaves.AddRange(0, conn.t.NumPieces()) + return + } else if !torrent.haveAnyPieces() { + conn.Post(pp.Message{Type: pp.HaveNone}) + conn.sentHaves.Clear() + return + } + } + conn.PostBitfield() + }() if conn.PeerExtensionBytes.SupportsExtended() && cl.extensionBytes.SupportsExtended() { conn.Post(pp.Message{ Type: pp.Extended, @@ -893,20 +907,6 @@ return b }(), }) } - func() { - if conn.fastEnabled() { - if torrent.haveAllPieces() { - conn.Post(pp.Message{Type: pp.HaveAll}) - conn.sentHaves.AddRange(0, conn.t.NumPieces()) - return - } else if !torrent.haveAnyPieces() { - conn.Post(pp.Message{Type: pp.HaveNone}) - conn.sentHaves.Clear() - return - } - } - conn.PostBitfield() - }() if conn.PeerExtensionBytes.SupportsDHT() && cl.extensionBytes.SupportsDHT() && cl.dHT != nil { conn.Post(pp.Message{ Type: pp.Port,