public TestFederatedPegBlockDefinition(
     IBlockBufferGenerator blockBufferGenerator,
     ICoinView coinView,
     IConsensusManager consensusManager,
     IDateTimeProvider dateTimeProvider,
     IContractExecutorFactory executorFactory,
     ILoggerFactory loggerFactory,
     ITxMempool mempool,
     MempoolSchedulerLock mempoolLock,
     Network network,
     ISenderRetriever senderRetriever,
     IStateRepositoryRoot stateRoot,
     MinerSettings minerSettings)
     : base(blockBufferGenerator, coinView, consensusManager, dateTimeProvider, executorFactory, loggerFactory, mempool, mempoolLock, network, senderRetriever, stateRoot, minerSettings)
 {
 }
Exemplo n.º 2
0
 public PosPowBlockDefinition(
     IConsensusManager consensusManager,
     IDateTimeProvider dateTimeProvider,
     ILoggerFactory loggerFactory,
     ITxMempool mempool,
     MempoolSchedulerLock mempoolLock,
     Network network,
     MinerSettings minerSettings,
     IStakeChain stakeChain,
     IStakeValidator stakeValidator)
     : base(consensusManager, dateTimeProvider, loggerFactory, mempool, mempoolLock, minerSettings, network)
 {
     this.logger         = loggerFactory.CreateLogger(this.GetType().FullName);
     this.stakeChain     = stakeChain;
     this.stakeValidator = stakeValidator;
 }
Exemplo n.º 3
0
 public ColdStakingWalletRPCController(
     IBlockStore blockStore,
     IBroadcasterManager broadcasterManager,
     ChainIndexer chainIndexer,
     IConsensusManager consensusManager,
     IFullNode fullNode,
     ILoggerFactory loggerFactory,
     Network network,
     IScriptAddressReader scriptAddressReader,
     StoreSettings storeSettings,
     IWalletManager walletManager,
     WalletSettings walletSettings,
     IWalletTransactionHandler walletTransactionHandler) :
     base(blockStore, broadcasterManager, chainIndexer, consensusManager, fullNode, loggerFactory, network, scriptAddressReader, storeSettings, walletManager, walletSettings, walletTransactionHandler)
 {
 }
Exemplo n.º 4
0
        public PoAFeature(FederationManager federationManager, PayloadProvider payloadProvider, IConnectionManager connectionManager, ConcurrentChain chain,
                          IInitialBlockDownloadState initialBlockDownloadState, IConsensusManager consensusManager, IPeerBanning peerBanning, ILoggerFactory loggerFactory,
                          IPoAMiner miner, VotingManager votingManager)
        {
            this.federationManager         = federationManager;
            this.connectionManager         = connectionManager;
            this.chain                     = chain;
            this.initialBlockDownloadState = initialBlockDownloadState;
            this.consensusManager          = consensusManager;
            this.peerBanning               = peerBanning;
            this.loggerFactory             = loggerFactory;
            this.miner                     = miner;
            this.votingManager             = votingManager;

            payloadProvider.DiscoverPayloads(this.GetType().Assembly);
        }
Exemplo n.º 5
0
        public FederationGatewayControllerTests()
        {
            this.network = FederatedPegNetwork.NetworksSelector.Regtest();

            this.loggerFactory = Substitute.For <ILoggerFactory>();
            this.logger        = Substitute.For <ILogger>();
            this.loggerFactory.CreateLogger(null).ReturnsForAnyArgs(this.logger);
            this.leaderProvider            = Substitute.For <ILeaderProvider>();
            this.depositExtractor          = Substitute.For <IDepositExtractor>();
            this.leaderReceiver            = Substitute.For <ILeaderReceiver>();
            this.consensusManager          = Substitute.For <IConsensusManager>();
            this.federationGatewaySettings = Substitute.For <IFederationGatewaySettings>();
            this.federationWalletManager   = Substitute.For <IFederationWalletManager>();
            this.keyValueRepository        = Substitute.For <IKeyValueRepository>();
            this.federationManager         = new FederationManager(NodeSettings.Default(this.network), this.network, this.loggerFactory, this.keyValueRepository);
        }
