mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-17 21:29:54 +01:00
Extract better and worse transports from preferences.
This commit is contained in:
@@ -42,6 +42,7 @@ class ConnectionRegistryImpl implements ConnectionRegistry {
|
|||||||
|
|
||||||
private final EventBus eventBus;
|
private final EventBus eventBus;
|
||||||
private final Map<TransportId, List<TransportId>> betterTransports;
|
private final Map<TransportId, List<TransportId>> betterTransports;
|
||||||
|
private final Map<TransportId, List<TransportId>> worseTransports;
|
||||||
|
|
||||||
private final Object lock = new Object();
|
private final Object lock = new Object();
|
||||||
@GuardedBy("lock")
|
@GuardedBy("lock")
|
||||||
@@ -53,21 +54,32 @@ class ConnectionRegistryImpl implements ConnectionRegistry {
|
|||||||
ConnectionRegistryImpl(EventBus eventBus, PluginConfig pluginConfig) {
|
ConnectionRegistryImpl(EventBus eventBus, PluginConfig pluginConfig) {
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
betterTransports = new HashMap<>();
|
betterTransports = new HashMap<>();
|
||||||
for (Pair<TransportId, TransportId> pair :
|
worseTransports = new HashMap<>();
|
||||||
pluginConfig.getTransportPreferences()) {
|
initTransportPreferences(pluginConfig.getTransportPreferences());
|
||||||
TransportId better = pair.getFirst();
|
|
||||||
TransportId worse = pair.getSecond();
|
|
||||||
List<TransportId> list = betterTransports.get(worse);
|
|
||||||
if (list == null) {
|
|
||||||
list = new ArrayList<>();
|
|
||||||
betterTransports.put(worse, list);
|
|
||||||
}
|
|
||||||
list.add(better);
|
|
||||||
}
|
|
||||||
contactConnections = new HashMap<>();
|
contactConnections = new HashMap<>();
|
||||||
connectedPendingContacts = new HashSet<>();
|
connectedPendingContacts = new HashSet<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initTransportPreferences(
|
||||||
|
List<Pair<TransportId, TransportId>> prefs) {
|
||||||
|
for (Pair<TransportId, TransportId> pair : prefs) {
|
||||||
|
TransportId better = pair.getFirst();
|
||||||
|
TransportId worse = pair.getSecond();
|
||||||
|
List<TransportId> betterList = betterTransports.get(worse);
|
||||||
|
if (betterList == null) {
|
||||||
|
betterList = new ArrayList<>();
|
||||||
|
betterTransports.put(worse, betterList);
|
||||||
|
}
|
||||||
|
betterList.add(better);
|
||||||
|
List<TransportId> worseList = worseTransports.get(better);
|
||||||
|
if (worseList == null) {
|
||||||
|
worseList = new ArrayList<>();
|
||||||
|
worseTransports.put(better, worseList);
|
||||||
|
}
|
||||||
|
worseList.add(worse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerConnection(ContactId c, TransportId t,
|
public void registerConnection(ContactId c, TransportId t,
|
||||||
boolean incoming) {
|
boolean incoming) {
|
||||||
|
|||||||
Reference in New Issue
Block a user