do not serialize meshes that have more downloaded pieces than total pieces. To be investigated further

pull/24/head
Zlatin Balevsky 2019-10-28 23:16:27 +00:00
parent e9e6e6920a
commit 2320d650f6
1 changed files with 4 additions and 1 deletions

View File

@ -67,7 +67,10 @@ class MeshManager {
json.infoHash = Base64.encode(mesh.infoHash.getRoot())
json.sources = mesh.sources.stream().map({it.toBase64()}).collect(Collectors.toList())
json.nPieces = mesh.pieces.nPieces
json.xHave = DataUtil.encodeXHave(mesh.pieces.downloaded, mesh.pieces.nPieces)
List<Integer> downloaded = mesh.pieces.getDownloaded()
if( downloaded.size() > mesh.pieces.nPieces)
return
json.xHave = DataUtil.encodeXHave(downloaded, mesh.pieces.nPieces)
writer.println(JsonOutput.toJson(json))
}
}