mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Force persistence write when editing Tor Bridge settings.
This is necessary because Tor settings are edited before the app has completed startup and normally persistence is prohibited.
This commit is contained in:
parent
c9235299a8
commit
684fd39c75
@ -410,7 +410,16 @@ public class PersistenceManager<T extends PersistableEnvelope> {
|
||||
}
|
||||
}
|
||||
|
||||
public void forcePersistNow() {
|
||||
// Tor Bridges settings are edited before app init completes, require persistNow to be forced, see writeToDisk()
|
||||
persistNow(null, true);
|
||||
}
|
||||
|
||||
public void persistNow(@Nullable Runnable completeHandler) {
|
||||
persistNow(completeHandler, false);
|
||||
}
|
||||
|
||||
private void persistNow(@Nullable Runnable completeHandler, boolean force) {
|
||||
long ts = System.currentTimeMillis();
|
||||
try {
|
||||
// The serialisation is done on the user thread to avoid threading issue with potential mutations of the
|
||||
@ -420,7 +429,7 @@ public class PersistenceManager<T extends PersistableEnvelope> {
|
||||
// For the write to disk task we use a thread. We do not have any issues anymore if the persistable objects
|
||||
// gets mutated while the thread is running as we have serialized it already and do not operate on the
|
||||
// reference to the persistable object.
|
||||
getWriteToDiskExecutor().execute(() -> writeToDisk(serialized, completeHandler));
|
||||
getWriteToDiskExecutor().execute(() -> writeToDisk(serialized, completeHandler, force));
|
||||
|
||||
long duration = System.currentTimeMillis() - ts;
|
||||
if (duration > 100) {
|
||||
@ -433,10 +442,11 @@ public class PersistenceManager<T extends PersistableEnvelope> {
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToDisk(protobuf.PersistableEnvelope serialized, @Nullable Runnable completeHandler) {
|
||||
if (!allServicesInitialized.get()) {
|
||||
private void writeToDisk(protobuf.PersistableEnvelope serialized, @Nullable Runnable completeHandler, boolean force) {
|
||||
if (!allServicesInitialized.get() && !force) {
|
||||
log.warn("Application has not completed start up yet so we do not permit writing data to disk.");
|
||||
UserThread.execute(completeHandler);
|
||||
if (completeHandler != null)
|
||||
UserThread.execute(completeHandler);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -679,7 +679,7 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
|
||||
public void setBridgeAddresses(List<String> bridgeAddresses) {
|
||||
prefPayload.setBridgeAddresses(bridgeAddresses);
|
||||
// We call that before shutdown so we dont want a delay here
|
||||
requestPersistence();
|
||||
persistenceManager.forcePersistNow();
|
||||
}
|
||||
|
||||
// Only used from PB but keep it explicit as it may be used from the client and then we want to persist
|
||||
@ -690,17 +690,17 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
|
||||
|
||||
public void setBridgeOptionOrdinal(int bridgeOptionOrdinal) {
|
||||
prefPayload.setBridgeOptionOrdinal(bridgeOptionOrdinal);
|
||||
requestPersistence();
|
||||
persistenceManager.forcePersistNow();
|
||||
}
|
||||
|
||||
public void setTorTransportOrdinal(int torTransportOrdinal) {
|
||||
prefPayload.setTorTransportOrdinal(torTransportOrdinal);
|
||||
requestPersistence();
|
||||
persistenceManager.forcePersistNow();
|
||||
}
|
||||
|
||||
public void setCustomBridges(String customBridges) {
|
||||
prefPayload.setCustomBridges(customBridges);
|
||||
requestPersistence();
|
||||
persistenceManager.forcePersistNow();
|
||||
}
|
||||
|
||||
public void setBitcoinNodesOptionOrdinal(int bitcoinNodesOptionOrdinal) {
|
||||
|
Loading…
Reference in New Issue
Block a user