diff --git a/.gitignore b/.gitignore
index b1cc84ff079..25ccd9afd15 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,8 +30,6 @@ desktop.ini
*.class
deploy
*/releases/*
-/monitor/TorHiddenServiceStartupTimeTests/*
-/monitor/monitor-tor/*
.java-version
.localnet
/apitest/src/main/resources/dao-setup*
diff --git a/Makefile b/Makefile
index 58ff18290b2..1575383b664 100644
--- a/Makefile
+++ b/Makefile
@@ -37,7 +37,6 @@
#
# $ ls -1 bisq-*
# bisq-desktop
-# bisq-monitor
# bisq-relay
# bisq-seednode
# bisq-statsnode
diff --git a/build.gradle b/build.gradle
index aebb42af476..5c4ae044e06 100644
--- a/build.gradle
+++ b/build.gradle
@@ -93,7 +93,6 @@ configure(subprojects) {
configure([project(':cli'),
project(':daemon'),
project(':desktop'),
- project(':monitor'),
project(':seednode'),
project(':statsnode'),
project(':apitest')]) {
@@ -506,52 +505,6 @@ configure(project(':desktop')) {
}
-configure(project(':monitor')) {
- apply plugin: 'org.openjfx.javafxplugin'
-
- javafx {
- version = "$javafxVersion"
- modules = ['javafx.base']
- }
-
- mainClassName = 'bisq.monitor.Monitor'
-
- test {
- useJUnitPlatform()
- testLogging {
- events "passed", "skipped", "failed"
- }
- }
-
- dependencies {
- implementation project(':assets')
- implementation project(':common')
- implementation project(':core')
- implementation project(':p2p')
- annotationProcessor "org.projectlombok:lombok:$lombokVersion"
- compileOnly "org.projectlombok:lombok:$lombokVersion"
- implementation "ch.qos.logback:logback-classic:$logbackVersion"
- implementation "ch.qos.logback:logback-core:$logbackVersion"
- implementation "com.google.guava:guava:$guavaVersion"
- implementation "org.slf4j:slf4j-api:$slf4jVersion"
- implementation("com.github.bisq-network.netlayer:tor.external:$netlayerVersion") {
- exclude(module: 'slf4j-api')
- }
- implementation("com.github.bisq-network.netlayer:tor.native:$netlayerVersion") {
- exclude(module: 'slf4j-api')
- }
- implementation("com.google.inject:guice:$guiceVersion") {
- exclude(module: 'guava')
- }
- testAnnotationProcessor "org.projectlombok:lombok:$lombokVersion"
- testCompileOnly "org.projectlombok:lombok:$lombokVersion"
- testImplementation "org.junit.jupiter:junit-jupiter-api:$jupiterVersion"
- testImplementation "org.junit.jupiter:junit-jupiter-params:$jupiterVersion"
- testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$jupiterVersion")
- }
-}
-
-
configure(project(':seednode')) {
apply plugin: 'com.github.johnrengelman.shadow'
diff --git a/monitor/README.md b/monitor/README.md
deleted file mode 100644
index f2ed142b89a..00000000000
--- a/monitor/README.md
+++ /dev/null
@@ -1,246 +0,0 @@
-# Bisq Network Monitor Node
-
-The Bisq monitor node collects a set of metrics which are of interest to developers and users alike. These metrics are then made available through reporters.
-
-The *Settled* release features these metrics:
-- Tor Startup Time: The time it takes to start Tor starting at a clean system, unpacking the shipped Tor binaries, firing up Tor until Tor is connected to the Tor network and ready to use.
-- Tor Roundtrip Time: Given a bootstrapped Tor, the roundtrip time of connecting to a hidden service is measured.
-- Tor Hidden Service Startup Time: Given a bootstrapped Tor, the time it takes to create and announce a freshly created hidden service.
-- P2P Round Trip Time: A metric hitchhiking the Ping/Pong messages of the Keep-Alive-Mechanism to determine the Round Trip Time when issuing a Ping to a seed node.
-- P2P Seed Node Message Snapshot: Get absolute number and constellation of messages a fresh Bisq client will get on startup. Also reports diffs between seed nodes on a per-message-type basis.
-- P2P Network Load: listens to the P2P network and its broadcast messages. Reports every X seconds.
-- P2P Market Statistics: a demonstration metric which extracts market information from broadcast messages. This demo implementation reports the number of open offers per market.
-
-
-The *Settled* release features these reporters:
-- A reporter that simply writes the findings to `System.err`
-- A reporter that reports the findings to a Graphite/Carbon instance using the [plaintext protocol](https://graphite.readthedocs.io/en/latest/feeding-carbon.html#the-plaintext-protocol)
-
-## Configuration
-
-The *Bisq Network Monitor Node* is to be configured via a Java properties file. There is a default configuration file shipped with the monitor which reports to the one monitoring service currently up and running.
-
-If you want to tweak the configuration, you can pass the location of the file as command line parameter:
-
-```
-./bisq-monitor /path/to/your/config.properties
-```
-
-A sample configuration file looks like follows:
-
-```
-## System configuration
-
-# true overwrites the reporters picked by the developers (for debugging for example) (defaults to false)
-System.useConsoleReporter=true
-
-# 0 -> BTC_MAINNET, 1 -> BTC_TESTNET (default)
-System.baseCurrencyNetwork=0
-
-## Each Metric is configured via a set of properties.
-##
-## The minimal set of properties required to run a Metric is:
-##
-## YourMetricName.enabled=true|false
-## YourMetricName.run.interval=10 [seconds]
-
-#Edit and uncomment the lines below to your liking
-
-#TorStartupTime Metric
-TorStartupTime.enabled=true
-TorStartupTime.run.interval=100
-TorStartupTime.run.socksPort=90500 # so that there is no interference with a system Tor
-
-#TorRoundTripTime Metric
-TorRoundTripTime.enabled=true
-TorRoundTripTime.run.interval=100
-TorRoundTripTime.run.sampleSize=5
-TorRoundTripTime.run.hosts=http://expyuzz4wqqyqhjn.onion:80 # torproject.org hidden service
-
-#TorHiddenServiceStartupTime Metric
-TorHiddenServiceStartupTime.enabled=true
-TorHiddenServiceStartupTime.run.interval=100
-TorHiddenServiceStartupTime.run.localPort=90501 # so that there is no interference with a system Tor
-TorHiddenServiceStartupTime.run.servicePort=90511 # so that there is no interference with a system Tor
-
-#P2PRoundTripTime Metric
-P2PRoundTripTime.enabled=true
-P2PRoundTripTime.run.interval=100
-P2PRoundTripTime.run.sampleSize=5
-P2PRoundTripTime.run.hosts=723ljisnynbtdohi.onion:8000, fl3mmribyxgrv63c.onion:8000
-P2PRoundTripTime.run.torProxyPort=9060
-
-#P2PNetworkLoad Metric
-P2PNetworkLoad.enabled=true
-P2PNetworkLoad.run.interval=100
-P2PNetworkLoad.run.torProxyPort=9061
-P2PNetworkLoad.run.historySize=500
-
-#P2PNetworkMessageSnapshot Metric
-P2PSeedNodeSnapshot.enabled=true
-P2PSeedNodeSnapshot.run.interval=24
-P2PSeedNodeSnapshot.run.hosts=3f3cu2yw7u457ztq.onion:8000, 723ljisnynbtdohi.onion:8000, fl3mmribyxgrv63c.onion:8000
-P2PSeedNodeSnapshot.run.torProxyPort=9062
-
-#P2PMarketStats Metric
-P2PMarketStats.enabled=true
-P2PMarketStats.run.interval=37
-P2PMarketStats.run.hosts=ef5qnzx6znifo3df.onion:8000
-P2PMarketStats.run.torProxyPort=9063
-
-#PriceNodeStats Metric
-PriceNodeStats.enabled=true
-PriceNodeStats.run.interval=42
-PriceNodeStats.run.hosts=http://5bmpx76qllutpcyp.onion, http://xc3nh4juf2hshy7e.onion, http://44mgyoe2b6oqiytt.onion, http://62nvujg5iou3vu3i.onion, http://ceaanhbvluug4we6.onion
-
-#MarketStats Metric
-MarketStats.enabled=true
-MarketStats.run.interval=191
-
-## Reporters are configured via a set of properties as well.
-##
-## In contrast to Metrics, Reporters do not have a minimal set of properties.
-
-#GraphiteReporter
-GraphiteReporter.serviceUrl=k6evlhg44acpchtc.onion:2003
-
-```
-
-## Run
-
-The distribution ships with a systemd .service file. Validate/change the executable/config paths within the shipped `bisq-monitor.service` file and copy/move the file to your systemd directory (something along `/usr/lib/systemd/system/`). Now you can control your *Monitor Node* via the usual systemd start/stop commands
-
-```
-systemctl start bisq-monitor.service
-systemctl stop bisq-monitor.service
-```
-and
-```
-systemctl enable bisq-monitor.service
-```
-
-You can reload the configuration without restarting the service by using
-
-```
-systemctl reload bisq-monitor.service
-```
-
-Follow the logs created by the service by inspecting
-
-```
-journalctl --unit bisq-monitor --follow
-```
-
-# Monitoring Service
-
-A typical monitoring service consists of a [Graphite](https://graphiteapp.org/) and a [Grafana](https://grafana.com/) instance.
-Both are available via Docker-containers.
-
-## Setting up Graphite
-
-### Install
-
-For a docker setup, use
-
-```
-docker run -d --name graphite --restart=always -p 2003:2003 -p 8080:8080 graphiteapp/graphite-statsd
-```
-
-- Port 2003 is used for the [plaintext protocol](https://graphite.readthedocs.io/en/latest/feeding-carbon.html#the-plaintext-protocol) mentioned above
-- Port 8080 offers an API for user interfaces.
-
-more information can be found [here](https://graphite.readthedocs.io/en/latest/install.html)
-
-### Configuration
-
-For configuration, you must adapt the whisper database schema to suit your needs. First, stop your docker container by running
-
-```
-docker stop graphite
-```
-
-Find your config files within the `Source` directory stated in
-
-```
-docker inspect graphite | grep -C 2 graphite/conf\",
-```
-
-Edit `storage-schemas.conf` so that the frequency of your incoming data (configured in the monitor configs `interval`) is matched. For example, insert
-```
-[bisq]
-pattern = ^bisq.*
-retentions = 10s:1h,5m:31d,30m:2y,1h:5y
-```
-before the `[default...` blocks of the file. This basically says, that every incoming set of data reflects 5 minutes of the time series. Furthermore, every 30 minutes, the data is compressed and thus, takes less memory as it is kept for 2 years.
-
-Further, edit `storage-aggregation.conf` to configure how your data is compressed. For example, insert
-```
-[bisq]
-pattern=^bisq.*
-xFilesFactor = 0
-aggregationMethod = average
-```
-before the `[default...` blocks of the file. With this configuration, whenever data is aggregated, the `average` data is made available given that at least `0%` of the data points (i.e. floor(30 / 5 * 40%) = 2 data points) exist. Otherwise, the aggregated data is dropped. Since we start the first hour with a frequency of 10s but only supply data every 4 to 6 minutes, our aggregated values would get dropped.
-
-*Please note, that I have not been able to get the whole thing to work without the 10s:1h part yet*
-
-Finally, update the database. For doing that, go to the storage directory of graphite, the `Source` directory stated in
-```
-docker inspect graphite | grep -C 2 graphite/conf\",
-```
-Once there, you have two options:
-- delete the whisper directory
-```
-rm -r whisper
-```
-- update the database by doing
-```
-find ./ -type f -name '*.wsp' -exec whisper-resize.py --nobackup {} 10s:1h 5m:31d 30m:2y 1h:5y \;
-```
-
-and finally, restart your graphite container:
-```
-docker start graphite
-```
-
-
-Other than that, there is no further configuration necessary. However, you might change your iptables/firewalls to not let anyone access your Graphite instance from the outside.
-
-### Backup your data
-
-The metric data is kept in the `Source` directory stated in
-```
-docker inspect graphite | grep -C 2 graphite/conf\",
-```
-ready to be backed up regularly.
-
-## Setting up Grafana
-
-### Install
-
-For a docker setup, use
-
-```
-docker run -d --name=grafana -p 3000:3000 grafana/grafana
-```
-
-- Port 3000 offers the web interface
-
-more information can be found [here](https://grafana.com/grafana/download?platform=docker)
-
-### Configuration
-
-- Once you have Grafana up and running, go to the *Data Source* configuration tab.
-- Once there click *Add data source* and select *Graphite*.
-- In the HTTP section enter the IP address of your graphite docker container and the port `8080` (as we have configured before). E.g. `http://172.170.1:8080`
-- Select `Server (default)` as an *Access* method and hit *Save & Test*.
-
-You should be all set. You can now proceed to add Dashboards, Panels and finally display the prettiest Graphs you can think of.
-A working connection to Graphite should let you add your data series in a *Graph*s *Metrics* tab in a pretty intuitive way.
-
-- Optional: hide your Grafana instance behind a reverse proxy like nginx and add some TLS.
-- Optional: make your Grafana instance accessible via a Tor hidden service.
-
-### Backup your data
-
-Grafana stores every dashboard as a JSON model. This model can be accessed (copied/restored) within the dashboard's settings and its *JSON Model* tab. Do with the data whatever you want.
diff --git a/monitor/bisq-monitor.service b/monitor/bisq-monitor.service
deleted file mode 100644
index 892c69ae53b..00000000000
--- a/monitor/bisq-monitor.service
+++ /dev/null
@@ -1,16 +0,0 @@
-[Unit]
-Description=Bisq network monitor
-After=network.target
-
-[Service]
-WorkingDirectory=~
-Environment="JAVA_OPTS='-Xmx500M'"
-ExecStart=/home/bisq/bisq/bisq-monitor /home/bisq/monitor.properties
-ExecReload=/bin/kill -USR1 $MAINPID
-Restart=on-failure
-
-User=bisq
-Group=bisq
-
-[Install]
-WantedBy=multi-user.target
diff --git a/monitor/collectd.conf b/monitor/collectd.conf
deleted file mode 100644
index f6106508b11..00000000000
--- a/monitor/collectd.conf
+++ /dev/null
@@ -1,136 +0,0 @@
-Hostname "__ONION_ADDRESS__"
-Interval 30
-
-LoadPlugin syslog
-
- LogLevel info
-
-
-LoadPlugin cpu
-LoadPlugin df
-LoadPlugin disk
-LoadPlugin fhcount
-LoadPlugin interface
-LoadPlugin java
-LoadPlugin load
-LoadPlugin memory
-LoadPlugin processes
-LoadPlugin swap
-LoadPlugin write_graphite
-
-
- ReportByCpu true
- ValuesPercentage true
-
-
-
- MountPoint "/"
-
-
-
- Disk "/[hs]da/"
-
-
-
- ValuesAbsolute false
- ValuesPercentage true
-
-
-
- Interface "eth0"
-
-
-
- JVMArg "-verbose:jni"
- JVMArg "-Djava.class.path=/usr/share/collectd/java/collectd-api.jar:/usr/share/collectd/java/generic-jmx.jar"
-
- LoadPlugin "org.collectd.java.GenericJMX"
-
- # Generic heap/nonheap memory usage.
-
- ObjectName "java.lang:type=Memory"
- #InstanceFrom ""
- InstancePrefix "memory"
-
- # Creates four values: committed, init, max, used
-
- Type "memory"
- #InstancePrefix ""
- #InstanceFrom ""
- Table true
- Attribute "HeapMemoryUsage"
- InstancePrefix "heap-"
-
-
- # Creates four values: committed, init, max, used
-
- Type "memory"
- #InstancePrefix ""
- #InstanceFrom ""
- Table true
- Attribute "NonHeapMemoryUsage"
- InstancePrefix "nonheap-"
-
-
-
- # Memory usage by memory pool.
-
- ObjectName "java.lang:type=MemoryPool,*"
- InstancePrefix "memory_pool-"
- InstanceFrom "name"
-
-
- Type "memory"
- #InstancePrefix ""
- #InstanceFrom ""
- Table true
- Attribute "Usage"
-
-
-
-
- ServiceURL "service:jmx:rmi:///jndi/rmi://localhost:6969/jmxrmi"
- Collect "memory_pool"
- Collect "memory"
-
-
- # See /usr/share/doc/collectd/examples/GenericJMX.conf
- # for an example config.
-
-
-
-#
-# ReportRelative true
-#
-
-#
-# ValuesAbsolute true
-# ValuesPercentage false
-#
-
-#
-# Process "name"
-# ProcessMatch "foobar" "/usr/bin/perl foobar\\.pl.*"
-#
-
-#
-# ReportByDevice false
-# ReportBytes true
-#
-
-
-
- Host "127.0.0.1"
- Port "2003"
- Protocol "tcp"
- ReconnectInterval 0
- LogSendErrors false
- Prefix "servers."
- StoreRates true
- AlwaysAppendDS false
- EscapeCharacter "_"
- SeparateInstances false
- PreserveSeparator false
- DropDuplicateFields false
-
-
diff --git a/monitor/install_collectd_debian.sh b/monitor/install_collectd_debian.sh
deleted file mode 100755
index 83bdf339db7..00000000000
--- a/monitor/install_collectd_debian.sh
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/bin/bash
-set -e
-
-echo "[*] Bisq Server Monitoring installation script"
-
-##### change paths if necessary for your system
-BISQ_REPO_URL=https://raw.githubusercontent.com/bisq-network/bisq
-BISQ_REPO_TAG=master
-ROOT_USER=root
-ROOT_GROUP=root
-ROOT_HOME=~root
-ROOT_PKG=(nginx collectd openssl)
-
-SYSTEMD_ENV_HOME=/etc/default
-
-#####
-
-echo "[*] Gathering information"
-read -p "Please provide the onion address of your service (eg. 3f3cu2yw7u457ztq): " onionaddress
-
-echo "[*] Updating apt repo sources"
-sudo -H -i -u "${ROOT_USER}" DEBIAN_FRONTEND=noninteractive apt-get update -q
-
-echo "[*] Upgrading OS packages"
-sudo -H -i -u "${ROOT_USER}" DEBIAN_FRONTEND=noninteractive apt-get upgrade -qq -y
-
-echo "[*] Installing base packages"
-sudo -H -i -u "${ROOT_USER}" DEBIAN_FRONTEND=noninteractive apt-get install -qq -y ${ROOT_PKG[@]}
-
-echo "[*] Preparing Bisq init script for monitoring"
-# remove stuff it it is there already
-for file in "${SYSTEMD_ENV_HOME}/bisq.env" "${SYSTEMD_ENV_HOME}/bisq-pricenode.env"
-do
- if [ -f "$file" ];then
- sudo -H -i -u "${ROOT_USER}" sed -i -e 's/-Dcom.sun.management.jmxremote //g' -e 's/-Dcom.sun.management.jmxremote.local.only=true//g' -e 's/ -Dcom.sun.management.jmxremote.host=127.0.0.1//g' -e 's/ -Dcom.sun.management.jmxremote.port=6969//g' -e 's/ -Dcom.sun.management.jmxremote.rmi.port=6969//g' -e 's/ -Dcom.sun.management.jmxremote.ssl=false//g' -e 's/ -Dcom.sun.management.jmxremote.authenticate=false//g' "${file}"
- sudo -H -i -u "${ROOT_USER}" sed -i -e '/JAVA_OPTS/ s/"$/ -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=true -Dcom.sun.management.jmxremote.host=127.0.0.1 -Dcom.sun.management.jmxremote.port=6969 -Dcom.sun.management.jmxremote.rmi.port=6969 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"/' "${file}"
- fi
-done
-
-echo "[*] Seeding entropy from /dev/urandom"
-sudo -H -i -u "${ROOT_USER}" /bin/sh -c "head -1500 /dev/urandom > ${ROOT_HOME}/.rnd"
-echo "[*] Installing Nginx config"
-sudo -H -i -u "${ROOT_USER}" openssl req -x509 -nodes -newkey rsa:2048 -days 3000 -keyout /etc/nginx/cert.key -out /etc/nginx/cert.crt -subj="/O=Bisq/OU=Bisq Infrastructure/CN=$onionaddress"
-curl -s "${BISQ_REPO_URL}/${BISQ_REPO_TAG}/monitor/nginx.conf" > /tmp/nginx.conf
-sudo -H -i -u "${ROOT_USER}" install -c -o "${ROOT_USER}" -g "${ROOT_GROUP}" -m 644 /tmp/nginx.conf /etc/nginx/nginx.conf
-
-echo "[*] Installing collectd config"
-curl -s "${BISQ_REPO_URL}/${BISQ_REPO_TAG}/monitor/collectd.conf" > /tmp/collectd.conf
-sudo -H -i -u "${ROOT_USER}" install -c -o "${ROOT_USER}" -g "${ROOT_GROUP}" -m 644 /tmp/collectd.conf /etc/collectd/collectd.conf
-sudo -H -i -u "${ROOT_USER}" sed -i -e "s/__ONION_ADDRESS__/$onionaddress/" /etc/collectd/collectd.conf
-
-echo "[*] Updating systemd daemon configuration"
-sudo -H -i -u "${ROOT_USER}" systemctl daemon-reload
-sudo -H -i -u "${ROOT_USER}" systemctl enable nginx.service
-sudo -H -i -u "${ROOT_USER}" systemctl enable collectd.service
-
-echo "[*] Restarting services"
-set +e
-service bisq status >/dev/null 2>&1
-[ $? != 4 ] && sudo -H -i -u "${ROOT_USER}" systemctl restart bisq.service
-service bisq-pricenode status >/dev/null 2>&1
-[ $? != 4 ] && sudo -H -i -u "${ROOT_USER}" systemctl restart bisq-pricenode.service
-sudo -H -i -u "${ROOT_USER}" systemctl restart nginx.service
-sudo -H -i -u "${ROOT_USER}" systemctl restart collectd.service
-
-echo '[*] Done!'
-
-echo ' '
-echo '[*] Report this certificate to the monitoring team!'
-echo '----------------------------------------------------------------'
-echo "Server: $onionaddress"
-echo ' '
-cat /etc/nginx/cert.crt
-echo '----------------------------------------------------------------'
-echo ' '
diff --git a/monitor/nginx.conf b/monitor/nginx.conf
deleted file mode 100644
index fc1a962f148..00000000000
--- a/monitor/nginx.conf
+++ /dev/null
@@ -1,28 +0,0 @@
-load_module /usr/lib/nginx/modules/ngx_stream_module.so;
-
-worker_processes 1;
-
-events {
- worker_connections 1024;
-}
-
-stream {
-
- log_format basic '$remote_addr [$time_local] '
- '$protocol Status $status Sent $bytes_sent Received $bytes_received '
- 'Time $session_time';
-
- error_log syslog:server=unix:/dev/log;
- access_log syslog:server=unix:/dev/log basic;
-
- server {
- listen 127.0.0.1:2003;
- proxy_pass monitor.bisq.network:2002;
- proxy_ssl on;
-
- proxy_ssl_certificate /etc/nginx/cert.crt;
- proxy_ssl_certificate_key /etc/nginx/cert.key;
-
- proxy_ssl_session_reuse on;
- }
-}
diff --git a/monitor/src/main/java/bisq/monitor/AvailableTor.java b/monitor/src/main/java/bisq/monitor/AvailableTor.java
deleted file mode 100644
index 0c79ec48e39..00000000000
--- a/monitor/src/main/java/bisq/monitor/AvailableTor.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * This file is part of Bisq.
- *
- * Bisq 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.
- *
- * Bisq 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 Bisq. If not, see .
- */
-
-package bisq.monitor;
-
-import bisq.network.p2p.network.TorMode;
-
-import org.berndpruenster.netlayer.tor.Tor;
-
-import java.io.File;
-
-/**
- * This class uses an already defined Tor via Tor.getDefault()
- *
- * @author Florian Reimair
- *
- */
-public class AvailableTor extends TorMode {
-
- private final String hiddenServiceDirectory;
-
- public AvailableTor(File torWorkingDirectory, String hiddenServiceDirectory) {
- super(torWorkingDirectory);
-
- this.hiddenServiceDirectory = hiddenServiceDirectory;
- }
-
- @Override
- public Tor getTor() {
- return Tor.getDefault();
- }
-
- @Override
- public String getHiddenServiceDirectory() {
- return hiddenServiceDirectory;
- }
-
-}
diff --git a/monitor/src/main/java/bisq/monitor/Configurable.java b/monitor/src/main/java/bisq/monitor/Configurable.java
deleted file mode 100644
index 6280f02255b..00000000000
--- a/monitor/src/main/java/bisq/monitor/Configurable.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * This file is part of Bisq.
- *
- * Bisq 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.
- *
- * Bisq 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 Bisq. If not, see .
- */
-
-package bisq.monitor;
-
-import java.util.Properties;
-
-/**
- * Does some pre-computation for a configurable class.
- *
- * @author Florian Reimair
- */
-public abstract class Configurable {
-
- protected Properties configuration = new Properties();
-
- private String name;
-
- /**
- * Filters all java properties starting with {@link Configurable#getName()} of
- * the class and makes them available. Does NOT parse the content of
- * the properties!
- *
- * For example, if the implementing class sets its name (using
- * {@link Configurable#setName(String)}) to MyName, the list of
- * properties is scanned for properties starting with MyName.
- * Matching lines are made available to the class without the prefix. For
- * example, a property MyName.answer=42 is made available as
- * configuration.getProperty("answer") resulting in
- * 42.
- *
- * @param properties a set of configuration properties
- */
- public void configure(final Properties properties) {
- // only configure the Properties which belong to us
- final Properties myProperties = new Properties();
- properties.forEach((k, v) -> {
- String key = (String) k;
- if (key.startsWith(getName()))
- myProperties.put(key.substring(key.indexOf(".") + 1), v);
- });
-
- // configure all properties that belong to us
- this.configuration = myProperties;
- }
-
- protected String getName() {
- return name;
- }
-
- /**
- * Set the name used to filter through configuration properties. See
- * {@link Configurable#configure(Properties)}.
- *
- * @param name the name of the configurable
- */
- protected void setName(String name) {
- this.name = name;
- }
-}
diff --git a/monitor/src/main/java/bisq/monitor/Metric.java b/monitor/src/main/java/bisq/monitor/Metric.java
deleted file mode 100644
index 08598e1e9cf..00000000000
--- a/monitor/src/main/java/bisq/monitor/Metric.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * This file is part of Bisq.
- *
- * Bisq 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.
- *
- * Bisq 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 Bisq. If not, see .
- */
-
-package bisq.monitor;
-
-import bisq.common.app.Version;
-import bisq.common.util.Utilities;
-
-import java.util.Properties;
-import java.util.Random;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
-import lombok.extern.slf4j.Slf4j;
-
-import static bisq.common.config.Config.BASE_CURRENCY_NETWORK;
-
-/**
- * Starts a Metric (in its own {@link Thread}), manages its properties and shuts
- * it down gracefully. Furthermore, configuration updates and execution are done
- * in a thread-save manner. Implementing classes only have to implement the
- * {@link Metric#execute()} method.
- *
- * @author Florian Reimair
- */
-@Slf4j
-public abstract class Metric extends Configurable implements Runnable {
-
- private static final String INTERVAL = "run.interval";
- private static ScheduledExecutorService executor;
- protected final Reporter reporter;
- private ScheduledFuture> scheduler;
-
- /**
- * disable execution
- */
- private void disable() {
- if (scheduler != null)
- scheduler.cancel(false);
- }
-
- /**
- * enable execution
- */
- private void enable() {
- scheduler = executor.scheduleWithFixedDelay(this, new Random().nextInt(60),
- Long.parseLong(configuration.getProperty(INTERVAL)), TimeUnit.SECONDS);
- }
-
- /**
- * Constructor.
- */
- protected Metric(Reporter reporter) {
-
- this.reporter = reporter;
-
- setName(this.getClass().getSimpleName());
-
- if (executor == null) {
- executor = new ScheduledThreadPoolExecutor(6);
- }
- }
-
- boolean enabled() {
- if (scheduler != null)
- return !scheduler.isCancelled();
- else
- return false;
- }
-
- @Override
- public void configure(final Properties properties) {
- synchronized (this) {
- log.info("{} (re)loading config...", getName());
- super.configure(properties);
- reporter.configure(properties);
-
- Version.setBaseCryptoNetworkId(Integer.parseInt(properties.getProperty("System." + BASE_CURRENCY_NETWORK, "1"))); // defaults to BTC_TESTNET
-
- // decide whether to enable or disable the task
- if (configuration.isEmpty() || !configuration.getProperty("enabled", "false").equals("true")
- || !configuration.containsKey(INTERVAL)) {
- disable();
-
- // some informative log output
- if (configuration.isEmpty())
- log.error("{} is not configured at all. Will not run.", getName());
- else if (!configuration.getProperty("enabled", "false").equals("true"))
- log.info("{} is deactivated. Will not run.", getName());
- else if (!configuration.containsKey(INTERVAL))
- log.error("{} is missing mandatory '" + INTERVAL + "' property. Will not run.", getName());
- else
- log.error("{} is mis-configured. Will not run.", getName());
- } else if (!enabled() && configuration.getProperty("enabled", "false").equals("true")) {
- // check if this Metric got activated after being disabled.
- // if so, resume execution
- enable();
- log.info("{} got activated. Starting up.", getName());
- }
- }
- }
-
- @Override
- public void run() {
- try {
- Thread.currentThread().setName("Metric: " + getName());
-
- // execute all the things
- synchronized (this) {
- log.info("{} started", getName());
- execute();
- log.info("{} done", getName());
- }
- } catch (Throwable e) {
- log.error("A metric misbehaved!", e);
- }
- }
-
- /**
- * Gets scheduled repeatedly.
- */
- protected abstract void execute();
-
- /**
- * initiate an orderly shutdown on all metrics. Blocks until all metrics are
- * shut down or after one minute.
- */
- public static void haltAllMetrics() {
- Utilities.shutdownAndAwaitTermination(executor, 2, TimeUnit.MINUTES);
- }
-}
diff --git a/monitor/src/main/java/bisq/monitor/Monitor.java b/monitor/src/main/java/bisq/monitor/Monitor.java
deleted file mode 100644
index ea6b0db3619..00000000000
--- a/monitor/src/main/java/bisq/monitor/Monitor.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * This file is part of Bisq.
- *
- * Bisq 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.
- *
- * Bisq 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 Bisq. If not, see .
- */
-
-package bisq.monitor;
-
-import bisq.monitor.metric.MarketStats;
-import bisq.monitor.metric.P2PMarketStats;
-import bisq.monitor.metric.P2PNetworkLoad;
-import bisq.monitor.metric.P2PRoundTripTime;
-import bisq.monitor.metric.P2PSeedNodeSnapshot;
-import bisq.monitor.metric.PriceNodeStats;
-import bisq.monitor.metric.TorHiddenServiceStartupTime;
-import bisq.monitor.metric.TorRoundTripTime;
-import bisq.monitor.metric.TorStartupTime;
-import bisq.monitor.reporter.ConsoleReporter;
-import bisq.monitor.reporter.GraphiteReporter;
-
-import bisq.common.app.Capabilities;
-import bisq.common.app.Capability;
-
-import org.berndpruenster.netlayer.tor.NativeTor;
-import org.berndpruenster.netlayer.tor.Tor;
-
-import java.io.File;
-import java.io.FileInputStream;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import lombok.extern.slf4j.Slf4j;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-
-
-import sun.misc.Signal;
-
-/**
- * Monitor executable for the Bisq network.
- *
- * @author Florian Reimair
- */
-@Slf4j
-public class Monitor {
-
- public static final File TOR_WORKING_DIR = new File("monitor/work/monitor-tor");
- private static String[] args = {};
-
- public static void main(String[] args) throws Throwable {
- Monitor.args = args;
- new Monitor().start();
- }
-
- /**
- * A list of all active {@link Metric}s
- */
- private final List metrics = new ArrayList<>();
-
- /**
- * Starts up all configured Metrics.
- *
- * @throws Throwable in case something goes wrong
- */
- private void start() throws Throwable {
-
- // start Tor
- Tor.setDefault(new NativeTor(TOR_WORKING_DIR, null, null, false));
-
- //noinspection deprecation,deprecation,deprecation,deprecation,deprecation,deprecation,deprecation,deprecation
- Capabilities.app.addAll(Capability.TRADE_STATISTICS,
- Capability.TRADE_STATISTICS_2,
- Capability.ACCOUNT_AGE_WITNESS,
- Capability.ACK_MSG,
- Capability.PROPOSAL,
- Capability.BLIND_VOTE,
- Capability.DAO_STATE,
- Capability.BUNDLE_OF_ENVELOPES,
- Capability.REFUND_AGENT,
- Capability.MEDIATION,
- Capability.TRADE_STATISTICS_3);
-
- // assemble Metrics
- // - create reporters
- Reporter graphiteReporter = new GraphiteReporter();
-
- // only use ConsoleReporter if requested (for debugging for example)
- Properties properties = getProperties();
- if ("true".equals(properties.getProperty("System.useConsoleReporter", "false")))
- graphiteReporter = new ConsoleReporter();
-
- // - add available metrics with their reporters
- metrics.add(new TorStartupTime(graphiteReporter));
- metrics.add(new TorRoundTripTime(graphiteReporter));
- metrics.add(new TorHiddenServiceStartupTime(graphiteReporter));
- metrics.add(new P2PRoundTripTime(graphiteReporter));
- metrics.add(new P2PNetworkLoad(graphiteReporter));
- metrics.add(new P2PSeedNodeSnapshot(graphiteReporter));
- metrics.add(new P2PMarketStats(graphiteReporter));
- metrics.add(new PriceNodeStats(graphiteReporter));
- metrics.add(new MarketStats(graphiteReporter));
-
- // prepare configuration reload
- // Note that this is most likely only work on Linux
- Signal.handle(new Signal("USR1"), signal -> {
- try {
- configure();
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- });
-
- // configure Metrics
- // - which also starts the metrics if appropriate
- configure();
-
- // exit Metrics gracefully on shutdown
- Runtime.getRuntime().addShutdownHook(new Thread(() -> {
- // set the name of the Thread for debugging purposes
- log.info("system shutdown initiated");
-
- log.info("shutting down active metrics...");
- Metric.haltAllMetrics();
-
- try {
- log.info("shutting down tor...");
- Tor tor = Tor.getDefault();
- checkNotNull(tor, "tor must not be null");
- tor.shutdown();
- } catch (Throwable ignore) {
- }
-
- log.info("system halt");
- }, "Monitor Shutdown Hook ")
- );
- }
-
- /**
- * Reload the configuration from disk.
- *
- * @throws Exception if something goes wrong
- */
- private void configure() throws Exception {
- Properties properties = getProperties();
- for (Metric current : metrics)
- current.configure(properties);
- }
-
- /**
- * Overloads a default set of properties with a file if given
- *
- * @return a set of properties
- * @throws Exception in case something goes wrong
- */
- private Properties getProperties() throws Exception {
- Properties result = new Properties();
-
- // if we have a config file load the config file, else, load the default config
- // from the resources
- if (args.length > 0)
- result.load(new FileInputStream(args[0]));
- else
- result.load(Monitor.class.getClassLoader().getResourceAsStream("metrics.properties"));
-
- return result;
- }
-}
diff --git a/monitor/src/main/java/bisq/monitor/OnionParser.java b/monitor/src/main/java/bisq/monitor/OnionParser.java
deleted file mode 100644
index 58f186f068a..00000000000
--- a/monitor/src/main/java/bisq/monitor/OnionParser.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * This file is part of Bisq.
- *
- * Bisq 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.
- *
- * Bisq 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 Bisq. If not, see .
- */
-
-package bisq.monitor;
-
-import bisq.network.p2p.NodeAddress;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-/**
- * Helper for parsing and pretty printing onion addresses.
- *
- * @author Florian Reimair
- */
-public class OnionParser {
-
- public static NodeAddress getNodeAddress(final String current) throws MalformedURLException {
- String nodeAddress = current.trim();
- if (!nodeAddress.startsWith("http://"))
- nodeAddress = "http://" + nodeAddress;
- URL tmp = new URL(nodeAddress);
- return new NodeAddress(tmp.getHost(), tmp.getPort() > 0 ? tmp.getPort() : 80);
- }
-
- public static String prettyPrint(final NodeAddress host) {
- return host.getHostNameWithoutPostFix();
- }
-
- public static String prettyPrint(String host) throws MalformedURLException {
- return prettyPrint(getNodeAddress(host));
- }
-}
diff --git a/monitor/src/main/java/bisq/monitor/Reporter.java b/monitor/src/main/java/bisq/monitor/Reporter.java
deleted file mode 100644
index 5c0202e7f38..00000000000
--- a/monitor/src/main/java/bisq/monitor/Reporter.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * This file is part of Bisq.
- *
- * Bisq 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.
- *
- * Bisq 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 Bisq. If not, see .
- */
-
-package bisq.monitor;
-
-import java.util.Map;
-
-/**
- * Reports findings to a specific service/file/place using the proper means to
- * do so.
- *
- * @author Florian Reimair
- */
-public abstract class Reporter extends Configurable {
-
- protected Reporter() {
- setName(this.getClass().getSimpleName());
- }
-
- /**
- * Report our findings.
- *
- * @param value the value to report
- */
- public abstract void report(long value);
-
- /**
- * Report our findings
- *
- * @param value the value to report
- * @param prefix a common prefix to be included in the tag name
- */
- public abstract void report(long value, String prefix);
-
- /**
- * Report our findings.
- *
- * @param values Map
- */
- public abstract void report(Map values);
-
- /**
- * Report our findings.
- *
- * @param values Map
- * @param prefix for example "torStartupTime"
- */
- public abstract void report(Map values, String prefix);
-
- /**
- * Report our findings one by one.
- *
- * @param key the metric name
- * @param value the value to report
- * @param timestamp a unix timestamp in milliseconds
- * @param prefix for example "torStartupTime"
- */
- public abstract void report(String key, String value, String timestamp, String prefix);
-
-}
diff --git a/monitor/src/main/java/bisq/monitor/StatisticsHelper.java b/monitor/src/main/java/bisq/monitor/StatisticsHelper.java
deleted file mode 100644
index c73c904ff21..00000000000
--- a/monitor/src/main/java/bisq/monitor/StatisticsHelper.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * This file is part of Bisq.
- *
- * Bisq 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.
- *
- * Bisq 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 Bisq. If not, see .
- */
-
-package bisq.monitor;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.LongSummaryStatistics;
-import java.util.Map;
-
-/**
- * Calculates average, max, min, p25, p50, p75 off of a list of samples and
- * throws in the sample size for good measure.
- *
- * @author Florian Reimair
- */
-public class StatisticsHelper {
-
- public static Map process(Collection input) {
-
- List samples = new ArrayList<>(input);
-
- // aftermath
- Collections.sort(samples);
-
- // - average, max, min , sample size
- LongSummaryStatistics statistics = samples.stream().mapToLong(val -> val).summaryStatistics();
-
- Map results = new HashMap<>();
- results.put("average", String.valueOf(Math.round(statistics.getAverage())));
- results.put("max", String.valueOf(statistics.getMax()));
- results.put("min", String.valueOf(statistics.getMin()));
- results.put("sampleSize", String.valueOf(statistics.getCount()));
-
- // - p25, median, p75
- Integer[] percentiles = new Integer[] { 25, 50, 75 };
- for (Integer percentile : percentiles) {
- double rank = statistics.getCount() * percentile / 100.0;
- Long percentileValue;
- if (samples.size() <= rank + 1)
- percentileValue = samples.get(samples.size() - 1);
- else if (Math.floor(rank) == rank)
- percentileValue = samples.get((int) rank);
- else
- percentileValue = Math.round(samples.get((int) Math.floor(rank))
- + (samples.get((int) (Math.floor(rank) + 1)) - samples.get((int) Math.floor(rank)))
- / (rank - Math.floor(rank)));
- results.put("p" + percentile, String.valueOf(percentileValue));
- }
-
- return results;
- }
-}
diff --git a/monitor/src/main/java/bisq/monitor/ThreadGate.java b/monitor/src/main/java/bisq/monitor/ThreadGate.java
deleted file mode 100644
index 60fa1586e3b..00000000000
--- a/monitor/src/main/java/bisq/monitor/ThreadGate.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * This file is part of Bisq.
- *
- * Bisq 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.
- *
- * Bisq 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 Bisq. If not, see .
- */
-
-package bisq.monitor;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import lombok.extern.slf4j.Slf4j;
-
-/**
- * Gate pattern to help with thread synchronization
- *
- * @author Florian Reimair
- */
-@Slf4j
-public class ThreadGate {
-
- private CountDownLatch lock = new CountDownLatch(0);
-
- /**
- * Make everyone wait until the gate is open again.
- */
- public void engage() {
- lock = new CountDownLatch(1);
- }
-
- /**
- * Make everyone wait until the gate is open again.
- *
- * @param numberOfLocks how often the gate has to be unlocked until the gate
- * opens.
- */
- public void engage(int numberOfLocks) {
- lock = new CountDownLatch(numberOfLocks);
- }
-
- /**
- * Wait for the gate to be opened. Blocks until the gate is open again. Returns
- * immediately if the gate is already open.
- */
- public synchronized void await() {
- while (lock.getCount() > 0)
- try {
- if (!lock.await(60, TimeUnit.SECONDS)) {
- log.warn("timeout occurred!");
- break; // break the loop
- }
- } catch (InterruptedException ignore) {
- }
- }
-
- /**
- * Open the gate and let everyone proceed with their execution.
- */
- public void proceed() {
- lock.countDown();
- }
-
- /**
- * Open the gate with no regards on how many locks are still in place.
- */
- public void unlock() {
- while (lock.getCount() > 0)
- lock.countDown();
- }
-}
diff --git a/monitor/src/main/java/bisq/monitor/metric/MarketStats.java b/monitor/src/main/java/bisq/monitor/metric/MarketStats.java
deleted file mode 100644
index f54c862446c..00000000000
--- a/monitor/src/main/java/bisq/monitor/metric/MarketStats.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * This file is part of Bisq.
- *
- * bisq 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.
- *
- * bisq 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 bisq. If not, see .
- */
-
-package bisq.monitor.metric;
-
-import bisq.monitor.Metric;
-import bisq.monitor.Reporter;
-
-import java.net.URL;
-import java.net.URLConnection;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import lombok.extern.slf4j.Slf4j;
-
-/**
- * Uses the markets API to retrieve market volume data.
- *
- * @author Florian Reimair
- *
- */
-@Slf4j
-public class MarketStats extends Metric {
- private static final String MARKETS_BISQ_NETWORK = "https://markets.bisq.network";
- // poor mans JSON parser
- private final Pattern marketPattern = Pattern.compile("\"market\" ?: ?\"([a-z_]+)\"");
- private final Pattern amountPattern = Pattern.compile("\"amount\" ?: ?\"([\\d\\.]+)\"");
- private final Pattern volumePattern = Pattern.compile("\"volume\" ?: ?\"([\\d\\.]+)\"");
- private final Pattern timestampPattern = Pattern.compile("\"trade_date\" ?: ?([\\d]+)");
-
- private Long lastRun = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - TimeUnit.MINUTES.toMillis(15));
-
- public MarketStats(Reporter reporter) {
- super(reporter);
- }
-
- @Override
- protected void execute() {
- try {
- // for each configured host
- Map result = new HashMap<>();
-
- // assemble query
- long now = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis());
- String query = "/api/trades?format=json&market=all×tamp_from=" + lastRun + "×tamp_to=" + now;
- lastRun = now; // thought about adding 1 second but what if a trade is done exactly in this one second?
-
- // connect
- URLConnection connection = new URL(MARKETS_BISQ_NETWORK + query).openConnection();
-
- // prepare to receive data
- BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
-
- String line, all = "";
- while ((line = in.readLine()) != null)
- all += ' ' + line;
- in.close();
-
- Arrays.stream(all.substring(0, all.length() - 2).split("}")).forEach(trade -> {
- Matcher market = marketPattern.matcher(trade);
- Matcher amount = amountPattern.matcher(trade);
- Matcher timestamp = timestampPattern.matcher(trade);
- market.find();
- if (market.group(1).endsWith("btc")) {
- amount = volumePattern.matcher(trade);
- }
- amount.find();
- timestamp.find();
- reporter.report("volume." + market.group(1), amount.group(1), timestamp.group(1), getName());
- });
- } catch (IllegalStateException ignore) {
- // no match found
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-}
diff --git a/monitor/src/main/java/bisq/monitor/metric/P2PMarketStats.java b/monitor/src/main/java/bisq/monitor/metric/P2PMarketStats.java
deleted file mode 100644
index 368e9cb03c1..00000000000
--- a/monitor/src/main/java/bisq/monitor/metric/P2PMarketStats.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * This file is part of Bisq.
- *
- * bisq 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.
- *
- * bisq 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 bisq. If not, see .
- */
-
-package bisq.monitor.metric;
-
-import bisq.monitor.Reporter;
-
-import bisq.core.offer.OfferUtil;
-import bisq.core.offer.bisq_v1.OfferPayload;
-
-import bisq.network.p2p.NodeAddress;
-import bisq.network.p2p.network.Connection;
-import bisq.network.p2p.peers.getdata.messages.GetDataResponse;
-import bisq.network.p2p.peers.getdata.messages.PreliminaryGetDataRequest;
-import bisq.network.p2p.storage.payload.ProtectedStorageEntry;
-import bisq.network.p2p.storage.payload.ProtectedStoragePayload;
-
-import bisq.common.proto.network.NetworkEnvelope;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Random;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.stream.Collectors;
-
-import lombok.extern.slf4j.Slf4j;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Demo Stats metric derived from the OfferPayload messages we get from the seed nodes
- *
- * @author Florian Reimair
- */
-@Slf4j
-public class P2PMarketStats extends P2PSeedNodeSnapshotBase {
- final Map> versionBucketsPerHost = new ConcurrentHashMap<>();
- final Map> offerVolumeBucketsPerHost = new ConcurrentHashMap<>();
- final Map>> offerVolumeDistributionBucketsPerHost = new ConcurrentHashMap<>();
- final Map>> offersPerTraderBucketsPerHost = new ConcurrentHashMap<>();
- final Map>> volumePerTraderBucketsPerHost = new ConcurrentHashMap<>();
-
- /**
- * Efficient way to aggregate numbers.
- */
- private static class Aggregator {
- private long value = 0;
-
- synchronized long value() {
- return value;
- }
-
- synchronized void increment() {
- value++;
- }
-
- synchronized void add(long amount) {
- value += amount;
- }
- }
-
- private abstract static class OfferStatistics extends Statistics {
- @Override
- public synchronized void log(Object message) {
- if (message instanceof OfferPayload) {
- OfferPayload currentMessage = (OfferPayload) message;
- // For logging different data types
- String market = currentMessage.getDirection() + "." + currentMessage.getBaseCurrencyCode() + "_" + currentMessage.getCounterCurrencyCode();
-
- process(market, currentMessage);
- }
- }
-
- abstract void process(String market, OfferPayload currentMessage);
- }
-
- private class OfferCountStatistics extends OfferStatistics {
-
- @Override
- void process(String market, OfferPayload currentMessage) {
- buckets.putIfAbsent(market, new Aggregator());
- buckets.get(market).increment();
- }
- }
-
- private class OfferVolumeStatistics extends OfferStatistics {
-
- @Override
- void process(String market, OfferPayload currentMessage) {
- buckets.putIfAbsent(market, new Aggregator());
- buckets.get(market).add(currentMessage.getAmount());
- }
- }
-
- private class OfferVolumeDistributionStatistics extends OfferStatistics> {
-
- @Override
- void process(String market, OfferPayload currentMessage) {
- buckets.putIfAbsent(market, new ArrayList<>());
- buckets.get(market).add(currentMessage.getAmount());
- }
- }
-
- private class OffersPerTraderStatistics extends OfferStatistics