Exemplo n.º 6
0
        public ConsensusFeature(
            Network network,
            IChainState chainState,
            IConnectionManager connectionManager,
            Signals.ISignals signals,
            IConsensusManager consensusManager,
            NodeDeployments nodeDeployments)
        {
            this.chainState        = chainState;
            this.connectionManager = connectionManager;
            this.signals           = signals;
            this.consensusManager  = consensusManager;
            this.nodeDeployments   = nodeDeployments;

            this.chainState.MaxReorgLength = network.Consensus.MaxReorgLength;
        }
 public PowBlockDefinition(
     IConsensusManager consensusManager,
     IDateTimeProvider dateTimeProvider,
     ILoggerFactory loggerFactory,
     ITxMempool mempool,
     MempoolSchedulerLock mempoolLock,
     MinerSettings minerSettings,
     Network network,
     IConsensusRuleEngine consensusRules,
     NodeDeployments nodeDeployments,
     BlockDefinitionOptions options = null)
     : base(consensusManager, dateTimeProvider, loggerFactory, mempool, mempoolLock, minerSettings, network, nodeDeployments)
 {
     this.consensusRules = consensusRules;
     this.logger         = loggerFactory.CreateLogger(this.GetType().FullName);
 }
        public FederationGatewayControllerTests()
        {
            this.network = CirrusNetwork.NetworksSelector.Regtest();

            this.crossChainTransferStore = Substitute.For <ICrossChainTransferStore>();
            this.loggerFactory           = Substitute.For <ILoggerFactory>();
            this.logger = Substitute.For <ILogger>();
            this.loggerFactory.CreateLogger(null).ReturnsForAnyArgs(this.logger);
            this.depositExtractor        = Substitute.For <IDepositExtractor>();
            this.consensusManager        = Substitute.For <IConsensusManager>();
            this.federatedPegSettings    = Substitute.For <IFederatedPegSettings>();
            this.federationWalletManager = Substitute.For <IFederationWalletManager>();
            this.signals = new Signals(this.loggerFactory, null);

            this.signedMultisigTransactionBroadcaster = Substitute.For <ISignedMultisigTransactionBroadcaster>();
        }
        public IdleFederationMembersKicker(ISignals signals, Network network, IKeyValueRepository keyValueRepository, IConsensusManager consensusManager,
                                           IFederationManager federationManager, ISlotsManager slotsManager, VotingManager votingManager, ILoggerFactory loggerFactory, IDateTimeProvider timeProvider)
        {
            this.signals            = signals;
            this.network            = network;
            this.keyValueRepository = keyValueRepository;
            this.consensusManager   = consensusManager;
            this.federationManager  = federationManager;
            this.slotsManager       = slotsManager;
            this.votingManager      = votingManager;
            this.timeProvider       = timeProvider;

            this.consensusFactory = this.network.Consensus.ConsensusFactory as PoAConsensusFactory;
            this.logger           = loggerFactory.CreateLogger(this.GetType().FullName);
            this.federationMemberMaxIdleTimeSeconds = ((PoAConsensusOptions)network.Consensus.Options).FederationMemberMaxIdleTimeSeconds;
        }
Exemplo n.º 10
0
 public WalletRPCController(IWalletManager walletManager,
                            IWalletTransactionHandler walletTransactionHandler,
                            IFullNode fullNode,
                            IBroadcasterManager broadcasterManager,
                            IConsensusManager consensusManager,
                            ConcurrentChain chain,
                            ILoggerFactory loggerFactory,
                            WalletSettings walletSettings) : base(fullNode: fullNode, consensusManager: consensusManager, chain: chain)
 {
     this.walletManager            = walletManager;
     this.walletTransactionHandler = walletTransactionHandler;
     this.fullNode           = fullNode;
     this.broadcasterManager = broadcasterManager;
     this.logger             = loggerFactory.CreateLogger(this.GetType().FullName);
     this.walletSettings     = walletSettings;
 }
 public PosBlockDefinition(
     IConsensusManager consensusManager,
     IDateTimeProvider dateTimeProvider,
     ILoggerFactory loggerFactory,
     ITxMempool mempool,
     MempoolSchedulerLock mempoolLock,
     MinerSettings minerSettings,
     Network network,
     IStakeChain stakeChain,
     IStakeValidator stakeValidator)
     : base(consensusManager, dateTimeProvider, loggerFactory, mempool, mempoolLock, minerSettings, network)
 {
     this.logger         = loggerFactory.CreateLogger("Impleum.Bitcoin.Fullnode");
     this.stakeChain     = stakeChain;
     this.stakeValidator = stakeValidator;
 }
