Search in sources :

Example 1 with BootstrapListener

use of bisq.network.p2p.BootstrapListener in project bisq-core by bisq-network.

the class DisputeManager method onAllServicesInitialized.

public void onAllServicesInitialized() {
    p2PService.addP2PServiceListener(new BootstrapListener() {

        @Override
        public void onUpdatedDataReceived() {
            tryApplyMessages();
        }
    });
    walletsSetup.downloadPercentageProperty().addListener((observable, oldValue, newValue) -> {
        if (walletsSetup.isDownloadComplete())
            tryApplyMessages();
    });
    walletsSetup.numPeersProperty().addListener((observable, oldValue, newValue) -> {
        if (walletsSetup.hasSufficientPeersForBroadcast())
            tryApplyMessages();
    });
    tryApplyMessages();
    cleanupDisputes();
}
Also used : BootstrapListener(bisq.network.p2p.BootstrapListener)

Example 2 with BootstrapListener

use of bisq.network.p2p.BootstrapListener 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)

Example 3 with BootstrapListener

use of bisq.network.p2p.BootstrapListener in project bisq-core by bisq-network.

the class AccountAgeWitnessService method onAllServicesInitialized.

// /////////////////////////////////////////////////////////////////////////////////////////
// Lifecycle
// /////////////////////////////////////////////////////////////////////////////////////////
public void onAllServicesInitialized() {
    p2PService.getP2PDataStorage().addPersistableNetworkPayloadMapListener(payload -> {
        if (payload instanceof AccountAgeWitness)
            addToMap((AccountAgeWitness) payload);
    });
    // At startup the P2PDataStorage initializes earlier, otherwise we ge the listener called.
    p2PService.getP2PDataStorage().getPersistableNetworkPayloadList().getMap().values().forEach(e -> {
        if (e instanceof AccountAgeWitness)
            addToMap((AccountAgeWitness) e);
    });
    if (p2PService.isBootstrapped()) {
        republishAllFiatAccounts();
    } else {
        p2PService.addP2PServiceListener(new BootstrapListener() {

            @Override
            public void onUpdatedDataReceived() {
                republishAllFiatAccounts();
            }
        });
    }
}
Also used : BootstrapListener(bisq.network.p2p.BootstrapListener)

Example 4 with BootstrapListener

use of bisq.network.p2p.BootstrapListener in project bisq-desktop by bisq-network.

the class MainViewModel method setupDevDummyPaymentAccounts.

private void setupDevDummyPaymentAccounts() {
    if (user.getPaymentAccounts() != null && user.getPaymentAccounts().isEmpty()) {
        PerfectMoneyAccount perfectMoneyAccount = new PerfectMoneyAccount();
        perfectMoneyAccount.init();
        perfectMoneyAccount.setAccountNr("dummy_" + new Random().nextInt(100));
        // Don't translate only for dev
        perfectMoneyAccount.setAccountName("PerfectMoney dummy");
        perfectMoneyAccount.setSelectedTradeCurrency(GlobalSettings.getDefaultTradeCurrency());
        user.addPaymentAccount(perfectMoneyAccount);
        if (p2PService.isBootstrapped()) {
            accountAgeWitnessService.publishMyAccountAgeWitness(perfectMoneyAccount.getPaymentAccountPayload());
        } else {
            p2PService.addP2PServiceListener(new BootstrapListener() {

                @Override
                public void onUpdatedDataReceived() {
                    accountAgeWitnessService.publishMyAccountAgeWitness(perfectMoneyAccount.getPaymentAccountPayload());
                }
            });
        }
        CryptoCurrencyAccount cryptoCurrencyAccount = new CryptoCurrencyAccount();
        cryptoCurrencyAccount.init();
        // Don't translate only for dev
        cryptoCurrencyAccount.setAccountName("ETH dummy");
        cryptoCurrencyAccount.setAddress("0x" + new Random().nextInt(1000000));
        cryptoCurrencyAccount.setSingleTradeCurrency(CurrencyUtil.getCryptoCurrency("ETH").get());
        user.addPaymentAccount(cryptoCurrencyAccount);
    }
}
Also used : Random(java.util.Random) BootstrapListener(bisq.network.p2p.BootstrapListener) CryptoCurrencyAccount(bisq.core.payment.CryptoCurrencyAccount) PerfectMoneyAccount(bisq.core.payment.PerfectMoneyAccount)

Example 5 with BootstrapListener

use of bisq.network.p2p.BootstrapListener in project bisq-core by bisq-network.

the class OpenOfferManager method onAllServicesInitialized.

public void onAllServicesInitialized() {
    p2PService.addDecryptedDirectMessageListener(this);
    if (p2PService.isBootstrapped()) {
        onBootstrapComplete();
    } else {
        p2PService.addP2PServiceListener(new BootstrapListener() {

            @Override
            public void onUpdatedDataReceived() {
                onBootstrapComplete();
            }
        });
    }
    cleanUpAddressEntries();
}
Also used : BootstrapListener(bisq.network.p2p.BootstrapListener)

Aggregations

BootstrapListener (bisq.network.p2p.BootstrapListener)5 CryptoCurrencyAccount (bisq.core.payment.CryptoCurrencyAccount)1 PerfectMoneyAccount (bisq.core.payment.PerfectMoneyAccount)1 P2PService (bisq.network.p2p.P2PService)1 HashMapChangedListener (bisq.network.p2p.storage.HashMapChangedListener)1 ProtectedStorageEntry (bisq.network.p2p.storage.payload.ProtectedStorageEntry)1 Random (java.util.Random)1