From 9da2b3c11a608c368b4707d8f650e52c30472b5e Mon Sep 17 00:00:00 2001 From: CalDescent Date: Sun, 27 Feb 2022 07:28:11 +0000 Subject: [PATCH] Don't respond to file list requests with just the metadata file. We have the separate metadata protocol for this now. --- .../arbitrary/ArbitraryDataFileListManager.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/org/qortal/controller/arbitrary/ArbitraryDataFileListManager.java b/src/main/java/org/qortal/controller/arbitrary/ArbitraryDataFileListManager.java index a3f11e3e..956280e3 100644 --- a/src/main/java/org/qortal/controller/arbitrary/ArbitraryDataFileListManager.java +++ b/src/main/java/org/qortal/controller/arbitrary/ArbitraryDataFileListManager.java @@ -538,6 +538,7 @@ public class ArbitraryDataFileListManager { List hashes = new ArrayList<>(); ArbitraryTransactionData transactionData = null; boolean allChunksExist = false; + boolean hasMetadata = false; try (final Repository repository = RepositoryManager.getRepository()) { @@ -562,6 +563,7 @@ public class ArbitraryDataFileListManager { // Add the metadata file if (arbitraryDataFile.getMetadataHash() != null) { requestedHashes.add(arbitraryDataFile.getMetadataHash()); + hasMetadata = true; } // Add the chunk hashes @@ -594,6 +596,12 @@ public class ArbitraryDataFileListManager { LOGGER.error(String.format("Repository issue while fetching arbitrary file list for peer %s", peer), e); } + // If the only file we have is the metadata then we shouldn't respond. Most nodes will already have that, + // or can use the separate metadata protocol to fetch it. This should greatly reduce network spam. + if (hasMetadata && hashes.size() == 1) { + hashes.clear(); + } + // We should only respond if we have at least one hash if (hashes.size() > 0) {