Search in sources :

Example 31 with NodeAddress

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

the class ArbitratorSelectionRule method select.

public static NodeAddress select(List<NodeAddress> acceptedArbitratorNodeAddresses, Offer offer) {
    List<NodeAddress> candidates = new ArrayList<>();
    for (NodeAddress offerArbitratorNodeAddress : offer.getArbitratorNodeAddresses()) {
        candidates.addAll(acceptedArbitratorNodeAddresses.stream().filter(offerArbitratorNodeAddress::equals).collect(Collectors.toList()));
    }
    checkArgument(candidates.size() > 0, "candidates.size() <= 0");
    int index = Math.abs(Arrays.hashCode(Hash.getSha256Hash(offer.getId().getBytes()))) % candidates.size();
    NodeAddress selectedArbitrator = candidates.get(index);
    log.debug("selectedArbitrator " + selectedArbitrator);
    return selectedArbitrator;
}
Also used : ArrayList(java.util.ArrayList) NodeAddress(bisq.network.p2p.NodeAddress)

Example 32 with NodeAddress

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

the class BuyerAsTakerProtocol method doApplyMailboxMessage.

// /////////////////////////////////////////////////////////////////////////////////////////
// Mailbox
// /////////////////////////////////////////////////////////////////////////////////////////
@Override
public void doApplyMailboxMessage(NetworkEnvelope networkEnvelop, Trade trade) {
    this.trade = trade;
    final NodeAddress senderNodeAddress = ((MailboxMessage) networkEnvelop).getSenderNodeAddress();
    if (networkEnvelop instanceof PublishDepositTxRequest)
        handle((PublishDepositTxRequest) networkEnvelop, senderNodeAddress);
    else if (networkEnvelop instanceof PayoutTxPublishedMessage) {
        handle((PayoutTxPublishedMessage) networkEnvelop, senderNodeAddress);
    } else
        log.error("We received an unhandled MailboxMessage" + networkEnvelop.toString());
}
Also used : PayoutTxPublishedMessage(bisq.core.trade.messages.PayoutTxPublishedMessage) BuyerProcessPayoutTxPublishedMessage(bisq.core.trade.protocol.tasks.buyer.BuyerProcessPayoutTxPublishedMessage) NodeAddress(bisq.network.p2p.NodeAddress) MailboxMessage(bisq.network.p2p.MailboxMessage) TakerProcessPublishDepositTxRequest(bisq.core.trade.protocol.tasks.taker.TakerProcessPublishDepositTxRequest) PublishDepositTxRequest(bisq.core.trade.messages.PublishDepositTxRequest)

Aggregations

NodeAddress (bisq.network.p2p.NodeAddress)32 BtcWalletService (bisq.core.btc.wallet.BtcWalletService)6 Contract (bisq.core.trade.Contract)5 Test (org.junit.Test)5 PubKeyRing (bisq.common.crypto.PubKeyRing)4 AddressEntry (bisq.core.btc.AddressEntry)4 Offer (bisq.core.offer.Offer)4 PaymentAccountPayload (bisq.core.payment.payload.PaymentAccountPayload)4 SendMailboxMessageListener (bisq.network.p2p.SendMailboxMessageListener)4 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 Insets (javafx.geometry.Insets)4 PeerInfoIcon (bisq.desktop.components.PeerInfoIcon)3 MailboxMessage (bisq.network.p2p.MailboxMessage)3 List (java.util.List)3 TableCell (javafx.scene.control.TableCell)3 TableColumn (javafx.scene.control.TableColumn)3 ErrorMessageHandler (bisq.common.handlers.ErrorMessageHandler)2 ResultHandler (bisq.common.handlers.ResultHandler)2 BisqEnvironment (bisq.core.app.BisqEnvironment)2