use of bisq.network.p2p.storage.HashMapChangedListener in project bisq-core by bisq-network.
the class ArbitratorManager method onAllServicesInitialized.
// /////////////////////////////////////////////////////////////////////////////////////////
// API
// /////////////////////////////////////////////////////////////////////////////////////////
public void onAllServicesInitialized() {
arbitratorService.addHashSetChangedListener(new HashMapChangedListener() {
@Override
public void onAdded(ProtectedStorageEntry data) {
if (data.getProtectedStoragePayload() instanceof Arbitrator)
updateArbitratorMap();
}
@Override
public void onRemoved(ProtectedStorageEntry data) {
if (data.getProtectedStoragePayload() instanceof Arbitrator) {
updateArbitratorMap();
final Arbitrator arbitrator = (Arbitrator) data.getProtectedStoragePayload();
user.removeAcceptedArbitrator(arbitrator);
user.removeAcceptedMediator(getMediator(arbitrator));
}
}
});
persistedAcceptedArbitrators = new ArrayList<>(user.getAcceptedArbitrators());
user.clearAcceptedArbitrators();
// TODO we mirror arbitrator data for mediator as long we have not impl. it in the UI
user.clearAcceptedMediators();
if (user.getRegisteredArbitrator() != null) {
P2PService p2PService = arbitratorService.getP2PService();
if (p2PService.isBootstrapped())
startRepublishArbitrator();
else
p2PService.addP2PServiceListener(new BootstrapListener() {
@Override
public void onUpdatedDataReceived() {
startRepublishArbitrator();
}
});
}
filterManager.filterProperty().addListener((observable, oldValue, newValue) -> updateArbitratorMap());
updateArbitratorMap();
}
use of bisq.network.p2p.storage.HashMapChangedListener in project bisq-core by bisq-network.
the class FilterManager method onAllServicesInitialized.
public void onAllServicesInitialized() {
if (!ignoreDevMsg) {
final List<ProtectedStorageEntry> list = new ArrayList<>(p2PService.getP2PDataStorage().getMap().values());
list.forEach(e -> {
final ProtectedStoragePayload protectedStoragePayload = e.getProtectedStoragePayload();
if (protectedStoragePayload instanceof Filter)
addFilter((Filter) protectedStoragePayload);
});
p2PService.addHashSetChangedListener(new HashMapChangedListener() {
@Override
public void onAdded(ProtectedStorageEntry data) {
if (data.getProtectedStoragePayload() instanceof Filter) {
Filter filter = (Filter) data.getProtectedStoragePayload();
addFilter(filter);
}
}
@Override
public void onRemoved(ProtectedStorageEntry data) {
if (data.getProtectedStoragePayload() instanceof Filter) {
Filter filter = (Filter) data.getProtectedStoragePayload();
if (verifySignature(filter))
resetFilters();
}
}
});
}
p2PService.addP2PServiceListener(new P2PServiceListener() {
@Override
public void onDataReceived() {
}
@Override
public void onNoSeedNodeAvailable() {
}
@Override
public void onNoPeersAvailable() {
}
@Override
public void onUpdatedDataReceived() {
// We should have received all data at that point and if the filers was not set we
// clean up as it might be that we missed the filter remove message if we have not been online.
UserThread.runAfter(() -> {
if (filterProperty.get() == null)
resetFilters();
}, 1);
}
@Override
public void onTorNodeReady() {
}
@Override
public void onHiddenServicePublished() {
}
@Override
public void onSetupFailed(Throwable throwable) {
}
@Override
public void onRequestCustomBridges() {
}
});
}
use of bisq.network.p2p.storage.HashMapChangedListener in project bisq-core by bisq-network.
the class TradeStatisticsManager method onAllServicesInitialized.
public void onAllServicesInitialized() {
if (dumpStatistics) {
ArrayList<CurrencyTuple> fiatCurrencyList = new ArrayList<>(CurrencyUtil.getAllSortedFiatCurrencies().stream().map(e -> new CurrencyTuple(e.getCode(), e.getName(), 8)).collect(Collectors.toList()));
jsonFileManager.writeToDisc(Utilities.objectToJson(fiatCurrencyList), "fiat_currency_list");
ArrayList<CurrencyTuple> cryptoCurrencyList = new ArrayList<>(CurrencyUtil.getAllSortedCryptoCurrencies().stream().map(e -> new CurrencyTuple(e.getCode(), e.getName(), 8)).collect(Collectors.toList()));
cryptoCurrencyList.add(0, new CurrencyTuple(Res.getBaseCurrencyCode(), Res.getBaseCurrencyName(), 8));
jsonFileManager.writeToDisc(Utilities.objectToJson(cryptoCurrencyList), "crypto_currency_list");
}
p2PService.getP2PDataStorage().addPersistableNetworkPayloadMapListener(payload -> {
if (payload instanceof TradeStatistics2)
addToMap((TradeStatistics2) payload, true);
});
p2PService.getP2PDataStorage().getPersistableNetworkPayloadList().getMap().values().forEach(e -> {
if (e instanceof TradeStatistics2)
addToMap((TradeStatistics2) e, false);
});
// TODO can be removed after version older than v0.6.0 are not used anymore
// We listen to TradeStatistics objects from old clients as well and convert them into TradeStatistics2 objects
p2PService.addHashSetChangedListener(new HashMapChangedListener() {
@Override
public void onAdded(ProtectedStorageEntry data) {
final ProtectedStoragePayload protectedStoragePayload = data.getProtectedStoragePayload();
if (protectedStoragePayload instanceof TradeStatistics)
p2PService.getP2PDataStorage().addPersistableNetworkPayload(ConvertToTradeStatistics2((TradeStatistics) protectedStoragePayload), p2PService.getNetworkNode().getNodeAddress(), true, false, false, false);
}
@Override
public void onRemoved(ProtectedStorageEntry data) {
// We don't remove items
}
});
priceFeedService.applyLatestBisqMarketPrice(tradeStatisticsSet);
dump();
// print all currencies sorted by nr. of trades
// printAllCurrencyStats();
}
Aggregations