예제 #1
0
 public SlotsManager(Network network, IFederationManager federationManager, ChainIndexer chainIndexer, ILoggerFactory loggerFactory)
 {
     Guard.NotNull(network, nameof(network));
     this.federationManager = Guard.NotNull(federationManager, nameof(federationManager));
     this.chainIndexer      = chainIndexer;
     this.consensusOptions  = (network as PoANetwork).ConsensusOptions;
     this.logger            = loggerFactory.CreateLogger(this.GetType().FullName);
 }
예제 #2
0
        public SlotsManager(Network network, FederationManager federationManager, ILoggerFactory loggerFactory)
        {
            Guard.NotNull(network, nameof(network));
            this.federationManager = Guard.NotNull(federationManager, nameof(federationManager));

            this.consensusOptions = (network as PoANetwork).ConsensusOptions;
            this.logger           = loggerFactory.CreateLogger("Impleum.Bitcoin.FullNode");
        }
        public SlotsManager(Network network, IFederationManager federationManager, IFederationHistory federationHistory, ChainIndexer chainIndexer)
        {
            Guard.NotNull(network, nameof(network));

            this.federationManager = Guard.NotNull(federationManager, nameof(federationManager));
            this.federationHistory = federationHistory;
            this.chainIndexer      = chainIndexer;
            this.consensusOptions  = (network as PoANetwork).ConsensusOptions;
        }
예제 #4
0
        private uint GetRoundLengthSeconds(PoAConsensusOptions poAConsensusOptions, int?federationMembersCount)
        {
            uint roundLength = (uint)(federationMembersCount * poAConsensusOptions.TargetSpacingSeconds);

            return(roundLength);
        }
예제 #5
0
        /// <inheritdoc />
        public IFederationMember GetFederationMemberForTimestamp(uint headerUnixTimestamp, PoAConsensusOptions poAConsensusOptions)
        {
            List <IFederationMember> federationMembers = this.federationManager.GetFederationMembers();

            uint roundTime = this.GetRoundLengthSeconds(poAConsensusOptions, federationMembers.Count);

            // Time when current round started.
            uint roundStartTimestamp = (headerUnixTimestamp / roundTime) * roundTime;

            // Slot number in current round.
            int currentSlotNumber = (int)((headerUnixTimestamp - roundStartTimestamp) / poAConsensusOptions.TargetSpacingSeconds);

            return(federationMembers[currentSlotNumber]);
        }