diff --git a/core/src/main/java/bisq/core/app/BisqExecutable.java b/core/src/main/java/bisq/core/app/BisqExecutable.java index 18104e292e..b96ca3c865 100644 --- a/core/src/main/java/bisq/core/app/BisqExecutable.java +++ b/core/src/main/java/bisq/core/app/BisqExecutable.java @@ -168,8 +168,8 @@ public abstract class BisqExecutable implements GracefulShutDownHandler, BisqSet } AtomicInteger remaining = new AtomicInteger(hosts.size()); - hosts.forEach(e -> { - e.readPersisted(() -> { + hosts.forEach(host -> { + host.readPersisted(() -> { if (remaining.decrementAndGet() == 0) { UserThread.execute(completeHandler); } diff --git a/core/src/main/java/bisq/core/app/misc/AppSetupWithP2P.java b/core/src/main/java/bisq/core/app/misc/AppSetupWithP2P.java index 8827636559..952d63e3b8 100644 --- a/core/src/main/java/bisq/core/app/misc/AppSetupWithP2P.java +++ b/core/src/main/java/bisq/core/app/misc/AppSetupWithP2P.java @@ -19,7 +19,6 @@ package bisq.core.app.misc; import bisq.core.account.sign.SignedWitnessService; import bisq.core.account.witness.AccountAgeWitnessService; -import bisq.core.app.TorSetup; import bisq.core.filter.FilterManager; import bisq.core.trade.statistics.TradeStatisticsManager; @@ -28,6 +27,8 @@ import bisq.network.p2p.P2PServiceListener; import bisq.network.p2p.network.CloseConnectionReason; import bisq.network.p2p.network.Connection; import bisq.network.p2p.network.ConnectionListener; +import bisq.network.p2p.peers.PeerManager; +import bisq.network.p2p.storage.P2PDataStorage; import bisq.common.config.Config; import bisq.common.proto.persistable.PersistedDataHost; @@ -47,32 +48,36 @@ public class AppSetupWithP2P extends AppSetup { protected final AccountAgeWitnessService accountAgeWitnessService; private final SignedWitnessService signedWitnessService; protected final FilterManager filterManager; - private final TorSetup torSetup; - protected BooleanProperty p2pNetWorkReady; + private final P2PDataStorage p2PDataStorage; + private final PeerManager peerManager; protected final TradeStatisticsManager tradeStatisticsManager; protected ArrayList persistedDataHosts; + protected BooleanProperty p2pNetWorkReady; @Inject public AppSetupWithP2P(P2PService p2PService, + P2PDataStorage p2PDataStorage, + PeerManager peerManager, TradeStatisticsManager tradeStatisticsManager, AccountAgeWitnessService accountAgeWitnessService, SignedWitnessService signedWitnessService, FilterManager filterManager, - TorSetup torSetup, Config config) { super(config); this.p2PService = p2PService; + this.p2PDataStorage = p2PDataStorage; + this.peerManager = peerManager; this.tradeStatisticsManager = tradeStatisticsManager; this.accountAgeWitnessService = accountAgeWitnessService; this.signedWitnessService = signedWitnessService; this.filterManager = filterManager; - this.torSetup = torSetup; this.persistedDataHosts = new ArrayList<>(); } @Override public void initPersistedDataHosts() { - persistedDataHosts.add(p2PService); + persistedDataHosts.add(p2PDataStorage); + persistedDataHosts.add(peerManager); // we apply at startup the reading of persisted data but don't want to get it triggered in the constructor persistedDataHosts.forEach(e -> { @@ -88,7 +93,7 @@ public class AppSetupWithP2P extends AppSetup { @Override protected void initBasicServices() { String postFix = "_" + config.baseCurrencyNetwork.name(); - p2PService.getP2PDataStorage().readFromResources(postFix, this::startInitP2PNetwork); + p2PDataStorage.readFromResources(postFix, this::startInitP2PNetwork); } private void startInitP2PNetwork() { diff --git a/core/src/main/java/bisq/core/app/misc/AppSetupWithP2PAndDAO.java b/core/src/main/java/bisq/core/app/misc/AppSetupWithP2PAndDAO.java index 3331906c8d..95751832c9 100644 --- a/core/src/main/java/bisq/core/app/misc/AppSetupWithP2PAndDAO.java +++ b/core/src/main/java/bisq/core/app/misc/AppSetupWithP2PAndDAO.java @@ -19,7 +19,6 @@ package bisq.core.app.misc; import bisq.core.account.sign.SignedWitnessService; import bisq.core.account.witness.AccountAgeWitnessService; -import bisq.core.app.TorSetup; import bisq.core.dao.DaoSetup; import bisq.core.dao.governance.ballot.BallotListService; import bisq.core.dao.governance.blindvote.MyBlindVoteListService; @@ -31,6 +30,8 @@ import bisq.core.filter.FilterManager; import bisq.core.trade.statistics.TradeStatisticsManager; import bisq.network.p2p.P2PService; +import bisq.network.p2p.peers.PeerManager; +import bisq.network.p2p.storage.P2PDataStorage; import bisq.common.config.Config; @@ -44,6 +45,8 @@ public class AppSetupWithP2PAndDAO extends AppSetupWithP2P { @Inject public AppSetupWithP2PAndDAO(P2PService p2PService, + P2PDataStorage p2PDataStorage, + PeerManager peerManager, TradeStatisticsManager tradeStatisticsManager, AccountAgeWitnessService accountAgeWitnessService, SignedWitnessService signedWitnessService, @@ -55,14 +58,14 @@ public class AppSetupWithP2PAndDAO extends AppSetupWithP2P { MyProposalListService myProposalListService, MyReputationListService myReputationListService, MyProofOfBurnListService myProofOfBurnListService, - TorSetup torSetup, Config config) { super(p2PService, + p2PDataStorage, + peerManager, tradeStatisticsManager, accountAgeWitnessService, signedWitnessService, filterManager, - torSetup, config); this.daoSetup = daoSetup; diff --git a/core/src/main/java/bisq/core/setup/CorePersistedDataHost.java b/core/src/main/java/bisq/core/setup/CorePersistedDataHost.java index 426504a407..35b042dfdb 100644 --- a/core/src/main/java/bisq/core/setup/CorePersistedDataHost.java +++ b/core/src/main/java/bisq/core/setup/CorePersistedDataHost.java @@ -35,7 +35,8 @@ import bisq.core.trade.failed.FailedTradesManager; import bisq.core.user.Preferences; import bisq.core.user.User; -import bisq.network.p2p.P2PService; +import bisq.network.p2p.peers.PeerManager; +import bisq.network.p2p.storage.P2PDataStorage; import bisq.common.config.Config; import bisq.common.proto.persistable.PersistedDataHost; @@ -63,7 +64,8 @@ public class CorePersistedDataHost { persistedDataHosts.add(injector.getInstance(ArbitrationDisputeListService.class)); persistedDataHosts.add(injector.getInstance(MediationDisputeListService.class)); persistedDataHosts.add(injector.getInstance(RefundDisputeListService.class)); - persistedDataHosts.add(injector.getInstance(P2PService.class)); + persistedDataHosts.add(injector.getInstance(P2PDataStorage.class)); + persistedDataHosts.add(injector.getInstance(PeerManager.class)); if (injector.getInstance(Config.class).daoActivated) { persistedDataHosts.add(injector.getInstance(BallotListService.class)); diff --git a/p2p/src/main/java/bisq/network/p2p/P2PService.java b/p2p/src/main/java/bisq/network/p2p/P2PService.java index 9c9fb083cf..a290406fbe 100644 --- a/p2p/src/main/java/bisq/network/p2p/P2PService.java +++ b/p2p/src/main/java/bisq/network/p2p/P2PService.java @@ -52,7 +52,6 @@ import bisq.common.crypto.KeyRing; import bisq.common.crypto.PubKeyRing; import bisq.common.proto.ProtobufferException; import bisq.common.proto.network.NetworkEnvelope; -import bisq.common.proto.persistable.PersistedDataHost; import bisq.common.util.Utilities; import com.google.inject.Inject; @@ -105,7 +104,7 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; public class P2PService implements SetupListener, MessageListener, ConnectionListener, RequestDataManager.Listener, - HashMapChangedListener, PersistedDataHost { + HashMapChangedListener { private static final Logger log = LoggerFactory.getLogger(P2PService.class); private final SeedNodeRepository seedNodeRepository; @@ -184,12 +183,6 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis }); } - @Override - public void readPersisted(Runnable completeHandler) { - p2PDataStorage.readPersisted(completeHandler); - peerManager.readPersisted(completeHandler); - } - /////////////////////////////////////////////////////////////////////////////////////////// // API