/// <summary>
    /// Triggers full pruning.
    /// </summary>
    /// <returns>Status of triggering full pruning.</returns>
    public PruningStatus Trigger()
    {
        PruningTriggerEventArgs args = new PruningTriggerEventArgs();

        Prune?.Invoke(this, args);
        return(args.Status);
    }
Example #2
0
        /// <summary>
        /// Is activated by pruning trigger, tries to start full pruning.
        /// </summary>
        private void OnPrune(object?sender, PruningTriggerEventArgs e)
        {
            // Lets assume pruning is in progress
            e.Status = PruningStatus.InProgress;

            if (DateTime.Now - _lastPruning < _minimumPruningDelay)
            {
                e.Status = PruningStatus.Delayed;
            }
            // If we are already pruning, we don't need to do anything
            else if (CanStartNewPruning())
            {
                // we mark that we are waiting for block (for thread safety)
                if (Interlocked.CompareExchange(ref _waitingForBlockProcessed, 1, 0) == 0)
                {
                    // we don't want to start pruning in the middle of block processing, lets wait for new head.
                    _blockTree.NewHeadBlock += OnNewHead;
                    e.Status = PruningStatus.Starting;
                }
            }
        }
Example #3
0
 private void OnPrune(object?sender, PruningTriggerEventArgs e)
 {
     Prune?.Invoke(sender, e);
 }