Browse Source

Use the first responding peer in the relay map.

This encourages shorter relays, since longer ones will take more time to respond, and also prevents a peer from intentionally taking a long time to respond so that it overwrites an existing entry.

Longer term we could consider keeping track of all respondents for each hash, if there are still issues with data retrieval. I suspect this won't be needed though, as the requesting peer has 16+ different peers connected, and therefore potentially 16 different mappings already.
pull/66/head
CalDescent 3 years ago
parent
commit
8a42dce763
  1. 5
      src/main/java/org/qortal/controller/arbitrary/ArbitraryDataFileListManager.java

5
src/main/java/org/qortal/controller/arbitrary/ArbitraryDataFileListManager.java

@ -383,8 +383,9 @@ public class ArbitraryDataFileListManager {
for (byte[] hash : hashes) {
String hash58 = Base58.encode(hash);
Triple<String, Peer, Long> value = new Triple<>(signature58, peer, now);
arbitraryDataFileManager.arbitraryRelayMap.put(hash58, value);
LOGGER.debug("Added {} to relay map: {}, {}, {}", hash58, signature58, peer, now);
if (arbitraryDataFileManager.arbitraryRelayMap.putIfAbsent(hash58, value) == null) {
LOGGER.debug("Added {} to relay map: {}, {}, {}", hash58, signature58, peer, now);
}
}
// Forward to requesting peer

Loading…
Cancel
Save