Skip to content

Commit

Permalink
Merge pull request #27 from ghubstan/0-lightbend-network-config
Browse files Browse the repository at this point in the history
Use typesafe Misq.conf in NetworkServiceConfigFactory
  • Loading branch information
chimp1984 authored Jan 3, 2022
2 parents 94f6e49 + 17ddb2a commit 2f1cd0e
Show file tree
Hide file tree
Showing 5 changed files with 200 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
import network.misq.common.util.ConfigUtil;

import java.util.concurrent.CompletableFuture;

Expand All @@ -31,8 +32,7 @@ public ServiceProvider(String configFileName) {
}

protected Config getConfig(String path) {
misqConfig.checkValid(ConfigFactory.defaultReference(), path);
return misqConfig.getConfig(path);
return ConfigUtil.getConfig(misqConfig, path);
}

public abstract CompletableFuture<Boolean> initialize();
Expand Down
101 changes: 65 additions & 36 deletions application/src/main/resources/Misq.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,42 +22,71 @@ misq {
p2pServiceNodeConfig="PEER_GROUP,DATA,CONFIDENTIAL,RELAY,MONITOR"
}

i2pPeerGroupServiceConfig {
peerGroupConfig {
minNumConnectedPeers=8
maxNumConnectedPeers=12
minNumReportedPeers=30
}

peerExchangeConfig {
numSeeNodesAtBoostrap=2
numPersistedPeersAtBoostrap=100
numReportedPeersAtBoostrap=50
}

keepAliveServiceConfig {
bootstrapTime=1111
interval=2222
}
}

