Skip to content

Commit

Permalink
Fixed handling of default.json pool configuration.
Browse files Browse the repository at this point in the history
Fixed a bug with loading of pool json files with filenames starting with a,b,c and d.
Moved a few more common values to default-example.json.
  • Loading branch information
bonesoul committed Oct 3, 2014
1 parent fbcf11d commit 5f33b41
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 26 deletions.
19 changes: 11 additions & 8 deletions src/CoiniumServ/Configuration/ConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public ConfigManager(IConfigFactory configFactory, IJsonConfigReader jsonConfigR
LoadGlobalConfig(); // read the global config.
// LoadDaemonManagerConfig(); // load the global daemon manager config. - disabled until we need it.
LoadSoftwareManagerConfig(); // load software manager config file.
LoadDefaultPoolConfig(); // load default pool config if exists.
LoadPoolConfigs(); // load the per-pool config files.
}

Expand Down Expand Up @@ -120,26 +121,28 @@ private void LoadSoftwareManagerConfig()
SoftwareRepositoryConfig = new SoftwareRepositoryConfig(_configFactory, data);
}

private void LoadDefaultPoolConfig()
{
var data = _jsonConfigReader.Read(string.Format("{0}/default.json", PoolConfigRoot));
_defaultPoolConfig = data ?? null; // set the default config data.
}

private void LoadPoolConfigs()
{
PoolConfigs = new List<IPoolConfig>(); // list of pool configurations.
var files = FileHelpers.GetFilesByExtension(PoolConfigRoot, ".json");

foreach (var file in files)
{
var filename = Path.GetFileNameWithoutExtension(file); // read the filename.
if (!string.IsNullOrEmpty(filename) && filename.Equals("default", StringComparison.OrdinalIgnoreCase)) // if it's the default.json,
continue; // just skip it.

var data = _jsonConfigReader.Read(file); // read the pool config json.

if (data == null) // make sure we have loaded json data.
continue;

// check if we have a default.json pool config.
var filename = Path.GetFileNameWithoutExtension(file);
if (!string.IsNullOrEmpty(filename) && filename.Equals("default", StringComparison.OrdinalIgnoreCase))
{
_defaultPoolConfig = data;
continue; // don't add the default.json to list of pools and yet again do not load the coinconfig data for it.
}

if (!data.enabled) // skip pools that are not enabled.
continue;

Expand Down
6 changes: 6 additions & 0 deletions src/CoiniumServ/config/pools/default-example.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"txMessage": "http://www.coiniumserv.com/"
},
"payments": {
"enabled": true,
"interval": 60,
"minimum": 0.01
},
Expand All @@ -20,9 +21,11 @@
"rebroadcastTimeout": 55
},
"stratum": {
"enabled": true,
"bind": "0.0.0.0",
"diff": 16,
"vardiff": {
"enabled": true,
"minDiff": 8,
"maxDiff": 512,
"targetTime": 15,
Expand All @@ -31,13 +34,15 @@
}
},
"banning": {
"enabled": true,
"duration": 600,
"invalidPercent": 50,
"checkThreshold": 100,
"purgeInterval": 300
},
"storage": {
"hybrid": {
"enabled": true,
"redis": {
"host": "127.0.0.1",
"port": 6379,
Expand All @@ -52,6 +57,7 @@
}
},
"mpos": {
"enabled": false,
"mysql": {
"host": "127.0.0.1",
"port": 3306,
Expand Down
19 changes: 1 addition & 18 deletions src/CoiniumServ/config/pools/pool.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,11 @@
"myxWybbhUkGzGF7yaf2QVNx3hh3HWTya5t": 1
}
],
"payments": {
"enabled": true
},
"stratum": {
"enabled": true,
"port": 3333,
"vardiff": {
"enabled": true
}
},
"banning": {
"enabled": true
"port": 3333
},
"storage": {
"hybrid": {
"enabled": false,
"mysql": {
"database": "db-name"
}
},
"mpos": {
"enabled": false,
"mysql": {
"database": "db-name"
}
Expand Down

0 comments on commit 5f33b41

Please sign in to comment.