improve stability on tor, refactor startup and shut down

refactor startup sequence to improve message reliability
refactor shut down sequence to finish processing messages
reduce monerod requests to improve slow tor connections
refactor trade wallet polling
monero node service uses default data directory unless local
connections service checks connection by polling daemon
connections service supports getRefreshPeriodMs and shutting down
add make config: monerod-stagenet-custom
fix bugs in key image polling
force stop wallet on deletion
trade manager initializes persisted trades on data received
support hardcoding monero log level and request stack traces
remove xmrAddress from Arbitrator model
fix formatting of MoneroWalletRpcManager
This commit is contained in:
woodser 2023-04-17 08:54:10 -04:00
parent 5e364f7e7e
commit 2afa5d761d
51 changed files with 1058 additions and 644 deletions

View file

@ -190,6 +190,7 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis
}
private void doShutDown() {
if (p2PDataStorage != null) {
p2PDataStorage.shutDown();
}

View file

@ -64,7 +64,6 @@ import javax.inject.Singleton;
import java.security.PublicKey;
import java.time.Clock;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.Date;
@ -345,11 +344,7 @@ public class MailboxMessageService implements HashMapChangedListener, PersistedD
.map(e -> (ProtectedMailboxStorageEntry) e)
.filter(e -> networkNode.getNodeAddress() != null)
.collect(Collectors.toSet());
if (entries.size() > 1) {
threadedBatchProcessMailboxEntries(entries);
} else if (entries.size() == 1) {
processSingleMailboxEntry(entries);
}
threadedBatchProcessMailboxEntries(entries);
}
@Override
@ -375,14 +370,6 @@ public class MailboxMessageService implements HashMapChangedListener, PersistedD
p2PDataStorage.addHashMapChangedListener(this);
}
private void processSingleMailboxEntry(Collection<ProtectedMailboxStorageEntry> protectedMailboxStorageEntries) {
checkArgument(protectedMailboxStorageEntries.size() == 1);
var mailboxItems = new ArrayList<>(getMailboxItems(protectedMailboxStorageEntries));
if (mailboxItems.size() == 1) {
handleMailboxItem(mailboxItems.get(0));
}
}
// We run the batch processing of all mailbox messages we have received at startup in a thread to not block the UI.
// For about 1000 messages decryption takes about 1 sec.
private void threadedBatchProcessMailboxEntries(Collection<ProtectedMailboxStorageEntry> protectedMailboxStorageEntries) {
@ -390,7 +377,7 @@ public class MailboxMessageService implements HashMapChangedListener, PersistedD
long ts = System.currentTimeMillis();
ListenableFuture<Set<MailboxItem>> future = executor.submit(() -> {
var mailboxItems = getMailboxItems(protectedMailboxStorageEntries);
log.info("Batch processing of {} mailbox entries took {} ms",
log.trace("Batch processing of {} mailbox entries took {} ms",
protectedMailboxStorageEntries.size(),
System.currentTimeMillis() - ts);
return mailboxItems;