mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-06-19 12:24:19 -04:00
Add markets spreads view
This commit is contained in:
parent
5cc00a8c6e
commit
3a16897350
13 changed files with 640 additions and 28 deletions
|
@ -22,7 +22,7 @@ import io.bitsquare.app.Version;
|
||||||
import io.bitsquare.gui.common.view.View;
|
import io.bitsquare.gui.common.view.View;
|
||||||
import io.bitsquare.gui.common.view.ViewPath;
|
import io.bitsquare.gui.common.view.ViewPath;
|
||||||
import io.bitsquare.gui.main.MainView;
|
import io.bitsquare.gui.main.MainView;
|
||||||
import io.bitsquare.gui.main.market.MarketView;
|
import io.bitsquare.gui.main.markets.MarketView;
|
||||||
import io.bitsquare.storage.Storage;
|
import io.bitsquare.storage.Storage;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
|
@ -26,7 +26,7 @@ import io.bitsquare.gui.components.SystemNotification;
|
||||||
import io.bitsquare.gui.main.account.AccountView;
|
import io.bitsquare.gui.main.account.AccountView;
|
||||||
import io.bitsquare.gui.main.disputes.DisputesView;
|
import io.bitsquare.gui.main.disputes.DisputesView;
|
||||||
import io.bitsquare.gui.main.funds.FundsView;
|
import io.bitsquare.gui.main.funds.FundsView;
|
||||||
import io.bitsquare.gui.main.market.MarketView;
|
import io.bitsquare.gui.main.markets.MarketView;
|
||||||
import io.bitsquare.gui.main.offer.BuyOfferView;
|
import io.bitsquare.gui.main.offer.BuyOfferView;
|
||||||
import io.bitsquare.gui.main.offer.SellOfferView;
|
import io.bitsquare.gui.main.offer.SellOfferView;
|
||||||
import io.bitsquare.gui.main.portfolio.PortfolioView;
|
import io.bitsquare.gui.main.portfolio.PortfolioView;
|
||||||
|
|
|
@ -20,9 +20,11 @@
|
||||||
<?import javafx.scene.control.Tab?>
|
<?import javafx.scene.control.Tab?>
|
||||||
<?import javafx.scene.control.TabPane?>
|
<?import javafx.scene.control.TabPane?>
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
<TabPane fx:id="root" fx:controller="io.bitsquare.gui.main.market.MarketView"
|
<TabPane fx:id="root" fx:controller="io.bitsquare.gui.main.markets.MarketView"
|
||||||
AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0"
|
AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0"
|
||||||
AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0"
|
AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0"
|
||||||
xmlns:fx="http://javafx.com/fxml">
|
xmlns:fx="http://javafx.com/fxml">
|
||||||
<Tab fx:id="tab" text="All currency markets" closable="false"/>
|
|
||||||
|
<Tab fx:id="chartsTab" text="Offer book" closable="false"/>
|
||||||
|
<Tab fx:id="statisticsTab" text="Spreads" closable="false"/>
|
||||||
</TabPane>
|
</TabPane>
|
|
@ -0,0 +1,92 @@
|
||||||
|
/*
|
||||||
|
* 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.gui.main.markets;
|
||||||
|
|
||||||
|
import io.bitsquare.gui.Navigation;
|
||||||
|
import io.bitsquare.gui.common.model.Activatable;
|
||||||
|
import io.bitsquare.gui.common.view.*;
|
||||||
|
import io.bitsquare.gui.main.MainView;
|
||||||
|
import io.bitsquare.gui.main.markets.charts.MarketsChartsView;
|
||||||
|
import io.bitsquare.gui.main.markets.statistics.MarketsStatisticsView;
|
||||||
|
import javafx.beans.value.ChangeListener;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.control.Tab;
|
||||||
|
import javafx.scene.control.TabPane;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
@FxmlView
|
||||||
|
public class MarketView extends ActivatableViewAndModel<TabPane, Activatable> {
|
||||||
|
@FXML
|
||||||
|
Tab chartsTab, statisticsTab;
|
||||||
|
private final ViewLoader viewLoader;
|
||||||
|
private final Navigation navigation;
|
||||||
|
private Navigation.Listener navigationListener;
|
||||||
|
private ChangeListener<Tab> tabChangeListener;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public MarketView(CachingViewLoader viewLoader, Navigation navigation) {
|
||||||
|
this.viewLoader = viewLoader;
|
||||||
|
this.navigation = navigation;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
navigationListener = viewPath -> {
|
||||||
|
if (viewPath.size() == 3 && viewPath.indexOf(MarketView.class) == 1)
|
||||||
|
loadView(viewPath.tip());
|
||||||
|
};
|
||||||
|
|
||||||
|
tabChangeListener = (ov, oldValue, newValue) -> {
|
||||||
|
if (newValue == chartsTab)
|
||||||
|
navigation.navigateTo(MainView.class, MarketView.class, MarketsChartsView.class);
|
||||||
|
else if (newValue == statisticsTab)
|
||||||
|
navigation.navigateTo(MainView.class, MarketView.class, MarketsStatisticsView.class);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void activate() {
|
||||||
|
root.getSelectionModel().selectedItemProperty().addListener(tabChangeListener);
|
||||||
|
navigation.addListener(navigationListener);
|
||||||
|
|
||||||
|
if (root.getSelectionModel().getSelectedItem() == chartsTab)
|
||||||
|
navigation.navigateTo(MainView.class, MarketView.class, MarketsChartsView.class);
|
||||||
|
else
|
||||||
|
navigation.navigateTo(MainView.class, MarketView.class, MarketsStatisticsView.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void deactivate() {
|
||||||
|
root.getSelectionModel().selectedItemProperty().removeListener(tabChangeListener);
|
||||||
|
navigation.removeListener(navigationListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadView(Class<? extends View> viewClass) {
|
||||||
|
final Tab tab;
|
||||||
|
View view = viewLoader.load(viewClass);
|
||||||
|
|
||||||
|
if (view instanceof MarketsChartsView) tab = chartsTab;
|
||||||
|
else if (view instanceof MarketsStatisticsView) tab = statisticsTab;
|
||||||
|
else throw new IllegalArgumentException("Navigation to " + viewClass + " is not supported");
|
||||||
|
|
||||||
|
tab.setContent(view.getRoot());
|
||||||
|
root.getSelectionModel().select(tab);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
~ 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/>.
|
||||||
|
-->
|
||||||
|
|
||||||
|
|
||||||
|
<?import javafx.geometry.Insets?>
|
||||||
|
<?import javafx.scene.layout.*?>
|
||||||
|
<VBox fx:id="root" fx:controller="io.bitsquare.gui.main.markets.charts.MarketsChartsView"
|
||||||
|
spacing="20.0" fillWidth="true"
|
||||||
|
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||||
|
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"
|
||||||
|
xmlns:fx="http://javafx.com/fxml">
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="10.0" left="20.0" top="10.0" right="20"/>
|
||||||
|
</padding>
|
||||||
|
|
||||||
|
</VBox>
|
|
@ -15,21 +15,22 @@
|
||||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.bitsquare.gui.main.market;
|
package io.bitsquare.gui.main.markets.charts;
|
||||||
|
|
||||||
import io.bitsquare.common.UserThread;
|
import io.bitsquare.common.UserThread;
|
||||||
import io.bitsquare.common.util.Tuple2;
|
import io.bitsquare.common.util.Tuple2;
|
||||||
import io.bitsquare.gui.common.view.ActivatableViewAndModel;
|
import io.bitsquare.gui.common.view.ActivatableViewAndModel;
|
||||||
import io.bitsquare.gui.common.view.FxmlView;
|
import io.bitsquare.gui.common.view.FxmlView;
|
||||||
|
import io.bitsquare.gui.main.markets.statistics.MarketStatisticItem;
|
||||||
import io.bitsquare.gui.main.offer.offerbook.OfferBookListItem;
|
import io.bitsquare.gui.main.offer.offerbook.OfferBookListItem;
|
||||||
import io.bitsquare.gui.util.BSFormatter;
|
import io.bitsquare.gui.util.BSFormatter;
|
||||||
|
import io.bitsquare.locale.CurrencyUtil;
|
||||||
import io.bitsquare.locale.TradeCurrency;
|
import io.bitsquare.locale.TradeCurrency;
|
||||||
import io.bitsquare.trade.offer.Offer;
|
import io.bitsquare.trade.offer.Offer;
|
||||||
import javafx.beans.property.ReadOnlyObjectWrapper;
|
import javafx.beans.property.ReadOnlyObjectWrapper;
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
import javafx.beans.property.StringProperty;
|
import javafx.beans.property.StringProperty;
|
||||||
import javafx.collections.ListChangeListener;
|
import javafx.collections.ListChangeListener;
|
||||||
import javafx.fxml.FXML;
|
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.chart.AreaChart;
|
import javafx.scene.chart.AreaChart;
|
||||||
|
@ -46,9 +47,7 @@ import org.fxmisc.easybind.Subscription;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@FxmlView
|
@FxmlView
|
||||||
public class MarketView extends ActivatableViewAndModel<TabPane, MarketViewModel> {
|
public class MarketsChartsView extends ActivatableViewAndModel<VBox, MarketsChartsViewModel> {
|
||||||
@FXML
|
|
||||||
Tab tab;
|
|
||||||
|
|
||||||
private NumberAxis xAxis, yAxis;
|
private NumberAxis xAxis, yAxis;
|
||||||
XYChart.Series seriesBuy, seriesSell;
|
XYChart.Series seriesBuy, seriesSell;
|
||||||
|
@ -63,12 +62,13 @@ public class MarketView extends ActivatableViewAndModel<TabPane, MarketViewModel
|
||||||
private StringProperty amountColumnLabel = new SimpleStringProperty("Amount (BTC)");
|
private StringProperty amountColumnLabel = new SimpleStringProperty("Amount (BTC)");
|
||||||
private StringProperty volumeColumnLabel = new SimpleStringProperty("Volume (EUR)");
|
private StringProperty volumeColumnLabel = new SimpleStringProperty("Volume (EUR)");
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Constructor, lifecycle
|
// Constructor, lifecycle
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public MarketView(MarketViewModel model, BSFormatter formatter) {
|
public MarketsChartsView(MarketsChartsViewModel model, BSFormatter formatter) {
|
||||||
super(model);
|
super(model);
|
||||||
this.formatter = formatter;
|
this.formatter = formatter;
|
||||||
|
|
||||||
|
@ -111,13 +111,7 @@ public class MarketView extends ActivatableViewAndModel<TabPane, MarketViewModel
|
||||||
hBox.setAlignment(Pos.CENTER);
|
hBox.setAlignment(Pos.CENTER);
|
||||||
hBox.getChildren().addAll(tupleBuy.second, tupleSell.second);
|
hBox.getChildren().addAll(tupleBuy.second, tupleSell.second);
|
||||||
|
|
||||||
VBox vBox = new VBox();
|
root.getChildren().addAll(currencyHBox, areaChart, hBox);
|
||||||
vBox.setSpacing(20);
|
|
||||||
vBox.setFillWidth(true);
|
|
||||||
vBox.setPadding(new Insets(10, 20, 10, 20));
|
|
||||||
vBox.getChildren().addAll(currencyHBox, areaChart, hBox);
|
|
||||||
|
|
||||||
tab.setContent(vBox);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -286,4 +280,117 @@ public class MarketView extends ActivatableViewAndModel<TabPane, MarketViewModel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private TableColumn<MarketStatisticItem, MarketStatisticItem> getCurrencyColumn() {
|
||||||
|
TableColumn<MarketStatisticItem, MarketStatisticItem> column = new TableColumn<MarketStatisticItem, MarketStatisticItem>("Currency") {
|
||||||
|
{
|
||||||
|
setMinWidth(100);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||||
|
column.setCellFactory(
|
||||||
|
new Callback<TableColumn<MarketStatisticItem, MarketStatisticItem>, TableCell<MarketStatisticItem,
|
||||||
|
MarketStatisticItem>>() {
|
||||||
|
@Override
|
||||||
|
public TableCell<MarketStatisticItem, MarketStatisticItem> call(
|
||||||
|
TableColumn<MarketStatisticItem, MarketStatisticItem> column) {
|
||||||
|
return new TableCell<MarketStatisticItem, MarketStatisticItem>() {
|
||||||
|
@Override
|
||||||
|
public void updateItem(final MarketStatisticItem item, boolean empty) {
|
||||||
|
super.updateItem(item, empty);
|
||||||
|
if (item != null && !empty)
|
||||||
|
setText(CurrencyUtil.getNameByCode(item.currencyCode));
|
||||||
|
else
|
||||||
|
setText("");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return column;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TableColumn<MarketStatisticItem, MarketStatisticItem> getNumberOfOffersColumn() {
|
||||||
|
TableColumn<MarketStatisticItem, MarketStatisticItem> column = new TableColumn<MarketStatisticItem, MarketStatisticItem>("Total offers") {
|
||||||
|
{
|
||||||
|
setMinWidth(100);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||||
|
column.setCellFactory(
|
||||||
|
new Callback<TableColumn<MarketStatisticItem, MarketStatisticItem>, TableCell<MarketStatisticItem,
|
||||||
|
MarketStatisticItem>>() {
|
||||||
|
@Override
|
||||||
|
public TableCell<MarketStatisticItem, MarketStatisticItem> call(
|
||||||
|
TableColumn<MarketStatisticItem, MarketStatisticItem> column) {
|
||||||
|
return new TableCell<MarketStatisticItem, MarketStatisticItem>() {
|
||||||
|
@Override
|
||||||
|
public void updateItem(final MarketStatisticItem item, boolean empty) {
|
||||||
|
super.updateItem(item, empty);
|
||||||
|
if (item != null && !empty)
|
||||||
|
setText(String.valueOf(item.numberOfOffers));
|
||||||
|
else
|
||||||
|
setText("");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return column;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TableColumn<MarketStatisticItem, MarketStatisticItem> getTotalAmountColumn() {
|
||||||
|
TableColumn<MarketStatisticItem, MarketStatisticItem> column = new TableColumn<MarketStatisticItem, MarketStatisticItem>("Total amount (BTC)") {
|
||||||
|
{
|
||||||
|
setMinWidth(130);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||||
|
column.setCellFactory(
|
||||||
|
new Callback<TableColumn<MarketStatisticItem, MarketStatisticItem>, TableCell<MarketStatisticItem,
|
||||||
|
MarketStatisticItem>>() {
|
||||||
|
@Override
|
||||||
|
public TableCell<MarketStatisticItem, MarketStatisticItem> call(
|
||||||
|
TableColumn<MarketStatisticItem, MarketStatisticItem> column) {
|
||||||
|
return new TableCell<MarketStatisticItem, MarketStatisticItem>() {
|
||||||
|
@Override
|
||||||
|
public void updateItem(final MarketStatisticItem item, boolean empty) {
|
||||||
|
super.updateItem(item, empty);
|
||||||
|
if (item != null && !empty)
|
||||||
|
setText(formatter.formatCoin(item.totalAmount));
|
||||||
|
else
|
||||||
|
setText("");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return column;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TableColumn<MarketStatisticItem, MarketStatisticItem> getSpreadColumn() {
|
||||||
|
TableColumn<MarketStatisticItem, MarketStatisticItem> column = new TableColumn<MarketStatisticItem, MarketStatisticItem>("Spread") {
|
||||||
|
{
|
||||||
|
setMinWidth(130);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||||
|
column.setCellFactory(
|
||||||
|
new Callback<TableColumn<MarketStatisticItem, MarketStatisticItem>, TableCell<MarketStatisticItem,
|
||||||
|
MarketStatisticItem>>() {
|
||||||
|
@Override
|
||||||
|
public TableCell<MarketStatisticItem, MarketStatisticItem> call(
|
||||||
|
TableColumn<MarketStatisticItem, MarketStatisticItem> column) {
|
||||||
|
return new TableCell<MarketStatisticItem, MarketStatisticItem>() {
|
||||||
|
@Override
|
||||||
|
public void updateItem(final MarketStatisticItem item, boolean empty) {
|
||||||
|
super.updateItem(item, empty);
|
||||||
|
if (item != null && !empty && item.spread != null)
|
||||||
|
setText(formatter.formatFiatWithCode(item.spread));
|
||||||
|
else
|
||||||
|
setText("");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return column;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -15,7 +15,7 @@
|
||||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.bitsquare.gui.main.market;
|
package io.bitsquare.gui.main.markets.charts;
|
||||||
|
|
||||||
import com.google.common.math.LongMath;
|
import com.google.common.math.LongMath;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
@ -37,7 +37,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
class MarketViewModel extends ActivatableViewModel {
|
class MarketsChartsViewModel extends ActivatableViewModel {
|
||||||
|
|
||||||
private final OfferBook offerBook;
|
private final OfferBook offerBook;
|
||||||
private final Preferences preferences;
|
private final Preferences preferences;
|
||||||
|
@ -56,7 +56,7 @@ class MarketViewModel extends ActivatableViewModel {
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public MarketViewModel(OfferBook offerBook, Preferences preferences) {
|
public MarketsChartsViewModel(OfferBook offerBook, Preferences preferences) {
|
||||||
this.offerBook = offerBook;
|
this.offerBook = offerBook;
|
||||||
this.preferences = preferences;
|
this.preferences = preferences;
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ class MarketViewModel extends ActivatableViewModel {
|
||||||
|
|
||||||
private void updateChartData(ObservableList<OfferBookListItem> offerBookListItems) {
|
private void updateChartData(ObservableList<OfferBookListItem> offerBookListItems) {
|
||||||
List<Offer> offerList = offerBookListItems.stream()
|
List<Offer> offerList = offerBookListItems.stream()
|
||||||
.map(e -> e.getOffer())
|
.map(OfferBookListItem::getOffer)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
buyOfferList.clear();
|
buyOfferList.clear();
|
|
@ -0,0 +1,24 @@
|
||||||
|
package io.bitsquare.gui.main.markets.statistics;
|
||||||
|
|
||||||
|
import org.bitcoinj.core.Coin;
|
||||||
|
import org.bitcoinj.utils.Fiat;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public class MarketStatisticItem {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(MarketStatisticItem.class);
|
||||||
|
public final String currencyCode;
|
||||||
|
public final int numberOfOffers;
|
||||||
|
@Nullable
|
||||||
|
public final Fiat spread;
|
||||||
|
public final Coin totalAmount;
|
||||||
|
|
||||||
|
public MarketStatisticItem(String currencyCode, int numberOfOffers, @Nullable Fiat spread, Coin totalAmount) {
|
||||||
|
this.currencyCode = currencyCode;
|
||||||
|
this.numberOfOffers = numberOfOffers;
|
||||||
|
this.spread = spread;
|
||||||
|
this.totalAmount = totalAmount;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,117 @@
|
||||||
|
/*
|
||||||
|
* 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.gui.main.markets.statistics;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import io.bitsquare.gui.common.model.ActivatableViewModel;
|
||||||
|
import io.bitsquare.gui.main.offer.offerbook.OfferBook;
|
||||||
|
import io.bitsquare.gui.main.offer.offerbook.OfferBookListItem;
|
||||||
|
import io.bitsquare.trade.offer.Offer;
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.collections.ListChangeListener;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
|
import org.bitcoinj.core.Coin;
|
||||||
|
import org.bitcoinj.utils.Fiat;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
class MarketsStatisticViewModel extends ActivatableViewModel {
|
||||||
|
|
||||||
|
private final OfferBook offerBook;
|
||||||
|
private final ObservableList<OfferBookListItem> offerBookListItems;
|
||||||
|
private final ListChangeListener<OfferBookListItem> listChangeListener;
|
||||||
|
final ObservableList<MarketStatisticItem> marketStatisticItems = FXCollections.observableArrayList();
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Constructor, lifecycle
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public MarketsStatisticViewModel(OfferBook offerBook) {
|
||||||
|
this.offerBook = offerBook;
|
||||||
|
|
||||||
|
offerBookListItems = offerBook.getOfferBookListItems();
|
||||||
|
listChangeListener = c -> update(offerBookListItems);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void activate() {
|
||||||
|
offerBookListItems.addListener(listChangeListener);
|
||||||
|
offerBook.fillOfferBookListItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void deactivate() {
|
||||||
|
offerBookListItems.removeListener(listChangeListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void update(ObservableList<OfferBookListItem> offerBookListItems) {
|
||||||
|
Map<String, List<Offer>> offersByCurrencyMap = new HashMap<>();
|
||||||
|
for (OfferBookListItem offerBookListItem : offerBookListItems) {
|
||||||
|
Offer offer = offerBookListItem.getOffer();
|
||||||
|
String currencyCode = offer.getCurrencyCode();
|
||||||
|
if (!offersByCurrencyMap.containsKey(currencyCode))
|
||||||
|
offersByCurrencyMap.put(currencyCode, new ArrayList<>());
|
||||||
|
offersByCurrencyMap.get(currencyCode).add(offer);
|
||||||
|
}
|
||||||
|
marketStatisticItems.clear();
|
||||||
|
long totalAmount = 0;
|
||||||
|
for (String currencyCode : offersByCurrencyMap.keySet()) {
|
||||||
|
List<Offer> offers = offersByCurrencyMap.get(currencyCode);
|
||||||
|
List<Offer> buyOffers = offers
|
||||||
|
.stream()
|
||||||
|
.filter(e -> e.getDirection().equals(Offer.Direction.BUY))
|
||||||
|
.sorted((o1, o2) -> {
|
||||||
|
long a = o1.getPrice().value;
|
||||||
|
long b = o2.getPrice().value;
|
||||||
|
if (a != b)
|
||||||
|
return a < b ? 1 : -1;
|
||||||
|
return 0;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
Fiat bestBuyOfferPrice = buyOffers.isEmpty() ? null : buyOffers.get(0).getPrice();
|
||||||
|
List<Offer> sellOffers = offers
|
||||||
|
.stream()
|
||||||
|
.filter(e -> e.getDirection().equals(Offer.Direction.SELL))
|
||||||
|
.sorted((o1, o2) -> {
|
||||||
|
long a = o1.getPrice().value;
|
||||||
|
long b = o2.getPrice().value;
|
||||||
|
if (a != b)
|
||||||
|
return a > b ? 1 : -1;
|
||||||
|
return 0;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
Fiat bestSellOfferPrice = sellOffers.isEmpty() ? null : sellOffers.get(0).getPrice();
|
||||||
|
|
||||||
|
Fiat spread = null;
|
||||||
|
if (bestBuyOfferPrice != null && bestSellOfferPrice != null) {
|
||||||
|
spread = bestSellOfferPrice.subtract(bestBuyOfferPrice);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Offer offer : offers) {
|
||||||
|
totalAmount += offer.getAmount().getValue();
|
||||||
|
}
|
||||||
|
marketStatisticItems.add(new MarketStatisticItem(currencyCode, offers.size(), spread, Coin.valueOf(totalAmount)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
~ 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/>.
|
||||||
|
-->
|
||||||
|
|
||||||
|
|
||||||
|
<?import javafx.geometry.Insets?>
|
||||||
|
<?import javafx.scene.layout.*?>
|
||||||
|
<GridPane fx:id="root" fx:controller="io.bitsquare.gui.main.markets.statistics.MarketsStatisticsView"
|
||||||
|
hgap="5.0" vgap="5.0"
|
||||||
|
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||||
|
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"
|
||||||
|
xmlns:fx="http://javafx.com/fxml">
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="10.0" left="25.0" top="20.0" right="25"/>
|
||||||
|
</padding>
|
||||||
|
|
||||||
|
</GridPane>
|
|
@ -0,0 +1,202 @@
|
||||||
|
/*
|
||||||
|
* 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.gui.main.markets.statistics;
|
||||||
|
|
||||||
|
import io.bitsquare.gui.common.view.ActivatableViewAndModel;
|
||||||
|
import io.bitsquare.gui.common.view.FxmlView;
|
||||||
|
import io.bitsquare.gui.components.TableGroupHeadline;
|
||||||
|
import io.bitsquare.gui.util.BSFormatter;
|
||||||
|
import io.bitsquare.locale.CurrencyUtil;
|
||||||
|
import javafx.beans.property.ReadOnlyObjectWrapper;
|
||||||
|
import javafx.geometry.Insets;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.TableCell;
|
||||||
|
import javafx.scene.control.TableColumn;
|
||||||
|
import javafx.scene.control.TableView;
|
||||||
|
import javafx.scene.layout.GridPane;
|
||||||
|
import javafx.scene.layout.Priority;
|
||||||
|
import javafx.util.Callback;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
@FxmlView
|
||||||
|
public class MarketsStatisticsView extends ActivatableViewAndModel<GridPane, MarketsStatisticViewModel> {
|
||||||
|
private BSFormatter formatter;
|
||||||
|
private int gridRow = 0;
|
||||||
|
private TableView<MarketStatisticItem> statisticsTableView;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Constructor, lifecycle
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public MarketsStatisticsView(MarketsStatisticViewModel model, BSFormatter formatter) {
|
||||||
|
super(model);
|
||||||
|
this.formatter = formatter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
TableGroupHeadline header = new TableGroupHeadline("Statistics");
|
||||||
|
GridPane.setRowIndex(header, gridRow);
|
||||||
|
GridPane.setMargin(header, new Insets(0, -10, -10, -10));
|
||||||
|
root.getChildren().add(header);
|
||||||
|
|
||||||
|
statisticsTableView = new TableView<>();
|
||||||
|
GridPane.setRowIndex(statisticsTableView, gridRow);
|
||||||
|
GridPane.setMargin(statisticsTableView, new Insets(20, -10, -10, -10));
|
||||||
|
GridPane.setVgrow(statisticsTableView, Priority.ALWAYS);
|
||||||
|
GridPane.setHgrow(statisticsTableView, Priority.ALWAYS);
|
||||||
|
root.getChildren().add(statisticsTableView);
|
||||||
|
statisticsTableView.getColumns().add(getCurrencyColumn());
|
||||||
|
statisticsTableView.getColumns().add(getNumberOfOffersColumn());
|
||||||
|
statisticsTableView.getColumns().add(getTotalAmountColumn());
|
||||||
|
statisticsTableView.getColumns().add(getSpreadColumn());
|
||||||
|
statisticsTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
|
||||||
|
Label placeholder = new Label("Currently there are no offers available");
|
||||||
|
placeholder.setWrapText(true);
|
||||||
|
statisticsTableView.setPlaceholder(placeholder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void activate() {
|
||||||
|
statisticsTableView.setItems(model.marketStatisticItems);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void deactivate() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Columns
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
private TableColumn<MarketStatisticItem, MarketStatisticItem> getCurrencyColumn() {
|
||||||
|
TableColumn<MarketStatisticItem, MarketStatisticItem> column = new TableColumn<MarketStatisticItem, MarketStatisticItem>("Currency") {
|
||||||
|
{
|
||||||
|
setMinWidth(100);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||||
|
column.setCellFactory(
|
||||||
|
new Callback<TableColumn<MarketStatisticItem, MarketStatisticItem>, TableCell<MarketStatisticItem,
|
||||||
|
MarketStatisticItem>>() {
|
||||||
|
@Override
|
||||||
|
public TableCell<MarketStatisticItem, MarketStatisticItem> call(
|
||||||
|
TableColumn<MarketStatisticItem, MarketStatisticItem> column) {
|
||||||
|
return new TableCell<MarketStatisticItem, MarketStatisticItem>() {
|
||||||
|
@Override
|
||||||
|
public void updateItem(final MarketStatisticItem item, boolean empty) {
|
||||||
|
super.updateItem(item, empty);
|
||||||
|
if (item != null && !empty)
|
||||||
|
setText(CurrencyUtil.getNameByCode(item.currencyCode));
|
||||||
|
else
|
||||||
|
setText("");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return column;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TableColumn<MarketStatisticItem, MarketStatisticItem> getNumberOfOffersColumn() {
|
||||||
|
TableColumn<MarketStatisticItem, MarketStatisticItem> column = new TableColumn<MarketStatisticItem, MarketStatisticItem>("Total offers") {
|
||||||
|
{
|
||||||
|
setMinWidth(100);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||||
|
column.setCellFactory(
|
||||||
|
new Callback<TableColumn<MarketStatisticItem, MarketStatisticItem>, TableCell<MarketStatisticItem,
|
||||||
|
MarketStatisticItem>>() {
|
||||||
|
@Override
|
||||||
|
public TableCell<MarketStatisticItem, MarketStatisticItem> call(
|
||||||
|
TableColumn<MarketStatisticItem, MarketStatisticItem> column) {
|
||||||
|
return new TableCell<MarketStatisticItem, MarketStatisticItem>() {
|
||||||
|
@Override
|
||||||
|
public void updateItem(final MarketStatisticItem item, boolean empty) {
|
||||||
|
super.updateItem(item, empty);
|
||||||
|
if (item != null && !empty)
|
||||||
|
setText(String.valueOf(item.numberOfOffers));
|
||||||
|
else
|
||||||
|
setText("");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return column;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TableColumn<MarketStatisticItem, MarketStatisticItem> getTotalAmountColumn() {
|
||||||
|
TableColumn<MarketStatisticItem, MarketStatisticItem> column = new TableColumn<MarketStatisticItem, MarketStatisticItem>("Total amount (BTC)") {
|
||||||
|
{
|
||||||
|
setMinWidth(130);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||||
|
column.setCellFactory(
|
||||||
|
new Callback<TableColumn<MarketStatisticItem, MarketStatisticItem>, TableCell<MarketStatisticItem,
|
||||||
|
MarketStatisticItem>>() {
|
||||||
|
@Override
|
||||||
|
public TableCell<MarketStatisticItem, MarketStatisticItem> call(
|
||||||
|
TableColumn<MarketStatisticItem, MarketStatisticItem> column) {
|
||||||
|
return new TableCell<MarketStatisticItem, MarketStatisticItem>() {
|
||||||
|
@Override
|
||||||
|
public void updateItem(final MarketStatisticItem item, boolean empty) {
|
||||||
|
super.updateItem(item, empty);
|
||||||
|
if (item != null && !empty)
|
||||||
|
setText(formatter.formatCoin(item.totalAmount));
|
||||||
|
else
|
||||||
|
setText("");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return column;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TableColumn<MarketStatisticItem, MarketStatisticItem> getSpreadColumn() {
|
||||||
|
TableColumn<MarketStatisticItem, MarketStatisticItem> column = new TableColumn<MarketStatisticItem, MarketStatisticItem>("Spread") {
|
||||||
|
{
|
||||||
|
setMinWidth(130);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||||
|
column.setCellFactory(
|
||||||
|
new Callback<TableColumn<MarketStatisticItem, MarketStatisticItem>, TableCell<MarketStatisticItem,
|
||||||
|
MarketStatisticItem>>() {
|
||||||
|
@Override
|
||||||
|
public TableCell<MarketStatisticItem, MarketStatisticItem> call(
|
||||||
|
TableColumn<MarketStatisticItem, MarketStatisticItem> column) {
|
||||||
|
return new TableCell<MarketStatisticItem, MarketStatisticItem>() {
|
||||||
|
@Override
|
||||||
|
public void updateItem(final MarketStatisticItem item, boolean empty) {
|
||||||
|
super.updateItem(item, empty);
|
||||||
|
if (item != null && !empty && item.spread != null)
|
||||||
|
setText(formatter.formatFiatWithCode(item.spread));
|
||||||
|
else
|
||||||
|
setText("");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return column;
|
||||||
|
}
|
||||||
|
}
|
|
@ -32,14 +32,12 @@ import javax.inject.Inject;
|
||||||
|
|
||||||
@FxmlView
|
@FxmlView
|
||||||
public class SettingsView extends ActivatableViewAndModel<TabPane, Activatable> {
|
public class SettingsView extends ActivatableViewAndModel<TabPane, Activatable> {
|
||||||
|
@FXML
|
||||||
@FXML Tab preferencesTab, networkSettingsTab;
|
Tab preferencesTab, networkSettingsTab;
|
||||||
|
|
||||||
private Navigation.Listener navigationListener;
|
|
||||||
private ChangeListener<Tab> tabChangeListener;
|
|
||||||
|
|
||||||
private final ViewLoader viewLoader;
|
private final ViewLoader viewLoader;
|
||||||
private final Navigation navigation;
|
private final Navigation navigation;
|
||||||
|
private Navigation.Listener navigationListener;
|
||||||
|
private ChangeListener<Tab> tabChangeListener;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public SettingsView(CachingViewLoader viewLoader, Navigation navigation) {
|
public SettingsView(CachingViewLoader viewLoader, Navigation navigation) {
|
||||||
|
|
|
@ -341,7 +341,7 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis
|
||||||
connection.setConnectionPriority(ConnectionPriority.DIRECT_MSG);
|
connection.setConnectionPriority(ConnectionPriority.DIRECT_MSG);
|
||||||
|
|
||||||
log.info("\n\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n" +
|
log.info("\n\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n" +
|
||||||
"Received SealedAndSignedMessage and decrypted it.\ndecryptedMsgWithPubKey={}"
|
"Decrypted SealedAndSignedMessage:\ndecryptedMsgWithPubKey={}"
|
||||||
+ "\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", decryptedMsgWithPubKey);
|
+ "\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", decryptedMsgWithPubKey);
|
||||||
connection.getPeerAddressOptional().ifPresent(peerAddresses ->
|
connection.getPeerAddressOptional().ifPresent(peerAddresses ->
|
||||||
decryptedMailListeners.stream().forEach(
|
decryptedMailListeners.stream().forEach(
|
||||||
|
@ -400,6 +400,9 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis
|
||||||
Log.traceCall();
|
Log.traceCall();
|
||||||
checkArgument(optionalEncryptionService.isPresent(), "EncryptionService not set. Seems that is called on a seed node which must not happen.");
|
checkArgument(optionalEncryptionService.isPresent(), "EncryptionService not set. Seems that is called on a seed node which must not happen.");
|
||||||
try {
|
try {
|
||||||
|
log.info("\n\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" +
|
||||||
|
"Encrypt message:\nmessage={}"
|
||||||
|
+ "\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n", message);
|
||||||
SealedAndSignedMessage sealedAndSignedMessage = new SealedAndSignedMessage(
|
SealedAndSignedMessage sealedAndSignedMessage = new SealedAndSignedMessage(
|
||||||
optionalEncryptionService.get().encryptAndSign(pubKeyRing, message), peerAddress.getAddressPrefixHash());
|
optionalEncryptionService.get().encryptAndSign(pubKeyRing, message), peerAddress.getAddressPrefixHash());
|
||||||
SettableFuture<Connection> future = networkNode.sendMessage(peerAddress, sealedAndSignedMessage);
|
SettableFuture<Connection> future = networkNode.sendMessage(peerAddress, sealedAndSignedMessage);
|
||||||
|
@ -495,6 +498,9 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis
|
||||||
checkArgument(optionalKeyRing.isPresent(), "keyRing not set. Seems that is called on a seed node which must not happen.");
|
checkArgument(optionalKeyRing.isPresent(), "keyRing not set. Seems that is called on a seed node which must not happen.");
|
||||||
checkArgument(optionalEncryptionService.isPresent(), "EncryptionService not set. Seems that is called on a seed node which must not happen.");
|
checkArgument(optionalEncryptionService.isPresent(), "EncryptionService not set. Seems that is called on a seed node which must not happen.");
|
||||||
try {
|
try {
|
||||||
|
log.info("\n\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" +
|
||||||
|
"Encrypt message:\nmessage={}"
|
||||||
|
+ "\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n", message);
|
||||||
SealedAndSignedMessage sealedAndSignedMessage = new SealedAndSignedMessage(
|
SealedAndSignedMessage sealedAndSignedMessage = new SealedAndSignedMessage(
|
||||||
optionalEncryptionService.get().encryptAndSign(peersPubKeyRing, message), peerAddress.getAddressPrefixHash());
|
optionalEncryptionService.get().encryptAndSign(peersPubKeyRing, message), peerAddress.getAddressPrefixHash());
|
||||||
SettableFuture<Connection> future = networkNode.sendMessage(peerAddress, sealedAndSignedMessage);
|
SettableFuture<Connection> future = networkNode.sendMessage(peerAddress, sealedAndSignedMessage);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue