void EthereumMiner::begin() { if(_configuration.minerType == CPUMiner) { dev::eth::EthashCPUMiner::setNumInstances(_configuration.maxMiningThreads); emit platformInfo(QString::fromStdString(dev::eth::EthashCPUMiner::platformInfo())); } else if (_configuration.minerType == OpenCLMiner) { if(!dev::eth::EthashGPUMiner::configureGPU( _configuration.localWorkSize, _configuration.globalWorkSizeMultiplier, _configuration.msPerBatch, _configuration.openclPlatform, _configuration.openclDevice, _configuration.recognizeCPUAsOpenCLDevice, _configuration.extraGPUMemory, _configuration.currentBlock )) { emit error("Failed to initialize GPU miner."); } dev::eth::EthashGPUMiner::setNumInstances(_configuration.maxMiningThreads); emit platformInfo(QString::fromStdString(dev::eth::EthashGPUMiner::platformInfo())); } std::map<std::string, dev::eth::GenericFarm<dev::eth::EthashProofOfWork>::SealerDescriptor> sealers; sealers[sealerString(CPUMiner)] = dev::eth::GenericFarm<dev::eth::EthashProofOfWork>::SealerDescriptor{&dev::eth::EthashCPUMiner::instances, [](dev::eth::GenericMiner<dev::eth::EthashProofOfWork>::ConstructionInfo ci){ return new dev::eth::EthashCPUMiner(ci); }}; sealers[sealerString(OpenCLMiner)] = dev::eth::GenericFarm<dev::eth::EthashProofOfWork>::SealerDescriptor{&dev::eth::EthashGPUMiner::instances, [](dev::eth::GenericMiner<dev::eth::EthashProofOfWork>::ConstructionInfo ci){ return new dev::eth::EthashGPUMiner(ci); }}; _powFarm.setSealers(sealers); _powFarm.start(sealerString(_configuration.minerType)); _powFarm.onSolutionFound([&](dev::eth::EthashProofOfWork::Solution sol) { QString nonce = "0x" + QString::fromStdString(sol.nonce.hex()); QString headerHash = "0x" + QString::fromStdString(_currentWorkPackage.headerHash.hex()); QString mixHash = "0x" + QString::fromStdString(sol.mixHash.hex()); qDebug() << "Solution found; Submitting ..."; qDebug() << " Nonce:" << nonce; qDebug() << " Mixhash:" << mixHash; qDebug() << " Header-hash:" << headerHash; qDebug() << " Seedhash:" << QString::fromStdString(_currentWorkPackage.seedHash.hex()); qDebug() << " Target: " << QString::fromStdString(dev::h256(_currentWorkPackage.boundary).hex()); qDebug() << " Ethash: " << QString::fromStdString(dev::h256(dev::eth::EthashAux::eval(_currentWorkPackage.seedHash, _currentWorkPackage.headerHash, sol.nonce).value).hex()); _ethereumProtocol->eth_submitWork(nonce, headerHash, mixHash); emit solutionFound(nonce, headerHash, mixHash); _currentWorkPackage.reset(); _ethereumProtocol->eth_getWork(); return true; }); connectToServer(); }
//---------------------------------------------------------------------------- void PolygonDistance::OnDisplay () { ClearScreen(); const int lineThick = 0; const int solutionThick = 2; const int centroidThick = 4; ColorRGB lineColor(0, 0, 0); ColorRGB centroidColor(0, 0, 128); // Draw the polygons. int i; for (i = 0; i < NUM_POLYGONS; ++i) { const int n = mPolygons[i].NumVertices; for (int j0 = n-1, j1 = 0; j1 < mPolygons[i].NumVertices; j0 = j1++) { DrawLineSegment(lineThick, lineColor, mPolygons[i].Vertices[j0], mPolygons[i].Vertices[j1]); } } // Draw the segment joining the nearest points. for (int k0 = NUM_POLYGONS-1, k1 = 0; k1 < NUM_POLYGONS; k0 = k1++) { // Copy the polygon vertices. Vector2f* v00 = new1<Vector2f>(mPolygons[k0].NumVertices); Vector2f* v01 = new1<Vector2f>(mPolygons[k1].NumVertices); memcpy(v00, mPolygons[k0].Vertices, mPolygons[k0].NumVertices*sizeof(Vector2f)); memcpy(v01, mPolygons[k1].Vertices, mPolygons[k1].NumVertices*sizeof(Vector2f)); int statusCode; float retValue; Vector2f closest[2]; LCPPolyDist2(mPolygons[k0].NumVertices, v00, mPolygons[k0].NumVertices, mPolygons[k0].Faces, mPolygons[k1].NumVertices, v01, mPolygons[k1].NumVertices, mPolygons[k1].Faces, statusCode, retValue, closest); // Draw the segment joining the closest points. DrawLineSegment(lineThick, lineColor, closest[0], closest[1]); if (mDrawPerpendiculars && retValue > 0.1f) { // Compute perpendiculars to edges at solution points. Vector2f end[2]; ComputePerpendiculars(mPolygons[k0].NumVertices, mPolygons[k0].Vertices, closest[0], end); DrawPerpendiculars(end); ComputePerpendiculars(mPolygons[k1].NumVertices, mPolygons[k1].Vertices, closest[1], end); DrawPerpendiculars(end); } // Draw the nearest points. switch (statusCode) { case LCPPolyDist2::SC_FOUND_SOLUTION: { ColorRGB solutionFound(0, 128, 0); for (i = 0; i < 2; ++i) { DrawPoints(solutionThick, solutionFound, closest[i]); } break; } case LCPPolyDist2::SC_TEST_POINTS_TEST_FAILED: { ColorRGB testPointsFailed(0, 0, 128); for (i = 0; i < 2; ++i) { DrawPoints(solutionThick, testPointsFailed, closest[i]); } break; } case LCPPolyDist2::SC_VERIFY_FAILURE: { ColorRGB verifyFailed(128, 0, 0); for (i = 0; i < 2; ++i) { DrawPoints(solutionThick, verifyFailed, closest[i]); } break; } } // Draw the centroids. DrawPoints(centroidThick, centroidColor, mPolygons[k0].Centroid); DrawPoints(centroidThick, centroidColor, mPolygons[k1].Centroid); delete1(v00); delete1(v01); } WindowApplication2::OnDisplay(); }