Skip to content

Commit

Permalink
Resolve the issue of not being able to produce a block
Browse files Browse the repository at this point in the history
  • Loading branch information
chopin-fan committed Jan 10, 2025
1 parent 103ebda commit f8047f1
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,17 @@ protected override async Task ProcessLogEventAsync(Block block, LogEvent logEven
var distanceToLib = new IrreversibleBlockHeightUnacceptable();
distanceToLib.MergeFrom(logEvent);

if (distanceToLib.DistanceToIrreversibleBlockHeight > 0)
{
var chain = await _blockchainService.GetChainAsync();
Logger.LogDebug($"Distance to lib height: {distanceToLib.DistanceToIrreversibleBlockHeight}");
if ( block.Height - chain.LastIrreversibleBlockHeight < distanceToLib.DistanceToIrreversibleBlockHeight/2)
{
return;
}
Logger.LogDebug("Will rollback to lib height.");
_taskQueueManager.Enqueue(
async () =>
{
var chain = await _blockchainService.GetChainAsync();
await _blockchainService.ResetChainToLibAsync(chain);
}, KernelConstants.UpdateChainQueueName);
}
Expand Down

0 comments on commit f8047f1

Please sign in to comment.