void MinerManager::start() { m_logger(Logging::DEBUGGING) << "starting"; BlockMiningParameters params; for (;;) { m_logger(Logging::INFO) << "requesting mining parameters"; try { params = requestMiningParameters(m_dispatcher, m_config.daemonHost, m_config.daemonPort, m_config.miningAddress); } catch (ConnectException& e) { m_logger(Logging::WARNING) << "Couldn't connect to daemon: " << e.what(); System::Timer timer(m_dispatcher); timer.sleep(std::chrono::seconds(m_config.scanPeriod)); continue; } adjustBlockTemplate(params.blockTemplate); break; } startBlockchainMonitoring(); startMining(params); eventLoop(); }
void MiningFrame::startStopClicked(QAbstractButton* _button) { if (_button == m_ui->m_startButton && m_ui->m_startButton->isChecked()) { startMining(); } else if (_button == m_ui->m_stopButton && m_ui->m_stopButton->isChecked()) { stopMining(); } }
void MinerManager::eventLoop() { size_t blocksMined = 0; for (;;) { m_logger(Logging::DEBUGGING) << "waiting for event"; MinerEvent event = waitEvent(); switch (event.type) { case MinerEventType::BLOCK_MINED: { m_logger(Logging::DEBUGGING) << "got BLOCK_MINED event"; stopBlockchainMonitoring(); if (submitBlock(m_minedBlock, m_config.daemonHost, m_config.daemonPort)) { m_lastBlockTimestamp = m_minedBlock.timestamp; if (m_config.blocksLimit != 0 && ++blocksMined == m_config.blocksLimit) { m_logger(Logging::INFO) << "Miner mined requested " << m_config.blocksLimit << " blocks. Quitting"; return; } } BlockMiningParameters params = requestMiningParameters(m_dispatcher, m_config.daemonHost, m_config.daemonPort, m_config.miningAddress); adjustBlockTemplate(params.blockTemplate); startBlockchainMonitoring(); startMining(params); break; } case MinerEventType::BLOCKCHAIN_UPDATED: { m_logger(Logging::DEBUGGING) << "got BLOCKCHAIN_UPDATED event"; stopMining(); stopBlockchainMonitoring(); BlockMiningParameters params = requestMiningParameters(m_dispatcher, m_config.daemonHost, m_config.daemonPort, m_config.miningAddress); adjustBlockTemplate(params.blockTemplate); startBlockchainMonitoring(); startMining(params); break; } default: assert(false); return; } } }
CompareChiDialog::CompareChiDialog() { hide(); steps = new QSpinBox; steps->setMinimum(10); steps->setMaximum(1000); steps->setSingleStep(10); steps->setValue(100); maxValue = new QSpinBox; maxValue->setMinimum(100); maxValue->setMaximum(10000); maxValue->setSingleStep(100); maxValue->setValue(1000); userNameEdit1 = new QLineEdit; userNameEdit2 = new QLineEdit; theresoldCut = new QCheckBox; medianFilter = new QCheckBox; aperture = new QSpinBox; aperture->setMinimum(1); aperture->setDisabled(true); inputLayout = new QFormLayout; inputLayout->addRow("User name #1", userNameEdit1); inputLayout->addRow("User name #2", userNameEdit2); inputLayout->addRow("Use theresold cut", theresoldCut); inputLayout->addRow("Maximum theresold in msec:", maxValue); inputLayout->addRow("Use median filter", medianFilter); // inputLayout->addRow("Aperture", aperture); inputLayout->addRow("Accuracy step:", steps); buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); graph = new QPushButton("Plot"); buttons->addButton(graph, QDialogButtonBox::ActionRole); mainLayout = new QVBoxLayout; mainLayout->addLayout(this->inputLayout); mainLayout->addWidget(this->buttons); setLayout(mainLayout); connect(buttons, SIGNAL(accepted()), this, SLOT(startMining())); connect(buttons, SIGNAL(rejected()), this, SLOT(reject())); connect(graph, SIGNAL(clicked()), this, SLOT(createGraph())); connect(medianFilter, SIGNAL(clicked(bool)), aperture, SLOT(setEnabled(bool))); setWindowTitle("Chi-square probability"); setWindowIcon(QIcon(":/img/chisquare.png")); show(); }
void MiningFrame::startMiningClicked(bool _on) { if (_on) { m_ui->m_startMiningButton->setText(tr("Stop")); m_ui->m_startMiningButton->setFixedWidth(50); m_ui->m_hashrateLabel->setText("0 H/s"); m_ui->m_donationHashRateLabel->setText("0 H/s"); startMining(); } else { m_ui->m_startMiningButton->setText(tr("Start mining")); m_ui->m_startMiningButton->setFixedWidth(190); stopMining(); } m_ui->m_hashRateFrame->setVisible(_on); }
void EthereumMiner::restartMining() { stopMining(); startMining(); }