Add delay between remove and add new filter

We saw that some seed nodes have 2 filters after filter update.
This should not be the case as the remove is broadcast before the
add but seems there is some issue in the P2P storage which does
not cover that correctly.
By adding a 5 sec delay between the remove and add we mitigate
that issue, though should be fixes in the P2P layer but that
will be a more complex and larger effort.
This commit is contained in:
chimp1984 2020-11-17 20:14:44 -05:00
parent 5b97b97349
commit bf2c94160f
No known key found for this signature in database
GPG key ID: 9801B4EC591F90E3

View file

@ -27,6 +27,7 @@ import bisq.core.filter.FilterManager;
import bisq.core.filter.PaymentAccountFilter;
import bisq.core.locale.Res;
import bisq.common.UserThread;
import bisq.common.app.DevEnv;
import bisq.common.config.Config;
@ -223,12 +224,16 @@ public class FilterWindow extends Overlay<FilterWindow> {
);
// We remove first the old filter
// We delay a bit with adding as it seems that the instant add/remove calls lead to issues that the
// remove msg was rejected (P2P storage should handle it but seems there are edge cases where its not
// working as expected)
if (filterManager.canRemoveDevFilter(privKeyString)) {
filterManager.removeDevFilter(privKeyString);
UserThread.runAfter(() -> addDevFilter(removeFilterMessageButton, privKeyString, newFilter),
5);
} else {
addDevFilter(removeFilterMessageButton, privKeyString, newFilter);
}
filterManager.addDevFilter(newFilter, privKeyString);
removeFilterMessageButton.setDisable(filterManager.getDevFilter() == null);
hide();
} else {
new Popup().warning(Res.get("shared.invalidKey")).onClose(this::blurAgain).show();
}
@ -258,6 +263,12 @@ public class FilterWindow extends Overlay<FilterWindow> {
GridPane.setMargin(hBox, new Insets(10, 0, 0, 0));
}
private void addDevFilter(Button removeFilterMessageButton, String privKeyString, Filter newFilter) {
filterManager.addDevFilter(newFilter, privKeyString);
removeFilterMessageButton.setDisable(filterManager.getDevFilter() == null);
hide();
}
private void setupFieldFromList(InputTextField field, List<String> values) {
if (values != null)
field.setText(String.join(", ", values));