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;
}
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());
}
Aggregations