Exemplo n.º 12
0
        public MiningController(IConsensusManager consensusManager, IFullNode fullNode, ILoggerFactory loggerFactory, Network network, IPowMining powMining, IWalletManager walletManager)
        {
            Guard.NotNull(consensusManager, nameof(consensusManager));
            Guard.NotNull(fullNode, nameof(fullNode));
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(network, nameof(network));
            Guard.NotNull(powMining, nameof(powMining));
            Guard.NotNull(walletManager, nameof(walletManager));

            this.consensusManager = consensusManager;
            this.logger           = loggerFactory.CreateLogger(this.GetType().FullName);
            this.miningFeature    = fullNode.NodeFeature <MiningFeature>();
            this.network          = network;
            this.powMining        = powMining;
            this.walletManager    = walletManager;
        }
Exemplo n.º 13
0
 public WalletRPCController(IWalletManager walletManager,
                            IWalletTransactionHandler walletTransactionHandler,
                            IFullNode fullNode,
                            IBroadcasterManager broadcasterManager,
                            IConsensusManager consensusManager,
                            ChainIndexer chainIndexer,
                            ILoggerFactory loggerFactory,
                            WalletSettings walletSettings) : base(fullNode: fullNode, consensusManager: consensusManager, chainIndexer: chainIndexer)
 {
     this.walletManager            = walletManager;
     this.walletTransactionHandler = walletTransactionHandler;
     this.fullNode           = fullNode;
     this.broadcasterManager = broadcasterManager;
     this.logger             = loggerFactory.CreateLogger("Impleum.Bitcoin.FullNode");
     this.walletSettings     = walletSettings;
 }
Exemplo n.º 14
0
        public NodeController(
            ChainIndexer chainIndexer,
            IChainState chainState,
            IConnectionManager connectionManager,
            IDateTimeProvider dateTimeProvider,
            IFullNode fullNode,
            ILoggerFactory loggerFactory,
            NodeSettings nodeSettings,
            Network network,
            IAsyncProvider asyncProvider,
            ISelfEndpointTracker selfEndpointTracker,
            IConsensusManager consensusManager,
            IBlockStore blockStore,
            IGetUnspentTransaction getUnspentTransaction             = null,
            INetworkDifficulty networkDifficulty                     = null,
            IPooledGetUnspentTransaction pooledGetUnspentTransaction = null,
            IPooledTransaction pooledTransaction                     = null)
        {
            Guard.NotNull(fullNode, nameof(fullNode));
            Guard.NotNull(network, nameof(network));
            Guard.NotNull(chainIndexer, nameof(chainIndexer));
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(nodeSettings, nameof(nodeSettings));
            Guard.NotNull(chainState, nameof(chainState));
            Guard.NotNull(connectionManager, nameof(connectionManager));
            Guard.NotNull(dateTimeProvider, nameof(dateTimeProvider));
            Guard.NotNull(asyncProvider, nameof(asyncProvider));
            Guard.NotNull(selfEndpointTracker, nameof(selfEndpointTracker));

            this.chainIndexer        = chainIndexer;
            this.chainState          = chainState;
            this.connectionManager   = connectionManager;
            this.dateTimeProvider    = dateTimeProvider;
            this.fullNode            = fullNode;
            this.logger              = loggerFactory.CreateLogger(this.GetType().FullName);
            this.network             = network;
            this.nodeSettings        = nodeSettings;
            this.asyncProvider       = asyncProvider;
            this.selfEndpointTracker = selfEndpointTracker;

            this.consensusManager            = consensusManager;
            this.blockStore                  = blockStore;
            this.getUnspentTransaction       = getUnspentTransaction;
            this.networkDifficulty           = networkDifficulty;
            this.pooledGetUnspentTransaction = pooledGetUnspentTransaction;
            this.pooledTransaction           = pooledTransaction;
        }
