コード例 #1
0
 private void TriggerOnTriggerBlockProduction(object?sender, BlockProductionEventArgs e)
 {
     if (_checkCondition.Invoke(e))
     {
         TriggerBlockProduction?.Invoke(this, e);
     }
 }
コード例 #2
0
 private void InvokeTriggerBlockProduction(BlockProductionEventArgs e)
 {
     if (CanTriggerBlockProduction)
     {
         // if we can trigger production lets do it directly, this should be most common case
         TriggerBlockProduction?.Invoke(this, e);
     }
     else
     {
         // otherwise set delayed production task
         // we need to clone event args as its BlockProductionTask will be awaited in delayed production task
         e.BlockProductionTask = InvokeTriggerBlockProductionDelayed(e.Clone());
     }
 }
コード例 #3
0
        private async Task <Block?> InvokeTriggerBlockProductionDelayed(BlockProductionEventArgs e)
        {
            CancellationToken cancellationToken = e.CancellationToken;

            // retry production until its allowed or its cancelled
            while (!CanTriggerBlockProduction && !cancellationToken.IsCancellationRequested)
            {
                if (_logger.IsDebug)
                {
                    _logger.Debug($"Delaying producing block, chain not processed yet. BlockProcessingQueue count {_blockProcessingQueue.Count}.");
                }
                await Task.Delay(ChainNotYetProcessedMillisecondsDelay, cancellationToken);
            }

            if (!cancellationToken.IsCancellationRequested)
            {
                TriggerBlockProduction?.Invoke(this, e);
            }

            return(await e.BlockProductionTask);
        }
コード例 #4
0
 private void OnBlockProduction(object?sender, BlockProductionEventArgs e)
 {
     e.BlockProductionTask = TryProduceBlock(e.ParentHeader, e.CancellationToken);
 }
コード例 #5
0
 private void OnInnerTriggerBlockProduction(object?sender, BlockProductionEventArgs e) =>
 TriggerBlockProduction?.Invoke(sender, e);
コード例 #6
0
 private void OnTriggerBlockProduction(object?sender, BlockProductionEventArgs e) => InvokeTriggerBlockProduction(e);