public VotingManager( IFederationManager federationManager, IPollResultExecutor pollResultExecutor, INodeStats nodeStats, DataFolder dataFolder, DBreezeSerializer dBreezeSerializer, ISignals signals, Network network, ChainIndexer chainIndexer, IBlockRepository blockRepository = null, INodeLifetime nodeLifetime = null) { this.federationManager = Guard.NotNull(federationManager, nameof(federationManager)); this.pollResultExecutor = Guard.NotNull(pollResultExecutor, nameof(pollResultExecutor)); this.signals = Guard.NotNull(signals, nameof(signals)); this.nodeStats = Guard.NotNull(nodeStats, nameof(nodeStats)); this.locker = new object(); this.votingDataEncoder = new VotingDataEncoder(); this.scheduledVotingData = new List <VotingData>(); this.PollsRepository = new PollsRepository(chainIndexer, dataFolder, dBreezeSerializer, network as PoANetwork); this.logger = LogManager.GetCurrentClassLogger(); this.network = network; this.poaConsensusOptions = (PoAConsensusOptions)this.network.Consensus.Options; Guard.Assert(this.poaConsensusOptions.PollExpiryBlocks != 0); this.blockRepository = blockRepository; this.chainIndexer = chainIndexer; this.nodeLifetime = nodeLifetime; this.isInitialized = false; }
public VotingManager(IFederationManager federationManager, ILoggerFactory loggerFactory, IPollResultExecutor pollResultExecutor, INodeStats nodeStats, DataFolder dataFolder, DBreezeSerializer dBreezeSerializer, ISignals signals, Network network, IBlockRepository blockRepository = null, ChainIndexer chainIndexer = null, INodeLifetime nodeLifetime = null, NodeSettings nodeSettings = null) { this.federationManager = Guard.NotNull(federationManager, nameof(federationManager)); this.pollResultExecutor = Guard.NotNull(pollResultExecutor, nameof(pollResultExecutor)); this.signals = Guard.NotNull(signals, nameof(signals)); this.nodeStats = Guard.NotNull(nodeStats, nameof(nodeStats)); this.locker = new object(); this.votingDataEncoder = new VotingDataEncoder(loggerFactory); this.scheduledVotingData = new List <VotingData>(); this.PollsRepository = new PollsRepository(dataFolder, loggerFactory, dBreezeSerializer, chainIndexer, nodeSettings); this.logger = loggerFactory.CreateLogger(this.GetType().FullName); this.network = network; this.poaConsensusOptions = (PoAConsensusOptions)this.network.Consensus.Options; this.blockRepository = blockRepository; this.chainIndexer = chainIndexer; this.nodeLifetime = nodeLifetime; this.isInitialized = false; }
public SlotsManagerTests() { this.network = new TestPoANetwork(); this.consensusOptions = this.network.ConsensusOptions; this.federationManager = PoATestsBase.CreateFederationManager(this); this.slotsManager = new SlotsManager(this.network, this.federationManager, new LoggerFactory()); }
public SlotsManagerTests() { this.network = new TestPoANetwork(); this.consensusOptions = this.network.ConsensusOptions; (this.federationManager, this.federationHistory) = PoATestsBase.CreateFederationManager(this); this.chainIndexer = new Mock <ChainIndexer>(); this.slotsManager = new SlotsManager(this.network, this.federationManager, this.federationHistory, this.chainIndexer.Object); }
public SlotsManagerTests() { this.network = new TestPoANetwork(); this.consensusOptions = this.network.ConsensusOptions; var fedManager = new FederationManager(NodeSettings.Default(this.network), this.network, new LoggerFactory()); this.slotsManager = new SlotsManager(this.network, fedManager, new LoggerFactory()); }
public SlotsManagerTests() { this.network = new TestPoANetwork(); this.consensusOptions = this.network.ConsensusOptions; this.federationManager = PoATestsBase.CreateFederationManager(this).federationManager; this.chainIndexer = new Mock <ChainIndexer>(); this.slotsManager = new SlotsManager(this.network, this.federationManager, this.chainIndexer.Object, new LoggerFactory()); }
public ReconstructFederationService( IFederationManager federationManager, NodeSettings nodeSettings, Network network, IIdleFederationMembersKicker idleFederationMembersKicker, VotingManager votingManager) { this.federationManager = federationManager; this.idleFederationMembersKicker = idleFederationMembersKicker; this.nodeSettings = nodeSettings; this.votingManager = votingManager; this.locker = new object(); this.logger = LogManager.GetCurrentClassLogger(); this.poaConsensusOptions = (PoAConsensusOptions)network.Consensus.Options; }
/// <inheritdoc /> public override void Initialize() { base.Initialize(); var engine = this.Parent as PoAConsensusRuleEngine; // TODO: Consider adding these via a constructor on this rule. this.slotsManager = engine.SlotsManager; this.federationHistory = engine.FederationHistory; this.validator = engine.PoaHeaderValidator; this.poAConsensusOptions = engine.Network.Consensus.Options as PoAConsensusOptions; KeyValuePair <int, CheckpointInfo> lastCheckPoint = engine.Network.Checkpoints.LastOrDefault(); this.lastCheckPoint = (lastCheckPoint.Value != null) ? new HashHeightPair(lastCheckPoint.Value.Hash, lastCheckPoint.Key) : null; }
public PoATestsBase(TestPoANetwork network = null) { this.loggerFactory = new LoggerFactory(); this.signals = new Signals.Signals(this.loggerFactory, null); this.network = network == null ? new TestPoANetwork() : network; this.consensusOptions = this.network.ConsensusOptions; this.dBreezeSerializer = new DBreezeSerializer(this.network.Consensus.ConsensusFactory); this.ChainIndexer = new ChainIndexer(this.network); IDateTimeProvider timeProvider = new DateTimeProvider(); this.consensusSettings = new ConsensusSettings(NodeSettings.Default(this.network)); this.federationManager = CreateFederationManager(this, this.network, this.loggerFactory, this.signals); this.chainIndexerMock = new Mock <ChainIndexer>(); var header = new BlockHeader(); this.chainIndexerMock.Setup(x => x.Tip).Returns(new ChainedHeader(header, header.GetHash(), 0)); this.slotsManager = new SlotsManager(this.network, this.federationManager, this.chainIndexerMock.Object, this.loggerFactory); this.poaHeaderValidator = new PoABlockHeaderValidator(this.loggerFactory); this.asyncProvider = new AsyncProvider(this.loggerFactory, this.signals, new Mock <INodeLifetime>().Object); var dataFolder = new DataFolder(TestBase.CreateTestDir(this)); var finalizedBlockRepo = new FinalizedBlockInfoRepository(new KeyValueRepository(dataFolder, this.dBreezeSerializer), this.loggerFactory, this.asyncProvider); finalizedBlockRepo.LoadFinalizedBlockInfoAsync(this.network).GetAwaiter().GetResult(); this.resultExecutorMock = new Mock <IPollResultExecutor>(); this.votingManager = new VotingManager(this.federationManager, this.loggerFactory, this.slotsManager, this.resultExecutorMock.Object, new NodeStats(timeProvider, this.loggerFactory), dataFolder, this.dBreezeSerializer, this.signals, finalizedBlockRepo, this.network); this.votingManager.Initialize(); this.chainState = new ChainState(); this.rulesEngine = new PoAConsensusRuleEngine(this.network, this.loggerFactory, new DateTimeProvider(), this.ChainIndexer, new NodeDeployments(this.network, this.ChainIndexer), this.consensusSettings, new Checkpoints(this.network, this.consensusSettings), new Mock <ICoinView>().Object, this.chainState, new InvalidBlockHashStore(timeProvider), new NodeStats(timeProvider, this.loggerFactory), this.slotsManager, this.poaHeaderValidator, this.votingManager, this.federationManager, this.asyncProvider, new ConsensusRulesContainer()); List <ChainedHeader> headers = ChainedHeadersHelper.CreateConsecutiveHeaders(50, null, false, null, this.network); this.currentHeader = headers.Last(); }
public VotingManager(IFederationManager federationManager, ILoggerFactory loggerFactory, IPollResultExecutor pollResultExecutor, INodeStats nodeStats, DataFolder dataFolder, DBreezeSerializer dBreezeSerializer, ISignals signals, IFinalizedBlockInfoRepository finalizedBlockInfo, Network network) { this.federationManager = Guard.NotNull(federationManager, nameof(federationManager)); this.pollResultExecutor = Guard.NotNull(pollResultExecutor, nameof(pollResultExecutor)); this.signals = Guard.NotNull(signals, nameof(signals)); this.nodeStats = Guard.NotNull(nodeStats, nameof(nodeStats)); this.finalizedBlockInfo = Guard.NotNull(finalizedBlockInfo, nameof(finalizedBlockInfo)); this.locker = new object(); this.votingDataEncoder = new VotingDataEncoder(loggerFactory); this.scheduledVotingData = new List <VotingData>(); this.pollsRepository = new PollsRepository(dataFolder, loggerFactory, dBreezeSerializer); this.logger = loggerFactory.CreateLogger(this.GetType().FullName); this.network = network; this.poaConsensusOptions = (PoAConsensusOptions)this.network.Consensus.Options; this.isInitialized = false; }
public PoATestsBase(TestPoANetwork network = null) { this.loggerFactory = new LoggerFactory(); this.signals = new Signals.Signals(this.loggerFactory, null); this.network = network ?? new TestPoANetwork(); this.consensusOptions = this.network.ConsensusOptions; this.dBreezeSerializer = new DBreezeSerializer(this.network.Consensus.ConsensusFactory); this.ChainIndexer = new ChainIndexer(this.network); IDateTimeProvider dateTimeProvider = new DateTimeProvider(); this.consensusSettings = new ConsensusSettings(NodeSettings.Default(this.network)); (this.federationManager, this.federationHistory) = CreateFederationManager(this, this.network, this.loggerFactory, this.signals); this.slotsManager = new SlotsManager(this.network, this.federationManager, this.federationHistory, this.ChainIndexer); this.poaHeaderValidator = new PoABlockHeaderValidator(this.loggerFactory); this.asyncProvider = new AsyncProvider(this.loggerFactory, this.signals); var dataFolder = new DataFolder(TestBase.CreateTestDir(this)); this.resultExecutorMock = new Mock <IPollResultExecutor>(); this.votingManager = new VotingManager(this.federationManager, this.resultExecutorMock.Object, new NodeStats(dateTimeProvider, NodeSettings.Default(this.network), new Mock <IVersionProvider>().Object), dataFolder, this.dBreezeSerializer, this.signals, this.network, this.ChainIndexer, null); this.votingManager.Initialize(this.federationHistory); this.chainState = new ChainState(); this.rulesEngine = new PoAConsensusRuleEngine(this.network, this.loggerFactory, new DateTimeProvider(), this.ChainIndexer, new NodeDeployments(this.network, this.ChainIndexer), this.consensusSettings, new Checkpoints(this.network, this.consensusSettings), new Mock <ICoinView>().Object, this.chainState, new InvalidBlockHashStore(dateTimeProvider), new NodeStats(dateTimeProvider, NodeSettings.Default(this.network), new Mock <IVersionProvider>().Object), this.slotsManager, this.poaHeaderValidator, this.votingManager, this.federationManager, this.asyncProvider, new ConsensusRulesContainer(), this.federationHistory); List <ChainedHeader> headers = ChainedHeadersHelper.CreateConsecutiveHeaders(50, null, false, null, this.network); this.currentHeader = headers.Last(); }
public PoARulesTestsBase(PoANetwork network = null) { this.loggerFactory = new LoggerFactory(); this.network = network == null ? new PoANetwork() : network; this.consensusOptions = this.network.ConsensusOptions; this.chain = new ConcurrentChain(this.network); IDateTimeProvider timeProvider = new DateTimeProvider(); this.consensusSettings = new ConsensusSettings(NodeSettings.Default(this.network)); this.slotsManager = new SlotsManager(this.network, new FederationManager(NodeSettings.Default(this.network), this.network, this.loggerFactory), this.loggerFactory); this.poaHeaderValidator = new PoABlockHeaderValidator(this.loggerFactory); this.rulesEngine = new PoAConsensusRuleEngine(this.network, this.loggerFactory, new DateTimeProvider(), this.chain, new NodeDeployments(this.network, this.chain), this.consensusSettings, new Checkpoints(this.network, this.consensusSettings), new Mock <ICoinView>().Object, new ChainState(), new InvalidBlockHashStore(timeProvider), new NodeStats(timeProvider), this.slotsManager, this.poaHeaderValidator); List <ChainedHeader> headers = ChainedHeadersHelper.CreateConsecutiveHeaders(50, null, false, null, this.network); this.currentHeader = headers.Last(); }