Merge seednode repository at eedf81c

This commit is contained in:
Christoph Atteneder 2018-09-14 11:51:34 +02:00
parent a55673fe52
commit 3de0a8b964
No known key found for this signature in database
GPG Key ID: CD5DC1C529CDFD3B
13 changed files with 349 additions and 0 deletions

23
seednode/.dockerignore Normal file
View File

@ -0,0 +1,23 @@
docs/
.git/
.dockerignore
.editorconfig
.travis.yml
docker-compose.yml
docker/development/
docker/prod/
docker/README.md
# Gradle
.gradle
build
# IDEA
.idea
*.iml
# macOS
.DS_Store
# Vim
*.sw[op]

39
seednode/build.gradle Normal file
View File

@ -0,0 +1,39 @@
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
}
}
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'maven'
apply plugin: 'com.github.johnrengelman.shadow'
group = 'network.bisq'
version = '0.8.0-SNAPSHOT'
sourceCompatibility = 1.8
mainClassName = 'bisq.seednode.SeedNodeMain'
sourceSets.main.resources.srcDirs += ['src/main/java'] // to copy fxml and css files
repositories {
jcenter()
maven { url "https://jitpack.io" }
maven { url 'https://raw.githubusercontent.com/JesusMcCloud/tor-binary/master/release/' }
}
dependencies {
compile project(':core')
runtime 'org.bouncycastle:bcprov-jdk15on:1.56'
compileOnly 'org.projectlombok:lombok:1.16.16'
annotationProcessor 'org.projectlombok:lombok:1.16.16'
}
build.dependsOn installDist
installDist.destinationDir = file('build/app')
distZip.enabled = false

3
seednode/create_jar.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
./gradlew build -x test shadowJar

View File

@ -0,0 +1,22 @@
version: '2.1'
services:
seednode:
build:
context: .
dockerfile: docker/development/Dockerfile
image: bisq-seednode
ports:
- 8000:8000
environment:
- NODE_PORT=8000
- BASE_CURRENCY_NETWORK=BTC_REGTEST
- SEED_NODES=seednode:8000
- MY_ADDRESS=seednode:8000
- USE_LOCALHOST_FOR_P2P=true
volumes:
- m2:/root/.m2
volumes:
m2:
name: m2

21
seednode/docker/README.md Normal file
View File

@ -0,0 +1,21 @@
# bisq-seednode docker
Both images use the same [startSeedNode.sh](startSeedNode.sh) script so inspect it to see what environment variables you can tweak.
## Production image
In order to build image:
docker build . -f docker/prod/Dockerfile -t bisq/seednode
Run:
docker run bisq/seednode
You might want to mount tor hidden service directory:
docker run -v /your/tor/dir:/root/.local/share/seednode/btc_mainnet/tor/hiddenservice/ bisq/seednode
## Development image
docker-compose build

View File

