Misc good fixes
This commit is contained in:
parent
d430cf9ec9
commit
76f83e60b2
11
client.go
11
client.go
@ -849,7 +849,7 @@ func (me *Client) peerGotPiece(t *torrent, c *connection, piece int) {
|
|||||||
c.PeerPieces = append(c.PeerPieces, false)
|
c.PeerPieces = append(c.PeerPieces, false)
|
||||||
}
|
}
|
||||||
c.PeerPieces[piece] = true
|
c.PeerPieces[piece] = true
|
||||||
if !t.havePiece(piece) {
|
if t.wantPiece(piece) {
|
||||||
me.replenishConnRequests(t, c)
|
me.replenishConnRequests(t, c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -956,6 +956,8 @@ func (cl *Client) gotMetadataExtensionMsg(payload []byte, t *torrent, c *connect
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
t.SaveMetadataPiece(piece, payload[begin:])
|
t.SaveMetadataPiece(piece, payload[begin:])
|
||||||
|
c.UsefulChunksReceived++
|
||||||
|
c.lastUsefulChunkReceived = time.Now()
|
||||||
if !t.HaveAllMetadataPieces() {
|
if !t.HaveAllMetadataPieces() {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -1326,6 +1328,8 @@ func (cl *Client) setMetaData(t *torrent, md metainfo.Info, bytes []byte) (err e
|
|||||||
}
|
}
|
||||||
|
|
||||||
cl.downloadStrategy.TorrentStarted(t)
|
cl.downloadStrategy.TorrentStarted(t)
|
||||||
|
// TODO(anacrolix): I think this should be made available as a method, the
|
||||||
|
// channel only acts as a signal that the metadata has become available.
|
||||||
select {
|
select {
|
||||||
case t.gotMetainfo <- &metainfo.MetaInfo{
|
case t.gotMetainfo <- &metainfo.MetaInfo{
|
||||||
Info: metainfo.InfoEx{
|
Info: metainfo.InfoEx{
|
||||||
@ -1365,6 +1369,11 @@ func newTorrent(ih InfoHash, announceList [][]string, halfOpenLimit int) (t *tor
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// For shuffling the tracker tiers.
|
||||||
|
mathRand.Seed(time.Now().Unix())
|
||||||
|
}
|
||||||
|
|
||||||
// The trackers within each tier must be shuffled before use.
|
// The trackers within each tier must be shuffled before use.
|
||||||
// http://stackoverflow.com/a/12267471/149482
|
// http://stackoverflow.com/a/12267471/149482
|
||||||
// http://www.bittorrent.org/beps/bep_0012.html#order-of-processing
|
// http://www.bittorrent.org/beps/bep_0012.html#order-of-processing
|
||||||
|
Loading…
x
Reference in New Issue
Block a user