예제 #1
0
        public Hashgraph(Dictionary <string, int> participants, IStore store, Channel <Event> commitCh, ILogger logger)
        {
            this.logger = logger.AddNamedContext("HashGraph");
            var reverseParticipants = participants.ToDictionary(p => p.Value, p => p.Key);
            var cacheSize           = store.CacheSize();

            Participants        = participants;
            ReverseParticipants = reverseParticipants;
            Store                   = store;
            CommitChannel           = commitCh;
            AncestorCache           = new LruCache <string, bool>(cacheSize, null, logger, "AncestorCache");
            SelfAncestorCache       = new LruCache <string, bool>(cacheSize, null, logger, "SelfAncestorCache");
            OldestSelfAncestorCache = new LruCache <string, string>(cacheSize, null, logger, "OldestAncestorCache");
            StronglySeeCache        = new LruCache <string, bool>(cacheSize, null, logger, "StronglySeeCache");
            ParentRoundCache        = new LruCache <string, ParentRoundInfo>(cacheSize, null, logger, "ParentRoundCache");
            RoundCache              = new LruCache <string, int>(cacheSize, null, logger, "RoundCache");
            UndeterminedEvents      = new List <string>();
            SuperMajority           = 2 * participants.Count / 3 + 1;
            UndecidedRounds         = new Queue <int>(); //initialize
        }