예제 #1
0
        private IJob GetNewJob()
        {
            try
            {
                var blockTemplate = _daemonClient.GetBlockTemplate(_poolConfig.Coin.Options.BlockTemplateModeRequired);

                // TODO: convert generation transaction to ioc & DI based.
                var generationTransaction = new GenerationTransaction(ExtraNonce, _daemonClient, blockTemplate, _poolConfig);
                generationTransaction.Create();

                // create the job notification.
                var job = new Job(_jobCounter.Next(), _hashAlgorithm, blockTemplate, generationTransaction)
                {
                    CleanJobs = true // tell the miners to clean their existing jobs and start working on new one.
                };

                _jobTracker.Add(job);

                return(job);
            }
            catch (RpcException rpcException)
            {
                _logger.Error("New job creation failed: {0:l}", rpcException.Message);
                return(null);
            }
        }
예제 #2
0
        /// <summary>
        /// Entry point to the threaded execute functionality
        /// </summary>
        private void _execute()
        {
            IProcessingService  service = Container.Resolve <IProcessingService>();
            ObjectJobDefinition d       = new ObjectJobDefinition(_source.Pipeline, _filesToInputs());
            JobRequest          r       = new JobRequest(d);

            r.Identifier = _source.Identifier;
            IJobTicket  t       = service.JobManager.EnqueueJob(r);
            IJobTracker tracker = Container.Resolve <IJobTracker>();

            tracker.Add(t, _source.Handler);
        }
예제 #3
0
        private IJob GetNewJob()
        {
            try
            {
                _logger.Verbose("Trying to get new BlockTemplate... (2)");

                var blockTemplate = _daemonClient.GetBlockTemplate(_poolConfig.Coin.Options.BlockTemplateModeRequired);

                MetronomeTracker.CurrentMetronomeHash = blockTemplate.MetronomeHash;

                if (metronomeActive && BigInteger.Parse(blockTemplate.MetronomeHash, System.Globalization.NumberStyles.HexNumber).IsZero)
                {
                    if (_jobTracker.Current != null)
                    {
                        _jobTracker.Current.CleanJobs = true;
                        SendSleepSignal();
                    }
                    return(null);
                }

                _logger.Information("NEW Metro Hash: {0}", blockTemplate.MetronomeHash);

                // TODO: convert generation transaction to ioc & DI based.
                var generationTransaction = new GenerationTransaction(ExtraNonce, _daemonClient, blockTemplate, _poolConfig);
                generationTransaction.Create();

                // create the job notification.
                var job = new Job(_jobCounter.Next(), _hashAlgorithm, blockTemplate, generationTransaction)
                {
                    CleanJobs = true // tell the miners to clean their existing jobs and start working on new one.
                };

                _jobTracker.Add(job);

                return(job);
            }
            catch (RpcException rpcException)
            {
                /*if (rpcException.Message.Equals("Miners are sleeping", StringComparison.OrdinalIgnoreCase))
                 * {
                 *  _logger.Information("Miners ae sleeping");
                 *  Thread.Sleep(1000);
                 *  continue;
                 * }*/
                _logger.Error("New job creation failed: {0:l}", rpcException.Message);
                return(null);
            }
        }