Exemplo n.º 15
0
        /// <inheritdoc />
        public void Initialize(IConsensusManager consensusManager)
        {
            this.consensusManager = consensusManager;
            this.AddExternalIpToSelfEndpoints();

            if (this.ConnectionSettings.Listen)
            {
                this.peerDiscovery.DiscoverPeers(this);
            }

            foreach (IPeerConnector peerConnector in this.PeerConnectors)
            {
                peerConnector.Initialize(this);
                peerConnector.StartConnectAsync();
            }

            if (this.ConnectionSettings.Listen)
            {
                this.StartNodeServer();
            }

            // If external IP address supplied this overrides all.
            if (this.ConnectionSettings.ExternalEndpoint != null)
            {
                if (this.ConnectionSettings.ExternalEndpoint.Address.Equals(IPAddress.Loopback))
                {
                    this.selfEndpointTracker.UpdateAndAssignMyExternalAddress(this.ConnectionSettings.ExternalEndpoint, false);
                }
                else
                {
                    this.selfEndpointTracker.UpdateAndAssignMyExternalAddress(this.ConnectionSettings.ExternalEndpoint, true);
                }
            }
            else
            {
                // If external IP address not supplied take first routable bind address and set score to 10.
                IPEndPoint nodeServerEndpoint = this.ConnectionSettings.Bind?.FirstOrDefault(x => x.Endpoint.Address.IsRoutable(false))?.Endpoint;
                if (nodeServerEndpoint != null)
                {
                    this.selfEndpointTracker.UpdateAndAssignMyExternalAddress(nodeServerEndpoint, false, 10);
                }
                else
                {
                    this.selfEndpointTracker.UpdateAndAssignMyExternalAddress(new IPEndPoint(IPAddress.Parse("0.0.0.0").MapToIPv6Ex(), this.ConnectionSettings.Port), false);
                }
            }
        }
Exemplo n.º 16
0
 public FeatureController(
     IFullNode fullNode                   = null,
     Network network                      = null,
     NodeSettings nodeSettings            = null,
     ChainIndexer chainIndexer            = null,
     IChainState chainState               = null,
     IConnectionManager connectionManager = null,
     IConsensusManager consensusManager   = null)
 {
     this.FullNode          = fullNode;
     this.Settings          = nodeSettings;
     this.Network           = network;
     this.ChainIndexer      = chainIndexer;
     this.ChainState        = chainState;
     this.ConnectionManager = connectionManager;
     this.ConsensusManager  = consensusManager;
 }
Exemplo n.º 17
0
        public PoAMiner(
            IConsensusManager consensusManager,
            IDateTimeProvider dateTimeProvider,
            Network network,
            INodeLifetime nodeLifetime,
            ILoggerFactory loggerFactory,
            IInitialBlockDownloadState ibdState,
            BlockDefinition blockDefinition,
            ISlotsManager slotsManager,
            IConnectionManager connectionManager,
            PoABlockHeaderValidator poaHeaderValidator,
            IFederationManager federationManager,
            IFederationHistory federationHistory,
            IIntegrityValidator integrityValidator,
            IWalletManager walletManager,
            INodeStats nodeStats,
            VotingManager votingManager,
            PoASettings poAMinerSettings,
            IAsyncProvider asyncProvider,
            IIdleFederationMembersKicker idleFederationMembersKicker,
            NodeSettings nodeSettings)
        {
            this.consensusManager            = consensusManager;
            this.dateTimeProvider            = dateTimeProvider;
            this.network                     = network as PoANetwork;
            this.ibdState                    = ibdState;
            this.blockDefinition             = blockDefinition;
            this.slotsManager                = slotsManager;
            this.connectionManager           = connectionManager;
            this.poaHeaderValidator          = poaHeaderValidator;
            this.federationManager           = federationManager;
            this.federationHistory           = federationHistory;
            this.integrityValidator          = integrityValidator;
            this.walletManager               = walletManager;
            this.votingManager               = votingManager;
            this.poaSettings                 = poAMinerSettings;
            this.asyncProvider               = asyncProvider;
            this.idleFederationMembersKicker = idleFederationMembersKicker;

            this.logger            = loggerFactory.CreateLogger(this.GetType().FullName);
            this.cancellation      = CancellationTokenSource.CreateLinkedTokenSource(new[] { nodeLifetime.ApplicationStopping });
            this.votingDataEncoder = new VotingDataEncoder(loggerFactory);
            this.nodeSettings      = nodeSettings;

            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component, this.GetType().Name);
        }
