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); }
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; }
private uint GetRoundLengthSeconds(PoAConsensusOptions poAConsensusOptions, int?federationMembersCount) { uint roundLength = (uint)(federationMembersCount * poAConsensusOptions.TargetSpacingSeconds); return(roundLength); }
/// <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]); }