Open AskAlexSharov opened 2 months ago
Probably this code if downloading && t.Complete.Bool() {
in mainLoop
is also buggy by same reason.
Maybe let's remove d.downloading
? And new completeness markers in db
We can do this. It will just re-introduce premature downloader completion.
The underlying issue here is that Torrent.Complete is itself unreliable.
I think a better way of doing this is to examine. Torrent._completedPieces which is the actual source of truth and doesn't depend on the torrent code remembering to update Complete - which I don't think it always does correctly.
Lets wee what bugs emerge from re-testing post this change.
Or use:
func (t *Torrent) pieceCompleteUncached(piece pieceIndex) storage.Completion {
if t.storage == nil {
return storage.Completion{Complete: false, Ok: true}
}
return t.pieces[piece].Storage().Completion()
}
for all pieces. Which may be too slow.
The problem is likely to result from this code:
func (t *Torrent) haveAllPieces() bool {
if !t.haveInfo() {
return false
}
return t._completedPieces.GetCardinality() == bitmap.BitRange(t.numPieces())
}
Returning true when it should be false.
But I don't know when this happens
Existing node (has all files) already executing blocks - but still see much debug logs from downloader:
Reason is:
file - can be completed - even if we not downloaded it (start erigon on downloaded files).