mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Refactor: rename
This commit is contained in:
parent
364a7f524c
commit
a21d79ad63
@ -437,27 +437,27 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onBundleOfEnvelopes(BundleOfEnvelopes networkEnvelope, Connection connection) {
|
private void onBundleOfEnvelopes(BundleOfEnvelopes bundleOfEnvelopes, Connection connection) {
|
||||||
Map<P2PDataStorage.ByteArray, Set<NetworkEnvelope>> itemsByHash = new HashMap<>();
|
Map<P2PDataStorage.ByteArray, Set<NetworkEnvelope>> itemsByHash = new HashMap<>();
|
||||||
Set<NetworkEnvelope> envelopesToProcess = new HashSet<>();
|
Set<NetworkEnvelope> envelopesToProcess = new HashSet<>();
|
||||||
List<NetworkEnvelope> networkEnvelopes = networkEnvelope.getEnvelopes();
|
List<NetworkEnvelope> networkEnvelopes = bundleOfEnvelopes.getEnvelopes();
|
||||||
for (NetworkEnvelope current : networkEnvelopes) {
|
for (NetworkEnvelope networkEnvelope : networkEnvelopes) {
|
||||||
if (current instanceof AddPersistableNetworkPayloadMessage) {
|
if (networkEnvelope instanceof AddPersistableNetworkPayloadMessage) {
|
||||||
PersistableNetworkPayload persistableNetworkPayload = ((AddPersistableNetworkPayloadMessage) current).getPersistableNetworkPayload();
|
PersistableNetworkPayload persistableNetworkPayload = ((AddPersistableNetworkPayloadMessage) networkEnvelope).getPersistableNetworkPayload();
|
||||||
byte[] hash = persistableNetworkPayload.getHash();
|
byte[] hash = persistableNetworkPayload.getHash();
|
||||||
String itemName = persistableNetworkPayload.getClass().getSimpleName();
|
String itemName = persistableNetworkPayload.getClass().getSimpleName();
|
||||||
P2PDataStorage.ByteArray byteArray = new P2PDataStorage.ByteArray(hash);
|
P2PDataStorage.ByteArray byteArray = new P2PDataStorage.ByteArray(hash);
|
||||||
itemsByHash.putIfAbsent(byteArray, new HashSet<>());
|
itemsByHash.putIfAbsent(byteArray, new HashSet<>());
|
||||||
Set<NetworkEnvelope> envelopesByHash = itemsByHash.get(byteArray);
|
Set<NetworkEnvelope> envelopesByHash = itemsByHash.get(byteArray);
|
||||||
if (!envelopesByHash.contains(current)) {
|
if (!envelopesByHash.contains(networkEnvelope)) {
|
||||||
envelopesByHash.add(current);
|
envelopesByHash.add(networkEnvelope);
|
||||||
envelopesToProcess.add(current);
|
envelopesToProcess.add(networkEnvelope);
|
||||||
} else {
|
} else {
|
||||||
log.debug("We got duplicated items for {}. We ignore the duplicates. Hash: {}",
|
log.debug("We got duplicated items for {}. We ignore the duplicates. Hash: {}",
|
||||||
itemName, Utilities.encodeToHex(hash));
|
itemName, Utilities.encodeToHex(hash));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
envelopesToProcess.add(current);
|
envelopesToProcess.add(networkEnvelope);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
envelopesToProcess.forEach(envelope -> UserThread.execute(() ->
|
envelopesToProcess.forEach(envelope -> UserThread.execute(() ->
|
||||||
|
Loading…
Reference in New Issue
Block a user