Exemplo n.º 18
0
        public void Setup()
        {
            _container?.Dispose();
            TestUtils.DeleteTestChainData();

            var containerBuilder = new SimpleInjectorContainerBuilder(new ConfigManager(
                                                                          Path.Join(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "config2.json"),
                                                                          new RunOptions()
                                                                          ));

            containerBuilder.RegisterModule <BlockchainModule>();
            containerBuilder.RegisterModule <ConfigModule>();
            containerBuilder.RegisterModule <StorageModule>();
            containerBuilder.RegisterModule <ConsensusModule>();
            containerBuilder.RegisterModule <NetworkModule>();

            _container = containerBuilder.Build();

            _stateManager           = _container.Resolve <IStateManager>();
            _transactionManager     = _container.Resolve <ITransactionManager>();
            _transactionBuilder     = _container.Resolve <ITransactionBuilder>();
            _transactionSigner      = _container.Resolve <ITransactionSigner>();
            _transactionPool        = _container.Resolve <ITransactionPool>();
            _contractRegisterer     = _container.Resolve <IContractRegisterer>();
            _privateWallet          = _container.Resolve <IPrivateWallet>();
            _snapshotIndexer        = _container.Resolve <ISnapshotIndexRepository>();
            _networkManager         = _container.Resolve <INetworkManager>();
            _nodeRetrieval          = _container.Resolve <INodeRetrieval>();
            _systemContractReader   = _container.Resolve <ISystemContractReader>();
            _blockManager           = _container.Resolve <IBlockManager>();
            _validatorStatusManager = _container.Resolve <IValidatorStatusManager>();
            _configManager          = _container.Resolve <IConfigManager>();
            _consensusManager       = _container.Resolve <IConsensusManager>();
            if (TransactionUtils.ChainId(false) == 0)
            {
                var chainId    = _configManager.GetConfig <NetworkConfig>("network")?.ChainId;
                var newChainId = _configManager.GetConfig <NetworkConfig>("network")?.NewChainId;
                TransactionUtils.SetChainId((int)chainId !, (int)newChainId !);
                HardforkHeights.SetHardforkHeights(_configManager.GetConfig <HardforkConfig>("hardfork") ?? throw new InvalidOperationException());
            }

            ServiceBinder.BindService <GenericParameterAttributes>();
            _apiService = new BlockchainServiceWeb3(_transactionManager, _blockManager, _transactionPool,
                                                    _stateManager, _snapshotIndexer, _networkManager, _nodeRetrieval, _systemContractReader, _consensusManager);
        }
Exemplo n.º 19
0
 public SmartContractPoABlockDefinition(
     IBlockBufferGenerator blockBufferGenerator,
     ICoinView coinView,
     IConsensusManager consensusManager,
     IDateTimeProvider dateTimeProvider,
     IContractExecutorFactory executorFactory,
     ILoggerFactory loggerFactory,
     ITxMempool mempool,
     MempoolSchedulerLock mempoolLock,
     Network network,
     ISenderRetriever senderRetriever,
     IStateRepositoryRoot stateRoot,
     MinerSettings minerSettings)
     : base(blockBufferGenerator, coinView, consensusManager, dateTimeProvider, executorFactory, loggerFactory, mempool,
            mempoolLock, minerSettings, network, senderRetriever, stateRoot)
 {
     // TODO: Fix gross MinerSettings injection ^^
 }
 public ProvenHeadersConsensusManagerBehavior(
     ConcurrentChain chain,
     IInitialBlockDownloadState initialBlockDownloadState,
     IConsensusManager consensusManager,
     IPeerBanning peerBanning,
     ILoggerFactory loggerFactory,
     Network network,
     IChainState chainState) : base(chain, initialBlockDownloadState, consensusManager, peerBanning, loggerFactory)
 {
     this.chain = chain;
     this.initialBlockDownloadState = initialBlockDownloadState;
     this.consensusManager          = consensusManager;
     this.peerBanning   = peerBanning;
     this.network       = network;
     this.loggerFactory = loggerFactory;
     this.logger        = loggerFactory.CreateLogger(this.GetType().FullName, $"[{this.GetHashCode():x}] ");
     this.chainState    = chainState;
 }
 /// <inheritdoc />
 public FederatedPegBlockDefinition(
     IBlockBufferGenerator blockBufferGenerator,
     ICoinView coinView,
     IConsensusManager consensusManager,
     IDateTimeProvider dateTimeProvider,
     IContractExecutorFactory executorFactory,
     ILoggerFactory loggerFactory,
     ITxMempool mempool,
     MempoolSchedulerLock mempoolLock,
     Network network,
     ISenderRetriever senderRetriever,
     IStateRepositoryRoot stateRoot,
     IFederationGatewaySettings federationGatewaySettings)
     : base(blockBufferGenerator, coinView, consensusManager, dateTimeProvider, executorFactory, loggerFactory, mempool, mempoolLock, network, senderRetriever, stateRoot)
 {
     this.payToMultisigScript = federationGatewaySettings.MultiSigAddress.ScriptPubKey;
     this.payToMemberScript   = PayToPubkeyTemplate.Instance.GenerateScriptPubKey(new PubKey(federationGatewaySettings.PublicKey));
 }
