mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-07-22 06:38:55 -04:00
Add isOwner flag for broadcasting to all peers, remove popup for disconnects of rule violations, reduce max nr of network threads
This commit is contained in:
parent
60c8de796a
commit
aecbf7ced9
19 changed files with 130 additions and 153 deletions
|
@ -50,7 +50,7 @@ public class AlertService {
|
|||
}
|
||||
|
||||
public void addAlertMessage(Alert alert, @Nullable ResultHandler resultHandler, @Nullable ErrorMessageHandler errorMessageHandler) {
|
||||
boolean result = p2PService.addData(alert);
|
||||
boolean result = p2PService.addData(alert, true, true);
|
||||
if (result) {
|
||||
log.trace("Add alertMessage to network was successful. AlertMessage = " + alert);
|
||||
if (resultHandler != null) resultHandler.handleResult();
|
||||
|
@ -60,11 +60,13 @@ public class AlertService {
|
|||
}
|
||||
|
||||
public void removeAlertMessage(Alert alert, @Nullable ResultHandler resultHandler, @Nullable ErrorMessageHandler errorMessageHandler) {
|
||||
if (p2PService.removeData(alert)) {
|
||||
if (p2PService.removeData(alert, true)) {
|
||||
log.trace("Remove alertMessage from network was successful. AlertMessage = " + alert);
|
||||
if (resultHandler != null) resultHandler.handleResult();
|
||||
if (resultHandler != null)
|
||||
resultHandler.handleResult();
|
||||
} else {
|
||||
if (errorMessageHandler != null) errorMessageHandler.handleErrorMessage("Remove alertMessage failed");
|
||||
if (errorMessageHandler != null)
|
||||
errorMessageHandler.handleErrorMessage("Remove alertMessage failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ public class ArbitratorService {
|
|||
|
||||
public void addArbitrator(Arbitrator arbitrator, final ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
|
||||
log.debug("addArbitrator arbitrator.hashCode() " + arbitrator.hashCode());
|
||||
boolean result = p2PService.addData(arbitrator);
|
||||
boolean result = p2PService.addData(arbitrator, true, true);
|
||||
if (result) {
|
||||
log.trace("Add arbitrator to network was successful. Arbitrator.hashCode() = " + arbitrator.hashCode());
|
||||
resultHandler.handleResult();
|
||||
|
@ -70,7 +70,7 @@ public class ArbitratorService {
|
|||
|
||||
public void removeArbitrator(Arbitrator arbitrator, ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
|
||||
log.debug("removeArbitrator arbitrator.hashCode() " + arbitrator.hashCode());
|
||||
if (p2PService.removeData(arbitrator)) {
|
||||
if (p2PService.removeData(arbitrator, true)) {
|
||||
log.trace("Remove arbitrator from network was successful. Arbitrator.hashCode() = " + arbitrator.hashCode());
|
||||
resultHandler.handleResult();
|
||||
} else {
|
||||
|
|
|
@ -58,7 +58,7 @@ public final class Offer implements StoragePayload, RequiresOwnerIsOnlinePayload
|
|||
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||
@JsonExclude
|
||||
private static final Logger log = LoggerFactory.getLogger(Offer.class);
|
||||
public static final long TTL = TimeUnit.SECONDS.toMillis(60);
|
||||
public static final long TTL = TimeUnit.SECONDS.toMillis(4 * 60);
|
||||
public final static String TAC_OFFERER = "When placing that offer I accept that anyone who fulfills my conditions can " +
|
||||
"take that offer.";
|
||||
public static final String TAC_TAKER = "With taking the offer I commit to the trade conditions as defined.";
|
||||
|
|
|
@ -93,8 +93,8 @@ public class OfferBookService {
|
|||
doAddOffer(offer, resultHandler, errorMessageHandler, false);
|
||||
}
|
||||
|
||||
public void doAddOffer(Offer offer, ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler, boolean forceBroadcast) {
|
||||
boolean result = p2PService.addData(offer, forceBroadcast);
|
||||
private void doAddOffer(Offer offer, ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler, boolean forceBroadcast) {
|
||||
boolean result = p2PService.addData(offer, forceBroadcast, true);
|
||||
if (result) {
|
||||
log.trace("Add offer to network was successful. Offer ID = " + offer.getId());
|
||||
resultHandler.handleResult();
|
||||
|
@ -104,7 +104,7 @@ public class OfferBookService {
|
|||
}
|
||||
|
||||
public void refreshOffer(Offer offer, ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
|
||||
boolean result = p2PService.refreshTTL(offer);
|
||||
boolean result = p2PService.refreshTTL(offer, true);
|
||||
if (result) {
|
||||
log.trace("Add offer to network was successful. Offer ID = " + offer.getId());
|
||||
resultHandler.handleResult();
|
||||
|
@ -114,7 +114,7 @@ public class OfferBookService {
|
|||
}
|
||||
|
||||
public void removeOffer(Offer offer, @Nullable ResultHandler resultHandler, @Nullable ErrorMessageHandler errorMessageHandler) {
|
||||
if (p2PService.removeData(offer)) {
|
||||
if (p2PService.removeData(offer, true)) {
|
||||
log.trace("Remove offer from network was successful. Offer ID = " + offer.getId());
|
||||
if (resultHandler != null)
|
||||
resultHandler.handleResult();
|
||||
|
|
|
@ -33,7 +33,6 @@ import io.bitsquare.p2p.NodeAddress;
|
|||
import io.bitsquare.p2p.P2PService;
|
||||
import io.bitsquare.p2p.messaging.DecryptedDirectMessageListener;
|
||||
import io.bitsquare.p2p.messaging.SendDirectMessageListener;
|
||||
import io.bitsquare.p2p.peers.BroadcastHandler;
|
||||
import io.bitsquare.p2p.peers.PeerManager;
|
||||
import io.bitsquare.storage.Storage;
|
||||
import io.bitsquare.trade.TradableList;
|
||||
|
@ -63,7 +62,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
|||
|
||||
private static final long RETRY_REPUBLISH_DELAY_SEC = Timer.STRESS_TEST ? 1 : 5;
|
||||
private static final long REPUBLISH_AGAIN_AT_STARTUP_DELAY_SEC = Timer.STRESS_TEST ? 1 : 10;
|
||||
private static final long REPUBLISH_INTERVAL_MS = Timer.STRESS_TEST ? 3000 : 10 * Offer.TTL;
|
||||
private static final long REPUBLISH_INTERVAL_MS = Timer.STRESS_TEST ? 3000 : 2 * Offer.TTL;
|
||||
private static final long REFRESH_INTERVAL_MS = Timer.STRESS_TEST ? 1000 : (long) (Offer.TTL * 0.5);
|
||||
|
||||
private final KeyRing keyRing;
|
||||
|
@ -140,7 +139,6 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
|||
log.info("remove all open offers at shutDown");
|
||||
// we remove own offers from offerbook when we go offline
|
||||
// Normally we use a delay for broadcasting to the peers, but at shut down we want to get it fast out
|
||||
BroadcastHandler.useDelay(false);
|
||||
openOffers.forEach(openOffer -> offerBookService.removeOfferAtShutDown(openOffer.getOffer()));
|
||||
|
||||
if (completeHandler != null)
|
||||
|
|
|
@ -19,7 +19,6 @@ package io.bitsquare.trade.protocol.placeoffer.tasks;
|
|||
|
||||
import io.bitsquare.common.taskrunner.Task;
|
||||
import io.bitsquare.common.taskrunner.TaskRunner;
|
||||
import io.bitsquare.p2p.peers.BroadcastHandler;
|
||||
import io.bitsquare.trade.protocol.placeoffer.PlaceOfferModel;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -35,11 +34,9 @@ public class AddOfferToRemoteOfferBook extends Task<PlaceOfferModel> {
|
|||
protected void run() {
|
||||
try {
|
||||
runInterceptHook();
|
||||
BroadcastHandler.useDelay(false);
|
||||
model.offerBookService.addOffer(model.offer,
|
||||
() -> {
|
||||
model.offerAddedToOfferBook = true;
|
||||
BroadcastHandler.useDelay(true);
|
||||
complete();
|
||||
},
|
||||
errorMessage -> {
|
||||
|
|
|
@ -22,7 +22,6 @@ import io.bitsquare.btc.AddressEntry;
|
|||
import io.bitsquare.btc.FeePolicy;
|
||||
import io.bitsquare.common.taskrunner.Task;
|
||||
import io.bitsquare.common.taskrunner.TaskRunner;
|
||||
import io.bitsquare.p2p.peers.BroadcastHandler;
|
||||
import io.bitsquare.trade.offer.Offer;
|
||||
import io.bitsquare.trade.protocol.placeoffer.PlaceOfferModel;
|
||||
import org.bitcoinj.core.Coin;
|
||||
|
@ -63,7 +62,6 @@ public class BroadcastCreateOfferFeeTx extends Task<PlaceOfferModel> {
|
|||
// Tx malleability happened after broadcast. We first remove the malleable offer.
|
||||
// Then we publish the changed offer to the P2P network again after setting the new TxId.
|
||||
// Normally we use a delay for broadcasting to the peers, but at shut down we want to get it fast out
|
||||
BroadcastHandler.useDelay(false);
|
||||
model.offerBookService.removeOffer(model.offer,
|
||||
() -> {
|
||||
log.info("We store now the changed txID to the offer and add that again.");
|
||||
|
@ -71,10 +69,7 @@ public class BroadcastCreateOfferFeeTx extends Task<PlaceOfferModel> {
|
|||
model.offer.setOfferFeePaymentTxID(transaction.getHashAsString());
|
||||
model.setTransaction(transaction);
|
||||
model.offerBookService.addOffer(model.offer,
|
||||
() -> {
|
||||
BroadcastHandler.useDelay(true);
|
||||
complete();
|
||||
},
|
||||
() -> complete(),
|
||||
errorMessage -> {
|
||||
log.error("addOffer failed");
|
||||
addOfferFailed = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue