Skip to content

Commit

Permalink
chore: fix solo proposer
Browse files Browse the repository at this point in the history
  • Loading branch information
limebell committed Jan 17, 2025
1 parent 601ea0d commit 1680bad
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions sdk/node/Libplanet.Node/Services/SoloProposeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,29 @@ public SoloProposeService(
_blockInterval = TimeSpan.FromMilliseconds(options.BlockInterval);
_logger = logger;
_logger.LogInformation(
"SoloProposeService initialized. Interval: {BlockInterval}ms",
"SoloProposeService initialized. Interval: {BlockInterval}",
_blockInterval);
}

protected async override Task ExecuteAsync(CancellationToken stoppingToken)
{
using PeriodicTimer timer = new PeriodicTimer(_blockInterval);

try
{
while (await timer.WaitForNextTickAsync(stoppingToken))
{
await ProposeBlockAsync(stoppingToken);
}
await ProposeBlockAsync(stoppingToken);
}
catch (OperationCanceledException e)
{
_logger.LogInformation(e, "Timed Hosted Service is stopping.");
}
}

private Task ProposeBlockAsync(CancellationToken cancellationToken)
private async Task ProposeBlockAsync(CancellationToken cancellationToken)
{
while (!cancellationToken.IsCancellationRequested)
{
ProposeBlock();
Task.Delay(_blockInterval, cancellationToken);
await Task.Delay(_blockInterval, cancellationToken);
}

return Task.CompletedTask;
}

private void ProposeBlock()
Expand Down

0 comments on commit 1680bad

Please sign in to comment.