Fixed block template updates when not streaming (Fixes
@@ -85,7 +85,7 @@ namespace MiningCore.Blockchain.Ethereum
private const int MaxBlockBacklog = 3;
protected readonly Dictionary<string, EthereumJob> validJobs = new Dictionary<string, EthereumJob>();
private EthereumPoolConfigExtra extraPoolConfig;
- private JsonSerializer serializer;
+ private readonly JsonSerializer serializer;
protected async Task<bool> UpdateJobAsync()
{
@@ -93,7 +93,7 @@ namespace MiningCore.Blockchain.Ethereum
try
{
- UpdateJob(await GetBlockTemplateAsync());
+ return UpdateJob(await GetBlockTemplateAsync());
}
catch(Exception ex)
@@ -597,23 +597,7 @@ namespace MiningCore.Blockchain.Ethereum
protected virtual void SetupJobUpdates()
{
- if (extraPoolConfig?.EnableDaemonWebsocketStreaming == false)
- {
- Jobs = Observable.Interval(TimeSpan.FromMilliseconds(poolConfig.BlockRefreshInterval))
- .Select(_ => Observable.FromAsync(UpdateJobAsync))
- .Concat()
- .Do(isNew =>
- {
- if (isNew)
- logger.Info(() => $"[{LogCat}] New block {currentJob.BlockTemplate.Height} detected");
- })
- .Where(isNew => isNew)
- .Select(_ => GetJobParamsForStratum(true))
- .Publish()
- .RefCount();
- }
-
- else
+ if (extraPoolConfig?.EnableDaemonWebsocketStreaming == true)
{
var pendingBlockObs = daemon.WebsocketSubscribe(EC.ParitySubscribe,
new[] { (object)EC.GetBlockByNumber, new[] { "pending", (object)true } })
@@ -674,6 +658,22 @@ namespace MiningCore.Blockchain.Ethereum
.Publish()
.RefCount();
}
+
+ else
+ {
+ Jobs = Observable.Interval(TimeSpan.FromMilliseconds(poolConfig.BlockRefreshInterval))
+ .Select(_ => Observable.FromAsync(UpdateJobAsync))
+ .Concat()
+ .Do(isNew =>
+ {
+ if (isNew)
+ logger.Info(() => $"[{LogCat}] New block {currentJob.BlockTemplate.Height} detected");
+ })
+ .Where(isNew => isNew)
+ .Select(_ => GetJobParamsForStratum(true))
+ .Publish()
+ .RefCount();
+ }
}
#endregion // Overrides
