mirror of
https://github.com/bisq-network/bisq.git
synced 2025-03-26 20:30:55 +01:00
Use concrete dataStorageServices instead
p2PService.getP2PDataStorage().getAppendOnlyDataStoreMap(). p2PService.getP2PDataStorage().getAppendOnlyDataStoreMap() iterates over all services including the historical data store service. It used the getMap method which should not be used at historical data store service as it is not clear if the live data or all data should be accessed.
This commit is contained in:
parent
85caf88913
commit
4489e57849
5 changed files with 21 additions and 11 deletions
|
@ -73,6 +73,7 @@ public class SignedWitnessService {
|
|||
private final KeyRing keyRing;
|
||||
private final P2PService p2PService;
|
||||
private final ArbitratorManager arbitratorManager;
|
||||
private final SignedWitnessStorageService signedWitnessStorageService;
|
||||
private final User user;
|
||||
private final FilterManager filterManager;
|
||||
|
||||
|
@ -98,6 +99,7 @@ public class SignedWitnessService {
|
|||
this.keyRing = keyRing;
|
||||
this.p2PService = p2PService;
|
||||
this.arbitratorManager = arbitratorManager;
|
||||
this.signedWitnessStorageService = signedWitnessStorageService;
|
||||
this.user = user;
|
||||
this.filterManager = filterManager;
|
||||
|
||||
|
@ -117,7 +119,7 @@ public class SignedWitnessService {
|
|||
});
|
||||
|
||||
// At startup the P2PDataStorage initializes earlier, otherwise we get the listener called.
|
||||
p2PService.getP2PDataStorage().getAppendOnlyDataStoreMap().values().forEach(e -> {
|
||||
signedWitnessStorageService.getMap().values().forEach(e -> {
|
||||
if (e instanceof SignedWitness)
|
||||
addToMap((SignedWitness) e);
|
||||
});
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package bisq.core.app;
|
||||
|
||||
import bisq.core.account.sign.SignedWitness;
|
||||
import bisq.core.account.sign.SignedWitnessStorageService;
|
||||
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||
import bisq.core.alert.Alert;
|
||||
import bisq.core.alert.AlertManager;
|
||||
|
@ -124,6 +125,7 @@ public class BisqSetup {
|
|||
private final WalletsSetup walletsSetup;
|
||||
private final BtcWalletService btcWalletService;
|
||||
private final P2PService p2PService;
|
||||
private final SignedWitnessStorageService signedWitnessStorageService;
|
||||
private final TradeManager tradeManager;
|
||||
private final OpenOfferManager openOfferManager;
|
||||
private final Preferences preferences;
|
||||
|
@ -205,6 +207,7 @@ public class BisqSetup {
|
|||
WalletsSetup walletsSetup,
|
||||
BtcWalletService btcWalletService,
|
||||
P2PService p2PService,
|
||||
SignedWitnessStorageService signedWitnessStorageService,
|
||||
TradeManager tradeManager,
|
||||
OpenOfferManager openOfferManager,
|
||||
Preferences preferences,
|
||||
|
@ -225,6 +228,7 @@ public class BisqSetup {
|
|||
this.walletsSetup = walletsSetup;
|
||||
this.btcWalletService = btcWalletService;
|
||||
this.p2PService = p2PService;
|
||||
this.signedWitnessStorageService = signedWitnessStorageService;
|
||||
this.tradeManager = tradeManager;
|
||||
this.openOfferManager = openOfferManager;
|
||||
this.preferences = preferences;
|
||||
|
@ -652,7 +656,7 @@ public class BisqSetup {
|
|||
|
||||
private void checkSigningState(AccountAgeWitnessService.SignState state,
|
||||
String key, Consumer<String> displayHandler) {
|
||||
boolean signingStateFound = p2PService.getP2PDataStorage().getAppendOnlyDataStoreMap().values().stream()
|
||||
boolean signingStateFound = signedWitnessStorageService.getMap().values().stream()
|
||||
.anyMatch(payload -> isSignedWitnessOfMineWithState(payload, state));
|
||||
|
||||
maybeTriggerDisplayHandler(key, displayHandler, signingStateFound);
|
||||
|
|
|
@ -69,6 +69,7 @@ public class ProposalService implements HashMapChangedListener, AppendOnlyDataSt
|
|||
DaoStateListener, DaoSetupService {
|
||||
private final P2PService p2PService;
|
||||
private final PeriodService periodService;
|
||||
private final ProposalStorageService proposalStorageService;
|
||||
private final DaoStateService daoStateService;
|
||||
private final ProposalValidatorProvider validatorProvider;
|
||||
|
||||
|
@ -100,6 +101,7 @@ public class ProposalService implements HashMapChangedListener, AppendOnlyDataSt
|
|||
@Named(Config.DAO_ACTIVATED) boolean daoActivated) {
|
||||
this.p2PService = p2PService;
|
||||
this.periodService = periodService;
|
||||
this.proposalStorageService = proposalStorageService;
|
||||
this.daoStateService = daoStateService;
|
||||
this.validatorProvider = validatorProvider;
|
||||
|
||||
|
@ -217,7 +219,7 @@ public class ProposalService implements HashMapChangedListener, AppendOnlyDataSt
|
|||
}
|
||||
|
||||
private void fillListFromAppendOnlyDataStore() {
|
||||
p2PService.getP2PDataStorage().getAppendOnlyDataStoreMap().values().forEach(e -> onAppendOnlyDataAdded(e, false));
|
||||
proposalStorageService.getMap().values().forEach(e -> onAppendOnlyDataAdded(e, false));
|
||||
}
|
||||
|
||||
private void maybePublishToAppendOnlyDataStore() {
|
||||
|
|
|
@ -36,11 +36,10 @@ import bisq.core.locale.CurrencyUtil;
|
|||
import bisq.core.locale.Res;
|
||||
import bisq.core.offer.OfferPayload;
|
||||
import bisq.core.trade.statistics.TradeStatistics3;
|
||||
import bisq.core.trade.statistics.TradeStatistics3StorageService;
|
||||
import bisq.core.util.FormattingUtils;
|
||||
import bisq.core.util.coin.CoinFormatter;
|
||||
|
||||
import bisq.network.p2p.P2PService;
|
||||
|
||||
import bisq.common.util.Utilities;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -71,7 +70,7 @@ public class MarketView extends ActivatableView<TabPane, Void> {
|
|||
@FXML
|
||||
Tab offerBookTab, tradesTab, spreadTab;
|
||||
private final ViewLoader viewLoader;
|
||||
private final P2PService p2PService;
|
||||
private final TradeStatistics3StorageService tradeStatistics3StorageService;
|
||||
private final OfferBook offerBook;
|
||||
private final CoinFormatter formatter;
|
||||
private final Navigation navigation;
|
||||
|
@ -83,12 +82,12 @@ public class MarketView extends ActivatableView<TabPane, Void> {
|
|||
|
||||
@Inject
|
||||
public MarketView(CachingViewLoader viewLoader,
|
||||
P2PService p2PService,
|
||||
TradeStatistics3StorageService tradeStatistics3StorageService,
|
||||
OfferBook offerBook,
|
||||
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter,
|
||||
Navigation navigation) {
|
||||
this.viewLoader = viewLoader;
|
||||
this.p2PService = p2PService;
|
||||
this.tradeStatistics3StorageService = tradeStatistics3StorageService;
|
||||
this.offerBook = offerBook;
|
||||
this.formatter = formatter;
|
||||
this.navigation = navigation;
|
||||
|
@ -181,7 +180,7 @@ public class MarketView extends ActivatableView<TabPane, Void> {
|
|||
// all items of both traders in case the referral ID was only set by one trader.
|
||||
// If both traders had set it the tradeStatistics is only delivered once.
|
||||
// If both traders used a different referral ID then we would get 2 objects.
|
||||
List<String> list = p2PService.getP2PDataStorage().getAppendOnlyDataStoreMap().values().stream()
|
||||
List<String> list = tradeStatistics3StorageService.getMapOfAllData().values().stream()
|
||||
.filter(e -> e instanceof TradeStatistics3)
|
||||
.map(e -> (TradeStatistics3) e)
|
||||
.filter(tradeStatistics3 -> tradeStatistics3.getExtraDataMap() != null)
|
||||
|
|
|
@ -534,7 +534,10 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
|
|||
removeExpiredEntriesTimer = UserThread.runPeriodically(this::removeExpiredEntries, CHECK_TTL_INTERVAL_SEC);
|
||||
}
|
||||
|
||||
public Map<ByteArray, PersistableNetworkPayload> getAppendOnlyDataStoreMap() {
|
||||
// Domain access should use the concrete appendOnlyDataStoreService if available. The Historical data store require
|
||||
// care which data should be accessed (live data or all data).
|
||||
@VisibleForTesting
|
||||
Map<ByteArray, PersistableNetworkPayload> getAppendOnlyDataStoreMap() {
|
||||
return appendOnlyDataStoreService.getMap();
|
||||
}
|
||||
|
||||
|
@ -642,7 +645,7 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
|
|||
}
|
||||
|
||||
ByteArray hashAsByteArray = new ByteArray(payload.getHash());
|
||||
boolean payloadHashAlreadyInStore = getAppendOnlyDataStoreMap().containsKey(hashAsByteArray);
|
||||
boolean payloadHashAlreadyInStore = appendOnlyDataStoreService.getMap().containsKey(hashAsByteArray);
|
||||
|
||||
// Store already knows about this payload. Ignore it unless the caller specifically requests a republish.
|
||||
if (payloadHashAlreadyInStore && !reBroadcast) {
|
||||
|
|
Loading…
Add table
Reference in a new issue