Exemplo n.º 22
0
        public ConsensusFeature(
            Network network,
            IChainState chainState,
            IConnectionManager connectionManager,
            ISignals signals,
            IConsensusManager consensusManager,
            NodeDeployments nodeDeployments,
            IKeyValueRepository keyValueRepository)
        {
            this.chainState         = chainState;
            this.connectionManager  = connectionManager;
            this.signals            = signals;
            this.consensusManager   = consensusManager;
            this.nodeDeployments    = nodeDeployments;
            this.keyValueRepository = keyValueRepository;

            this.chainState.MaxReorgLength = network.Consensus.MaxReorgLength;
        }
Exemplo n.º 23
0
        public AddressIndexer(StoreSettings storeSettings, DataFolder dataFolder, ILoggerFactory loggerFactory, Network network, INodeStats nodeStats, IConsensusManager consensusManager, IAsyncProvider asyncProvider)
        {
            this.storeSettings       = storeSettings;
            this.network             = network;
            this.nodeStats           = nodeStats;
            this.dataFolder          = dataFolder;
            this.consensusManager    = consensusManager;
            this.asyncProvider       = asyncProvider;
            this.loggerFactory       = loggerFactory;
            this.scriptAddressReader = new ScriptAddressReader();

            this.lockObject           = new object();
            this.flushChangesInterval = TimeSpan.FromMinutes(10);
            this.lastFlushTime        = DateTime.Now;
            this.cancellation         = new CancellationTokenSource();
            this.logger = loggerFactory.CreateLogger(this.GetType().FullName);

            this.averageTimePerBlock = new AverageCalculator(200);
        }
Exemplo n.º 24
0
 public TestFederatedPegBlockDefinition(
     IBlockBufferGenerator blockBufferGenerator,
     ICoinView coinView,
     IConsensusManager consensusManager,
     IDateTimeProvider dateTimeProvider,
     IContractExecutorFactory executorFactory,
     ILoggerFactory loggerFactory,
     ITxMempool mempool,
     MempoolSchedulerLock mempoolLock,
     Network network,
     ISenderRetriever senderRetriever,
     IStateRepositoryRoot stateRoot,
     IBlockExecutionResultCache executionCache,
     ICallDataSerializer callDataSerializer,
     MinerSettings minerSettings,
     NodeDeployments nodeDeployments)
     : base(blockBufferGenerator, coinView, consensusManager, dateTimeProvider, executorFactory, loggerFactory, mempool, mempoolLock, network, senderRetriever, stateRoot, executionCache, callDataSerializer, minerSettings, nodeDeployments)
 {
 }
        public BlockStoreBehavior(ChainIndexer chainIndexer, IChainState chainState, ILoggerFactory loggerFactory, IConsensusManager consensusManager, IBlockStoreQueue blockStoreQueue)
        {
            Guard.NotNull(chainIndexer, nameof(chainIndexer));
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(consensusManager, nameof(consensusManager));
            Guard.NotNull(blockStoreQueue, nameof(blockStoreQueue));

            this.ChainIndexer     = chainIndexer;
            this.chainState       = chainState;
            this.logger           = loggerFactory.CreateLogger(this.GetType().FullName);
            this.loggerFactory    = loggerFactory;
            this.consensusManager = consensusManager;
            this.blockStoreQueue  = blockStoreQueue;

            this.CanRespondToGetDataPayload = true;

            this.PreferHeaders      = false;
            this.preferHeaderAndIDs = false;
        }
Exemplo n.º 26
0
 public TestPoAMiner(
     IConsensusManager consensusManager,
     IDateTimeProvider dateTimeProvider,
     Network network,
     INodeLifetime nodeLifetime,
     ILoggerFactory loggerFactory,
     IInitialBlockDownloadState ibdState,
     BlockDefinition blockDefinition,
     SlotsManager slotsManager,
     IConnectionManager connectionManager,
     PoABlockHeaderValidator poaHeaderValidator,
     FederationManager federationManager,
     IIntegrityValidator integrityValidator,
     IWalletManager walletManager,
     INodeStats nodeStats) : base(consensusManager, dateTimeProvider, network, nodeLifetime, loggerFactory, ibdState, blockDefinition, slotsManager,
                                  connectionManager, poaHeaderValidator, federationManager, integrityValidator, walletManager, nodeStats)
 {
     this.timeProvider       = dateTimeProvider as EditableTimeProvider;
     this.cancellationSource = new CancellationTokenSource();
 }
