mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-12-16 08:14:15 -05:00
WIP (testing)
This commit is contained in:
parent
a406a94976
commit
78a9662220
4 changed files with 9 additions and 8 deletions
|
|
@ -61,7 +61,7 @@ public class ArbitratorService {
|
||||||
log.debug("addArbitrator arbitrator.hashCode() " + arbitrator.hashCode());
|
log.debug("addArbitrator arbitrator.hashCode() " + arbitrator.hashCode());
|
||||||
boolean result = p2PService.addData(arbitrator);
|
boolean result = p2PService.addData(arbitrator);
|
||||||
if (result) {
|
if (result) {
|
||||||
log.trace("Add arbitrator to network was successful. Arbitrator = " + arbitrator);
|
log.trace("Add arbitrator to network was successful. Arbitrator.hashCode() = " + arbitrator.hashCode());
|
||||||
resultHandler.handleResult();
|
resultHandler.handleResult();
|
||||||
} else {
|
} else {
|
||||||
errorMessageHandler.handleErrorMessage("Add arbitrator failed");
|
errorMessageHandler.handleErrorMessage("Add arbitrator failed");
|
||||||
|
|
@ -71,7 +71,7 @@ public class ArbitratorService {
|
||||||
public void removeArbitrator(Arbitrator arbitrator, ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
|
public void removeArbitrator(Arbitrator arbitrator, ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
|
||||||
log.debug("removeArbitrator arbitrator.hashCode() " + arbitrator.hashCode());
|
log.debug("removeArbitrator arbitrator.hashCode() " + arbitrator.hashCode());
|
||||||
if (p2PService.removeData(arbitrator)) {
|
if (p2PService.removeData(arbitrator)) {
|
||||||
log.trace("Remove arbitrator from network was successful. Arbitrator = " + arbitrator);
|
log.trace("Remove arbitrator from network was successful. Arbitrator.hashCode() = " + arbitrator.hashCode());
|
||||||
resultHandler.handleResult();
|
resultHandler.handleResult();
|
||||||
} else {
|
} else {
|
||||||
errorMessageHandler.handleErrorMessage("Remove arbitrator failed");
|
errorMessageHandler.handleErrorMessage("Remove arbitrator failed");
|
||||||
|
|
|
||||||
|
|
@ -258,7 +258,7 @@ public class OpenOfferManager {
|
||||||
|
|
||||||
private void startRefreshOffersThread() {
|
private void startRefreshOffersThread() {
|
||||||
// refresh sufficiently before offer would expire
|
// refresh sufficiently before offer would expire
|
||||||
refreshOffersPeriod = (long) (Offer.TTL * 0.7);
|
refreshOffersPeriod = (long) (Offer.TTL * 0.5);
|
||||||
refreshOffersTimer = UserThread.runPeriodically(OpenOfferManager.this::refreshOffers, refreshOffersPeriod, TimeUnit.MILLISECONDS);
|
refreshOffersTimer = UserThread.runPeriodically(OpenOfferManager.this::refreshOffers, refreshOffersPeriod, TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -274,6 +274,8 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis
|
||||||
|
|
||||||
isBootstrapped = true;
|
isBootstrapped = true;
|
||||||
p2pServiceListeners.stream().forEach(P2PServiceListener::onBootstrapComplete);
|
p2pServiceListeners.stream().forEach(P2PServiceListener::onBootstrapComplete);
|
||||||
|
|
||||||
|
p2PDataStorage.onBootstrapComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -61,14 +61,12 @@ public class P2PDataStorage implements MessageListener, ConnectionListener {
|
||||||
storage = new Storage<>(storageDir);
|
storage = new Storage<>(storageDir);
|
||||||
removeExpiredEntriesExecutor = Utilities.getScheduledThreadPoolExecutor("removeExpiredEntries", 1, 10, 5);
|
removeExpiredEntriesExecutor = Utilities.getScheduledThreadPoolExecutor("removeExpiredEntries", 1, 10, 5);
|
||||||
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init() {
|
|
||||||
HashMap<ByteArray, MapValue> persisted = storage.initAndGetPersisted("SequenceNumberMap");
|
HashMap<ByteArray, MapValue> persisted = storage.initAndGetPersisted("SequenceNumberMap");
|
||||||
if (persisted != null)
|
if (persisted != null)
|
||||||
sequenceNumberMap = getPurgedSequenceNumberMap(persisted);
|
sequenceNumberMap = getPurgedSequenceNumberMap(persisted);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onBootstrapComplete() {
|
||||||
removeExpiredEntriesExecutor.scheduleAtFixedRate(() -> UserThread.execute(() -> {
|
removeExpiredEntriesExecutor.scheduleAtFixedRate(() -> UserThread.execute(() -> {
|
||||||
log.trace("removeExpiredEntries");
|
log.trace("removeExpiredEntries");
|
||||||
// The moment when an object becomes expired will not be synchronous in the network and we could
|
// The moment when an object becomes expired will not be synchronous in the network and we could
|
||||||
|
|
@ -84,7 +82,7 @@ public class P2PDataStorage implements MessageListener, ConnectionListener {
|
||||||
ByteArray hashOfPayload = entry.getKey();
|
ByteArray hashOfPayload = entry.getKey();
|
||||||
ProtectedData protectedData = map.get(hashOfPayload);
|
ProtectedData protectedData = map.get(hashOfPayload);
|
||||||
toRemoveSet.add(protectedData);
|
toRemoveSet.add(protectedData);
|
||||||
log.trace("remove protectedData:\n\t" + protectedData);
|
log.error("remove protectedData:\n\t" + protectedData);
|
||||||
map.remove(hashOfPayload);
|
map.remove(hashOfPayload);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -240,6 +238,7 @@ public class P2PDataStorage implements MessageListener, ConnectionListener {
|
||||||
checkIfStoredDataPubKeyMatchesNewDataPubKey(ownerPubKey, hashOfPayload);
|
checkIfStoredDataPubKeyMatchesNewDataPubKey(ownerPubKey, hashOfPayload);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
|
log.error("refreshDate called for storedData:\n\t" + StringUtils.abbreviate(storedData.toString(), 100));
|
||||||
storedData.refreshDate();
|
storedData.refreshDate();
|
||||||
|
|
||||||
sequenceNumberMap.put(hashOfPayload, new MapValue(sequenceNumber, System.currentTimeMillis()));
|
sequenceNumberMap.put(hashOfPayload, new MapValue(sequenceNumber, System.currentTimeMillis()));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue