Skip to content

Commit

Permalink
filter out empty modules
Browse files Browse the repository at this point in the history
  • Loading branch information
LukaszRozmej committed Dec 11, 2024
1 parent f721a3f commit 93d87d0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/Nethermind/Nethermind.JsonRpc/JsonRpcConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class JsonRpcConfig : IJsonRpcConfig
{
public static readonly JsonRpcConfig Default = new();
private int? _webSocketsPort;
private string[] _enabledModules = ModuleType.DefaultModules.ToArray();
public bool Enabled { get; set; }
public string Host { get; set; } = "127.0.0.1";
public int Timeout { get; set; } = 20000;
Expand All @@ -29,7 +30,15 @@ public int WebSocketsPort

public string? IpcUnixDomainSocketPath { get; set; } = null;

public string[] EnabledModules { get; set; } = ModuleType.DefaultModules.ToArray();
public string[] EnabledModules
{
get => _enabledModules;
set
{
_enabledModules = value.Where(m => !string.IsNullOrWhiteSpace(m)).ToArray();
}
}

public string[] AdditionalRpcUrls { get; set; } = [];
public long? GasCap { get; set; } = 100000000;
public int ReportIntervalSeconds { get; set; } = 300;
Expand Down
5 changes: 3 additions & 2 deletions src/Nethermind/Nethermind.JsonRpc/JsonRpcUrlCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ public JsonRpcUrlCollection(ILogManager logManager, IJsonRpcConfig jsonRpcConfig

private void BuildUrls(bool includeWebSockets)
{
bool HasEngineApi = _jsonRpcConfig.EnabledModules.Any(m => m.Equals(ModuleType.Engine, StringComparison.InvariantCultureIgnoreCase));
JsonRpcUrl defaultUrl = new(Uri.UriSchemeHttp, _jsonRpcConfig.Host, _jsonRpcConfig.Port, RpcEndpoint.Http, HasEngineApi, _jsonRpcConfig.EnabledModules, HasEngineApi ? SocketClient<WebSocketMessageStream>.MAX_REQUEST_BODY_SIZE_FOR_ENGINE_API : _jsonRpcConfig.MaxRequestBodySize);
bool hasEngineApi = _jsonRpcConfig.EnabledModules.Any(m => m.Equals(ModuleType.Engine, StringComparison.InvariantCultureIgnoreCase));
long? maxRequestBodySize = hasEngineApi ? SocketClient<WebSocketMessageStream>.MAX_REQUEST_BODY_SIZE_FOR_ENGINE_API : _jsonRpcConfig.MaxRequestBodySize;
JsonRpcUrl defaultUrl = new(Uri.UriSchemeHttp, _jsonRpcConfig.Host, _jsonRpcConfig.Port, RpcEndpoint.Http, hasEngineApi, _jsonRpcConfig.EnabledModules, maxRequestBodySize);

Add(defaultUrl.Port, defaultUrl);

Expand Down

0 comments on commit 93d87d0

Please sign in to comment.