diff --git a/core/src/main/java/bisq/core/account/sign/SignedWitnessService.java b/core/src/main/java/bisq/core/account/sign/SignedWitnessService.java index f33dd7d234..498d8e7bba 100644 --- a/core/src/main/java/bisq/core/account/sign/SignedWitnessService.java +++ b/core/src/main/java/bisq/core/account/sign/SignedWitnessService.java @@ -140,7 +140,7 @@ public class SignedWitnessService { } else { p2PService.addP2PServiceListener(new BootstrapListener() { @Override - public void onUpdatedDataReceived() { + public void onDataReceived() { onBootstrapComplete(); } }); diff --git a/core/src/main/java/bisq/core/account/witness/AccountAgeWitnessService.java b/core/src/main/java/bisq/core/account/witness/AccountAgeWitnessService.java index 649dfaf756..5261676e23 100644 --- a/core/src/main/java/bisq/core/account/witness/AccountAgeWitnessService.java +++ b/core/src/main/java/bisq/core/account/witness/AccountAgeWitnessService.java @@ -214,7 +214,7 @@ public class AccountAgeWitnessService { } else { p2PService.addP2PServiceListener(new BootstrapListener() { @Override - public void onUpdatedDataReceived() { + public void onDataReceived() { onBootStrapped(); } }); diff --git a/core/src/main/java/bisq/core/app/AppStartupState.java b/core/src/main/java/bisq/core/app/AppStartupState.java index 6163b1a3cb..c9c2e7dde5 100644 --- a/core/src/main/java/bisq/core/app/AppStartupState.java +++ b/core/src/main/java/bisq/core/app/AppStartupState.java @@ -48,7 +48,7 @@ public class AppStartupState { private final BooleanProperty walletAndNetworkReady = new SimpleBooleanProperty(); private final BooleanProperty allDomainServicesInitialized = new SimpleBooleanProperty(); private final BooleanProperty applicationFullyInitialized = new SimpleBooleanProperty(); - private final BooleanProperty updatedDataReceived = new SimpleBooleanProperty(); + private final BooleanProperty dataReceived = new SimpleBooleanProperty(); private final BooleanProperty isBlockDownloadComplete = new SimpleBooleanProperty(); private final BooleanProperty hasSufficientPeersForBroadcast = new SimpleBooleanProperty(); @@ -57,8 +57,8 @@ public class AppStartupState { p2PService.addP2PServiceListener(new BootstrapListener() { @Override - public void onUpdatedDataReceived() { - updatedDataReceived.set(true); + public void onDataReceived() { + dataReceived.set(true); } }); @@ -72,7 +72,7 @@ public class AppStartupState { hasSufficientPeersForBroadcast.set(true); }); - p2pNetworkAndWalletInitialized = EasyBind.combine(updatedDataReceived, + p2pNetworkAndWalletInitialized = EasyBind.combine(dataReceived, isBlockDownloadComplete, hasSufficientPeersForBroadcast, allDomainServicesInitialized, @@ -122,14 +122,6 @@ public class AppStartupState { return applicationFullyInitialized; } - public boolean isUpdatedDataReceived() { - return updatedDataReceived.get(); - } - - public ReadOnlyBooleanProperty updatedDataReceivedProperty() { - return updatedDataReceived; - } - public boolean isBlockDownloadComplete() { return isBlockDownloadComplete.get(); } diff --git a/core/src/main/java/bisq/core/app/BisqSetup.java b/core/src/main/java/bisq/core/app/BisqSetup.java index 11eaf06007..bb1a528169 100644 --- a/core/src/main/java/bisq/core/app/BisqSetup.java +++ b/core/src/main/java/bisq/core/app/BisqSetup.java @@ -849,8 +849,8 @@ public class BisqSetup { return p2PNetworkSetup.getP2PNetworkStatusIconId(); } - public BooleanProperty getUpdatedDataReceived() { - return p2PNetworkSetup.getUpdatedDataReceived(); + public BooleanProperty getDataReceived() { + return p2PNetworkSetup.getDataReceived(); } public StringProperty getP2pNetworkLabelId() { diff --git a/core/src/main/java/bisq/core/app/P2PNetworkSetup.java b/core/src/main/java/bisq/core/app/P2PNetworkSetup.java index 6f474a7899..b3069fd574 100644 --- a/core/src/main/java/bisq/core/app/P2PNetworkSetup.java +++ b/core/src/main/java/bisq/core/app/P2PNetworkSetup.java @@ -73,7 +73,7 @@ public class P2PNetworkSetup { @Getter final StringProperty p2pNetworkWarnMsg = new SimpleStringProperty(); @Getter - final BooleanProperty updatedDataReceived = new SimpleBooleanProperty(); + final BooleanProperty dataReceived = new SimpleBooleanProperty(); @Getter final BooleanProperty p2pNetworkFailed = new SimpleBooleanProperty(); final FilterManager filterManager; @@ -97,12 +97,11 @@ public class P2PNetworkSetup { StringProperty bootstrapState = new SimpleStringProperty(); StringProperty bootstrapWarning = new SimpleStringProperty(); BooleanProperty hiddenServicePublished = new SimpleBooleanProperty(); - BooleanProperty initialP2PNetworkDataReceived = new SimpleBooleanProperty(); addP2PMessageFilter(); p2PNetworkInfoBinding = EasyBind.combine(bootstrapState, bootstrapWarning, p2PService.getNumConnectedPeers(), - walletsSetup.numPeersProperty(), hiddenServicePublished, initialP2PNetworkDataReceived, + walletsSetup.numPeersProperty(), hiddenServicePublished, dataReceived, (state, warning, numP2pPeers, numBtcPeers, hiddenService, dataReceived) -> { String result; String daoFullNode = preferences.isDaoFullNode() ? Res.get("mainView.footer.daoFullNode") + " / " : ""; @@ -171,8 +170,8 @@ public class P2PNetworkSetup { @Override public void onDataReceived() { log.debug("onRequestingDataCompleted"); - initialP2PNetworkDataReceived.set(true); bootstrapState.set(Res.get("mainView.bootstrapState.initialDataReceived")); + dataReceived.set(true); splashP2PNetworkAnimationVisible.set(false); p2pNetworkInitialized.set(true); } @@ -208,7 +207,6 @@ public class P2PNetworkSetup { public void onUpdatedDataReceived() { log.debug("onUpdatedDataReceived"); splashP2PNetworkAnimationVisible.set(false); - updatedDataReceived.set(true); } @Override diff --git a/core/src/main/java/bisq/core/dao/burningman/accounting/node/AccountingNode.java b/core/src/main/java/bisq/core/dao/burningman/accounting/node/AccountingNode.java index ef0b790e38..16fb164027 100644 --- a/core/src/main/java/bisq/core/dao/burningman/accounting/node/AccountingNode.java +++ b/core/src/main/java/bisq/core/dao/burningman/accounting/node/AccountingNode.java @@ -183,7 +183,7 @@ public abstract class AccountingNode implements DaoSetupService, DaoStateListene } @Override - public void onUpdatedDataReceived() { + public void onDataReceived() { onP2PNetworkReady(); } }; diff --git a/core/src/main/java/bisq/core/dao/node/BsqNode.java b/core/src/main/java/bisq/core/dao/node/BsqNode.java index 0bebd702da..8d8a5393a0 100644 --- a/core/src/main/java/bisq/core/dao/node/BsqNode.java +++ b/core/src/main/java/bisq/core/dao/node/BsqNode.java @@ -113,6 +113,7 @@ public abstract class BsqNode implements DaoSetupService { @Override public void onDataReceived() { + onP2PNetworkReady(); } @Override @@ -126,7 +127,6 @@ public abstract class BsqNode implements DaoSetupService { @Override public void onUpdatedDataReceived() { - onP2PNetworkReady(); } }; } diff --git a/core/src/main/java/bisq/core/dao/node/full/network/GetBlocksRequestHandler.java b/core/src/main/java/bisq/core/dao/node/full/network/GetBlocksRequestHandler.java index 411d49de4f..fac1616ce5 100644 --- a/core/src/main/java/bisq/core/dao/node/full/network/GetBlocksRequestHandler.java +++ b/core/src/main/java/bisq/core/dao/node/full/network/GetBlocksRequestHandler.java @@ -91,9 +91,12 @@ class GetBlocksRequestHandler { public void onGetBlocksRequest(GetBlocksRequest getBlocksRequest, Connection connection) { long ts = System.currentTimeMillis(); - // We limit number of blocks to 3000 which is about 3 weeks. - List blocks = new LinkedList<>(daoStateService.getBlocksFromBlockHeight(getBlocksRequest.getFromBlockHeight(), 3000)); - List rawBlocks = blocks.stream().map(RawBlock::fromBlock).collect(Collectors.toList()); + // We limit number of blocks to 3000 which is about 3 weeks and about 5 MB on data + List blocks = daoStateService.getBlocksFromBlockHeight(getBlocksRequest.getFromBlockHeight()); + List rawBlocks = new LinkedList<>(blocks).stream() + .map(RawBlock::fromBlock) + .limit(3000) + .collect(Collectors.toList()); GetBlocksResponse getBlocksResponse = new GetBlocksResponse(rawBlocks, getBlocksRequest.getNonce()); log.info("Received GetBlocksRequest from {} for blocks from height {}. " + "Building GetBlocksResponse with {} blocks took {} ms.", diff --git a/core/src/main/java/bisq/core/dao/node/lite/LiteNode.java b/core/src/main/java/bisq/core/dao/node/lite/LiteNode.java index 68e2769e14..952b2ae57a 100644 --- a/core/src/main/java/bisq/core/dao/node/lite/LiteNode.java +++ b/core/src/main/java/bisq/core/dao/node/lite/LiteNode.java @@ -87,6 +87,7 @@ public class LiteNode extends BsqNode { blockDownloadListener = (observable, oldValue, newValue) -> { if ((double) newValue == 1) { setupWalletBestBlockListener(); + maybeStartRequestingBlocks(); } }; } @@ -176,8 +177,13 @@ public class LiteNode extends BsqNode { } }); - if (!parseBlockchainComplete) + maybeStartRequestingBlocks(); + } + + private void maybeStartRequestingBlocks() { + if (walletsSetup.isDownloadComplete() && p2pNetworkReady && !parseBlockchainComplete) { startParseBlocks(); + } } // First we request the blocks from a full node @@ -192,7 +198,8 @@ public class LiteNode extends BsqNode { return; } - // If we request blocks we increment the ConnectionState counter. + // If we request blocks we increment the ConnectionState counter so that the connection does not get reset from + // INITIAL_DATA_EXCHANGE to PEER and therefore lower priority for getting closed ConnectionState.incrementExpectedInitialDataResponses(); if (chainHeight == daoStateService.getGenesisBlockHeight()) { @@ -229,6 +236,11 @@ public class LiteNode extends BsqNode { return; } + if (walletsSetup.isDownloadComplete() && chainTipHeight < bsqWalletService.getBestChainHeight()) { + // We need to request more blocks and increment the ConnectionState counter so that the connection does not get reset from + // INITIAL_DATA_EXCHANGE to PEER and therefore lower priority for getting closed + ConnectionState.incrementExpectedInitialDataResponses(); + } runDelayedBatchProcessing(new ArrayList<>(blockList), () -> { double duration = System.currentTimeMillis() - ts; @@ -239,8 +251,12 @@ public class LiteNode extends BsqNode { // We only request again if wallet is synced, otherwise we would get repeated calls we want to avoid. // We deal with that case at the setupWalletBestBlockListener method above. if (walletsSetup.isDownloadComplete() && daoStateService.getChainHeight() < bsqWalletService.getBestChainHeight()) { + log.info("We have completed batch processing of {} blocks but we have still {} missing blocks and request again.", + blockList.size(), bsqWalletService.getBestChainHeight() - daoStateService.getChainHeight()); + liteNodeNetworkService.requestBlocks(daoStateService.getChainHeight() + 1); } else { + log.info("We have completed batch processing of {} blocks and we have reached the chain tip of the wallet.", blockList.size()); onParsingComplete.run(); onParseBlockChainComplete(); } diff --git a/core/src/main/java/bisq/core/dao/node/lite/network/RequestBlocksHandler.java b/core/src/main/java/bisq/core/dao/node/lite/network/RequestBlocksHandler.java index 8c72b8fb2c..447390794b 100644 --- a/core/src/main/java/bisq/core/dao/node/lite/network/RequestBlocksHandler.java +++ b/core/src/main/java/bisq/core/dao/node/lite/network/RequestBlocksHandler.java @@ -128,7 +128,7 @@ public class RequestBlocksHandler implements MessageListener { }, TIMEOUT_MIN, TimeUnit.MINUTES); - log.info("We request blocks from peer {} from block height {}.", nodeAddress, getBlocksRequest.getFromBlockHeight()); + log.info("\n\n>> We request blocks from peer {} from block height {}.\n", nodeAddress, getBlocksRequest.getFromBlockHeight()); networkNode.addMessageListener(this); @@ -136,7 +136,7 @@ public class RequestBlocksHandler implements MessageListener { Futures.addCallback(future, new FutureCallback<>() { @Override public void onSuccess(Connection connection) { - log.info("Sending of GetBlocksRequest message to peer {} succeeded.", nodeAddress.getFullAddress()); + log.debug("Sending of GetBlocksRequest message to peer {} succeeded.", nodeAddress.getFullAddress()); } @Override @@ -190,7 +190,9 @@ public class RequestBlocksHandler implements MessageListener { } terminate(); - log.info("We received from peer {} a BlocksResponse with {} blocks", + log.info("\n#################################################################\n" + + "We received from peer {} a BlocksResponse with {} blocks" + + "\n#################################################################\n", nodeAddress.getFullAddress(), getBlocksResponse.getBlocks().size()); listener.onComplete(getBlocksResponse); } diff --git a/core/src/main/java/bisq/core/dao/node/messages/GetBlocksResponse.java b/core/src/main/java/bisq/core/dao/node/messages/GetBlocksResponse.java index 4d9876c09c..448c3c7328 100644 --- a/core/src/main/java/bisq/core/dao/node/messages/GetBlocksResponse.java +++ b/core/src/main/java/bisq/core/dao/node/messages/GetBlocksResponse.java @@ -75,7 +75,7 @@ public final class GetBlocksResponse extends NetworkEnvelope implements DirectMe List list = proto.getRawBlocksList().stream() .map(RawBlock::fromProto) .collect(Collectors.toList()); - log.info("Received a GetBlocksResponse with {} blocks and {} kB size", list.size(), proto.getSerializedSize() / 1000d); + log.info("\n\n<< Received a GetBlocksResponse with {} blocks and {} kB size\n", list.size(), proto.getSerializedSize() / 1000d); return new GetBlocksResponse(proto.getRawBlocksList().isEmpty() ? new ArrayList<>() : list, diff --git a/core/src/main/java/bisq/core/dao/state/DaoStateService.java b/core/src/main/java/bisq/core/dao/state/DaoStateService.java index e71ca09b6c..ebdfd1e3f1 100644 --- a/core/src/main/java/bisq/core/dao/state/DaoStateService.java +++ b/core/src/main/java/bisq/core/dao/state/DaoStateService.java @@ -349,15 +349,8 @@ public class DaoStateService implements DaoSetupService { } public List getBlocksFromBlockHeight(int fromBlockHeight) { - return getBlocksFromBlockHeight(fromBlockHeight, Integer.MAX_VALUE); - } - - public List getBlocksFromBlockHeight(int fromBlockHeight, int numMaxBlocks) { - // We limit requests to numMaxBlocks blocks, to avoid performance issues and too - // large network data in case a node requests too far back in history. return getBlocks().stream() .filter(block -> block.getHeight() >= fromBlockHeight) - .limit(numMaxBlocks) .collect(Collectors.toList()); } diff --git a/core/src/main/java/bisq/core/filter/FilterManager.java b/core/src/main/java/bisq/core/filter/FilterManager.java index 68bdefd1d8..0fc5c7a950 100644 --- a/core/src/main/java/bisq/core/filter/FilterManager.java +++ b/core/src/main/java/bisq/core/filter/FilterManager.java @@ -188,6 +188,12 @@ public class FilterManager { p2PService.addP2PServiceListener(new P2PServiceListener() { @Override public void onDataReceived() { + // We should have received all data at that point and if the filters were not set we + // clean up the persisted banned nodes in the options file as it might be that we missed the filter + // remove message if we have not been online. + if (filterProperty.get() == null) { + clearBannedNodes(); + } } @Override @@ -200,12 +206,6 @@ public class FilterManager { @Override public void onUpdatedDataReceived() { - // We should have received all data at that point and if the filters were not set we - // clean up the persisted banned nodes in the options file as it might be that we missed the filter - // remove message if we have not been online. - if (filterProperty.get() == null) { - clearBannedNodes(); - } } @Override diff --git a/core/src/main/java/bisq/core/offer/OfferBookService.java b/core/src/main/java/bisq/core/offer/OfferBookService.java index 60099f0bc6..653e87541d 100644 --- a/core/src/main/java/bisq/core/offer/OfferBookService.java +++ b/core/src/main/java/bisq/core/offer/OfferBookService.java @@ -112,7 +112,7 @@ public class OfferBookService { if (dumpStatistics) { p2PService.addP2PServiceListener(new BootstrapListener() { @Override - public void onUpdatedDataReceived() { + public void onDataReceived() { addOfferBookChangedListener(new OfferBookChangedListener() { @Override public void onAdded(Offer offer) { diff --git a/core/src/main/java/bisq/core/offer/OpenOfferManager.java b/core/src/main/java/bisq/core/offer/OpenOfferManager.java index 7ea84ff0b3..b2288cd7f4 100644 --- a/core/src/main/java/bisq/core/offer/OpenOfferManager.java +++ b/core/src/main/java/bisq/core/offer/OpenOfferManager.java @@ -211,7 +211,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe } else { p2PService.addP2PServiceListener(new BootstrapListener() { @Override - public void onUpdatedDataReceived() { + public void onDataReceived() { onBootstrapComplete(); } }); diff --git a/core/src/main/java/bisq/core/offer/bisq_v1/TriggerPriceService.java b/core/src/main/java/bisq/core/offer/bisq_v1/TriggerPriceService.java index 09e49a3795..026b3bb64c 100644 --- a/core/src/main/java/bisq/core/offer/bisq_v1/TriggerPriceService.java +++ b/core/src/main/java/bisq/core/offer/bisq_v1/TriggerPriceService.java @@ -78,7 +78,7 @@ public class TriggerPriceService { } else { p2PService.addP2PServiceListener(new BootstrapListener() { @Override - public void onUpdatedDataReceived() { + public void onDataReceived() { onBootstrapComplete(); } }); diff --git a/core/src/main/java/bisq/core/offer/bsq_swap/OpenBsqSwapOfferService.java b/core/src/main/java/bisq/core/offer/bsq_swap/OpenBsqSwapOfferService.java index 70735a5706..4163c72e92 100644 --- a/core/src/main/java/bisq/core/offer/bsq_swap/OpenBsqSwapOfferService.java +++ b/core/src/main/java/bisq/core/offer/bsq_swap/OpenBsqSwapOfferService.java @@ -122,7 +122,7 @@ public class OpenBsqSwapOfferService { }; bootstrapListener = new BootstrapListener() { @Override - public void onUpdatedDataReceived() { + public void onDataReceived() { onP2PServiceReady(); p2PService.removeP2PServiceListener(bootstrapListener); } diff --git a/core/src/main/java/bisq/core/support/dispute/DisputeManager.java b/core/src/main/java/bisq/core/support/dispute/DisputeManager.java index de31120b9e..fefb2db9b9 100644 --- a/core/src/main/java/bisq/core/support/dispute/DisputeManager.java +++ b/core/src/main/java/bisq/core/support/dispute/DisputeManager.java @@ -253,7 +253,7 @@ public abstract class DisputeManager> extends Sup p2PService.addP2PServiceListener(new BootstrapListener() { @Override - public void onUpdatedDataReceived() { + public void onDataReceived() { tryApplyMessages(); checkDisputesForUpdates(); } diff --git a/core/src/main/java/bisq/core/support/dispute/agent/DisputeAgentManager.java b/core/src/main/java/bisq/core/support/dispute/agent/DisputeAgentManager.java index 73a73110d4..fc52403765 100644 --- a/core/src/main/java/bisq/core/support/dispute/agent/DisputeAgentManager.java +++ b/core/src/main/java/bisq/core/support/dispute/agent/DisputeAgentManager.java @@ -161,7 +161,7 @@ public abstract class DisputeAgentManager { else p2PService.addP2PServiceListener(new BootstrapListener() { @Override - public void onUpdatedDataReceived() { + public void onDataReceived() { startRepublishDisputeAgent(); } }); diff --git a/core/src/main/java/bisq/core/trade/TradeManager.java b/core/src/main/java/bisq/core/trade/TradeManager.java index 507e1934e8..18b3ab89e4 100644 --- a/core/src/main/java/bisq/core/trade/TradeManager.java +++ b/core/src/main/java/bisq/core/trade/TradeManager.java @@ -400,7 +400,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi } else { p2PService.addP2PServiceListener(new BootstrapListener() { @Override - public void onUpdatedDataReceived() { + public void onDataReceived() { initPersistedTrades(); } }); diff --git a/core/src/main/java/bisq/core/trade/bisq_v1/CleanupMailboxMessagesService.java b/core/src/main/java/bisq/core/trade/bisq_v1/CleanupMailboxMessagesService.java index c27d200408..4a872d2c5e 100644 --- a/core/src/main/java/bisq/core/trade/bisq_v1/CleanupMailboxMessagesService.java +++ b/core/src/main/java/bisq/core/trade/bisq_v1/CleanupMailboxMessagesService.java @@ -69,7 +69,7 @@ public class CleanupMailboxMessagesService { } else { p2PService.addP2PServiceListener(new BootstrapListener() { @Override - public void onUpdatedDataReceived() { + public void onDataReceived() { cleanupMailboxMessages(trades); } }); diff --git a/core/src/main/java/bisq/core/trade/statistics/TradeStatisticsConverter.java b/core/src/main/java/bisq/core/trade/statistics/TradeStatisticsConverter.java index c785368208..5eff6ce9b9 100644 --- a/core/src/main/java/bisq/core/trade/statistics/TradeStatisticsConverter.java +++ b/core/src/main/java/bisq/core/trade/statistics/TradeStatisticsConverter.java @@ -95,7 +95,7 @@ public class TradeStatisticsConverter { } @Override - public void onUpdatedDataReceived() { + public void onDataReceived() { } }); diff --git a/core/src/main/java/bisq/core/trade/txproof/xmr/XmrTxProofService.java b/core/src/main/java/bisq/core/trade/txproof/xmr/XmrTxProofService.java index 02612ee025..52f97829a3 100644 --- a/core/src/main/java/bisq/core/trade/txproof/xmr/XmrTxProofService.java +++ b/core/src/main/java/bisq/core/trade/txproof/xmr/XmrTxProofService.java @@ -337,7 +337,7 @@ public class XmrTxProofService implements AssetTxProofService { } else { bootstrapListener = new BootstrapListener() { @Override - public void onUpdatedDataReceived() { + public void onDataReceived() { p2PService.removeP2PServiceListener(bootstrapListener); result.set(true); } diff --git a/desktop/src/main/java/bisq/desktop/main/MainView.java b/desktop/src/main/java/bisq/desktop/main/MainView.java index 802e1e5281..c364923d27 100644 --- a/desktop/src/main/java/bisq/desktop/main/MainView.java +++ b/desktop/src/main/java/bisq/desktop/main/MainView.java @@ -820,7 +820,7 @@ public class MainView extends InitializableView } }); - model.getUpdatedDataReceived().addListener((observable, oldValue, newValue) -> { + model.getDataReceived().addListener((observable, oldValue, newValue) -> { p2PNetworkIcon.setOpacity(1); p2pNetworkProgressBar.setProgress(0); }); diff --git a/desktop/src/main/java/bisq/desktop/main/MainViewModel.java b/desktop/src/main/java/bisq/desktop/main/MainViewModel.java index 85c8016221..01a2db63f5 100644 --- a/desktop/src/main/java/bisq/desktop/main/MainViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/MainViewModel.java @@ -536,7 +536,7 @@ public class MainViewModel implements ViewModel, BisqSetup.BisqSetupListener { } else { p2PService.addP2PServiceListener(new BootstrapListener() { @Override - public void onUpdatedDataReceived() { + public void onDataReceived() { setupInvalidOpenOffersHandler(); } }); @@ -699,7 +699,7 @@ public class MainViewModel implements ViewModel, BisqSetup.BisqSetupListener { } else { p2PService.addP2PServiceListener(new BootstrapListener() { @Override - public void onUpdatedDataReceived() { + public void onDataReceived() { accountAgeWitnessService.publishMyAccountAgeWitness(aliPayAccount.getPaymentAccountPayload()); } }); @@ -842,8 +842,8 @@ public class MainViewModel implements ViewModel, BisqSetup.BisqSetupListener { return bisqSetup.getP2PNetworkStatusIconId(); } - BooleanProperty getUpdatedDataReceived() { - return bisqSetup.getUpdatedDataReceived(); + BooleanProperty getDataReceived() { + return bisqSetup.getDataReceived(); } StringProperty getP2pNetworkLabelId() { diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/TradeStepView.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/TradeStepView.java index 8979eaaaef..b86ace6c20 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/TradeStepView.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/TradeStepView.java @@ -208,7 +208,7 @@ public abstract class TradeStepView extends AnchorPane { } else { bootstrapListener = new BootstrapListener() { @Override - public void onUpdatedDataReceived() { + public void onDataReceived() { registerSubscriptions(); } }; diff --git a/desktop/src/main/resources/logback.xml b/desktop/src/main/resources/logback.xml index 52dd4e1e9b..144f2cb128 100644 --- a/desktop/src/main/resources/logback.xml +++ b/desktop/src/main/resources/logback.xml @@ -2,10 +2,12 @@ - %highlight(%d{MMM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{30}: %msg %xEx%n) + %highlight(%d{MMM-dd HH:mm:ss.SSS} [%thread] %-5level%logger{40}: %msg %xEx%n) + + diff --git a/p2p/src/main/java/bisq/network/p2p/BootstrapListener.java b/p2p/src/main/java/bisq/network/p2p/BootstrapListener.java index 3b82d4945b..436acace4b 100644 --- a/p2p/src/main/java/bisq/network/p2p/BootstrapListener.java +++ b/p2p/src/main/java/bisq/network/p2p/BootstrapListener.java @@ -40,11 +40,11 @@ public abstract class BootstrapListener implements P2PServiceListener { } @Override - public void onDataReceived() { + public void onUpdatedDataReceived() { } @Override - public abstract void onUpdatedDataReceived(); + public abstract void onDataReceived(); @Override public void onRequestCustomBridges() { diff --git a/p2p/src/main/java/bisq/network/p2p/P2PService.java b/p2p/src/main/java/bisq/network/p2p/P2PService.java index 673bec09ea..b535ba0129 100644 --- a/p2p/src/main/java/bisq/network/p2p/P2PService.java +++ b/p2p/src/main/java/bisq/network/p2p/P2PService.java @@ -310,7 +310,7 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis @Override public void onUpdatedDataReceived() { - applyIsBootstrapped(P2PServiceListener::onUpdatedDataReceived); + p2pServiceListeners.forEach(P2PServiceListener::onUpdatedDataReceived); } @Override @@ -325,7 +325,8 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis @Override public void onDataReceived() { - p2pServiceListeners.forEach(P2PServiceListener::onDataReceived); + applyIsBootstrapped(P2PServiceListener::onDataReceived); + } private void applyIsBootstrapped(Consumer listenerHandler) { diff --git a/p2p/src/main/java/bisq/network/p2p/peers/getdata/RequestDataHandler.java b/p2p/src/main/java/bisq/network/p2p/peers/getdata/RequestDataHandler.java index 42b3ee67d8..02289a2d39 100644 --- a/p2p/src/main/java/bisq/network/p2p/peers/getdata/RequestDataHandler.java +++ b/p2p/src/main/java/bisq/network/p2p/peers/getdata/RequestDataHandler.java @@ -142,7 +142,7 @@ class RequestDataHandler implements MessageListener { } getDataRequestType = getDataRequest.getClass().getSimpleName(); - log.info("We send a {} to peer {}. ", getDataRequestType, nodeAddress); + log.info("\n\n>> We send a {} to peer {}\n", getDataRequestType, nodeAddress); networkNode.addMessageListener(this); SettableFuture future = networkNode.sendMessage(nodeAddress, getDataRequest); //noinspection UnstableApiUsage @@ -242,7 +242,7 @@ class RequestDataHandler implements MessageListener { StringBuilder sb = new StringBuilder(); String sep = System.lineSeparator(); sb.append(sep).append("#################################################################").append(sep); - sb.append("Connected to node: ").append(peersNodeAddress.getFullAddress()).append(sep); + sb.append("Data provided by node: ").append(peersNodeAddress.getFullAddress()).append(sep); int items = dataSet.size() + persistableNetworkPayloadSet.size(); sb.append("Received ").append(items).append(" instances from a ") .append(getDataRequestType).append(sep); @@ -252,7 +252,7 @@ class RequestDataHandler implements MessageListener { .append(" / ") .append(Utilities.readableFileSize(value.second.get())) .append(sep)); - sb.append("#################################################################"); + sb.append("#################################################################\n"); log.info(sb.toString()); } diff --git a/p2p/src/main/java/bisq/network/p2p/peers/getdata/RequestDataManager.java b/p2p/src/main/java/bisq/network/p2p/peers/getdata/RequestDataManager.java index 9fc6539101..cc28058889 100644 --- a/p2p/src/main/java/bisq/network/p2p/peers/getdata/RequestDataManager.java +++ b/p2p/src/main/java/bisq/network/p2p/peers/getdata/RequestDataManager.java @@ -109,6 +109,7 @@ public class RequestDataManager implements MessageListener, ConnectionListener, private Optional nodeAddressOfPreliminaryDataRequest = Optional.empty(); private Timer retryTimer; private boolean dataUpdateRequested; + private boolean allDataReceived; private boolean stopped; private int numRepeatedRequests = 0; @@ -359,17 +360,26 @@ public class RequestDataManager implements MessageListener, ConnectionListener, checkNotNull(listener).onUpdatedDataReceived(); } - checkNotNull(listener).onDataReceived(); - if (wasTruncated) { - if (numRepeatedRequests < 10) { + if (numRepeatedRequests < 20) { + // If we had allDataReceived already set to true but get a response with truncated flag, + // we still repeat the request to that node for higher redundancy. Otherwise, one seed node + // providing incomplete data would stop others to fill the gaps. log.info("DataResponse did not contain all data, so we repeat request until we got all data"); UserThread.runAfter(() -> requestData(nodeAddress, remainingNodeAddresses), 2); - } else { - log.info("DataResponse still did not contained all data but we requested already 10 times and stop now."); + } else if (!allDataReceived) { + allDataReceived = true; + log.warn("\n#################################################################\n" + + "Loading initial data from {} did not complete after 20 repeated requests. \n" + + "#################################################################\n", nodeAddress); + checkNotNull(listener).onDataReceived(); } - } else { - log.info("DataResponse contained all data"); + } else if (!allDataReceived) { + allDataReceived = true; + log.info("\n\n#################################################################\n" + + "Loading initial data from {} completed\n" + + "#################################################################\n", nodeAddress); + checkNotNull(listener).onDataReceived(); } } diff --git a/p2p/src/main/java/bisq/network/p2p/peers/getdata/messages/GetDataResponse.java b/p2p/src/main/java/bisq/network/p2p/peers/getdata/messages/GetDataResponse.java index 0378ee83d5..4cae802e80 100644 --- a/p2p/src/main/java/bisq/network/p2p/peers/getdata/messages/GetDataResponse.java +++ b/p2p/src/main/java/bisq/network/p2p/peers/getdata/messages/GetDataResponse.java @@ -126,9 +126,9 @@ public final class GetDataResponse extends NetworkEnvelope implements SupportedC NetworkProtoResolver resolver, int messageVersion) { boolean wasTruncated = proto.getWasTruncated(); - log.info("Received a GetDataResponse with {} {}", + log.info("\n\n<< Received a GetDataResponse with {} {}\n", Utilities.readableFileSize(proto.getSerializedSize()), - wasTruncated ? " (was truncated)" : ""); + wasTruncated ? " (still data missing)" : " (all data received)"); Set dataSet = proto.getDataSetList().stream() .map(entry -> (ProtectedStorageEntry) resolver.fromProto(entry)).collect(Collectors.toSet()); Set persistableNetworkPayloadSet = proto.getPersistableNetworkPayloadItemsList().stream() diff --git a/p2p/src/main/java/bisq/network/p2p/storage/persistence/HistoricalDataStoreService.java b/p2p/src/main/java/bisq/network/p2p/storage/persistence/HistoricalDataStoreService.java index a1fdcecd26..ce86e2001e 100644 --- a/p2p/src/main/java/bisq/network/p2p/storage/persistence/HistoricalDataStoreService.java +++ b/p2p/src/main/java/bisq/network/p2p/storage/persistence/HistoricalDataStoreService.java @@ -145,7 +145,7 @@ public abstract class HistoricalDataStoreService { - log.info("We have created the {} store for the live data and filled it with {} entries from the persisted data.", + log.debug("We have created the {} store for the live data and filled it with {} entries from the persisted data.", getFileName(), getMapOfLiveData().size()); // Now we add our historical data stores. @@ -185,7 +185,7 @@ public abstract class HistoricalDataStoreService { storesByVersion.put(version, persisted); allHistoricalPayloads.putAll(persisted.getMap()); - log.info("We have read from {} {} historical items.", fileName, persisted.getMap().size()); + log.debug("We have read from {} {} historical items.", fileName, persisted.getMap().size()); pruneStore(persisted, version); completeHandler.run(); }, @@ -199,11 +199,11 @@ public abstract class HistoricalDataStoreService postLive) { - log.info("We pruned data from our live data store which are already contained in the historical data store with version {}. " + + log.debug("We pruned data from our live data store which are already contained in the historical data store with version {}. " + "The live map had {} entries before pruning and has {} entries afterwards.", version, preLive, postLive); } else { - log.info("No pruning from historical data store with version {} was applied", version); + log.debug("No pruning from historical data store with version {} was applied", version); } requestPersistence(); } diff --git a/p2p/src/main/java/bisq/network/p2p/storage/persistence/StoreService.java b/p2p/src/main/java/bisq/network/p2p/storage/persistence/StoreService.java index 671b924d04..185e5580e0 100644 --- a/p2p/src/main/java/bisq/network/p2p/storage/persistence/StoreService.java +++ b/p2p/src/main/java/bisq/network/p2p/storage/persistence/StoreService.java @@ -113,18 +113,18 @@ public abstract class StoreService { File destinationFile = new File(Paths.get(absolutePathOfStorageDir, fileName).toString()); if (!destinationFile.exists()) { try { - log.info("We copy resource to file: resourceFileName={}, destinationFile={}", resourceFileName, destinationFile); + log.debug("We copy resource to file: resourceFileName={}, destinationFile={}", resourceFileName, destinationFile); FileUtil.resourceToFile(resourceFileName, destinationFile); return true; } catch (ResourceNotFoundException e) { - log.info("Could not find resourceFile " + resourceFileName + ". That is expected if none is provided yet."); + log.debug("Could not find resourceFile " + resourceFileName + ". That is expected if none is provided yet."); } catch (Throwable e) { log.error("Could not copy resourceFile " + resourceFileName + " to " + destinationFile.getAbsolutePath() + ".\n" + e.getMessage()); e.printStackTrace(); } } else { - log.info("No resource file was copied. {} exists already.", fileName); + log.debug("No resource file was copied. {} exists already.", fileName); } return false; } diff --git a/p2p/src/test/java/bisq/network/p2p/PeerServiceTest.java b/p2p/src/test/java/bisq/network/p2p/PeerServiceTest.java index b638f67d02..7f44e8bded 100644 --- a/p2p/src/test/java/bisq/network/p2p/PeerServiceTest.java +++ b/p2p/src/test/java/bisq/network/p2p/PeerServiceTest.java @@ -31,7 +31,6 @@ import org.slf4j.LoggerFactory; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; // TorNode created. Took 6 sec. // Hidden service created. Took 40-50 sec. @@ -94,7 +93,7 @@ public class PeerServiceTest { } - @Test + //@Test public void testSingleSeedNode() throws InterruptedException { LocalhostNetworkNode.setSimulateTorDelayTorNode(0); LocalhostNetworkNode.setSimulateTorDelayHiddenService(0); diff --git a/statsnode/src/main/java/bisq/statistics/Statistics.java b/statsnode/src/main/java/bisq/statistics/Statistics.java index 879bd5e809..2177744b82 100644 --- a/statsnode/src/main/java/bisq/statistics/Statistics.java +++ b/statsnode/src/main/java/bisq/statistics/Statistics.java @@ -55,7 +55,7 @@ public class Statistics { priceFeedService.setCurrencyCode("USD"); p2pService.addP2PServiceListener(new BootstrapListener() { @Override - public void onUpdatedDataReceived() { + public void onDataReceived() { // we need to have tor ready log.info("onBootstrapComplete: we start requestPriceFeed"); priceFeedService.requestPriceFeed(price -> log.info("requestPriceFeed. price=" + price),