Beispiel #1
0
        public Task <Block?> BuildBlock(BlockHeader?parentHeader = null, CancellationToken?cancellationToken = null, IBlockTracer?blockTracer = null)
        {
            BlockProductionEventArgs args = new(parentHeader, cancellationToken, blockTracer);

            TriggerBlockProduction?.Invoke(this, args);
            return(args.BlockProductionTask);
        }
Beispiel #2
0
 private void TriggerOnTriggerBlockProduction(object?sender, BlockProductionEventArgs e)
 {
     if (_checkCondition.Invoke(e))
     {
         TriggerBlockProduction?.Invoke(this, e);
     }
 }
Beispiel #3
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());
     }
 }
Beispiel #4
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);
        }
Beispiel #5
0
 private void TxPoolOnNewPending(object?sender, TxEventArgs e)
 {
     TriggerBlockProduction?.Invoke(this, new BlockProductionEventArgs());
 }
 private void TimerOnElapsed(object sender, ElapsedEventArgs e)
 {
     TriggerBlockProduction?.Invoke(this, new BlockProductionEventArgs());
     _timer.Enabled = true;
 }
 private void OnInnerTriggerBlockProduction(object?sender, BlockProductionEventArgs e) =>
 TriggerBlockProduction?.Invoke(sender, e);
 private void BlockProductionTriggerOnTriggerBlockProduction(object?sender, EventArgs e)
 {
     TriggerBlockProduction?.Invoke(sender, e);
 }
 public void BuildBlock()
 {
     TriggerBlockProduction?.Invoke(this, EventArgs.Empty);
 }