Skip to content
This repository was archived by the owner on Oct 20, 2023. It is now read-only.

Commit 76f9715

Browse files
author
Oliver Weichhold
committed
cryptonight concurrency init
1 parent 77fc44c commit 76f9715

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/Miningcore/Program.cs

+13-1
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ private static async Task PreFlightChecks(IServiceProvider services)
781781

782782
// Configure Cryptonight
783783
Cryptonight.messageBus = messageBus;
784-
Cryptonight.InitContexts(clusterConfig.CryptonightMaxThreads ?? 1);
784+
Cryptonight.InitContexts(GetDefaultConcurrency(clusterConfig.CryptonightMaxThreads));
785785

786786
// Configure RandomX
787787
RandomX.messageBus = messageBus;
@@ -979,6 +979,18 @@ private static void ConfigureIpRateLimitOptions(IpRateLimitOptions options)
979979
logger.Info(() => $"API access limited to {(string.Join(", ", rules.Select(x => $"{x.Limit} requests per {x.Period}")))}, except from {string.Join(", ", options.IpWhitelist)}");
980980
}
981981

982+
private static int GetDefaultConcurrency(int? value)
983+
{
984+
value = value switch
985+
{
986+
null => 1,
987+
-1 => Environment.ProcessorCount,
988+
_ => value
989+
};
990+
991+
return value.Value;
992+
}
993+
982994
private static void OnAppDomainUnhandledException(object sender, UnhandledExceptionEventArgs e)
983995
{
984996
if(logger != null)

0 commit comments

Comments
 (0)