Beispiel #1
0
        /// <summary>Takes current snapshot.</summary>
        /// <remarks>Not thread-safe. Caller should ensure that it's not called from different threads at once.</remarks>
        public ConsensusRulesPerformanceSnapshot TakeSnapshot()
        {
            var newSnapshot      = new ConsensusRulesPerformanceSnapshot(this.registeredRules);
            var previousSnapshot = this.currentSnapshot;

            this.currentSnapshot = newSnapshot;

            return(previousSnapshot);
        }
Beispiel #2
0
        public ConsensusRulesPerformanceCounter(ConsensusRulesContainer consensusRules)
        {
            this.registeredRules = new List <RuleItem>();

            RegisterRulesCollection(consensusRules.HeaderValidationRules.Select(x => x as IConsensusRuleBase),
                                    RuleType.Header);
            RegisterRulesCollection(consensusRules.IntegrityValidationRules.Select(x => x as IConsensusRuleBase),
                                    RuleType.Integrity);
            RegisterRulesCollection(consensusRules.PartialValidationRules.Select(x => x as IConsensusRuleBase),
                                    RuleType.Partial);
            RegisterRulesCollection(consensusRules.FullValidationRules.Select(x => x as IConsensusRuleBase),
                                    RuleType.Full);

            this.currentSnapshot = new ConsensusRulesPerformanceSnapshot(this.registeredRules);
        }