mirror of
https://github.com/Qortal/qortal.git
synced 2025-06-22 15:11:22 +00:00
Add accounts from the import queue individually, and then skip future duplicates before unnecessarily validating them again.
This closes a gap where accounts would be moved from onlineAccountsImportQueue to onlineAccountsToAdd, but not yet imported. During this time, there was nothing to stop them from being added to the import queue again, causing duplicate validations.
This commit is contained in:
parent
8099a5776d
commit
09a577d7e1
@ -193,9 +193,17 @@ public class OnlineAccountsManager {
|
|||||||
if (isStopping)
|
if (isStopping)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Skip this account if it's already validated
|
||||||
|
Set<OnlineAccountData> onlineAccounts = this.currentOnlineAccounts.computeIfAbsent(onlineAccountData.getTimestamp(), k -> ConcurrentHashMap.newKeySet());
|
||||||
|
if (onlineAccounts.contains(onlineAccountData)) {
|
||||||
|
// We have already validated this online account
|
||||||
|
onlineAccountsImportQueue.remove(onlineAccountData);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
boolean isValid = this.isValidCurrentAccount(repository, onlineAccountData);
|
boolean isValid = this.isValidCurrentAccount(repository, onlineAccountData);
|
||||||
if (isValid)
|
if (isValid)
|
||||||
onlineAccountsToAdd.add(onlineAccountData);
|
addAccounts(Arrays.asList(onlineAccountData));
|
||||||
|
|
||||||
// Remove from queue
|
// Remove from queue
|
||||||
onlineAccountsImportQueue.remove(onlineAccountData);
|
onlineAccountsImportQueue.remove(onlineAccountData);
|
||||||
@ -203,11 +211,6 @@ public class OnlineAccountsManager {
|
|||||||
} catch (DataException e) {
|
} catch (DataException e) {
|
||||||
LOGGER.error("Repository issue while verifying online accounts", e);
|
LOGGER.error("Repository issue while verifying online accounts", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!onlineAccountsToAdd.isEmpty()) {
|
|
||||||
LOGGER.debug("Merging {} validated online accounts from import queue", onlineAccountsToAdd.size());
|
|
||||||
addAccounts(onlineAccountsToAdd);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean importQueueContainsExactMatch(OnlineAccountData acc) {
|
private boolean importQueueContainsExactMatch(OnlineAccountData acc) {
|
||||||
@ -381,7 +384,7 @@ public class OnlineAccountsManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGGER.debug(String.format("we have online accounts for timestamps: %s", String.join(", ", this.currentOnlineAccounts.keySet().stream().map(l -> Long.toString(l)).collect(Collectors.joining(", ")))));
|
LOGGER.trace(String.format("we have online accounts for timestamps: %s", String.join(", ", this.currentOnlineAccounts.keySet().stream().map(l -> Long.toString(l)).collect(Collectors.joining(", ")))));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user