Skip to content

Commit

Permalink
Avoid crash on useless config parameters (#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasDorier committed Nov 28, 2024
1 parent 3e0b204 commit 9721474
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions NBXplorer/Configuration/ExplorerConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public ExplorerConfiguration LoadArgs(IConfiguration config)

var obsolete = string.Join(", ",
new[] { "dbtrie", "automigrate", "nomigrateevts", "nomigraterawtxs", "cachechain", "deleteaftermigration", "dbcache" }
.Where(o => TryGetOrDefault<bool>(config, o, false)));
.Where(o => !string.IsNullOrEmpty(config[o])));

if (obsolete != string.Empty)
{
Expand All @@ -216,18 +216,6 @@ public ExplorerConfiguration LoadArgs(IConfiguration config)
return this;
}

private T TryGetOrDefault<T>(IConfiguration conf, string key, T defaultValue)
{
try
{
return conf.GetOrDefault<T>(key, defaultValue);
}
catch
{
return defaultValue;
}
}

private int GetPort(EndPoint nodeEndpoint)
{
if (nodeEndpoint is IPEndPoint endPoint)
Expand Down

0 comments on commit 9721474

Please sign in to comment.