Merge pull request #6546 from jmacxx/offer_availability_dao_sync_check

Maker check DAO health when handling OfferAvailabilityRequest.
This commit is contained in:
Alejandro García 2023-02-03 15:10:57 +00:00 committed by GitHub
commit 27613de363
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 2 deletions

View File

@ -79,6 +79,7 @@ public class BisqHeadlessApp implements HeadlessApp {
bisqSetup.setSpvFileCorruptedHandler(msg -> log.error("onSpvFileCorruptedHandler: msg={}", msg));
bisqSetup.setChainFileLockedExceptionHandler(msg -> log.error("onChainFileLockedExceptionHandler: msg={}", msg));
bisqSetup.setDiskSpaceWarningHandler(msg -> log.error("onDiskSpaceWarningHandler: msg={}", msg));
bisqSetup.setChainNotSyncedHandler(msg -> log.error("onChainNotSyncedHandler: msg={}", msg));
bisqSetup.setLockedUpFundsHandler(msg -> log.info("onLockedUpFundsHandler: msg={}", msg));
bisqSetup.setShowFirstPopupIfResyncSPVRequestedHandler(() -> log.info("onShowFirstPopupIfResyncSPVRequestedHandler"));
bisqSetup.setRequestWalletPasswordHandler(aesKeyHandler -> log.info("onRequestWalletPasswordHandler"));

View File

@ -164,7 +164,7 @@ public class BisqSetup {
filterWarningHandler, displaySecurityRecommendationHandler, displayLocalhostHandler,
wrongOSArchitectureHandler, displaySignedByArbitratorHandler,
displaySignedByPeerHandler, displayPeerLimitLiftedHandler, displayPeerSignerHandler,
rejectedTxErrorMessageHandler, diskSpaceWarningHandler;
rejectedTxErrorMessageHandler, diskSpaceWarningHandler, chainNotSyncedHandler;
@Setter
@Nullable
private Consumer<Boolean> displayTorNetworkSettingsHandler;
@ -481,6 +481,7 @@ public class BisqSetup {
daoErrorMessageHandler,
daoWarnMessageHandler,
filterWarningHandler,
chainNotSyncedHandler,
voteResultExceptionHandler,
revolutAccountsUpdateHandler,
amazonGiftCardAccountsUpdateHandler,

View File

@ -204,6 +204,7 @@ public class DomainInitialisation {
Consumer<String> daoErrorMessageHandler,
Consumer<String> daoWarnMessageHandler,
Consumer<String> filterWarningHandler,
Consumer<String> chainNotSyncedHandler,
Consumer<VoteResultException> voteResultExceptionHandler,
Consumer<List<RevolutAccount>> revolutAccountsUpdateHandler,
Consumer<List<AmazonGiftCardAccount>> amazonGiftCardAccountsUpdateHandler,
@ -225,6 +226,7 @@ public class DomainInitialisation {
failedTradesManager.onAllServicesInitialized();
xmrTxProofService.onAllServicesInitialized();
openOfferManager.setChainNotSyncedHandler(chainNotSyncedHandler);
openOfferManager.onAllServicesInitialized();
openBsqSwapOfferService.onAllServicesInitialized();

View File

@ -89,9 +89,11 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import javax.annotation.Nullable;
@ -133,6 +135,8 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
private final TradableList<OpenOffer> openOffers = new TradableList<>();
private boolean stopped;
private Timer periodicRepublishOffersTimer, periodicRefreshOffersTimer, retryRepublishOffersTimer;
@Setter
private Consumer<String> chainNotSyncedHandler;
@Getter
private final ObservableList<Tuple2<OpenOffer, String>> invalidOffers = FXCollections.observableArrayList();
@ -653,6 +657,20 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
errorMessage = "We got a handleOfferAvailabilityRequest but our chain is not synced.";
log.info(errorMessage);
sendAckMessage(request, peer, false, errorMessage);
if (chainNotSyncedHandler != null) {
chainNotSyncedHandler.accept(Res.get("popup.warning.chainNotSynced"));
}
return;
}
// Don't allow trade start if DAO is not fully synced
if (!daoFacade.isDaoStateReadyAndInSync()) {
errorMessage = "We got a handleOfferAvailabilityRequest but our DAO is not synced.";
log.info(errorMessage);
sendAckMessage(request, peer, false, errorMessage);
if (chainNotSyncedHandler != null) {
chainNotSyncedHandler.accept(Res.get("popup.warning.daoNeedsResync"));
}
return;
}

View File

@ -399,7 +399,11 @@ public class MainViewModel implements ViewModel, BisqSetup.BisqSetupListener {
new Popup().warning(msg).show();
}
});
bisqSetup.setChainNotSyncedHandler(msg -> {
if (PopupManager.isNoPopupDisplayed()) {
new Popup().warning(msg).show();
}
});
bisqSetup.setLockedUpFundsHandler(msg -> {
// repeated popups of the same message text can be stopped by selecting the "Dont show again" checkbox
String key = Hex.encode(Hash.getSha256Ripemd160hash(msg.getBytes(Charsets.UTF_8)));