From 2320d650f621d7769d3b6eee850638248adcf859 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Mon, 28 Oct 2019 23:16:27 +0000 Subject: [PATCH] do not serialize meshes that have more downloaded pieces than total pieces. To be investigated further --- core/src/main/groovy/com/muwire/core/mesh/MeshManager.groovy | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/main/groovy/com/muwire/core/mesh/MeshManager.groovy b/core/src/main/groovy/com/muwire/core/mesh/MeshManager.groovy index 5059fce7..bee0c94a 100644 --- a/core/src/main/groovy/com/muwire/core/mesh/MeshManager.groovy +++ b/core/src/main/groovy/com/muwire/core/mesh/MeshManager.groovy @@ -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 downloaded = mesh.pieces.getDownloaded() + if( downloaded.size() > mesh.pieces.nPieces) + return + json.xHave = DataUtil.encodeXHave(downloaded, mesh.pieces.nPieces) writer.println(JsonOutput.toJson(json)) } }