示例#1
0
        public PowMining(
            IAsyncProvider asyncProvider,
            IBlockProvider blockProvider,
            IConsensusManager consensusManager,
            ChainIndexer chainIndexer,
            IDateTimeProvider dateTimeProvider,
            ITxMempool mempool,
            MempoolSchedulerLock mempoolLock,
            Network network,
            INodeLifetime nodeLifetime,
            ILoggerFactory loggerFactory,
            IInitialBlockDownloadState initialBlockDownloadState,
            MinerSettings minerSettings)
        {
            this.asyncProvider             = asyncProvider;
            this.blockProvider             = blockProvider;
            this.chainIndexer              = chainIndexer;
            this.consensusManager          = consensusManager;
            this.dateTimeProvider          = dateTimeProvider;
            this.loggerFactory             = loggerFactory;
            this.initialBlockDownloadState = initialBlockDownloadState;
            this.minerSettings             = minerSettings;
            this.logger       = loggerFactory.CreateLogger(GetType().FullName);
            this.mempool      = mempool;
            this.mempoolLock  = mempoolLock;
            this.network      = network;
            this.nodeLifetime = nodeLifetime;
            this.miningCancellationTokenSource =
                CancellationTokenSource.CreateLinkedTokenSource(this.nodeLifetime.ApplicationStopping);

            if (minerSettings.UseOpenCL)
            {
                this.openCLMiner = new OpenCLMiner(minerSettings, loggerFactory);
            }
        }
示例#2
0
 /// <inheritdoc />
 public void StopMining()
 {
     this.miningCancellationTokenSource.Cancel();
     this.miningLoop?.Dispose();
     this.miningLoop = null;
     this.miningCancellationTokenSource.Dispose();
     this.miningCancellationTokenSource = null;
     this.openCLMiner?.Dispose();
     this.openCLMiner = null;
 }