Exemplo n.º 27
0
        public PoAFeature(FederationManager federationManager, PayloadProvider payloadProvider, IConnectionManager connectionManager, ChainIndexer chainIndexer,
                          IInitialBlockDownloadState initialBlockDownloadState, IConsensusManager consensusManager, IPeerBanning peerBanning, ILoggerFactory loggerFactory,
                          IPoAMiner miner, VotingManager votingManager, Network network, IWhitelistedHashesRepository whitelistedHashesRepository,
                          IdleFederationMembersKicker idleFederationMembersKicker)
        {
            this.federationManager         = federationManager;
            this.connectionManager         = connectionManager;
            this.chainIndexer              = chainIndexer;
            this.initialBlockDownloadState = initialBlockDownloadState;
            this.consensusManager          = consensusManager;
            this.peerBanning   = peerBanning;
            this.loggerFactory = loggerFactory;
            this.miner         = miner;
            this.votingManager = votingManager;
            this.whitelistedHashesRepository = whitelistedHashesRepository;
            this.network = network;
            this.idleFederationMembersKicker = idleFederationMembersKicker;

            payloadProvider.DiscoverPayloads(this.GetType().Assembly);
        }
#pragma warning restore 649

        /// <inheritdoc />
        public WatchOnlyWalleRPCController(
            IFullNode fullNode,
            IConsensusManager consensusManager,
            ChainIndexer chainIndexer,
            Network network,
            WalletSettings walletSettings,
            IWalletManager walletManager,
            IWatchOnlyWalletManager watchOnlyWalletManager,
            IBlockStore blockStore,
            IChainState chainState) : base(fullNode: fullNode, consensusManager: consensusManager, chainIndexer: chainIndexer, network: network)
        {
            this.fullNode               = fullNode;
            this.chainIndexer           = chainIndexer;
            this.network                = network;
            this.walletSettings         = walletSettings;
            this.walletManager          = walletManager;
            this.watchOnlyWalletManager = watchOnlyWalletManager;
            this.blockStore             = blockStore;
            this.chainState             = chainState;
        }
Exemplo n.º 29
0
        /// <inheritdoc />
        public int?GetMultisigMinersApplicabilityHeight()
        {
            IConsensusManager consensusManager = this.fullNode.NodeService <IConsensusManager>();
            ChainedHeader     fork             = (this.lastBlockChecked == null) ? null : consensusManager.Tip.FindFork(this.lastBlockChecked);

            if (this.multisigMinersApplicabilityHeight != null && fork?.HashBlock == this.lastBlockChecked?.HashBlock)
            {
                return(this.multisigMinersApplicabilityHeight);
            }

            this.lastBlockChecked = fork;
            this.multisigMinersApplicabilityHeight = null;
            var commitmentHeightEncoder = new CollateralHeightCommitmentEncoder(this.logger);

            ChainedHeader[] headers = consensusManager.Tip.EnumerateToGenesis().TakeWhile(h => h != this.lastBlockChecked && h.Height >= this.network.CollateralCommitmentActivationHeight).Reverse().ToArray();

            ChainedHeader first = BinarySearch.BinaryFindFirst <ChainedHeader>(headers, (chainedHeader) =>
            {
                ChainedHeaderBlock block = consensusManager.GetBlockData(chainedHeader.HashBlock);
                if (block == null)
                {
                    return(null);
                }

                // Finding the height of the first STRAX collateral commitment height.
                (int?commitmentHeight, uint?magic) = commitmentHeightEncoder.DecodeCommitmentHeight(block.Block.Transactions.First());
                if (commitmentHeight == null)
                {
                    return(null);
                }

                return(magic == this.counterChainSettings.CounterChainNetwork.Magic);
            });

            this.lastBlockChecked = headers.LastOrDefault();
            this.multisigMinersApplicabilityHeight = first?.Height;

            this.UpdateMultisigMiners(first != null);

            return(this.multisigMinersApplicabilityHeight);
        }