mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-06-24 23:00:36 -04:00
Fix bug when trader is offline and use password protection signing payout tx fails
This commit is contained in:
parent
81fcc82972
commit
c021ea8ea2
6 changed files with 44 additions and 77 deletions
|
@ -95,7 +95,6 @@ public class ArbitratorManager {
|
||||||
private final ArbitratorService arbitratorService;
|
private final ArbitratorService arbitratorService;
|
||||||
private final User user;
|
private final User user;
|
||||||
private final ObservableMap<NodeAddress, Arbitrator> arbitratorsObservableMap = FXCollections.observableHashMap();
|
private final ObservableMap<NodeAddress, Arbitrator> arbitratorsObservableMap = FXCollections.observableHashMap();
|
||||||
private BootstrapListener bootstrapListener;
|
|
||||||
private Timer republishArbitratorTimer, retryRepublishArbitratorTimer;
|
private Timer republishArbitratorTimer, retryRepublishArbitratorTimer;
|
||||||
|
|
||||||
|
|
||||||
|
@ -125,9 +124,6 @@ public class ArbitratorManager {
|
||||||
public void shutDown() {
|
public void shutDown() {
|
||||||
stopRepublishArbitratorTimer();
|
stopRepublishArbitratorTimer();
|
||||||
stopRetryRepublishArbitratorTimer();
|
stopRetryRepublishArbitratorTimer();
|
||||||
if (bootstrapListener != null)
|
|
||||||
arbitratorService.getP2PService().removeP2PServiceListener(bootstrapListener);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -138,22 +134,15 @@ public class ArbitratorManager {
|
||||||
public void onAllServicesInitialized() {
|
public void onAllServicesInitialized() {
|
||||||
if (user.getRegisteredArbitrator() != null) {
|
if (user.getRegisteredArbitrator() != null) {
|
||||||
P2PService p2PService = arbitratorService.getP2PService();
|
P2PService p2PService = arbitratorService.getP2PService();
|
||||||
if (!p2PService.isBootstrapped()) {
|
if (p2PService.isBootstrapped())
|
||||||
bootstrapListener = new BootstrapListener() {
|
republishArbitrator();
|
||||||
|
else
|
||||||
|
p2PService.addP2PServiceListener(new BootstrapListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onBootstrapComplete() {
|
public void onBootstrapComplete() {
|
||||||
ArbitratorManager.this.onBootstrapComplete();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (p2PService.isBootstrapped())
|
|
||||||
onBootstrapComplete();
|
|
||||||
else
|
|
||||||
p2PService.addP2PServiceListener(bootstrapListener);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
republishArbitrator();
|
republishArbitrator();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
republishArbitratorTimer = UserThread.runPeriodically(this::republishArbitrator, REPUBLISH_MILLIS, TimeUnit.MILLISECONDS);
|
republishArbitratorTimer = UserThread.runPeriodically(this::republishArbitrator, REPUBLISH_MILLIS, TimeUnit.MILLISECONDS);
|
||||||
|
@ -247,15 +236,6 @@ public class ArbitratorManager {
|
||||||
// Private
|
// Private
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
private void onBootstrapComplete() {
|
|
||||||
if (bootstrapListener != null) {
|
|
||||||
arbitratorService.getP2PService().removeP2PServiceListener(bootstrapListener);
|
|
||||||
bootstrapListener = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
republishArbitrator();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void republishArbitrator() {
|
private void republishArbitrator() {
|
||||||
Arbitrator registeredArbitrator = user.getRegisteredArbitrator();
|
Arbitrator registeredArbitrator = user.getRegisteredArbitrator();
|
||||||
if (registeredArbitrator != null) {
|
if (registeredArbitrator != null) {
|
||||||
|
|
|
@ -70,7 +70,6 @@ public class DisputeManager {
|
||||||
private final DisputeList<Dispute> disputes;
|
private final DisputeList<Dispute> disputes;
|
||||||
transient private final ObservableList<Dispute> disputesObservableList;
|
transient private final ObservableList<Dispute> disputesObservableList;
|
||||||
private final String disputeInfo;
|
private final String disputeInfo;
|
||||||
private final BootstrapListener bootstrapListener;
|
|
||||||
private final CopyOnWriteArraySet<DecryptedMsgWithPubKey> decryptedMailboxMessageWithPubKeys = new CopyOnWriteArraySet<>();
|
private final CopyOnWriteArraySet<DecryptedMsgWithPubKey> decryptedMailboxMessageWithPubKeys = new CopyOnWriteArraySet<>();
|
||||||
private final CopyOnWriteArraySet<DecryptedMsgWithPubKey> decryptedDirectMessageWithPubKeys = new CopyOnWriteArraySet<>();
|
private final CopyOnWriteArraySet<DecryptedMsgWithPubKey> decryptedDirectMessageWithPubKeys = new CopyOnWriteArraySet<>();
|
||||||
|
|
||||||
|
@ -118,17 +117,23 @@ public class DisputeManager {
|
||||||
if (p2PService.isBootstrapped())
|
if (p2PService.isBootstrapped())
|
||||||
applyMessages();
|
applyMessages();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
bootstrapListener = new BootstrapListener() {
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// API
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public void onAllServicesInitialized() {
|
||||||
|
if (p2PService.isBootstrapped())
|
||||||
|
applyMessages();
|
||||||
|
else
|
||||||
|
p2PService.addP2PServiceListener(new BootstrapListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onBootstrapComplete() {
|
public void onBootstrapComplete() {
|
||||||
applyMessages();
|
applyMessages();
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
if (p2PService.isBootstrapped())
|
|
||||||
applyMessages();
|
|
||||||
else
|
|
||||||
p2PService.addP2PServiceListener(bootstrapListener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyMessages() {
|
private void applyMessages() {
|
||||||
|
@ -148,17 +153,6 @@ public class DisputeManager {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
decryptedMailboxMessageWithPubKeys.clear();
|
decryptedMailboxMessageWithPubKeys.clear();
|
||||||
|
|
||||||
if (bootstrapListener != null)
|
|
||||||
p2PService.removeP2PServiceListener(bootstrapListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// API
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
public void onAllServicesInitialized() {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dispatchMessage(DisputeMessage message) {
|
private void dispatchMessage(DisputeMessage message) {
|
||||||
|
|
|
@ -81,7 +81,6 @@ public class TradeManager {
|
||||||
private final Storage<TradableList<Trade>> tradableListStorage;
|
private final Storage<TradableList<Trade>> tradableListStorage;
|
||||||
private final TradableList<Trade> trades;
|
private final TradableList<Trade> trades;
|
||||||
private final BooleanProperty pendingTradesInitialized = new SimpleBooleanProperty();
|
private final BooleanProperty pendingTradesInitialized = new SimpleBooleanProperty();
|
||||||
private final BootstrapListener bootstrapListener;
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -147,19 +146,20 @@ public class TradeManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
bootstrapListener = new BootstrapListener() {
|
public void onAllServicesInitialized() {
|
||||||
|
if (p2PService.isBootstrapped())
|
||||||
|
initPendingTrades();
|
||||||
|
else
|
||||||
|
p2PService.addP2PServiceListener(new BootstrapListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onBootstrapComplete() {
|
public void onBootstrapComplete() {
|
||||||
// Get called after onMailboxMessageAdded from initial data request
|
// Get called after onMailboxMessageAdded from initial data request
|
||||||
// The mailbox message will be removed inside the tasks after they are processed successfully
|
// The mailbox message will be removed inside the tasks after they are processed successfully
|
||||||
initPendingTrades();
|
initPendingTrades();
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
if (p2PService.isBootstrapped())
|
|
||||||
initPendingTrades();
|
|
||||||
else
|
|
||||||
p2PService.addP2PServiceListener(bootstrapListener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -169,8 +169,6 @@ public class TradeManager {
|
||||||
|
|
||||||
private void initPendingTrades() {
|
private void initPendingTrades() {
|
||||||
Log.traceCall();
|
Log.traceCall();
|
||||||
if (bootstrapListener != null)
|
|
||||||
p2PService.removeP2PServiceListener(bootstrapListener);
|
|
||||||
|
|
||||||
//List<Trade> failedTrades = new ArrayList<>();
|
//List<Trade> failedTrades = new ArrayList<>();
|
||||||
for (Trade trade : trades) {
|
for (Trade trade : trades) {
|
||||||
|
|
|
@ -81,7 +81,6 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
||||||
private final Storage<TradableList<OpenOffer>> openOffersStorage;
|
private final Storage<TradableList<OpenOffer>> openOffersStorage;
|
||||||
private boolean stopped;
|
private boolean stopped;
|
||||||
private Timer periodicRepublishOffersTimer, periodicRefreshOffersTimer, retryRepublishOffersTimer;
|
private Timer periodicRepublishOffersTimer, periodicRefreshOffersTimer, retryRepublishOffersTimer;
|
||||||
private BootstrapListener bootstrapListener;
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -114,19 +113,17 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onAllServicesInitialized() {
|
public void onAllServicesInitialized() {
|
||||||
bootstrapListener = new BootstrapListener() {
|
|
||||||
@Override
|
|
||||||
public void onBootstrapComplete() {
|
|
||||||
OpenOfferManager.this.onBootstrapComplete();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
p2PService.addP2PServiceListener(bootstrapListener);
|
|
||||||
p2PService.addDecryptedDirectMessageListener(this);
|
p2PService.addDecryptedDirectMessageListener(this);
|
||||||
|
|
||||||
if (p2PService.isBootstrapped())
|
if (p2PService.isBootstrapped())
|
||||||
onBootstrapComplete();
|
onBootstrapComplete();
|
||||||
else
|
else
|
||||||
p2PService.addP2PServiceListener(bootstrapListener);
|
p2PService.addP2PServiceListener(new BootstrapListener() {
|
||||||
|
@Override
|
||||||
|
public void onBootstrapComplete() {
|
||||||
|
OpenOfferManager.this.onBootstrapComplete();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("WeakerAccess")
|
@SuppressWarnings("WeakerAccess")
|
||||||
|
@ -138,8 +135,6 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
||||||
stopped = true;
|
stopped = true;
|
||||||
p2PService.getPeerManager().removeListener(this);
|
p2PService.getPeerManager().removeListener(this);
|
||||||
p2PService.removeDecryptedDirectMessageListener(this);
|
p2PService.removeDecryptedDirectMessageListener(this);
|
||||||
if (bootstrapListener != null)
|
|
||||||
p2PService.removeP2PServiceListener(bootstrapListener);
|
|
||||||
|
|
||||||
stopPeriodicRefreshOffersTimer();
|
stopPeriodicRefreshOffersTimer();
|
||||||
stopPeriodicRepublishOffersTimer();
|
stopPeriodicRepublishOffersTimer();
|
||||||
|
@ -187,9 +182,6 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public void onBootstrapComplete() {
|
public void onBootstrapComplete() {
|
||||||
if (bootstrapListener != null)
|
|
||||||
p2PService.removeP2PServiceListener(bootstrapListener);
|
|
||||||
|
|
||||||
stopped = false;
|
stopped = false;
|
||||||
|
|
||||||
// Republish means we send the complete offer object
|
// Republish means we send the complete offer object
|
||||||
|
|
|
@ -468,6 +468,7 @@ public class MainViewModel implements ViewModel {
|
||||||
onDisputesChangeListener(disputeManager.getDisputesAsObservableList(), null);
|
onDisputesChangeListener(disputeManager.getDisputesAsObservableList(), null);
|
||||||
|
|
||||||
// tradeManager
|
// tradeManager
|
||||||
|
tradeManager.onAllServicesInitialized();
|
||||||
tradeManager.getTrades().addListener((ListChangeListener<Trade>) c -> updateBalance());
|
tradeManager.getTrades().addListener((ListChangeListener<Trade>) c -> updateBalance());
|
||||||
tradeManager.getTrades().addListener((ListChangeListener<Trade>) change -> onTradesChanged());
|
tradeManager.getTrades().addListener((ListChangeListener<Trade>) change -> onTradesChanged());
|
||||||
onTradesChanged();
|
onTradesChanged();
|
||||||
|
|
|
@ -116,6 +116,7 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init(boolean useLocalhost, int networkId, File storageDir) {
|
private void init(boolean useLocalhost, int networkId, File storageDir) {
|
||||||
|
if (!useLocalhost)
|
||||||
FileUtil.rollingBackup(new File(Paths.get(torDir.getAbsolutePath(), "hiddenservice").toString()), "private_key");
|
FileUtil.rollingBackup(new File(Paths.get(torDir.getAbsolutePath(), "hiddenservice").toString()), "private_key");
|
||||||
|
|
||||||
networkNode = useLocalhost ? new LocalhostNetworkNode(port) : new TorNetworkNode(port, torDir);
|
networkNode = useLocalhost ? new LocalhostNetworkNode(port) : new TorNetworkNode(port, torDir);
|
||||||
|
@ -277,11 +278,12 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis
|
||||||
"seedNodeOfPreliminaryDataRequest must be present");
|
"seedNodeOfPreliminaryDataRequest must be present");
|
||||||
peerExchangeManager.requestReportedPeersFromSeedNodes(seedNodeOfPreliminaryDataRequest.get());
|
peerExchangeManager.requestReportedPeersFromSeedNodes(seedNodeOfPreliminaryDataRequest.get());
|
||||||
|
|
||||||
|
if (!isBootstrapped) {
|
||||||
isBootstrapped = true;
|
isBootstrapped = true;
|
||||||
p2pServiceListeners.stream().forEach(P2PServiceListener::onBootstrapComplete);
|
p2pServiceListeners.stream().forEach(P2PServiceListener::onBootstrapComplete);
|
||||||
|
|
||||||
p2PDataStorage.onBootstrapComplete();
|
p2PDataStorage.onBootstrapComplete();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNoSeedNodeAvailable() {
|
public void onNoSeedNodeAvailable() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue