Search in sources :

Example 1 with P2PService

use of bisq.network.p2p.P2PService 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();
}
Also used : HashMapChangedListener(bisq.network.p2p.storage.HashMapChangedListener) BootstrapListener(bisq.network.p2p.BootstrapListener) P2PService(bisq.network.p2p.P2PService) ProtectedStorageEntry(bisq.network.p2p.storage.payload.ProtectedStorageEntry)

Aggregations

BootstrapListener (bisq.network.p2p.BootstrapListener)1 P2PService (bisq.network.p2p.P2PService)1 HashMapChangedListener (bisq.network.p2p.storage.HashMapChangedListener)1 ProtectedStorageEntry (bisq.network.p2p.storage.payload.ProtectedStorageEntry)1