Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • clients/cesium-grp/cesium-plus-pod
  • clients/java/duniter4j
  • ji_emme/duniter4j
  • dvermd/cesium-plus-pod
  • okayotanoka/cesium-plus-pod
  • pokapow/cesium-plus-pod
  • pini-gh/cesium-plus-pod
7 results
Select Git revision
Show changes
Commits on Source (179)
Showing
with 379 additions and 73 deletions
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
.classpath .classpath
.settings .settings
.idea .idea
.local
target target
*/target */target
duniter4j.iml duniter4j.iml
......
#!/bin/bash
set JAVA_HOME=/usr/lib/jvm/java-8-oracle
CESIUM_PLUS_POD_DIR="${HOME}/git/duniter/cesium-plus-pod"
DEPLOY_DIR="${CESIUM_PLUS_POD_DIR}/cesium-plus-pod-assembly/target/es-run-home/plugins/cesium-plus-pod-core"
# Go to project root
cd ..
ROOT=`pwd`
echo "***************************************"
echo " Compiling core-* ... "
# Remove old JAR
rm duniter4j-core-client/target/*.jar
rm duniter4j-core-shared/target/*.jar
# Compile the core-client
mvn install --quiet -DskipTests
if [[ $? -ne 0 ]]; then
exit 1
fi
echo " Successfully compiled ! "
echo "***************************************"
echo " Installing into Cesium+ pod (target assembly)... "
# Copy jar
mkdir -p ${DEPLOY_DIR}
if [[ $? -ne 0 ]]; then
exit 1
fi
rm -f "${DEPLOY_DIR}/duniter4j-core-client-*.jar"
rm -f "${DEPLOY_DIR}/duniter4j-core-shared-*.jar"
if [[ $? -ne 0 ]]; then
exit 1
fi
cd ${ROOT}/duniter4j-core-client/target/
JAR_FILE=`ls *.jar`
cp -v ${JAR_FILE} ${DEPLOY_DIR}/
if [[ $? -ne 0 ]]; then
exit 1
fi
cd ${ROOT}/duniter4j-core-shared/target/
JAR_FILE=`ls *.jar`
cp -v ${JAR_FILE} ${DEPLOY_DIR}/
if [[ $? -ne 0 ]]; then
exit 1
fi
echo " Successfully deployed !"
echo "************************"
#!/bin/bash
set JAVA_HOME=/usr/lib/jvm/java-8-oracle
CESIUM_PLUS_POD_DIR="${HOME}/git/duniter/cesium-plus-pod"
DEPLOY_DIR="${CESIUM_PLUS_POD_DIR}/cesium-plus-pod-assembly/target/es-run-home/plugins/cesium-plus-pod-core"
# Go to project root
cd ..
echo "***************************************"
echo " Compiling core-client... "
# Remove old JAR
rm duniter4j-core-client/target/*.jar
# Compile the core-client
mvn install -pl duniter4j-core-client --quiet -DskipTests
if [[ $? -ne 0 ]]; then
exit 1
fi
echo " Successfully compiled ! "
echo "***************************************"
echo " Installing into Cesium+ pod (target assembly)... "
# Copy jar
mkdir -p ${DEPLOY_DIR}
if [[ $? -ne 0 ]]; then
exit 1
fi
rm -f "${DEPLOY_DIR}/duniter4j-core-client-*.jar"
if [[ $? -ne 0 ]]; then
exit 1
fi
cd duniter4j-core-client/target/
JAR_FILE=`ls *.jar`
cp -v ${JAR_FILE} ${DEPLOY_DIR}/
if [[ $? -ne 0 ]]; then
exit 1
fi
echo " Successfully deployed !"
echo "************************"
[changelog version by version](src/changes/)
\ No newline at end of file
...@@ -38,18 +38,18 @@ WORKDIR /duniter4j ...@@ -38,18 +38,18 @@ WORKDIR /duniter4j
# tar -xzf archive.tar.gz && rm *.tar.gz && mv cesium-* src && \ # tar -xzf archive.tar.gz && rm *.tar.gz && mv cesium-* src && \
RUN cd /duniter4j && \ RUN cd /duniter4j && \
wget https://github.com/duniter/duniter4j/releases/download/duniter4j-${DUNITER4J_VERSION}/duniter4j-es-${DUNITER4J_VERSION}-standalone.zip && \ wget https://github.com/duniter/duniter4j/releases/download/duniter4j-${DUNITER4J_VERSION}/duniter4j-client-${DUNITER4J_VERSION}-standalone.zip && \
unzip *.zip && rm *.zip && mv duniter4j-es-* duniter4j-es && \ unzip *.zip && rm *.zip && mv duniter4j-client-* duniter4j-client && \
mkdir duniter4j-es/data && \ mkdir duniter4j-es/data && \
chown -R duniter4j:duniter4j duniter4j-es chown -R duniter4j:duniter4j duniter4j-client
RUN ln -s /duniter4j/duniter4j-es/bin/elasticsearch /usr/bin/duniter4j-es RUN ln -s /duniter4j/duniter4j-client/bin/elasticsearch /usr/bin/duniter4j-client
VOLUME /duniter4j/duniter4j-es VOLUME /duniter4j/duniter4j-client
EXPOSE 9200 9400 EXPOSE 9200 9400
USER duniter4j USER duniter4j
WORKDIR /duniter4j WORKDIR /duniter4j
ENTRYPOINT ["/usr/bin/duniter4j-es"] ENTRYPOINT ["/usr/bin/duniter4j-client"]
CMD [] CMD []
...@@ -7,12 +7,60 @@ Duniter4j is a Java Toolkit for [Duniter](http://duniter.org). ...@@ -7,12 +7,60 @@ Duniter4j is a Java Toolkit for [Duniter](http://duniter.org).
> See the [documentation web site](http://doc.e-is.pro/duniter4j/) > See the [documentation web site](http://doc.e-is.pro/duniter4j/)
## Modules ## Manual
- Install Java JRE (1.8 or higher)
- Download the file `duniter4j-client-vX.Y.Z.zip` from the [latest releases page](https://www.github.com/duniter/duniter4j/releases)
- Unzip the archive;
- The open a terminal and execute the script `duniter4j.sh` (or `duniter4j.bat`) :
```bash
cd duniter4j-client-vX.Y.Z
./duniter4j.sh --help
```
## Architecture
Duniter4j has tree main modules : Duniter4j has tree main modules :
- `duniter4j-core-shared`: A set of useful classes, used by other modules.
- `duniter4j-core-client`: [a Java API](./src/site/markdown/Java_API.md) to help Java developers to communicate with a Duniter network.
- `duniter4j-client`: [a command line tool](./src/site/markdown/CLI.md), to execute basic operation on a Duniter currency: transfer, view peers, ... - `duniter4j-client`: [a command line tool](./src/site/markdown/CLI.md), to execute basic operation on a Duniter currency: transfer, view peers, ...
- `duniter4j-core-client`: [a Java API](./src/site/markdown/Java_API.md) to help Java developers to communicate with a Duniter network.
## Build from sources
- Install Apache Maven (3.1.1+)
- Run the build command:
```bash
mvn install
```
## Use as Maven dependency
```xml
<dependencies>
<!-- Duniter4j dependency -->
<dependency>
<groupId>org.duniter</groupId>
<artifactId>duniter4j-core-client</artifactId>
<version>x.y.z</version> <!-- -->
</dependency>
</dependencies>
<!-- Duniter4j repository -->
<repositories>
<repository>
<id>duniter4j-public-group</id>
<url>https://nexus.e-is.pro/nexus/content/groups/duniter4j</url>
</repository>
</repositories>
```
## Create a new release
```bash
./release.sh
```
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>duniter4j</artifactId> <artifactId>duniter4j</artifactId>
<groupId>org.duniter</groupId> <groupId>org.duniter</groupId>
<version>1.1.1-SNAPSHOT</version> <version>1.6.2-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
...@@ -48,6 +48,10 @@ ...@@ -48,6 +48,10 @@
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>slf4j-log4j12</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
<dependency> <dependency>
<groupId>log4j</groupId> <groupId>log4j</groupId>
<artifactId>log4j</artifactId> <artifactId>log4j</artifactId>
...@@ -343,7 +347,7 @@ ...@@ -343,7 +347,7 @@
<id>linux-x64-bundle</id> <id>linux-x64-bundle</id>
<activation> <activation>
<property> <property>
<name>performRelease</name> <name>performFullRelease</name>
<value>true</value> <value>true</value>
</property> </property>
</activation> </activation>
...@@ -409,7 +413,7 @@ ...@@ -409,7 +413,7 @@
<id>linux-i586-bundle</id> <id>linux-i586-bundle</id>
<activation> <activation>
<property> <property>
<name>performRelease</name> <name>performFullRelease</name>
<value>true</value> <value>true</value>
</property> </property>
</activation> </activation>
...@@ -475,7 +479,7 @@ ...@@ -475,7 +479,7 @@
<id>windows-i586-bundle</id> <id>windows-i586-bundle</id>
<activation> <activation>
<property> <property>
<name>performRelease</name> <name>performFullRelease</name>
<value>true</value> <value>true</value>
</property> </property>
</activation> </activation>
...@@ -560,7 +564,7 @@ ...@@ -560,7 +564,7 @@
<id>windows-x64-bundle</id> <id>windows-x64-bundle</id>
<activation> <activation>
<property> <property>
<name>performRelease</name> <name>performFullRelease</name>
<value>true</value> <value>true</value>
</property> </property>
</activation> </activation>
......
#!/bin/bash #!/bin/bash
READLINK=`which readlink` READLINK=`which readlink`
if [ -z "$READLINK" ]; then if [[ -z "$READLINK" ]]; then
message "Required tool 'readlink' is missing. Please install before launch \"$0\" file." message "Required tool 'readlink' is missing. Please install before launch \"$0\" file."
exit 1 exit 1
fi fi
...@@ -10,8 +10,8 @@ fi ...@@ -10,8 +10,8 @@ fi
# Ensure BASEDIR points to the directory where the soft is installed. # Ensure BASEDIR points to the directory where the soft is installed.
# ------------------------------------------------------------------ # ------------------------------------------------------------------
SCRIPT_LOCATION=$0 SCRIPT_LOCATION=$0
if [ -x "$READLINK" ]; then if [[ -x "$READLINK" ]]; then
while [ -L "$SCRIPT_LOCATION" ]; do while [[ -L "$SCRIPT_LOCATION" ]]; do
SCRIPT_LOCATION=`"$READLINK" -e "$SCRIPT_LOCATION"` SCRIPT_LOCATION=`"$READLINK" -e "$SCRIPT_LOCATION"`
done done
fi fi
...@@ -22,11 +22,11 @@ export JAR="$JARDIR/${project.build.finalName}.${project.packaging}" ...@@ -22,11 +22,11 @@ export JAR="$JARDIR/${project.build.finalName}.${project.packaging}"
export I18N_DIR="$APPDIR/i18n" export I18N_DIR="$APPDIR/i18n"
# Retrieve the JAVA installation # Retrieve the JAVA installation
if [ "$JAVA_HOME~" == "~" ]; then if [[ "$JAVA_HOME~" == "~" ]]; then
export JAVA_HOME="$APPDIR/jre" export JAVA_HOME="$APPDIR/jre"
export JAVA_COMMAND="$JAVA_HOME/bin/java" export JAVA_COMMAND="$JAVA_HOME/bin/java"
if [ -f "$JAVA_HOME/bin/java" ]; then if [[ -f "$JAVA_HOME/bin/java" ]]; then
# If embedded JRE exists, make sure java is executable # If embedded JRE exists, make sure java is executable
chmod +x "$JAVA_COMMAND" chmod +x "$JAVA_COMMAND"
else else
...@@ -37,7 +37,7 @@ else ...@@ -37,7 +37,7 @@ else
export JAVA_COMMAND="$JAVA_HOME/bin/java" export JAVA_COMMAND="$JAVA_HOME/bin/java"
fi fi
if [ -d "$HOME" ]; then if [[ -d "$HOME" ]]; then
export BASEDIR="$HOME/.config/duniter4j" export BASEDIR="$HOME/.config/duniter4j"
export CONFIG_DIR="$BASEDIR/config" export CONFIG_DIR="$BASEDIR/config"
export CONFIG_FILE="$CONFIG_DIR/duniter4j-client.config" export CONFIG_FILE="$CONFIG_DIR/duniter4j-client.config"
...@@ -48,14 +48,21 @@ else ...@@ -48,14 +48,21 @@ else
export CONFIG_FILE="$CONFIG_DIR/config/duniter4j-client.config" export CONFIG_FILE="$CONFIG_DIR/config/duniter4j-client.config"
export LOG_FILE="$APPDIR/logs/${project.build.finalName}.log" export LOG_FILE="$APPDIR/logs/${project.build.finalName}.log"
echo "Using base" echo "Using basedir: $APPDIR"
fi fi
if [[ "$JAVA_OPTS~" == "~" ]]; then
# Configuring apache simplelog to use Log4j
JAVA_OPTS="-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger"
exprt ${JAVA_OPTS}
fi
# Create the config dir if need # Create the config dir if need
mkdir -p "$CONFIG_DIR" mkdir -p "$CONFIG_DIR"
# Create the config file (if need) # Create the config file (if need)
if [ ! -f "$CONFIG_FILE" ]; then if [[ ! -f "$CONFIG_FILE" ]]; then
echo "INFO - Initialized configuration file: $CONFIG_FILE" echo "INFO - Initialized configuration file: $CONFIG_FILE"
cp -u $JARDIR/duniter4j-client.config $CONFIG_FILE cp -u $JARDIR/duniter4j-client.config $CONFIG_FILE
fi fi
...@@ -68,12 +75,12 @@ while true; do ...@@ -68,12 +75,12 @@ while true; do
$JAVA_COMMAND $JAVA_OPTS -Dduniter4j.log.file=$LOG_FILE -Dduniter4j.i18n.directory=$I18N_DIR -jar $JAR --basedir $BASEDIR --config $CONFIG_FILE $* $JAVA_COMMAND $JAVA_OPTS -Dduniter4j.log.file=$LOG_FILE -Dduniter4j.i18n.directory=$I18N_DIR -jar $JAR --basedir $BASEDIR --config $CONFIG_FILE $*
exitcode=$? exitcode=$?
if [ ! "$exitcode" -eq "130" ]; then if [[ ! "$exitcode" -eq "130" ]]; then
echo "INFO - Application stopped with exitcode: $exitcode" echo "INFO - Application stopped with exitcode: $exitcode"
fi fi
## Continue only if exitcode=88 (will restart the application) ## Continue only if exitcode=88 (will restart the application)
if [ ! "$exitcode" -eq "88" ]; then if [[ ! "$exitcode" -eq "88" ]]; then
# quit now! # quit now!
exit $exitcode exit $exitcode
fi fi
......
...@@ -28,3 +28,6 @@ log4j.logger.org.nuiton.util=WARN ...@@ -28,3 +28,6 @@ log4j.logger.org.nuiton.util=WARN
log4j.logger.org.nuiton.config=WARN log4j.logger.org.nuiton.config=WARN
log4j.logger.org.nuiton.converter=WARN log4j.logger.org.nuiton.converter=WARN
log4j.logger.org.nuiton.i18n=ERROR log4j.logger.org.nuiton.i18n=ERROR
# Http client connection debug
#log4j.logger.org.apache.http.impl.conn=DEBUG
\ No newline at end of file
...@@ -32,7 +32,10 @@ import org.duniter.client.actions.TransactionAction; ...@@ -32,7 +32,10 @@ import org.duniter.client.actions.TransactionAction;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.duniter.core.client.config.Configuration; import org.duniter.core.client.config.Configuration;
import org.duniter.core.client.config.ConfigurationOption; import org.duniter.core.client.config.ConfigurationOption;
import org.duniter.core.client.model.bma.jackson.JacksonUtils;
import org.duniter.core.client.service.DataContext;
import org.duniter.core.client.service.ServiceLocator; import org.duniter.core.client.service.ServiceLocator;
import org.duniter.core.util.Preconditions;
import org.duniter.core.util.StringUtils; import org.duniter.core.util.StringUtils;
import org.nuiton.i18n.I18n; import org.nuiton.i18n.I18n;
import org.nuiton.i18n.init.DefaultI18nInitializer; import org.nuiton.i18n.init.DefaultI18nInitializer;
...@@ -76,11 +79,11 @@ public class Main { ...@@ -76,11 +79,11 @@ public class Main {
// Parsing args // Parsing args
JCommander jc = new JCommander(this); JCommander jc = new JCommander(this);
actions.entrySet().forEach(entry -> jc.addCommand(entry.getKey(), entry.getValue())); actions.forEach(jc::addCommand);
try { try {
jc.parse(args); jc.parse(args);
jc.getParameters().stream().forEach(param -> { jc.getParameters().forEach(param -> {
if (param.getParameter().password() if (param.getParameter().password()
&& param.getParameter().required() && param.getParameter().required()
&& param.getParameter().echoInput() && param.getParameter().echoInput()
...@@ -94,7 +97,6 @@ public class Main { ...@@ -94,7 +97,6 @@ public class Main {
catch(ParameterException e) { catch(ParameterException e) {
System.err.println(e.getMessage()); System.err.println(e.getMessage());
System.err.println("Try --help for usage"); System.err.println("Try --help for usage");
//jc.usage();
System.exit(-1); System.exit(-1);
} }
...@@ -122,7 +124,11 @@ public class Main { ...@@ -122,7 +124,11 @@ public class Main {
} }
// Set a default account id, then load cache // Set a default account id, then load cache
ServiceLocator.instance().getDataContext().setAccountId(0); // TODO: load data context (e.g. from a data file, or from config file)
DataContext context = loadDataContext();
if (context != null) {
ServiceLocator.instance().getDataContext().copy(context);
}
// Initialize service locator // Initialize service locator
ServiceLocator.instance().init(); ServiceLocator.instance().init();
...@@ -196,4 +202,22 @@ public class Main { ...@@ -196,4 +202,22 @@ public class Main {
return configArgs.toArray(new String[configArgs.size()]); return configArgs.toArray(new String[configArgs.size()]);
} }
protected DataContext loadDataContext() {
File dataDirectory = Configuration.instance().getDataDirectory();
if (!dataDirectory.exists()) return null; // Skip if not exists
Preconditions.checkArgument(dataDirectory.isDirectory(), "Invalid directory: " + dataDirectory.getAbsolutePath());
File dataFile = new File(dataDirectory, "data.json");
if (!dataFile.exists()) return null; // Skip if not exists
Preconditions.checkArgument(dataFile.canRead(), "Cannot read data file: " + dataFile.getAbsolutePath());
try {
return JacksonUtils.getThreadObjectMapper().readValue(dataFile, DataContext.class);
} catch (Exception e) {
System.err.println(String.format("Cannot read data file: %s. Skipping.", dataFile.getAbsolutePath()));
return null;
}
}
} }
...@@ -32,7 +32,9 @@ import org.duniter.client.actions.utils.Formatters; ...@@ -32,7 +32,9 @@ import org.duniter.client.actions.utils.Formatters;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.duniter.core.client.config.Configuration; import org.duniter.core.client.config.Configuration;
import org.duniter.core.client.config.ConfigurationOption; import org.duniter.core.client.config.ConfigurationOption;
import org.duniter.core.client.model.bma.EndpointApi;
import org.duniter.core.client.model.local.Peer; import org.duniter.core.client.model.local.Peer;
import org.duniter.core.client.model.local.Peers;
import org.duniter.core.client.service.ServiceLocator; import org.duniter.core.client.service.ServiceLocator;
import org.duniter.core.client.service.local.NetworkService; import org.duniter.core.client.service.local.NetworkService;
import org.duniter.core.util.CollectionUtils; import org.duniter.core.util.CollectionUtils;
...@@ -79,33 +81,37 @@ public class NetworkAction extends AbstractAction { ...@@ -79,33 +81,37 @@ public class NetworkAction extends AbstractAction {
final Peer mainPeer = peerParameters.getPeer(); final Peer mainPeer = peerParameters.getPeer();
checkOutputFileIfNotNull(); // make sure the file (if any) is writable checkOutputFileIfNotNull(); // make sure the file (if any) is writable
// Reducing node timeout when broadcast Configuration config = Configuration.instance();
if (peerParameters.timeout != null) {
Configuration.instance().getApplicationConfig().setOption(ConfigurationOption.NETWORK_TIMEOUT.getKey(), peerParameters.timeout.toString()); // Configure network timeout
Integer timeout = peerParameters.timeout;
if (timeout == null) {
timeout = 300; // Override default timeout to 300ms.
} }
config.getApplicationConfig().setOption(ConfigurationOption.NETWORK_TIMEOUT.getKey(), timeout.toString());
dateFormat = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.SHORT, SimpleDateFormat.MEDIUM, I18n.getDefaultLocale()); dateFormat = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.SHORT, SimpleDateFormat.MEDIUM, I18n.getDefaultLocale());
console = new RegexAnsiConsole(); console = new RegexAnsiConsole();
System.setOut(console); System.setOut(console);
log.info(I18n.t("duniter4j.client.network.loadingPeers")); log.info(I18n.t("duniter4j.client.network.loadingPeers", timeout));
NetworkService service = ServiceLocator.instance().getNetworkService(); NetworkService service = ServiceLocator.instance().getNetworkService();
if (!autoRefresh) { if (!autoRefresh) {
Long now = System.currentTimeMillis();
List<Peer> peers = service.getPeers(mainPeer); List<Peer> peers = service.getPeers(mainPeer);
showPeersTable(peers, false); showPeersTable(peers, false);
log.info(I18n.t("duniter4j.client.network.executionTime", System.currentTimeMillis() - now));
} }
else { else {
service.addPeersChangeListener(mainPeer, peers -> showPeersTable(peers, true)); service.addPeersChangeListener(mainPeer, peers -> showPeersTable(peers, true));
try { try {
while(true) { while (true) Thread.sleep(10000);
Thread.sleep(10000); // 10 s
}
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); // end
} }
} }
...@@ -126,11 +132,14 @@ public class NetworkAction extends AbstractAction { ...@@ -126,11 +132,14 @@ public class NetworkAction extends AbstractAction {
return; return;
} }
Peer mainConsensusPeer = peers.iterator().next(); Peer.Stats mainConsensusStats = peers.stream()
Peer.Stats mainConsensusStats = mainConsensusPeer.getStats(); .filter(p -> p.getStats() != null && p.getStats().getMedianTime() != null && p.getStats().isMainConsensus())
if (mainConsensusStats.isMainConsensus()) { .map(Peer::getStats)
Long mediantTime = mainConsensusStats.getMedianTime(); .findFirst().orElse(null);
String medianTime = dateFormat.format(new Date(mediantTime * 1000));
// Define color of main consensus info
if (mainConsensusStats != null) {
String medianTime = dateFormat.format(new Date(mainConsensusStats.getMedianTime() * 1000));
String mainBuid = formatBuid(mainConsensusStats); String mainBuid = formatBuid(mainConsensusStats);
console.reset() console.reset()
...@@ -140,7 +149,7 @@ public class NetworkAction extends AbstractAction { ...@@ -140,7 +149,7 @@ public class NetworkAction extends AbstractAction {
.fgString(medianTime, Ansi.Color.GREEN); .fgString(medianTime, Ansi.Color.GREEN);
peers.stream() peers.stream()
.filter(peer -> peer.getStats().isForkConsensus()) .filter(peer -> peer.getStats() != null && peer.getStats().isForkConsensus())
.map(peer -> formatBuid(peer.getStats())) .map(peer -> formatBuid(peer.getStats()))
.forEach(forkConsensusBuid -> console.fgString(Formatters.formatBuid(forkConsensusBuid), Ansi.Color.YELLOW)); .forEach(forkConsensusBuid -> console.fgString(Formatters.formatBuid(forkConsensusBuid), Ansi.Color.YELLOW));
...@@ -169,9 +178,9 @@ public class NetworkAction extends AbstractAction { ...@@ -169,9 +178,9 @@ public class NetworkAction extends AbstractAction {
Formatters.formatPubkey(peer.getPubkey()), Formatters.formatPubkey(peer.getPubkey()),
peer.getHost() + ":" + peer.getPort(), peer.getHost() + ":" + peer.getPort(),
peer.getStats().getStatus().name(), peer.getStats().getStatus().name(),
isUp && peer.isUseSsl() ? I18n.t("duniter4j.client.network.ssl") : "", isUp ? formatApi(peer) : "",
isUp ? peer.getStats().getVersion() : "", isUp ? peer.getStats().getVersion() : "",
(isUp && peer.getStats().getHardshipLevel() != null) ? peer.getStats().getHardshipLevel() : I18n.t("duniter4j.client.network.mirror"), isUp ? formatHarshipLevel(peer) : "",
isUp ? formatBuid(peer.getStats()) : "" isUp ? formatBuid(peer.getStats()) : ""
}; };
}) })
...@@ -235,6 +244,29 @@ public class NetworkAction extends AbstractAction { ...@@ -235,6 +244,29 @@ public class NetworkAction extends AbstractAction {
} }
protected String formatBuid(Peer.Stats stats) { protected String formatBuid(Peer.Stats stats) {
if (stats.getBlockNumber() == null) return "";
return Formatters.formatBuid(stats.getBlockNumber() + "-" + stats.getBlockHash()); return Formatters.formatBuid(stats.getBlockNumber() + "-" + stats.getBlockHash());
} }
protected String formatApi(Peer peer) {
if (Peers.hasBmaEndpoint(peer)) {
return peer.isUseSsl() ? I18n.t("duniter4j.client.network.ssl") : "";
}
if (Peers.hasWs2pEndpoint(peer)) {
return "WS2P";
}
return peer.getApi();
}
protected String formatHarshipLevel(Peer peer) {
// Mirror
if (peer.getStats().getHardshipLevel() == null || peer.getStats().getUid() == null) {
return I18n.t("duniter4j.client.network.mirror");
}
if (peer.getStats().getHardshipLevel() == 0) {
return "?";
}
return peer.getStats().getHardshipLevel().toString();
}
} }
...@@ -50,6 +50,7 @@ import org.slf4j.LoggerFactory; ...@@ -50,6 +50,7 @@ import org.slf4j.LoggerFactory;
import java.util.List; import java.util.List;
/** /**
* Created by blavenie on 22/03/17. * Created by blavenie on 22/03/17.
*/ */
...@@ -100,7 +101,7 @@ public class TransactionAction extends AbstractAction { ...@@ -100,7 +101,7 @@ public class TransactionAction extends AbstractAction {
Currency currency = ServiceLocator.instance().getBlockchainRemoteService().getCurrencyFromPeer(peer); Currency currency = ServiceLocator.instance().getBlockchainRemoteService().getCurrencyFromPeer(peer);
ServiceLocator.instance().getCurrencyService().save(currency); ServiceLocator.instance().getCurrencyService().save(currency);
peer.setCurrency(currency.getCurrencyName()); peer.setCurrency(currency.getId());
ServiceLocator.instance().getPeerService().save(peer); ServiceLocator.instance().getPeerService().save(peer);
...@@ -123,11 +124,10 @@ public class TransactionAction extends AbstractAction { ...@@ -123,11 +124,10 @@ public class TransactionAction extends AbstractAction {
} }
Wallet wallet = new Wallet( Wallet wallet = new Wallet(
currency.getCurrencyName(), currency.getId(),
null, null,
keypair.getPubKey(), keypair.getPubKey(),
keypair.getSecKey()); keypair.getSecKey());
wallet.setCurrencyId(currency.getId());
// Parse TX parameters // Parse TX parameters
parseTransactionParameters(); parseTransactionParameters();
...@@ -195,10 +195,10 @@ public class TransactionAction extends AbstractAction { ...@@ -195,10 +195,10 @@ public class TransactionAction extends AbstractAction {
peersFilter.filterType = NetworkService.FilterType.MEMBER; peersFilter.filterType = NetworkService.FilterType.MEMBER;
peersFilter.filterStatus = Peer.PeerStatus.UP; peersFilter.filterStatus = Peer.PeerStatus.UP;
if (useSsl) { if (useSsl) {
peersFilter.filterEndpoints = ImmutableList.of(EndpointApi.BMAS.name()); peersFilter.filterEndpoints = ImmutableList.of(EndpointApi.BMAS.label());
} }
else { else {
peersFilter.filterEndpoints = ImmutableList.of(EndpointApi.BASIC_MERKLED_API.name()); peersFilter.filterEndpoints = ImmutableList.of(EndpointApi.BASIC_MERKLED_API.label());
} }
// Sort by [lesser difficulty first] // Sort by [lesser difficulty first]
NetworkService.Sort sortLesserDifficulty = new NetworkService.Sort(); NetworkService.Sort sortLesserDifficulty = new NetworkService.Sort();
...@@ -219,7 +219,7 @@ public class TransactionAction extends AbstractAction { ...@@ -219,7 +219,7 @@ public class TransactionAction extends AbstractAction {
logTxSummary(wallet); logTxSummary(wallet);
peers.stream().forEach(peer -> { peers.stream().forEach(peer -> {
peer.setCurrency(currency.getCurrencyName()); peer.setCurrency(currency.getId());
peerService.save(peer); peerService.save(peer);
log.debug(String.format("Send TX to [%s]...", peer)); log.debug(String.format("Send TX to [%s]...", peer));
......
...@@ -46,7 +46,7 @@ public class PeerParameters { ...@@ -46,7 +46,7 @@ public class PeerParameters {
public boolean useSsl = false; public boolean useSsl = false;
@Parameter(names = "--timeout", description = "HTTP request timeout, in millisecond", descriptionKey = "duniter4j.client.params.peer.timeout") @Parameter(names = "--timeout", description = "HTTP request timeout, in millisecond", descriptionKey = "duniter4j.client.params.peer.timeout")
public Long timeout = null; public Integer timeout = null;
private Peer peer = null; private Peer peer = null;
...@@ -59,12 +59,12 @@ public class PeerParameters { ...@@ -59,12 +59,12 @@ public class PeerParameters {
String host = parts[0]; String host = parts[0];
Integer port = parts.length == 2 ? Integer.parseInt(parts[1]) : null; Integer port = parts.length == 2 ? Integer.parseInt(parts[1]) : null;
Peer.Builder peerBuilder = Peer.newBuilder().setHost(host); Peer.Builder peerBuilder = Peer.builder().host(host);
if (port != null) { if (port != null) {
peerBuilder.setPort(port); peerBuilder.port(port);
} }
if (useSsl){ if (useSsl){
peerBuilder.setUseSsl(useSsl); peerBuilder.useSsl(useSsl);
} }
peer = peerBuilder.build(); peer = peerBuilder.build();
...@@ -72,8 +72,8 @@ public class PeerParameters { ...@@ -72,8 +72,8 @@ public class PeerParameters {
} }
else { else {
Configuration config = Configuration.instance(); Configuration config = Configuration.instance();
peer = Peer.newBuilder().setHost(config.getNodeHost()) peer = Peer.builder().host(config.getNodeHost())
.setPort(config.getNodePort()) .port(config.getNodePort())
.build(); .build();
log.info(I18n.t("duniter4j.client.info.peer.fallback", peer.getHost(), peer.getPort())); log.info(I18n.t("duniter4j.client.info.peer.fallback", peer.getHost(), peer.getPort()));
} }
......
...@@ -2,12 +2,12 @@ org.duniter.core.client.service.bma.BlockchainRemoteServiceImpl ...@@ -2,12 +2,12 @@ org.duniter.core.client.service.bma.BlockchainRemoteServiceImpl
org.duniter.core.client.service.bma.NetworkRemoteServiceImpl org.duniter.core.client.service.bma.NetworkRemoteServiceImpl
org.duniter.core.client.service.bma.WotRemoteServiceImpl org.duniter.core.client.service.bma.WotRemoteServiceImpl
org.duniter.core.client.service.bma.TransactionRemoteServiceImpl org.duniter.core.client.service.bma.TransactionRemoteServiceImpl
org.duniter.core.client.service.elasticsearch.CurrencyRegistryRemoteServiceImpl org.duniter.core.client.service.elasticsearch.CurrencyPodRemoteServiceImpl
org.duniter.core.service.Ed25519CryptoServiceImpl org.duniter.core.service.Ed25519CryptoServiceImpl
org.duniter.core.client.service.HttpServiceImpl org.duniter.core.client.service.HttpServiceImpl
org.duniter.core.client.service.DataContext org.duniter.core.client.service.DataContext
org.duniter.core.client.service.local.PeerServiceImpl org.duniter.core.client.service.local.PeerServiceImpl
org.duniter.core.client.service.local.CurrencyServiceImpl org.duniter.core.client.service.local.CurrencyServiceImpl
org.duniter.core.client.service.local.NetworkServiceImpl org.duniter.core.client.service.local.NetworkServiceImpl
org.duniter.core.client.dao.mem.MemoryCurrencyDaoImpl org.duniter.core.client.repositories.mem.MemoryCurrencyRepositoryImpl
org.duniter.core.client.dao.mem.MemoryPeerDaoImpl org.duniter.core.client.repositories.mem.MemoryPeerRepositoryImpl
\ No newline at end of file \ No newline at end of file
...@@ -3,8 +3,9 @@ duniter4j.client.info.peer.fallback=Fallback to default Duniter peer\: [%s\:%d] ...@@ -3,8 +3,9 @@ duniter4j.client.info.peer.fallback=Fallback to default Duniter peer\: [%s\:%d]
duniter4j.client.network.action=Display network peers duniter4j.client.network.action=Display network peers
duniter4j.client.network.cesiumPlus=Cs+ duniter4j.client.network.cesiumPlus=Cs+
duniter4j.client.network.error.outputFieNotWritable=Output file not writable duniter4j.client.network.error.outputFieNotWritable=Output file not writable
duniter4j.client.network.header=Main block [%1$s] computed at [%2$s] validated by [%3$3.2f%%] of peers duniter4j.client.network.executionTime=Execution time\: %s ms
duniter4j.client.network.loadingPeers=Reading network peers... duniter4j.client.network.header=Head\: block {%1$s} computed at %2$s (UTC time) validated by {%3$3.2f%%} of the peers
duniter4j.client.network.loadingPeers=Reading network peers... (timeout\: %s ms)
duniter4j.client.network.mirror=Mirror duniter4j.client.network.mirror=Mirror
duniter4j.client.network.noPeers=No peers found duniter4j.client.network.noPeers=No peers found
duniter4j.client.network.params.continue=Continue scanning? (Will refresh on new peer/block). duniter4j.client.network.params.continue=Continue scanning? (Will refresh on new peer/block).
......
duniter4j.client.info.peer=Noeud Duniter {%s\:%s}
duniter4j.client.info.peer.fallback=Noeud Duniter par défaut {%s\:%d}
duniter4j.client.network.action=Afficher les noeuds Duniter
duniter4j.client.network.cesiumPlus=Cs+
duniter4j.client.network.error.outputFieNotWritable=Fichier de sortie non inscriptible
duniter4j.client.network.executionTime=Temps d'execution \: %s ms
duniter4j.client.network.header=Branche principale\: bloc {%1$s} calculé à %2$s (heure UTC) validé par {%3$3.2f%%} des noeuds
duniter4j.client.network.loadingPeers=Lecture des noeuds du réseau... (Délai d'attente \: %s ms)
duniter4j.client.network.mirror=Mirroir
duniter4j.client.network.noPeers=Aucun noeud trouvé
duniter4j.client.network.params.continue=Continue scanning? (Will refresh on new peer/block).
duniter4j.client.network.params.output=Output CSV file
duniter4j.client.network.ssl=SSL
duniter4j.client.params.authScrypt=Authentification par salage Scrypt ?
duniter4j.client.params.authScrypt.ask.passwd=Veuillez entrer votre mot de passe Scrypt (password) \:
duniter4j.client.params.authScrypt.ask.salt=Veuillez entrer votre identifiant secret Scrypt (Salt)\:
duniter4j.client.params.authScrypt.ask.scryptParams=Veuillez entrer les paramètres de Scrypt (N,r,p)\: [%d,%d,%d]
duniter4j.client.params.authScrypt.error.scryptParams=Paramètre Scrypt non valide (3 valeurs attendues - format 'N,r,p')"
duniter4j.client.params.authScrypt.passwd=Mot de passe
duniter4j.client.params.authScrypt.salt=Identifiant secret (salt)
duniter4j.client.params.authScrypt.scryptParams=Paramètre de salage Scrypt (N,r,p)
duniter4j.client.params.config=Fichier de configuration
duniter4j.client.params.debug=Activer les logs de debuggage
duniter4j.client.params.error.invalidOption=Valeur d'option [%s] invalid
duniter4j.client.params.help=Affichage de l'aide
duniter4j.client.params.peer=Noeud Duniter (hôte\:port)
duniter4j.client.params.peer.fallback=
duniter4j.client.params.peer.timeout=Délai de réponse max. d'un noeud, en millisecondes
duniter4j.client.params.peer.useSsl=Utiliser une connection SSL ?
duniter4j.client.transaction.action=Effectuer une transaction
duniter4j.client.transaction.broadcast.failed=Transaction NON envoyée. Aucun noeud n'a accepté la transaction.
duniter4j.client.transaction.broadcast.memberPeerCount=%d noeud membres trouvé, pour l'envoi multiple
duniter4j.client.transaction.broadcast.success=Transaction envoyée avec succès (à %d noeuds de la branche principale de la chaine de blocs)
duniter4j.client.transaction.broadcast.successOnForkOnly=Transaction NON envoyée sur la branche principale, mais seulement sur %d noeud d'une branche secondaire de la cheine de blocs
duniter4j.client.transaction.broadcast.summary=Envoi de la transation\:\n\t- De\: %s\n\t- A\: %s\n\t- Montant\: %s %s
duniter4j.client.transaction.error.broadcast.noMemberPeer=Aucun noeud membre trouvé \! L'option --broadcast va être ignorée
duniter4j.client.transaction.error.unknownAuth=Type d'authentification inconnue
duniter4j.client.transaction.loadingMemberPeers=Récupération des noeuds membres...
duniter4j.client.transaction.params.amount.ask=Veuillez entrer le montant (valeur entière) \:
duniter4j.client.transaction.params.output.ask=Veuillez entrer le destinataire (clef publique) \:
duniter4j.client.transaction.sent=Transaction envoyé avec succès.
duniter4j.client.info.peer=Noeud Duniter \: [%s\:%s] duniter4j.client.info.peer=Noeud Duniter {%s\:%s}
duniter4j.client.info.peer.fallback=Noeud Duniter (par défaut) \: [%s\:%d] duniter4j.client.info.peer.fallback=Noeud Duniter par défaut {%s\:%d}
duniter4j.client.network.action=Afficher les noeuds Duniter duniter4j.client.network.action=Afficher les noeuds Duniter
duniter4j.client.network.cesiumPlus=Cs+ duniter4j.client.network.cesiumPlus=Cs+
duniter4j.client.network.error.outputFieNotWritable=Fichier de sortie non inscriptible duniter4j.client.network.error.outputFieNotWritable=Fichier de sortie non inscriptible
duniter4j.client.network.header=Bloc principal [%1$s] calculé à [%2$s] validé par [%3$3.2f%%] des noeuds duniter4j.client.network.executionTime=Temps d'execution \: %s ms
duniter4j.client.network.loadingPeers=Lecture des noeuds du réseau... duniter4j.client.network.header=Branche principale\: bloc {%1$s} calculé à %2$s (heure UTC) validé par {%3$3.2f%%} des noeuds
duniter4j.client.network.loadingPeers=Lecture des noeuds du réseau... (Délai d'attente \: %s ms)
duniter4j.client.network.mirror=Mirroir duniter4j.client.network.mirror=Mirroir
duniter4j.client.network.noPeers=Aucun noeud trouvé duniter4j.client.network.noPeers=Aucun noeud trouvé
duniter4j.client.network.params.continue=Continue scanning? (Will refresh on new peer/block). duniter4j.client.network.params.continue=Continue scanning? (Will refresh on new peer/block).
...@@ -19,7 +20,7 @@ duniter4j.client.params.authScrypt.passwd=Mot de passe ...@@ -19,7 +20,7 @@ duniter4j.client.params.authScrypt.passwd=Mot de passe
duniter4j.client.params.authScrypt.salt=Identifiant secret (salt) duniter4j.client.params.authScrypt.salt=Identifiant secret (salt)
duniter4j.client.params.authScrypt.scryptParams=Paramètre de salage Scrypt (N,r,p) duniter4j.client.params.authScrypt.scryptParams=Paramètre de salage Scrypt (N,r,p)
duniter4j.client.params.config=Fichier de configuration duniter4j.client.params.config=Fichier de configuration
duniter4j.client.params.debug=Activer les logs de débuggage duniter4j.client.params.debug=Activer les logs de debuggage
duniter4j.client.params.error.invalidOption=Valeur d'option [%s] invalid duniter4j.client.params.error.invalidOption=Valeur d'option [%s] invalid
duniter4j.client.params.help=Affichage de l'aide duniter4j.client.params.help=Affichage de l'aide
duniter4j.client.params.peer=Noeud Duniter (hôte\:port) duniter4j.client.params.peer=Noeud Duniter (hôte\:port)
......
lombok.fieldnameconstants.uppercase=true
clear lombok.log.fieldName
lombok.log.fieldName = log
\ No newline at end of file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>org.duniter</groupId> <groupId>org.duniter</groupId>
<artifactId>duniter4j</artifactId> <artifactId>duniter4j</artifactId>
<version>1.1.1-SNAPSHOT</version> <version>1.6.2-SNAPSHOT</version>
</parent> </parent>
<artifactId>duniter4j-core-client</artifactId> <artifactId>duniter4j-core-client</artifactId>
...@@ -27,6 +28,7 @@ ...@@ -27,6 +28,7 @@
<artifactId>duniter4j-core-shared</artifactId> <artifactId>duniter4j-core-shared</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<!-- LOGGING DEPENDENCIES - SLF4J --> <!-- LOGGING DEPENDENCIES - SLF4J -->
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
...@@ -43,7 +45,6 @@ ...@@ -43,7 +45,6 @@
<groupId>org.glassfish.tyrus</groupId> <groupId>org.glassfish.tyrus</groupId>
<artifactId>tyrus-client</artifactId> <artifactId>tyrus-client</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.glassfish.tyrus</groupId> <groupId>org.glassfish.tyrus</groupId>
<artifactId>tyrus-container-grizzly-client</artifactId> <artifactId>tyrus-container-grizzly-client</artifactId>
...@@ -82,6 +83,12 @@ ...@@ -82,6 +83,12 @@
<artifactId>jackson-databind</artifactId> <artifactId>jackson-databind</artifactId>
</dependency> </dependency>
<!-- Compile -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<!-- Unit test --> <!-- Unit test -->
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
...@@ -93,6 +100,11 @@ ...@@ -93,6 +100,11 @@
<artifactId>slf4j-log4j12</artifactId> <artifactId>slf4j-log4j12</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>log4j</groupId> <groupId>log4j</groupId>
<artifactId>log4j</artifactId> <artifactId>log4j</artifactId>
......
# Generated by org.codehaus.mojo.license.AddThirdPartyMojo
#-------------------------------------------------------------------------------
# Already used licenses in project :
# - Apache 2.0
# - BSD License
# - BSD-3-Clause
# - CDDL
# - CDDL+GPL
# - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
# - Common Development and Distribution License (CDDL) v1.0
# - Dual license consisting of the CDDL v1.1 and GPL v2
# - Eclipse Public License 1.0
# - GPLv2+CE
# - General Public License (GPL) v3
# - Indiana University Extreme! Lab Software License, vesion 1.1.1
# - Lesser General Public License (LGPL) v 3.0
# - Lesser General Public License (LPGL)
# - Lesser General Public License (LPGL) v 2.1
# - Lesser General Public License (LPGL) version 3.0
# - MIT License
# - New BSD License
# - The Apache Software License, Version 2.0
#-------------------------------------------------------------------------------
# Please fill the missing licenses for dependencies :
#
#
#Tue Apr 13 11:29:47 CEST 2021
commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0