diff --git a/ethminer/MinerAux.h b/ethminer/MinerAux.h index 6539cd6b2..703605602 100644 --- a/ethminer/MinerAux.h +++ b/ethminer/MinerAux.h @@ -456,7 +456,7 @@ public: void execute() { - EthashAux::setCustomDirName(s_dagDir); + EthashAux::setDAGDirName(s_dagDir); EthashAux::setDAGEraseMode(m_eraseMode); EthashAux::eraseDAGs(); if (m_eraseMode == DAGEraseMode::All) @@ -998,7 +998,7 @@ private: #endif uint64_t m_currentBlock = 0; static char s_dagDir[256]; - // default value is 350MB of GPU memory for other stuff (windows system rendering, e.t.c.) + // default value was 350MB of GPU memory for other stuff (windows system rendering, e.t.c.) unsigned m_extraGPUMemory = 0;// 350000000; don't assume miners run desktops... /// DAG initialisation param. diff --git a/libethcore/EthashAux.cpp b/libethcore/EthashAux.cpp index 8147103c1..ba8027633 100644 --- a/libethcore/EthashAux.cpp +++ b/libethcore/EthashAux.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include "BlockInfo.h" #include "Exceptions.h" using namespace std; @@ -43,7 +44,7 @@ using namespace boost::filesystem; const char* DAGChannel::name() { return EthGreen "DAG"; } EthashAux* dev::eth::EthashAux::s_this = nullptr; -char dev::eth::EthashAux::s_customDirName[256] = ""; +char dev::eth::EthashAux::s_dagDirName[256] = ""; dev::eth::DAGEraseMode dev::eth::EthashAux::s_dagEraseMode = DAGEraseMode::None; const unsigned EthashProofOfWork::defaultLocalWorkSize = 64; @@ -73,14 +74,20 @@ uint64_t EthashAux::dataSize(uint64_t _blockNumber) } -void EthashAux::setCustomDirName(const char * custom_dir_name) +void EthashAux::setDAGDirName(const char * custom_dir_name) { - strcpy(s_customDirName, custom_dir_name); + char strbuf[256]; + if (strcmp(custom_dir_name, "") != 0) + strcpy(strbuf, custom_dir_name); + else + ethash_get_default_dirname(strbuf, 256); + + strcpy(s_dagDirName, strbuf); } -char * EthashAux::customDirName() +char * EthashAux::dagDirName() { - return s_customDirName; + return s_dagDirName; } void EthashAux::setDAGEraseMode(DAGEraseMode mode) @@ -92,7 +99,7 @@ void EthashAux::eraseDAGs() { if (s_dagEraseMode == DAGEraseMode::None) return; - path p(s_customDirName); + path p(s_dagDirName); vector files; directory_iterator end_itr; @@ -207,7 +214,7 @@ bytesConstRef EthashAux::LightAllocation::data() const EthashAux::FullAllocation::FullAllocation(ethash_light_t _light, ethash_callback_t _cb) { // cdebug << "About to call ethash_full_new..."; - full = ethash_full_new(_light, EthashAux::customDirName(), _cb); + full = ethash_full_new(_light, EthashAux::dagDirName(), _cb); // cdebug << "Called OK."; if (!full) { diff --git a/libethcore/EthashAux.h b/libethcore/EthashAux.h index 1f5b24eb1..a894eecff 100644 --- a/libethcore/EthashAux.h +++ b/libethcore/EthashAux.h @@ -117,8 +117,8 @@ public: static uint64_t number(h256 const& _seedHash); static uint64_t cacheSize(BlockInfo const& _header); static uint64_t dataSize(uint64_t _blockNumber); - static void setCustomDirName(const char * custom_dir_name); - static char * customDirName(); + static void setDAGDirName(const char * custom_dir_name); + static char * dagDirName(); static void setDAGEraseMode(DAGEraseMode mode); static void EthashAux::eraseDAGs(); @@ -145,7 +145,7 @@ private: void killCache(h256 const& _s); static EthashAux* s_this; - static char s_customDirName[256]; + static char s_dagDirName[256]; static DAGEraseMode s_dagEraseMode; SharedMutex x_lights;