forked from Qortal/qortal
Don't respond to file list requests with just the metadata file.
We have the separate metadata protocol for this now.
This commit is contained in:
parent
95400da977
commit
9da2b3c11a
@ -538,6 +538,7 @@ public class ArbitraryDataFileListManager {
|
|||||||
List<byte[]> hashes = new ArrayList<>();
|
List<byte[]> hashes = new ArrayList<>();
|
||||||
ArbitraryTransactionData transactionData = null;
|
ArbitraryTransactionData transactionData = null;
|
||||||
boolean allChunksExist = false;
|
boolean allChunksExist = false;
|
||||||
|
boolean hasMetadata = false;
|
||||||
|
|
||||||
try (final Repository repository = RepositoryManager.getRepository()) {
|
try (final Repository repository = RepositoryManager.getRepository()) {
|
||||||
|
|
||||||
@ -562,6 +563,7 @@ public class ArbitraryDataFileListManager {
|
|||||||
// Add the metadata file
|
// Add the metadata file
|
||||||
if (arbitraryDataFile.getMetadataHash() != null) {
|
if (arbitraryDataFile.getMetadataHash() != null) {
|
||||||
requestedHashes.add(arbitraryDataFile.getMetadataHash());
|
requestedHashes.add(arbitraryDataFile.getMetadataHash());
|
||||||
|
hasMetadata = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the chunk hashes
|
// 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);
|
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
|
// We should only respond if we have at least one hash
|
||||||
if (hashes.size() > 0) {
|
if (hashes.size() > 0) {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user