@ -0,0 +1,18 @@
###
# WARNING!!! THIS IMAGE IS FOR D E V E L O P M E N T USE ONLY!
###
FROM openjdk:8-jdk
RUN apt-get update && apt-get install -y --no-install-recommends \
openjfx && rm -rf /var/lib/apt/lists/*
WORKDIR /bisq-seednode
CMD ./docker/startSeedNode.sh
ENV APP_NAME=seednode
ENV NODE_PORT=8000
EXPOSE 8000
COPY . .

View File

@ -0,0 +1,16 @@
FROM openjdk:8-jdk
RUN apt-get update && apt-get install -y --no-install-recommends \
openjfx && rm -rf /var/lib/apt/lists/*
WORKDIR /bisq-seednode
CMD ./docker/startSeedNode.sh
ENV APP_NAME=seednode
ENV NODE_PORT=8000
EXPOSE 8000
COPY . .
RUN ./docker/setup.sh
ENV SKIP_BUILD=true

5
seednode/docker/setup.sh Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
if [ "$SKIP_BUILD" != "true" ]; then
./gradlew build
fi

View File

@ -0,0 +1,36 @@
#!/bin/bash
SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]})
SETUP_SCRIPT=${SCRIPT_DIR}/setup.sh
source ${SETUP_SCRIPT}
ARGS=""
if [ ! -z "$BASE_CURRENCY_NETWORK" ]; then
ARGS="$ARGS --baseCurrencyNetwork=$BASE_CURRENCY_NETWORK"
fi
if [ ! -z "$MAX_CONNECTIONS" ]; then
ARGS="$ARGS --maxConnections=$MAX_CONNECTIONS"
fi
if [ ! -z "$NODE_PORT" ]; then
ARGS="$ARGS --nodePort=$NODE_PORT"
fi
if [ ! -z "$APP_NAME" ]; then
ARGS="$ARGS --appName=$APP_NAME"
fi
if [ ! -z "$SEED_NODES" ]; then
ARGS="$ARGS --seedNodes=$SEED_NODES"
fi
if [ ! -z "$BTC_NODES" ]; then
ARGS="$ARGS --btcNodes=$BTC_NODES"
fi
if [ ! -z "$USE_LOCALHOST_FOR_P2P" ]; then
ARGS="$ARGS --useLocalhostForP2P=$USE_LOCALHOST_FOR_P2P"
fi
if [ ! -z "$MY_ADDRESS" ]; then
ARGS="$ARGS --myAddress=${MY_ADDRESS}"
elif [ ! -z "$ONION_ADDRESS" ]; then
ARGS="$ARGS --myAddress=${ONION_ADDRESS}.onion:$NODE_PORT"
fi
JAVA_OPTS='-Xms1800m -Xmx1800m' ./build/app/bin/bisq-seednode $ARGS

View File

@ -0,0 +1,46 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
package bisq.seednode;
import bisq.core.app.misc.AppSetup;
import bisq.core.app.misc.AppSetupWithP2P;
import bisq.core.app.misc.AppSetupWithP2PAndDAO;
import bisq.core.dao.DaoOptionKeys;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.name.Names;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class SeedNode {
@Setter
private Injector injector;
private AppSetup appSetup;
public SeedNode() {
}
public void startApplication() {
Boolean fullDaoNode = injector.getInstance(Key.get(Boolean.class, Names.named(DaoOptionKeys.FULL_DAO_NODE)));
appSetup = fullDaoNode ? injector.getInstance(AppSetupWithP2PAndDAO.class) : injector.getInstance(AppSetupWithP2P.class);
appSetup.start();
}
}

View File

@ -0,0 +1,100 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
package bisq.seednode;
import bisq.core.app.BisqEnvironment;
import bisq.core.app.BisqExecutable;
import bisq.core.app.misc.ExecutableForAppWithP2p;
import bisq.core.app.misc.ModuleForAppWithP2p;
import bisq.common.UserThread;
import bisq.common.app.AppModule;
import bisq.common.app.Capabilities;
import bisq.common.setup.CommonSetup;
import joptsimple.OptionSet;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class SeedNodeMain extends ExecutableForAppWithP2p {
private static final String VERSION = "0.8.0";
private SeedNode seedNode;
public static void main(String[] args) throws Exception {
log.info("SeedNode.VERSION: " + VERSION);
BisqEnvironment.setDefaultAppName("bisq_seednode");
if (BisqExecutable.setupInitialOptionParser(args))
new SeedNodeMain().execute(args);
}
@Override
protected void doExecute(OptionSet options) {
super.doExecute(options);
checkMemory(bisqEnvironment, this);
CommonSetup.setup(this);
keepRunning();
}
@Override
protected void addCapabilities() {
Capabilities.addCapability(Capabilities.Capability.SEED_NODE.ordinal());
}
@Override
protected void launchApplication() {
UserThread.execute(() -> {
try {
seedNode = new SeedNode();
UserThread.execute(this::onApplicationLaunched);
} catch (Exception e) {
e.printStackTrace();
}
});
}
@Override
protected void onApplicationLaunched() {
super.onApplicationLaunched();
}
///////////////////////////////////////////////////////////////////////////////////////////
// We continue with a series of synchronous execution tasks
///////////////////////////////////////////////////////////////////////////////////////////
@Override
protected AppModule getModule() {
return new ModuleForAppWithP2p(bisqEnvironment);
}
@Override
protected void applyInjector() {
super.applyInjector();
seedNode.setInjector(injector);
}
@Override
protected void startApplication() {
seedNode.startApplication();
}
}

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="CONSOLE_APPENDER" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%highlight(%d{MMM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{15}: %msg %xEx%n)</pattern>
</encoder>
</appender>
<root level="TRACE">
<appender-ref ref="CONSOLE_APPENDER"/>
</root>
<logger name="bisq.common.storage.Storage" level="WARN"/>
<logger name="bisq.common.storage.FileManager" level="WARN"/>
<logger name="com.neemre.btcdcli4j" level="WARN"/>
<logger name="com.msopentech.thali.toronionproxy.OnionProxyManagerEventHandler" level="INFO"/>
</configuration>

View File

@ -6,5 +6,6 @@ include 'desktop'
include 'monitor'
include 'pricenode'
include 'relay'
include 'seednode'
rootProject.name = 'bisq'