private void FinalizeBlocks(BlockHeader finalizingBlock)
        {
            var finalizedBlocks = GetFinalizedBlocks(finalizingBlock);

            if (finalizedBlocks.Any())
            {
                if (_logger.IsDebug)
                {
                    _logger.Debug(finalizedBlocks.Count == 1
                        ? $"Finalizing block {finalizedBlocks[0].Number} by block {finalizingBlock.Number}."
                        : $"Finalizing blocks {finalizedBlocks[0].Number}-{finalizedBlocks[finalizedBlocks.Count - 1].Number} by block {finalizingBlock.Number}.");
                }

                BlocksFinalized?.Invoke(this, new FinalizeEventArgs(finalizingBlock, finalizedBlocks));
                LastFinalizedBlockLevel = finalizedBlocks[finalizedBlocks.Count - 1].Number;
            }
        }
        private void FinalizeBlocks(BlockHeader finalizingBlock)
        {
            var finalizedBlocks = GetFinalizedBlocks(finalizingBlock);

            if (finalizedBlocks.Any())
            {
                if (_logger.IsDebug)
                {
                    _logger.Debug(finalizedBlocks.Count == 1
                        ? $"Blocks finalized by {finalizingBlock.ToString(BlockHeader.Format.FullHashAndNumber)} : {finalizedBlocks[0].ToString(BlockHeader.Format.FullHashAndNumber)}."
                        : $"Blocks finalized by {finalizingBlock.ToString(BlockHeader.Format.FullHashAndNumber)}: {finalizedBlocks[0].Number}-{finalizedBlocks[finalizedBlocks.Count - 1].Number} [{string.Join(",", finalizedBlocks.Select(b => b.Hash))}].");
                }

                BlocksFinalized?.Invoke(this, new FinalizeEventArgs(finalizingBlock, finalizedBlocks));
                LastFinalizedBlockLevel = finalizedBlocks[finalizedBlocks.Count - 1].Number;
            }
        }
Ejemplo n.º 3
0
 private void OnBlockFinalized(object?sender, FinalizeEventArgs e)
 {
     BlocksFinalized?.Invoke(this, e);
 }
 public void MarkFinalized(BlockHeader finalizingBlock, BlockHeader finalizedBlock)
 {
     LastFinalizedHash       = finalizedBlock.Hash !;
     LastFinalizedBlockLevel = Math.Max(LastFinalizedBlockLevel, finalizedBlock.Number);
     BlocksFinalized?.Invoke(this, new FinalizeEventArgs(finalizingBlock, finalizedBlock));
 }