Keep items in arbitraryDataFileHashResponses if they are currently being requested by another thread. This should help to locate the higher numbered chunks from larger resources.

This commit is contained in:
CalDescent 2022-02-20 11:33:09 +00:00
parent 146e7970bf
commit 7798b8dcdc
2 changed files with 8 additions and 2 deletions

View File

@ -37,7 +37,7 @@ public class ArbitraryDataFileManager extends Thread {
/** /**
* Map to keep track of our in progress (outgoing) arbitrary data file requests * Map to keep track of our in progress (outgoing) arbitrary data file requests
*/ */
private Map<String, Long> arbitraryDataFileRequests = Collections.synchronizedMap(new HashMap<>()); public Map<String, Long> arbitraryDataFileRequests = Collections.synchronizedMap(new HashMap<>());
/** /**
* Map to keep track of hashes that we might need to relay * Map to keep track of hashes that we might need to relay
@ -148,7 +148,7 @@ public class ArbitraryDataFileManager extends Thread {
} }
} }
else { else {
LOGGER.trace("Already requesting data file {} for signature {}", arbitraryDataFile, Base58.encode(signature)); LOGGER.trace("Already requesting data file {} for signature {} from peer {}", arbitraryDataFile, Base58.encode(signature), peer);
} }
} }
else { else {

View File

@ -80,6 +80,12 @@ public class ArbitraryDataFileRequestThread implements Runnable {
continue; continue;
} }
// Skip if already requesting, but don't remove, as we might want to retry later
if (arbitraryDataFileManager.arbitraryDataFileRequests.containsKey(hash58)) {
// Already requesting - leave this attempt for later
continue;
}
// We want to process this file // We want to process this file
shouldProcess = true; shouldProcess = true;
iterator.remove(); iterator.remove();