From b3261cbbd3b0f16095b1a85e1063d32da9e2a0dc Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Wed, 15 Aug 2018 22:08:06 +0200 Subject: [PATCH 1/4] Fix backward compatibility issues - Add Dao capabilities only if dao is activated - Change argument type for noCapabilityRequiredOrCapabilityIsSupported method - Fix wrong argument passed for noCapabilityRequiredOrCapabilityIsSupported --- .../core/notifications/alerts/TradeEvents.java | 1 - .../bisq/core/setup/CoreNetworkCapabilities.java | 14 ++++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/bisq/core/notifications/alerts/TradeEvents.java b/src/main/java/bisq/core/notifications/alerts/TradeEvents.java index 50bd4986..43f51ec8 100644 --- a/src/main/java/bisq/core/notifications/alerts/TradeEvents.java +++ b/src/main/java/bisq/core/notifications/alerts/TradeEvents.java @@ -65,7 +65,6 @@ private void setTradePhaseListener(Trade trade) { if (!trade.isPayoutPublished()) { trade.statePhaseProperty().addListener((observable, oldValue, newValue) -> { String msg = null; - log.error("setTradePhaseListener phase " + newValue); String shortId = trade.getShortId(); switch (newValue) { case INIT: diff --git a/src/main/java/bisq/core/setup/CoreNetworkCapabilities.java b/src/main/java/bisq/core/setup/CoreNetworkCapabilities.java index a39afcd3..9143bb64 100644 --- a/src/main/java/bisq/core/setup/CoreNetworkCapabilities.java +++ b/src/main/java/bisq/core/setup/CoreNetworkCapabilities.java @@ -31,14 +31,16 @@ public static void setSupportedCapabilities(BisqEnvironment bisqEnvironment) { Capabilities.Capability.TRADE_STATISTICS.ordinal(), Capabilities.Capability.TRADE_STATISTICS_2.ordinal(), Capabilities.Capability.ACCOUNT_AGE_WITNESS.ordinal(), - Capabilities.Capability.ACK_MSG.ordinal(), - Capabilities.Capability.PROPOSAL.ordinal(), - Capabilities.Capability.BLIND_VOTE.ordinal() + Capabilities.Capability.ACK_MSG.ordinal() )); - Boolean fullDaoNode = bisqEnvironment.getProperty(DaoOptionKeys.FULL_DAO_NODE, Boolean.class, false); - if (fullDaoNode) - supportedCapabilities.add(Capabilities.Capability.DAO_FULL_NODE.ordinal()); + if (bisqEnvironment.getProperty(DaoOptionKeys.DAO_ACTIVATED, Boolean.class, false)) { + supportedCapabilities.add(Capabilities.Capability.PROPOSAL.ordinal()); + supportedCapabilities.add(Capabilities.Capability.BLIND_VOTE.ordinal()); + + if (bisqEnvironment.getProperty(DaoOptionKeys.FULL_DAO_NODE, Boolean.class, false)) + supportedCapabilities.add(Capabilities.Capability.DAO_FULL_NODE.ordinal()); + } Capabilities.setSupportedCapabilities(supportedCapabilities); } From 32cbbf8445693f3fdd4ad1ccc2368fb939f8719a Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Wed, 15 Aug 2018 22:48:58 +0200 Subject: [PATCH 2/4] Fix backward compatibility issues - Add BSQ_BLOCK to capabilities for broadcast of new BSQ blocks - Make NewBlockBroadcastMessage implements CapabilityRequiringPayload - Call daoSetup.onAllServicesInitialized only if dao is activated - Publish bsq block only after parsing is complete --- src/main/java/bisq/core/app/BisqSetup.java | 10 ++++++---- .../java/bisq/core/dao/node/full/FullNode.java | 2 +- .../node/full/network/FullNodeNetworkService.java | 2 +- .../node/messages/NewBlockBroadcastMessage.java | 15 ++++++++++++++- .../bisq/core/setup/CoreNetworkCapabilities.java | 1 + 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/main/java/bisq/core/app/BisqSetup.java b/src/main/java/bisq/core/app/BisqSetup.java index 1f5a4d89..12dd7750 100644 --- a/src/main/java/bisq/core/app/BisqSetup.java +++ b/src/main/java/bisq/core/app/BisqSetup.java @@ -606,10 +606,12 @@ public void onBalanceChanged(Coin balance, Transaction tx) { feeService.onAllServicesInitialized(); - daoSetup.onAllServicesInitialized(errorMessage -> { - if (daoSetupErrorHandler != null) - daoSetupErrorHandler.accept(errorMessage); - }); + if (DevEnv.isDaoActivated()) { + daoSetup.onAllServicesInitialized(errorMessage -> { + if (daoSetupErrorHandler != null) + daoSetupErrorHandler.accept(errorMessage); + }); + } tradeStatisticsManager.onAllServicesInitialized(); diff --git a/src/main/java/bisq/core/dao/node/full/FullNode.java b/src/main/java/bisq/core/dao/node/full/FullNode.java index fcaba975..05b9ac7d 100644 --- a/src/main/java/bisq/core/dao/node/full/FullNode.java +++ b/src/main/java/bisq/core/dao/node/full/FullNode.java @@ -149,7 +149,7 @@ private void addBlockHandler() { private void onNewBlock(Block block) { jsonBlockChainExporter.maybeExport(); - if (p2pNetworkReady) + if (p2pNetworkReady && parseBlockchainComplete) fullNodeNetworkService.publishNewBlock(block); } diff --git a/src/main/java/bisq/core/dao/node/full/network/FullNodeNetworkService.java b/src/main/java/bisq/core/dao/node/full/network/FullNodeNetworkService.java index fd579415..4f19f596 100644 --- a/src/main/java/bisq/core/dao/node/full/network/FullNodeNetworkService.java +++ b/src/main/java/bisq/core/dao/node/full/network/FullNodeNetworkService.java @@ -98,7 +98,7 @@ public void shutDown() { public void publishNewBlock(Block block) { log.info("Publish new block at height={} and block hash={}", block.getHeight(), block.getHash()); RawBlock rawBlock = RawBlock.fromBlock(block); - final NewBlockBroadcastMessage newBlockBroadcastMessage = new NewBlockBroadcastMessage(rawBlock); + NewBlockBroadcastMessage newBlockBroadcastMessage = new NewBlockBroadcastMessage(rawBlock); broadcaster.broadcast(newBlockBroadcastMessage, networkNode.getNodeAddress(), null, true); } diff --git a/src/main/java/bisq/core/dao/node/messages/NewBlockBroadcastMessage.java b/src/main/java/bisq/core/dao/node/messages/NewBlockBroadcastMessage.java index d9553158..0d565e50 100644 --- a/src/main/java/bisq/core/dao/node/messages/NewBlockBroadcastMessage.java +++ b/src/main/java/bisq/core/dao/node/messages/NewBlockBroadcastMessage.java @@ -20,12 +20,18 @@ import bisq.core.dao.state.blockchain.RawBlock; import bisq.network.p2p.storage.messages.BroadcastMessage; +import bisq.network.p2p.storage.payload.CapabilityRequiringPayload; +import bisq.common.app.Capabilities; import bisq.common.app.Version; import bisq.common.proto.network.NetworkEnvelope; import io.bisq.generated.protobuffer.PB; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + import lombok.EqualsAndHashCode; import lombok.Getter; @@ -33,7 +39,7 @@ // nodes when they receive the NewBlockBroadcastMessage! @EqualsAndHashCode(callSuper = true) @Getter -public final class NewBlockBroadcastMessage extends BroadcastMessage { +public final class NewBlockBroadcastMessage extends BroadcastMessage implements CapabilityRequiringPayload { private final RawBlock block; public NewBlockBroadcastMessage(RawBlock block) { @@ -62,4 +68,11 @@ public static NetworkEnvelope fromProto(PB.NewBlockBroadcastMessage proto, int m return new NewBlockBroadcastMessage(RawBlock.fromProto(proto.getRawBlock()), messageVersion); } + + @Override + public List getRequiredCapabilities() { + return new ArrayList<>(Collections.singletonList( + Capabilities.Capability.BSQ_BLOCK.ordinal() + )); + } } diff --git a/src/main/java/bisq/core/setup/CoreNetworkCapabilities.java b/src/main/java/bisq/core/setup/CoreNetworkCapabilities.java index 9143bb64..5d0c55f4 100644 --- a/src/main/java/bisq/core/setup/CoreNetworkCapabilities.java +++ b/src/main/java/bisq/core/setup/CoreNetworkCapabilities.java @@ -37,6 +37,7 @@ public static void setSupportedCapabilities(BisqEnvironment bisqEnvironment) { if (bisqEnvironment.getProperty(DaoOptionKeys.DAO_ACTIVATED, Boolean.class, false)) { supportedCapabilities.add(Capabilities.Capability.PROPOSAL.ordinal()); supportedCapabilities.add(Capabilities.Capability.BLIND_VOTE.ordinal()); + supportedCapabilities.add(Capabilities.Capability.BSQ_BLOCK.ordinal()); if (bisqEnvironment.getProperty(DaoOptionKeys.FULL_DAO_NODE, Boolean.class, false)) supportedCapabilities.add(Capabilities.Capability.DAO_FULL_NODE.ordinal()); From 2495f70bf0441f90365f8a88f3249801d88e7db9 Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Wed, 15 Aug 2018 23:00:57 +0200 Subject: [PATCH 3/4] DAO: Show only ballots of current cycle --- src/main/java/bisq/core/dao/DaoFacade.java | 5 +++++ .../dao/governance/ballot/BallotListPresentation.java | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/src/main/java/bisq/core/dao/DaoFacade.java b/src/main/java/bisq/core/dao/DaoFacade.java index 1399b06a..7aa6d381 100644 --- a/src/main/java/bisq/core/dao/DaoFacade.java +++ b/src/main/java/bisq/core/dao/DaoFacade.java @@ -70,6 +70,7 @@ import javafx.beans.property.SimpleObjectProperty; import javafx.collections.ObservableList; +import javafx.collections.transformation.FilteredList; import java.util.List; import java.util.Optional; @@ -259,6 +260,10 @@ public ObservableList getBallots() { return ballotListPresentation.getBallots(); } + public FilteredList getBallotsOfCycle() { + return ballotListPresentation.getBallotsOfCycle(); + } + public Tuple2 getMeritAndStakeForProposal(String proposalTxId) { return myVoteListService.getMeritAndStakeForProposal(proposalTxId, myBlindVoteListService); } diff --git a/src/main/java/bisq/core/dao/governance/ballot/BallotListPresentation.java b/src/main/java/bisq/core/dao/governance/ballot/BallotListPresentation.java index 8e5792a7..65d50ef7 100644 --- a/src/main/java/bisq/core/dao/governance/ballot/BallotListPresentation.java +++ b/src/main/java/bisq/core/dao/governance/ballot/BallotListPresentation.java @@ -27,6 +27,7 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; +import javafx.collections.transformation.FilteredList; import java.util.List; @@ -39,9 +40,13 @@ @Slf4j public class BallotListPresentation implements BallotListService.BallotListChangeListener, BsqStateListener { private final BallotListService ballotListService; + private final PeriodService periodService; + private final BsqStateService bsqStateService; @Getter private final ObservableList ballots = FXCollections.observableArrayList(); + @Getter + private final FilteredList ballotsOfCycle = new FilteredList<>(ballots); /////////////////////////////////////////////////////////////////////////////////////////// @@ -54,6 +59,8 @@ public BallotListPresentation(BallotListService ballotListService, BsqStateService bsqStateService, ProposalValidator proposalValidator) { this.ballotListService = ballotListService; + this.periodService = periodService; + this.bsqStateService = bsqStateService; bsqStateService.addBsqStateListener(this); ballotListService.addListener(this); @@ -70,6 +77,8 @@ public void onNewBlockHeight(int blockHeight) { @Override public void onParseTxsComplete(Block block) { onListChanged(ballotListService.getBallotList().getList()); + + ballotsOfCycle.setPredicate(ballot -> periodService.isTxInCorrectCycle(ballot.getTxId(), bsqStateService.getChainHeight())); } @Override From 15e1e4e111af39550a4810330b2fb565a8c099ee Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Wed, 15 Aug 2018 23:48:49 +0200 Subject: [PATCH 4/4] Set notification flag to true if user updates from old version --- src/main/java/bisq/core/user/Preferences.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/bisq/core/user/Preferences.java b/src/main/java/bisq/core/user/Preferences.java index 731e0f9f..15e830e1 100644 --- a/src/main/java/bisq/core/user/Preferences.java +++ b/src/main/java/bisq/core/user/Preferences.java @@ -279,6 +279,15 @@ else if (useTorFlagFromOptions.equals("true")) if (referralIdFromOptions != null && !referralIdFromOptions.isEmpty()) setReferralId(referralIdFromOptions); + // For users from old versions the 4 flags a false but we want to have it true by default + // PhoneKeyAndToken is also null so we can use that to enable the flags + if (prefPayload.getPhoneKeyAndToken() == null) { + setUseSoundForMobileNotifications(true); + setUseTradeNotifications(true); + setUseMarketNotifications(true); + setUsePriceNotifications(true); + } + initialReadDone = true; persist(); }