mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Assign even more thread names at thread creation.
This commit is contained in:
parent
bcaac51830
commit
6273a58c3b
@ -49,33 +49,29 @@ public class SetupUtils {
|
||||
// If users compile themselves they might miss that step and then would get an exception in the trade.
|
||||
// To avoid that we add here at startup a sample encryption and signing to see if it don't causes an exception.
|
||||
// See: https://github.com/bisq-network/exchange/blob/master/doc/build.md#7-enable-unlimited-strength-for-cryptographic-keys
|
||||
Thread checkCryptoThread = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Thread.currentThread().setName("checkCryptoThread");
|
||||
// just use any simple dummy msg
|
||||
Ping payload = new Ping(1, 1);
|
||||
SealedAndSigned sealedAndSigned = EncryptionService.encryptHybridWithSignature(payload,
|
||||
keyRing.getSignatureKeyPair(), keyRing.getPubKeyRing().getEncryptionPubKey());
|
||||
DecryptedDataTuple tuple = encryptionService.decryptHybridWithSignature(sealedAndSigned,
|
||||
keyRing.getEncryptionKeyPair().getPrivate());
|
||||
if (tuple.getNetworkEnvelope() instanceof Ping &&
|
||||
((Ping) tuple.getNetworkEnvelope()).getNonce() == payload.getNonce() &&
|
||||
((Ping) tuple.getNetworkEnvelope()).getLastRoundTripTime() == payload.getLastRoundTripTime()) {
|
||||
log.debug("Crypto test succeeded");
|
||||
Thread checkCryptoThread = new Thread(() -> {
|
||||
try {
|
||||
// just use any simple dummy msg
|
||||
Ping payload = new Ping(1, 1);
|
||||
SealedAndSigned sealedAndSigned = EncryptionService.encryptHybridWithSignature(payload,
|
||||
keyRing.getSignatureKeyPair(), keyRing.getPubKeyRing().getEncryptionPubKey());
|
||||
DecryptedDataTuple tuple = encryptionService.decryptHybridWithSignature(sealedAndSigned,
|
||||
keyRing.getEncryptionKeyPair().getPrivate());
|
||||
if (tuple.getNetworkEnvelope() instanceof Ping &&
|
||||
((Ping) tuple.getNetworkEnvelope()).getNonce() == payload.getNonce() &&
|
||||
((Ping) tuple.getNetworkEnvelope()).getLastRoundTripTime() == payload.getLastRoundTripTime()) {
|
||||
log.debug("Crypto test succeeded");
|
||||
|
||||
UserThread.execute(resultHandler::handleResult);
|
||||
} else {
|
||||
errorHandler.accept(new CryptoException("Payload not correct after decryption"));
|
||||
}
|
||||
} catch (CryptoException | ProtobufferException e) {
|
||||
log.error(e.toString());
|
||||
e.printStackTrace();
|
||||
errorHandler.accept(e);
|
||||
UserThread.execute(resultHandler::handleResult);
|
||||
} else {
|
||||
errorHandler.accept(new CryptoException("Payload not correct after decryption"));
|
||||
}
|
||||
} catch (CryptoException | ProtobufferException e) {
|
||||
log.error(e.toString());
|
||||
e.printStackTrace();
|
||||
errorHandler.accept(e);
|
||||
}
|
||||
};
|
||||
}, "checkCryptoThread");
|
||||
checkCryptoThread.start();
|
||||
}
|
||||
|
||||
|
@ -21,11 +21,11 @@ import bisq.monitor.metric.MarketStats;
|
||||
import bisq.monitor.metric.P2PMarketStats;
|
||||
import bisq.monitor.metric.P2PNetworkLoad;
|
||||
import bisq.monitor.metric.P2PRoundTripTime;
|
||||
import bisq.monitor.metric.P2PSeedNodeSnapshot;
|
||||
import bisq.monitor.metric.PriceNodeStats;
|
||||
import bisq.monitor.metric.TorHiddenServiceStartupTime;
|
||||
import bisq.monitor.metric.TorRoundTripTime;
|
||||
import bisq.monitor.metric.TorStartupTime;
|
||||
import bisq.monitor.metric.P2PSeedNodeSnapshot;
|
||||
import bisq.monitor.reporter.ConsoleReporter;
|
||||
import bisq.monitor.reporter.GraphiteReporter;
|
||||
|
||||
@ -114,33 +114,29 @@ public class Monitor {
|
||||
configure();
|
||||
|
||||
// exit Metrics gracefully on shutdown
|
||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
// set the name of the Thread for debugging purposes
|
||||
setName("shutdownHook");
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||
// set the name of the Thread for debugging purposes
|
||||
log.info("system shutdown initiated");
|
||||
|
||||
log.info("system shutdown initiated");
|
||||
log.info("shutting down active metrics...");
|
||||
Metric.haltAllMetrics();
|
||||
|
||||
log.info("shutting down active metrics...");
|
||||
Metric.haltAllMetrics();
|
||||
try {
|
||||
log.info("shutting down tor...");
|
||||
Tor tor = Tor.getDefault();
|
||||
checkNotNull(tor, "tor must not be null");
|
||||
tor.shutdown();
|
||||
} catch (Throwable ignore) {
|
||||
}
|
||||
|
||||
try {
|
||||
log.info("shutting down tor...");
|
||||
Tor tor = Tor.getDefault();
|
||||
checkNotNull(tor, "tor must not be null");
|
||||
tor.shutdown();
|
||||
} catch (Throwable ignore) {
|
||||
}
|
||||
|
||||
log.info("system halt");
|
||||
}
|
||||
});
|
||||
log.info("system halt");
|
||||
}, "Monitor Shutdown Hook ")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload the configuration from disk.
|
||||
*
|
||||
*
|
||||
* @throws Exception if something goes wrong
|
||||
*/
|
||||
private void configure() throws Exception {
|
||||
|
Loading…
Reference in New Issue
Block a user