torPeerGroupServiceConfig {
peerGroupConfig {
minNumConnectedPeers=8
maxNumConnectedPeers=12
minNumReportedPeers=30
}

peerExchangeConfig {
numSeeNodesAtBoostrap=2
numPersistedPeersAtBoostrap=100
numReportedPeersAtBoostrap=50
}

keepAliveServiceConfig {
bootstrapTime=1111
interval=2222
}
clearNetPeerGroupServiceConfig {
bootstrapTimeInSeconds = 10
intervalInSeconds = 30
timeoutInSeconds = 120
maxAgeInHours = 2
maxPersisted = 100
maxReported = 100
maxSeeds = 4
}

defaultPeerGroupServiceConfig {
bootstrapTimeInSeconds = 10
intervalInSeconds = 20
timeoutInSeconds = 60
maxAgeInHours = 2
maxPersisted = 100
maxReported = 100
maxSeeds = 4
}

# Apply to i2p and tor services.
peerGroupConfig {
minNumConnectedPeers=8
maxNumConnectedPeers=12
minNumReportedPeers=1
}

# Apply to i2p and tor services.
peerExchangeStrategyConfig {
numSeedNodesAtBoostrap=2
numPersistedPeersAtBoostrap=10
numReportedPeersAtBoostrap=10
}

# Apply to i2p and tor services.
keepAliveServiceConfig {
maxIdleTimeInSeconds=180
intervalInSeconds=90
}

seedAddressByTransportType {
"tor" : [
"76ewqvsvh5nnuqnlro65nrxu3d4377aw5kv25p2uq7cpvoi4xslq7vyd.onion:1000",
"ucq3qw4qlzstpwtqig6lxll64tarmqi77u6t5iquvi52j66pqrsqcpad.onion:1001",
"fanvmqmbxyklaro3uanyotybrfcflc2ywlr5qd3ttvf2cva2huxrwuyd.onion:1002",
"4i45sndzsxnw24idfr57lzzbcxhfdjp3yikvxwb54p4bjay5j4lqjuqd.onion:1003",
"5wzt2sx53vzozoifkvntrl7rycegmker57aofb6qxgbunbw2p435fnyd.onion:1004",
"5ekgw2qowowt7ncgo2jnnwyehqfvj7gqj75cogt3apuyef32myj7byyd.onion:1005",
"cqvqm4ewvh2zdlrcz4whn6b5ltgg5hbef4ymp2pzk2hlrz4hjkqpmgyd.onion:1006",
"kctohowqiwkgeceag622c56kv5aqbeozm5ifjjldqo2x5hnzb5qkhfqd.onion:1007",
"hqvn6w7phvz6jifm2ak66flrdeieq24f653njkf4e7tsrqbramm3hpyd.onion:1008",
"onuyzrnp4zgnokmptj4krgwfydqh5snzoekhoo4hr3eo4qg7jhhziaad.onion:1009",
"zj6eiccp4irphbs4ihbgwcy3jo6unxap5nhac4r25mswrscuqqs5beqd.onion:1010",
"plj7e5vs67psw2jlryjrbuh4336zwrigcsiiwf4jeennkla5x2ly5qyd.onion:1011"
]
"i2p" : [
"KvQVpgFzxw7jvwdxLAjywlc9Y4hLPT49on2XPYzcRoHmQa-UA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OBZJPAWkwMl5rhlBNKZK-gnjHKzvGWi7p~JQVTD4DBXOREzl1Ja9KTh7DKI-LOr1IfmRvvgBJ~tMRwy~DhpPzrKnb3wQ7JOdbPov76LSrzZ4pJ0k0ZJCAwLLn-gLm0f1bCjZWuqDragzp4k1niNKYsDUS6yX3vAlybW-yqbCHIe-P0xojpru1YHaY0RRiz3F9M8h57lgX1bTIkE4XHZNAvTerC-2DP~Y32ZyVSuc14vaZ31WhqTfrXnl3h9RDZ8OfyjwL7zKQMznnMPbWFLv~KyTAcmI7wjGlmEXBjwk0jjVJhvrm4uEn648aNc3oPv4vryXH9u-~54J~gU3-wgii3zpYtpT9AhK2X0OTEvvnG0QZAL0gTwmyvlKSrKsRPfdl9AWWswmj8F3WxjK-BQAEAAcAAA==:5006",
"gFT7xEiKOYTOLOyJgFntwdGXpcGeq0XloyUXAqqQooqwWQC~UqpaFw5GANm-kjbNdkyymL8DJTw6HU~rXxPqVs6YKV~v80Rtrug2jQuIlPwXWEwRYnDl38bMMH4a6Qqq0--vh7JzhXt~fh4hiWPyiPkPZVN6F8PjLJ0myr54plzEz5ueMxW~bjOWshef8yWrvrXZ5QPMSJWwRhw1AClWZUjdjR-7yRZfT0XW4z7l3EE7ib~ZFzdRxcb~M3JFaudpIT5bowgPmByym-M5ZNZXws6~Nlu4OpflSsboAmXz-gdyMElpUOm8p0n1UyV0n20nTVRiuCVL0e~SSYVjNLSBdWfUSwYHG-TjDfFovAFd1Ns7sHZwOXFKZSWY6bUOuOW4rRwGKaXOvXGdvm881w-wIVgk6bah3fVIi-D6vjiKacFKQD6gxybneUci6KXi59cucBxzp3QPMlQLweAvX6cBKvKzleStJhH18MkJ1Q9MPNq8tl2WF4X-YPSnpkHsYtM6BQAEAAcAAA==:5007"
]
}
}
}
68 changes: 68 additions & 0 deletions common/src/main/java/network/misq/common/util/ConfigUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* 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 network.misq.common.util;

import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;

import java.util.List;
import java.util.function.BiFunction;
import java.util.stream.Collectors;

import static java.lang.String.format;

/**
* Static convenience methods for accessing typesafe configurations and values.
*/
public class ConfigUtil {

private static final BiFunction<String, Exception, IllegalStateException> toConfigValidationException = (path, ex) ->
new IllegalStateException(format("Error resolving configuration at path '%s'.", path), ex);

public static Config getConfig(Config config, String path) {
config.checkValid(ConfigFactory.defaultReference(), path);
return config.getConfig(path);
}

public static int getInt(Config config, String path) {
try {
config.checkValid(ConfigFactory.defaultReference(), path);
return config.getInt(path);
} catch (Exception ex) {
throw toConfigValidationException.apply(path, ex);
}
}

public static Long getLong(Config config, String path) {
try {
config.checkValid(ConfigFactory.defaultReference(), path);
return config.getLong(path);
} catch (Exception ex) {
throw toConfigValidationException.apply(path, ex);
}
}

public static List<String> getStringList(Config config, String path) {
try {
config.checkValid(ConfigFactory.defaultReference(), path);
return config.getList(path).unwrapped().stream().map(Object::toString).collect(Collectors.toList());
} catch (Exception ex) {
throw toConfigValidationException.apply(path, ex);
}
}
}
Loading

0 comments on commit 2f1cd0e

Please sign in to comment.