mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-07-28 09:24:15 -04:00
Fix bug with missing broadcast. Add total traffic info
This commit is contained in:
parent
fc1ab8a346
commit
92ad387d70
22 changed files with 48 additions and 180 deletions
|
@ -83,9 +83,8 @@ abstract public class Trade implements Tradable, Model, Serializable {
|
||||||
FIAT_PAYMENT_RECEIPT_MSG_SENT(Phase.FIAT_RECEIVED),
|
FIAT_PAYMENT_RECEIPT_MSG_SENT(Phase.FIAT_RECEIVED),
|
||||||
FIAT_PAYMENT_RECEIPT_MSG_RECEIVED(Phase.FIAT_RECEIVED),
|
FIAT_PAYMENT_RECEIPT_MSG_RECEIVED(Phase.FIAT_RECEIVED),
|
||||||
|
|
||||||
PAYOUT_TX_COMMITTED(Phase.PAYOUT_PAID),
|
|
||||||
PAYOUT_TX_SENT(Phase.PAYOUT_PAID),
|
PAYOUT_TX_SENT(Phase.PAYOUT_PAID),
|
||||||
PAYOUT_TX_RECEIVED(Phase.PAYOUT_PAID),
|
PAYOUT_TX_RECEIVED_AND_COMMITTED(Phase.PAYOUT_PAID),
|
||||||
PAYOUT_BROAD_CASTED(Phase.PAYOUT_PAID),
|
PAYOUT_BROAD_CASTED(Phase.PAYOUT_PAID),
|
||||||
|
|
||||||
WITHDRAW_COMPLETED(Phase.WITHDRAWN);
|
WITHDRAW_COMPLETED(Phase.WITHDRAWN);
|
||||||
|
|
|
@ -31,7 +31,6 @@ import io.bitsquare.trade.protocol.trade.messages.TradeMessage;
|
||||||
import io.bitsquare.trade.protocol.trade.tasks.buyer.*;
|
import io.bitsquare.trade.protocol.trade.tasks.buyer.*;
|
||||||
import io.bitsquare.trade.protocol.trade.tasks.offerer.*;
|
import io.bitsquare.trade.protocol.trade.tasks.offerer.*;
|
||||||
import io.bitsquare.trade.protocol.trade.tasks.shared.BroadcastAfterLockTime;
|
import io.bitsquare.trade.protocol.trade.tasks.shared.BroadcastAfterLockTime;
|
||||||
import io.bitsquare.trade.protocol.trade.tasks.shared.CommitPayoutTx;
|
|
||||||
import io.bitsquare.trade.protocol.trade.tasks.shared.InitWaitPeriodForOpenDispute;
|
import io.bitsquare.trade.protocol.trade.tasks.shared.InitWaitPeriodForOpenDispute;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -183,7 +182,6 @@ public class BuyerAsOffererProtocol extends TradeProtocol implements BuyerProtoc
|
||||||
taskRunner.addTasks(
|
taskRunner.addTasks(
|
||||||
ProcessFinalizePayoutTxRequest.class,
|
ProcessFinalizePayoutTxRequest.class,
|
||||||
SignAndFinalizePayoutTx.class,
|
SignAndFinalizePayoutTx.class,
|
||||||
CommitPayoutTx.class,
|
|
||||||
SendPayoutTxFinalizedMessage.class,
|
SendPayoutTxFinalizedMessage.class,
|
||||||
BroadcastAfterLockTime.class
|
BroadcastAfterLockTime.class
|
||||||
);
|
);
|
||||||
|
|
|
@ -30,7 +30,6 @@ import io.bitsquare.trade.protocol.trade.messages.PublishDepositTxRequest;
|
||||||
import io.bitsquare.trade.protocol.trade.messages.TradeMessage;
|
import io.bitsquare.trade.protocol.trade.messages.TradeMessage;
|
||||||
import io.bitsquare.trade.protocol.trade.tasks.buyer.*;
|
import io.bitsquare.trade.protocol.trade.tasks.buyer.*;
|
||||||
import io.bitsquare.trade.protocol.trade.tasks.shared.BroadcastAfterLockTime;
|
import io.bitsquare.trade.protocol.trade.tasks.shared.BroadcastAfterLockTime;
|
||||||
import io.bitsquare.trade.protocol.trade.tasks.shared.CommitPayoutTx;
|
|
||||||
import io.bitsquare.trade.protocol.trade.tasks.taker.*;
|
import io.bitsquare.trade.protocol.trade.tasks.taker.*;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -171,7 +170,6 @@ public class BuyerAsTakerProtocol extends TradeProtocol implements BuyerProtocol
|
||||||
taskRunner.addTasks(
|
taskRunner.addTasks(
|
||||||
ProcessFinalizePayoutTxRequest.class,
|
ProcessFinalizePayoutTxRequest.class,
|
||||||
SignAndFinalizePayoutTx.class,
|
SignAndFinalizePayoutTx.class,
|
||||||
CommitPayoutTx.class,
|
|
||||||
SendPayoutTxFinalizedMessage.class,
|
SendPayoutTxFinalizedMessage.class,
|
||||||
BroadcastAfterLockTime.class
|
BroadcastAfterLockTime.class
|
||||||
);
|
);
|
||||||
|
|
|
@ -27,7 +27,6 @@ import io.bitsquare.trade.protocol.trade.messages.*;
|
||||||
import io.bitsquare.trade.protocol.trade.tasks.offerer.*;
|
import io.bitsquare.trade.protocol.trade.tasks.offerer.*;
|
||||||
import io.bitsquare.trade.protocol.trade.tasks.seller.*;
|
import io.bitsquare.trade.protocol.trade.tasks.seller.*;
|
||||||
import io.bitsquare.trade.protocol.trade.tasks.shared.BroadcastAfterLockTime;
|
import io.bitsquare.trade.protocol.trade.tasks.shared.BroadcastAfterLockTime;
|
||||||
import io.bitsquare.trade.protocol.trade.tasks.shared.CommitPayoutTx;
|
|
||||||
import io.bitsquare.trade.protocol.trade.tasks.shared.InitWaitPeriodForOpenDispute;
|
import io.bitsquare.trade.protocol.trade.tasks.shared.InitWaitPeriodForOpenDispute;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -188,7 +187,6 @@ public class SellerAsOffererProtocol extends TradeProtocol implements SellerProt
|
||||||
|
|
||||||
taskRunner.addTasks(
|
taskRunner.addTasks(
|
||||||
ProcessPayoutTxFinalizedMessage.class,
|
ProcessPayoutTxFinalizedMessage.class,
|
||||||
CommitPayoutTx.class,
|
|
||||||
BroadcastAfterLockTime.class
|
BroadcastAfterLockTime.class
|
||||||
);
|
);
|
||||||
taskRunner.run();
|
taskRunner.run();
|
||||||
|
|
|
@ -29,7 +29,6 @@ import io.bitsquare.trade.protocol.trade.messages.PublishDepositTxRequest;
|
||||||
import io.bitsquare.trade.protocol.trade.messages.TradeMessage;
|
import io.bitsquare.trade.protocol.trade.messages.TradeMessage;
|
||||||
import io.bitsquare.trade.protocol.trade.tasks.seller.*;
|
import io.bitsquare.trade.protocol.trade.tasks.seller.*;
|
||||||
import io.bitsquare.trade.protocol.trade.tasks.shared.BroadcastAfterLockTime;
|
import io.bitsquare.trade.protocol.trade.tasks.shared.BroadcastAfterLockTime;
|
||||||
import io.bitsquare.trade.protocol.trade.tasks.shared.CommitPayoutTx;
|
|
||||||
import io.bitsquare.trade.protocol.trade.tasks.taker.*;
|
import io.bitsquare.trade.protocol.trade.tasks.taker.*;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -187,7 +186,6 @@ public class SellerAsTakerProtocol extends TradeProtocol implements SellerProtoc
|
||||||
|
|
||||||
taskRunner.addTasks(
|
taskRunner.addTasks(
|
||||||
ProcessPayoutTxFinalizedMessage.class,
|
ProcessPayoutTxFinalizedMessage.class,
|
||||||
CommitPayoutTx.class,
|
|
||||||
BroadcastAfterLockTime.class
|
BroadcastAfterLockTime.class
|
||||||
);
|
);
|
||||||
taskRunner.run();
|
taskRunner.run();
|
||||||
|
|
|
@ -57,6 +57,7 @@ public class SignAndFinalizePayoutTx extends TradeTask {
|
||||||
);
|
);
|
||||||
|
|
||||||
trade.setPayoutTx(transaction);
|
trade.setPayoutTx(transaction);
|
||||||
|
trade.setState(Trade.State.PAYOUT_TX_RECEIVED_AND_COMMITTED);
|
||||||
|
|
||||||
complete();
|
complete();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
|
|
@ -44,14 +44,15 @@ public class ProcessPayoutTxFinalizedMessage extends TradeTask {
|
||||||
checkTradeId(processModel.getId(), message);
|
checkTradeId(processModel.getId(), message);
|
||||||
checkNotNull(message);
|
checkNotNull(message);
|
||||||
checkArgument(message.payoutTx != null);
|
checkArgument(message.payoutTx != null);
|
||||||
trade.setPayoutTx(processModel.getWalletService().getTransactionFromSerializedTx(message.payoutTx));
|
trade.setPayoutTx(processModel.getTradeWalletService().addTransactionToWallet(message.payoutTx));
|
||||||
|
|
||||||
|
|
||||||
// update to the latest peer address of our peer if the message is correct
|
// update to the latest peer address of our peer if the message is correct
|
||||||
trade.setTradingPeerNodeAddress(processModel.getTempTradingPeerNodeAddress());
|
trade.setTradingPeerNodeAddress(processModel.getTempTradingPeerNodeAddress());
|
||||||
|
|
||||||
removeMailboxMessageAfterProcessing();
|
removeMailboxMessageAfterProcessing();
|
||||||
|
|
||||||
trade.setState(Trade.State.PAYOUT_TX_RECEIVED);
|
trade.setState(Trade.State.PAYOUT_TX_RECEIVED_AND_COMMITTED);
|
||||||
|
|
||||||
complete();
|
complete();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
|
|
@ -32,6 +32,8 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
public class BroadcastAfterLockTime extends TradeTask {
|
public class BroadcastAfterLockTime extends TradeTask {
|
||||||
private static final Logger log = LoggerFactory.getLogger(BroadcastAfterLockTime.class);
|
private static final Logger log = LoggerFactory.getLogger(BroadcastAfterLockTime.class);
|
||||||
|
|
||||||
|
@ -67,19 +69,14 @@ public class BroadcastAfterLockTime extends TradeTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void broadcastTx() {
|
private void broadcastTx() {
|
||||||
boolean needsBroadCast = true;
|
Transaction payoutTx = trade.getPayoutTx();
|
||||||
Transaction walletTx = processModel.getTradeWalletService().getWalletTx(trade.getPayoutTx().getHash());
|
checkNotNull(payoutTx, "payoutTx must not be null at BroadcastAfterLockTime.broadcastTx");
|
||||||
if (walletTx != null) {
|
TransactionConfidence.ConfidenceType confidenceType = payoutTx.getConfidence().getConfidenceType();
|
||||||
TransactionConfidence.ConfidenceType confidenceType = walletTx.getConfidence().getConfidenceType();
|
if (confidenceType.equals(TransactionConfidence.ConfidenceType.BUILDING)) {
|
||||||
if (confidenceType.equals(TransactionConfidence.ConfidenceType.PENDING) ||
|
|
||||||
confidenceType.equals(TransactionConfidence.ConfidenceType.BUILDING)) {
|
|
||||||
needsBroadCast = false;
|
|
||||||
trade.setState(Trade.State.PAYOUT_BROAD_CASTED);
|
trade.setState(Trade.State.PAYOUT_BROAD_CASTED);
|
||||||
complete();
|
complete();
|
||||||
}
|
} else {
|
||||||
}
|
processModel.getTradeWalletService().broadcastTx(payoutTx, new FutureCallback<Transaction>() {
|
||||||
if (needsBroadCast) {
|
|
||||||
processModel.getTradeWalletService().broadcastTx(trade.getPayoutTx(), new FutureCallback<Transaction>() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Transaction transaction) {
|
public void onSuccess(Transaction transaction) {
|
||||||
log.debug("BroadcastTx succeeded. Transaction:" + transaction);
|
log.debug("BroadcastTx succeeded. Transaction:" + transaction);
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of Bitsquare.
|
|
||||||
*
|
|
||||||
* Bitsquare is free software: you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or (at
|
|
||||||
* your option) any later version.
|
|
||||||
*
|
|
||||||
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
|
||||||
* License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.bitsquare.trade.protocol.trade.tasks.shared;
|
|
||||||
|
|
||||||
import io.bitsquare.common.taskrunner.TaskRunner;
|
|
||||||
import io.bitsquare.trade.Trade;
|
|
||||||
import io.bitsquare.trade.protocol.trade.tasks.TradeTask;
|
|
||||||
import org.bitcoinj.core.Transaction;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class CommitPayoutTx extends TradeTask {
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(CommitPayoutTx.class);
|
|
||||||
|
|
||||||
public CommitPayoutTx(TaskRunner taskHandler, Trade trade) {
|
|
||||||
super(taskHandler, trade);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void run() {
|
|
||||||
try {
|
|
||||||
runInterceptHook();
|
|
||||||
Transaction transaction = processModel.getTradeWalletService().addTransactionToWallet(trade.getPayoutTx());
|
|
||||||
trade.setPayoutTx(transaction);
|
|
||||||
trade.setState(Trade.State.PAYOUT_TX_COMMITTED);
|
|
||||||
|
|
||||||
complete();
|
|
||||||
} catch (Throwable t) {
|
|
||||||
failed(t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -36,7 +36,6 @@ import io.bitsquare.trade.protocol.trade.tasks.buyer.*;
|
||||||
import io.bitsquare.trade.protocol.trade.tasks.offerer.*;
|
import io.bitsquare.trade.protocol.trade.tasks.offerer.*;
|
||||||
import io.bitsquare.trade.protocol.trade.tasks.seller.*;
|
import io.bitsquare.trade.protocol.trade.tasks.seller.*;
|
||||||
import io.bitsquare.trade.protocol.trade.tasks.shared.BroadcastAfterLockTime;
|
import io.bitsquare.trade.protocol.trade.tasks.shared.BroadcastAfterLockTime;
|
||||||
import io.bitsquare.trade.protocol.trade.tasks.shared.CommitPayoutTx;
|
|
||||||
import io.bitsquare.trade.protocol.trade.tasks.shared.InitWaitPeriodForOpenDispute;
|
import io.bitsquare.trade.protocol.trade.tasks.shared.InitWaitPeriodForOpenDispute;
|
||||||
import io.bitsquare.trade.protocol.trade.tasks.taker.*;
|
import io.bitsquare.trade.protocol.trade.tasks.taker.*;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
|
@ -97,7 +96,6 @@ public class DebugView extends InitializableView {
|
||||||
|
|
||||||
ProcessFinalizePayoutTxRequest.class,
|
ProcessFinalizePayoutTxRequest.class,
|
||||||
SignAndFinalizePayoutTx.class,
|
SignAndFinalizePayoutTx.class,
|
||||||
CommitPayoutTx.class,
|
|
||||||
SendPayoutTxFinalizedMessage.class,
|
SendPayoutTxFinalizedMessage.class,
|
||||||
BroadcastAfterLockTime.class,
|
BroadcastAfterLockTime.class,
|
||||||
Boolean.class, /* used as seperator*/
|
Boolean.class, /* used as seperator*/
|
||||||
|
@ -124,7 +122,6 @@ public class DebugView extends InitializableView {
|
||||||
SendFinalizePayoutTxRequest.class,
|
SendFinalizePayoutTxRequest.class,
|
||||||
|
|
||||||
ProcessPayoutTxFinalizedMessage.class,
|
ProcessPayoutTxFinalizedMessage.class,
|
||||||
CommitPayoutTx.class,
|
|
||||||
BroadcastAfterLockTime.class,
|
BroadcastAfterLockTime.class,
|
||||||
Boolean.class /* used as seperator*/
|
Boolean.class /* used as seperator*/
|
||||||
)
|
)
|
||||||
|
@ -150,7 +147,6 @@ public class DebugView extends InitializableView {
|
||||||
|
|
||||||
ProcessFinalizePayoutTxRequest.class,
|
ProcessFinalizePayoutTxRequest.class,
|
||||||
SignAndFinalizePayoutTx.class,
|
SignAndFinalizePayoutTx.class,
|
||||||
CommitPayoutTx.class,
|
|
||||||
SendPayoutTxFinalizedMessage.class,
|
SendPayoutTxFinalizedMessage.class,
|
||||||
BroadcastAfterLockTime.class,
|
BroadcastAfterLockTime.class,
|
||||||
Boolean.class, /* used as seperator*/
|
Boolean.class, /* used as seperator*/
|
||||||
|
@ -176,7 +172,6 @@ public class DebugView extends InitializableView {
|
||||||
SendFinalizePayoutTxRequest.class,
|
SendFinalizePayoutTxRequest.class,
|
||||||
|
|
||||||
ProcessPayoutTxFinalizedMessage.class,
|
ProcessPayoutTxFinalizedMessage.class,
|
||||||
CommitPayoutTx.class,
|
|
||||||
BroadcastAfterLockTime.class,
|
BroadcastAfterLockTime.class,
|
||||||
Boolean.class /* used as seperator*/
|
Boolean.class /* used as seperator*/
|
||||||
)
|
)
|
||||||
|
|
|
@ -139,22 +139,10 @@ public class TransactionsListItem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Optional<AddressEntry> addressEntryOptional = walletService.getAddressEntryList().stream()
|
if (amountAsCoin.isZero())
|
||||||
.filter(e -> e.getAddressString() != null && e.getAddressString().equals(addressString))
|
|
||||||
.findAny();
|
|
||||||
if (addressEntryOptional.isPresent() &&
|
|
||||||
addressEntryOptional.get().getContext() == AddressEntry.Context.ARBITRATOR)
|
|
||||||
details = received ? "Received funds" : "Withdrawn from wallet";
|
|
||||||
else*/
|
|
||||||
if (amountAsCoin.isZero()) {
|
|
||||||
details = "No refund from dispute";
|
details = "No refund from dispute";
|
||||||
} else {
|
|
||||||
details = received ? "Received funds" : "Withdrawn from wallet";
|
|
||||||
}
|
|
||||||
if (received)
|
|
||||||
details = amountAsCoin.isPositive() ? "Received funds" : "No refund from dispute";
|
|
||||||
else
|
else
|
||||||
details = amountAsCoin.isNegative() ? "Withdrawn from wallet" : "No refund from dispute";
|
details = received ? "Received funds" : "Withdrawn from wallet";
|
||||||
}
|
}
|
||||||
|
|
||||||
date.set(formatter.formatDateTime(transaction.getUpdateTime()));
|
date.set(formatter.formatDateTime(transaction.getUpdateTime()));
|
||||||
|
|
|
@ -346,7 +346,7 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
|
||||||
withdrawToTextField.setPromptText("Fill in your destination address");
|
withdrawToTextField.setPromptText("Fill in your destination address");
|
||||||
|
|
||||||
if (BitsquareApp.DEV_MODE)
|
if (BitsquareApp.DEV_MODE)
|
||||||
withdrawToTextField.setText("mhpVDvMjJT1Gn7da44dkq1HXd3wXdFZpXu");
|
withdrawToTextField.setText("mi8k5f9L972VgDaT4LgjAhriC9hHEPL7EW");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<Tradable> getTradable(WithdrawalListItem item) {
|
private Optional<Tradable> getTradable(WithdrawalListItem item) {
|
||||||
|
|
|
@ -305,8 +305,7 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
||||||
case PAYOUT_TX_SENT:
|
case PAYOUT_TX_SENT:
|
||||||
buyerState.set(PendingTradesViewModel.BuyerState.WAIT_FOR_BROADCAST_AFTER_UNLOCK);
|
buyerState.set(PendingTradesViewModel.BuyerState.WAIT_FOR_BROADCAST_AFTER_UNLOCK);
|
||||||
break;
|
break;
|
||||||
case PAYOUT_TX_RECEIVED:
|
case PAYOUT_TX_RECEIVED_AND_COMMITTED:
|
||||||
case PAYOUT_TX_COMMITTED:
|
|
||||||
sellerState.set(SellerState.WAIT_FOR_BROADCAST_AFTER_UNLOCK);
|
sellerState.set(SellerState.WAIT_FOR_BROADCAST_AFTER_UNLOCK);
|
||||||
break;
|
break;
|
||||||
case PAYOUT_BROAD_CASTED:
|
case PAYOUT_BROAD_CASTED:
|
||||||
|
|
|
@ -130,7 +130,7 @@ public class BuyerStep5View extends TradeStepView {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (BitsquareApp.DEV_MODE)
|
if (BitsquareApp.DEV_MODE)
|
||||||
withdrawAddressTextField.setText("mhpVDvMjJT1Gn7da44dkq1HXd3wXdFZpXu");
|
withdrawAddressTextField.setText("mi8k5f9L972VgDaT4LgjAhriC9hHEPL7EW");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getBtcTradeAmountLabel() {
|
protected String getBtcTradeAmountLabel() {
|
||||||
|
|
|
@ -66,15 +66,14 @@
|
||||||
</TextField>
|
</TextField>
|
||||||
|
|
||||||
<Label fx:id="p2PPeersLabel" text="Connected peers:" GridPane.rowIndex="4"/>
|
<Label fx:id="p2PPeersLabel" text="Connected peers:" GridPane.rowIndex="4"/>
|
||||||
<TableView fx:id="p2PPeerTable" GridPane.rowIndex="4" GridPane.columnIndex="1" VBox.vgrow="ALWAYS"
|
<TableView fx:id="p2PPeerTable" GridPane.rowIndex="4" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS">
|
||||||
GridPane.hgrow="ALWAYS">
|
|
||||||
<columns>
|
<columns>
|
||||||
<TableColumn text="Onion address" fx:id="onionAddressColumn" minWidth="220">
|
<TableColumn text="Onion address" fx:id="onionAddressColumn" minWidth="220">
|
||||||
<cellValueFactory>
|
<cellValueFactory>
|
||||||
<PropertyValueFactory property="onionAddress"/>
|
<PropertyValueFactory property="onionAddress"/>
|
||||||
</cellValueFactory>
|
</cellValueFactory>
|
||||||
</TableColumn>
|
</TableColumn>
|
||||||
<TableColumn text="Type" fx:id="connectionTypeColumn" minWidth="70" maxWidth="80">
|
<TableColumn text="In/Out" fx:id="connectionTypeColumn" minWidth="70" maxWidth="80">
|
||||||
<cellValueFactory>
|
<cellValueFactory>
|
||||||
<PropertyValueFactory property="connectionType"/>
|
<PropertyValueFactory property="connectionType"/>
|
||||||
</cellValueFactory>
|
</cellValueFactory>
|
||||||
|
@ -99,7 +98,7 @@
|
||||||
<PropertyValueFactory property="receivedBytes"/>
|
<PropertyValueFactory property="receivedBytes"/>
|
||||||
</cellValueFactory>
|
</cellValueFactory>
|
||||||
</TableColumn>
|
</TableColumn>
|
||||||
<TableColumn text="Identity" fx:id="peerTypeColumn" minWidth="100" maxWidth="100">
|
<TableColumn text="Peer type" fx:id="peerTypeColumn" minWidth="100" maxWidth="100">
|
||||||
<cellValueFactory>
|
<cellValueFactory>
|
||||||
<PropertyValueFactory property="peerType"/>
|
<PropertyValueFactory property="peerType"/>
|
||||||
</cellValueFactory>
|
</cellValueFactory>
|
||||||
|
@ -107,6 +106,10 @@
|
||||||
</columns>
|
</columns>
|
||||||
</TableView>
|
</TableView>
|
||||||
|
|
||||||
|
<Label text="Total traffic:" GridPane.rowIndex="5"/>
|
||||||
|
<TextField fx:id="totalTraffic" GridPane.rowIndex="5" GridPane.columnIndex="1" editable="false"
|
||||||
|
focusTraversable="false"/>
|
||||||
|
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="NEVER" halignment="RIGHT"/>
|
<ColumnConstraints hgrow="NEVER" halignment="RIGHT"/>
|
||||||
<ColumnConstraints hgrow="ALWAYS"/>
|
<ColumnConstraints hgrow="ALWAYS"/>
|
||||||
|
|
|
@ -28,6 +28,7 @@ import io.bitsquare.gui.util.BSFormatter;
|
||||||
import io.bitsquare.p2p.NodeAddress;
|
import io.bitsquare.p2p.NodeAddress;
|
||||||
import io.bitsquare.p2p.P2PService;
|
import io.bitsquare.p2p.P2PService;
|
||||||
import io.bitsquare.p2p.P2PServiceListener;
|
import io.bitsquare.p2p.P2PServiceListener;
|
||||||
|
import io.bitsquare.p2p.network.Statistic;
|
||||||
import io.bitsquare.user.Preferences;
|
import io.bitsquare.user.Preferences;
|
||||||
import javafx.beans.value.ChangeListener;
|
import javafx.beans.value.ChangeListener;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
|
@ -38,6 +39,7 @@ import javafx.scene.control.*;
|
||||||
import javafx.scene.layout.GridPane;
|
import javafx.scene.layout.GridPane;
|
||||||
import javafx.util.StringConverter;
|
import javafx.util.StringConverter;
|
||||||
import org.bitcoinj.core.Peer;
|
import org.bitcoinj.core.Peer;
|
||||||
|
import org.fxmisc.easybind.EasyBind;
|
||||||
import org.reactfx.util.FxTimer;
|
import org.reactfx.util.FxTimer;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -55,7 +57,7 @@ public class NetworkSettingsView extends ActivatableViewAndModel<GridPane, Activ
|
||||||
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
TextField onionAddress;
|
TextField onionAddress, totalTraffic;
|
||||||
@FXML
|
@FXML
|
||||||
ComboBox<BitcoinNetwork> netWorkComboBox;
|
ComboBox<BitcoinNetwork> netWorkComboBox;
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -149,6 +151,7 @@ public class NetworkSettingsView extends ActivatableViewAndModel<GridPane, Activ
|
||||||
((Integer) o1.statistic.getSentBytes()).compareTo(((Integer) o2.statistic.getSentBytes())));
|
((Integer) o1.statistic.getSentBytes()).compareTo(((Integer) o2.statistic.getSentBytes())));
|
||||||
receivedBytesColumn.setComparator((o1, o2) ->
|
receivedBytesColumn.setComparator((o1, o2) ->
|
||||||
((Integer) o1.statistic.getReceivedBytes()).compareTo(((Integer) o2.statistic.getReceivedBytes())));*/
|
((Integer) o1.statistic.getReceivedBytes()).compareTo(((Integer) o2.statistic.getReceivedBytes())));*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -185,6 +188,9 @@ public class NetworkSettingsView extends ActivatableViewAndModel<GridPane, Activ
|
||||||
numP2PPeersChangeListener = (observable, oldValue, newValue) -> updateP2PStatistics();
|
numP2PPeersChangeListener = (observable, oldValue, newValue) -> updateP2PStatistics();
|
||||||
p2PService.getNumConnectedPeers().addListener(numP2PPeersChangeListener);
|
p2PService.getNumConnectedPeers().addListener(numP2PPeersChangeListener);
|
||||||
updateP2PStatistics();
|
updateP2PStatistics();
|
||||||
|
|
||||||
|
totalTraffic.textProperty().bind(EasyBind.combine(Statistic.totalSentBytesProperty(), Statistic.totalReceivedBytesProperty(),
|
||||||
|
(sent, received) -> "Sent:" + formatter.formatBytes((int) sent) + " / Received: " + formatter.formatBytes((int) received)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -201,6 +207,7 @@ public class NetworkSettingsView extends ActivatableViewAndModel<GridPane, Activ
|
||||||
p2PService.getNumConnectedPeers().removeListener(numP2PPeersChangeListener);
|
p2PService.getNumConnectedPeers().removeListener(numP2PPeersChangeListener);
|
||||||
|
|
||||||
p2PPeerTable.getItems().forEach(NetworkStatisticListItem::cleanup);
|
p2PPeerTable.getItems().forEach(NetworkStatisticListItem::cleanup);
|
||||||
|
totalTraffic.textProperty().unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateP2PStatistics() {
|
private void updateP2PStatistics() {
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
class NetworkStatisticListItem {
|
public class NetworkStatisticListItem {
|
||||||
private static final Logger log = LoggerFactory.getLogger(NetworkStatisticListItem.class);
|
private static final Logger log = LoggerFactory.getLogger(NetworkStatisticListItem.class);
|
||||||
|
|
||||||
private final Statistic statistic;
|
private final Statistic statistic;
|
||||||
|
|
|
@ -376,83 +376,8 @@ public class BSFormatter {
|
||||||
|
|
||||||
public String getDaysHoursMinutes(Date startDate, Date endDate) {
|
public String getDaysHoursMinutes(Date startDate, Date endDate) {
|
||||||
return DurationFormatUtils.formatDurationWords(endDate.getTime() - startDate.getTime(), true, true);
|
return DurationFormatUtils.formatDurationWords(endDate.getTime() - startDate.getTime(), true, true);
|
||||||
/* long secondsInMilli = 1000;
|
|
||||||
long minutesInMilli = secondsInMilli * 60;
|
|
||||||
long hoursInMilli = minutesInMilli * 60;
|
|
||||||
long daysInMilli = hoursInMilli * 24;
|
|
||||||
long elapsedDays = different / daysInMilli;
|
|
||||||
different = different % daysInMilli;
|
|
||||||
long elapsedHours = different / hoursInMilli;
|
|
||||||
different = different % hoursInMilli;
|
|
||||||
long elapsedMinutes = different / minutesInMilli;
|
|
||||||
String dayString = elapsedDays == 1 ? "day" : "days";
|
|
||||||
String hourString = elapsedHours == 1 ? "hour" : "hours";
|
|
||||||
String minuteString = elapsedMinutes == 1 ? "minute" : "minutes";
|
|
||||||
if (elapsedDays > 0)
|
|
||||||
return elapsedDays + " " + dayString + ", " + elapsedHours + " " + hourString + " and " + elapsedMinutes + " " + minuteString;
|
|
||||||
else if (elapsedHours > 0)
|
|
||||||
return elapsedHours + " " + hourString + " and " + elapsedMinutes + " " + minuteString;
|
|
||||||
else if (elapsedMinutes > 0)
|
|
||||||
return elapsedMinutes + " " + minuteString;
|
|
||||||
else
|
|
||||||
return null;*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* public List<String> tokenizePeriod(long time, boolean showSeconds, boolean showMillis) {
|
|
||||||
|
|
||||||
|
|
||||||
log.error("formatPastTimestamp " + time + "");
|
|
||||||
long secondsInMilli = 1000;
|
|
||||||
long minutesInMilli = secondsInMilli * 60;
|
|
||||||
long hoursInMilli = minutesInMilli * 60;
|
|
||||||
long daysInMilli = hoursInMilli * 24;
|
|
||||||
long elapsedDays = time / daysInMilli;
|
|
||||||
time = time % daysInMilli;
|
|
||||||
long elapsedHours = time / hoursInMilli;
|
|
||||||
time = time % hoursInMilli;
|
|
||||||
long elapsedMinutes = time / minutesInMilli;
|
|
||||||
time = time % minutesInMilli;
|
|
||||||
long elapsedSeconds = time / secondsInMilli;
|
|
||||||
time = time % secondsInMilli;
|
|
||||||
long elapsedMillis = time;
|
|
||||||
|
|
||||||
String dayString = elapsedDays == 1 ? elapsedDays + " day" : elapsedDays + " days";
|
|
||||||
String hourString = elapsedHours == 1 ? elapsedHours + " hour" : elapsedHours + " hours";
|
|
||||||
String minuteString = elapsedMinutes == 1 ? elapsedMinutes + " minute" : elapsedMinutes + " minutes";
|
|
||||||
String secondsString = elapsedSeconds == 1 ? elapsedSeconds + " second" : elapsedSeconds + " seconds";
|
|
||||||
String millisString = elapsedMillis + " ms";
|
|
||||||
List<String> tokens = new ArrayList<>();
|
|
||||||
|
|
||||||
if (elapsedDays > 0)
|
|
||||||
tokens.add(dayString);
|
|
||||||
|
|
||||||
if (elapsedHours > 0)
|
|
||||||
tokens.add(hourString);
|
|
||||||
|
|
||||||
if (elapsedMinutes > 0)
|
|
||||||
tokens.add(minuteString);
|
|
||||||
|
|
||||||
if (showSeconds && elapsedSeconds > 0)
|
|
||||||
tokens.add(secondsString);
|
|
||||||
|
|
||||||
if (showMillis && elapsedMillis > 0)
|
|
||||||
tokens.add(millisString);
|
|
||||||
|
|
||||||
return tokens;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String formatTimeTokens(List<String> tokens) {
|
|
||||||
if (tokens.size() > 1) {
|
|
||||||
String last = tokens.remove(tokens.size() - 1);
|
|
||||||
String result = tokens.stream().collect(Collectors.joining(", "));
|
|
||||||
return result + " and " + last;
|
|
||||||
} else if (tokens.size() == 1) {
|
|
||||||
return tokens.get(0);
|
|
||||||
} else {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
public String booleanToYesNo(boolean value) {
|
public String booleanToYesNo(boolean value) {
|
||||||
return value ? "Yes" : "No";
|
return value ? "Yes" : "No";
|
||||||
|
|
|
@ -683,7 +683,7 @@ public class Connection implements MessageListener {
|
||||||
Optional<NodeAddress> peersNodeAddressOptional = connection.getPeersNodeAddressOptional();
|
Optional<NodeAddress> peersNodeAddressOptional = connection.getPeersNodeAddressOptional();
|
||||||
if (peersNodeAddressOptional.isPresent())
|
if (peersNodeAddressOptional.isPresent())
|
||||||
checkArgument(peersNodeAddressOptional.get().equals(senderNodeAddress),
|
checkArgument(peersNodeAddressOptional.get().equals(senderNodeAddress),
|
||||||
"senderNodeAddress not matching connections peer address");
|
"senderNodeAddress not matching connections peer address.\nmessage=" + message);
|
||||||
else
|
else
|
||||||
connection.setPeersNodeAddress(senderNodeAddress);
|
connection.setPeersNodeAddress(senderNodeAddress);
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,15 +134,15 @@ public class PeerManager implements ConnectionListener, MessageListener {
|
||||||
// MessageListener implementation
|
// MessageListener implementation
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
//TODO move to RequestDataManager
|
||||||
@Override
|
@Override
|
||||||
public void onMessage(Message message, Connection connection) {
|
public void onMessage(Message message, Connection connection) {
|
||||||
// In case a seed node connects to another seed node we get his address at the DataRequest triggered from
|
// In case a seed node connects to another seed node we get his address at the DataRequest triggered from
|
||||||
// RequestDataManager.updateDataFromConnectedSeedNode
|
// RequestDataManager.updateDataFromConnectedSeedNode
|
||||||
if (message instanceof GetUpdatedDataRequest) {
|
if (message instanceof GetUpdatedDataRequest) {
|
||||||
Log.traceCall(message.toString() + "\n\tconnection=" + connection);
|
Log.traceCall(message.toString() + "\n\tconnection=" + connection);
|
||||||
Optional<NodeAddress> peersNodeAddressOptional = connection.getPeersNodeAddressOptional();
|
|
||||||
if (peersNodeAddressOptional.isPresent() &&
|
if (isSeedNode(connection))
|
||||||
seedNodeAddresses.contains(peersNodeAddressOptional.get()))
|
|
||||||
connection.setPeerType(Connection.PeerType.SEED_NODE);
|
connection.setPeerType(Connection.PeerType.SEED_NODE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,6 +123,10 @@ class PeerExchangeHandler implements MessageListener {
|
||||||
public void onMessage(Message message, Connection connection) {
|
public void onMessage(Message message, Connection connection) {
|
||||||
if (message instanceof GetPeersResponse) {
|
if (message instanceof GetPeersResponse) {
|
||||||
GetPeersResponse getPeersResponse = (GetPeersResponse) message;
|
GetPeersResponse getPeersResponse = (GetPeersResponse) message;
|
||||||
|
|
||||||
|
if (peerManager.isSeedNode(connection))
|
||||||
|
connection.setPeerType(Connection.PeerType.SEED_NODE);
|
||||||
|
|
||||||
// Check if the response is for our request
|
// Check if the response is for our request
|
||||||
if (getPeersResponse.requestNonce == nonce) {
|
if (getPeersResponse.requestNonce == nonce) {
|
||||||
Log.traceCall(message.toString() + "\n\tconnection=" + connection);
|
Log.traceCall(message.toString() + "\n\tconnection=" + connection);
|
||||||
|
|
|
@ -112,6 +112,10 @@ public class PeerExchangeManager implements MessageListener, ConnectionListener
|
||||||
public void onMessage(Message message, Connection connection) {
|
public void onMessage(Message message, Connection connection) {
|
||||||
if (message instanceof GetPeersRequest) {
|
if (message instanceof GetPeersRequest) {
|
||||||
Log.traceCall(message.toString() + "\n\tconnection=" + connection);
|
Log.traceCall(message.toString() + "\n\tconnection=" + connection);
|
||||||
|
|
||||||
|
if (peerManager.isSeedNode(connection))
|
||||||
|
connection.setPeerType(Connection.PeerType.SEED_NODE);
|
||||||
|
|
||||||
GetPeersRequestHandler getPeersRequestHandler = new GetPeersRequestHandler(networkNode,
|
GetPeersRequestHandler getPeersRequestHandler = new GetPeersRequestHandler(networkNode,
|
||||||
peerManager,
|
peerManager,
|
||||||
new GetPeersRequestHandler.Listener() {
|
new GetPeersRequestHandler.Listener() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue