Browse Source

fixed crash when using -E and using default DAG directory

cl-refactor
Genoil 9 years ago
parent
commit
7ea80205e4
  1. 4
      ethminer/MinerAux.h
  2. 21
      libethcore/EthashAux.cpp
  3. 6
      libethcore/EthashAux.h

4
ethminer/MinerAux.h

@ -456,7 +456,7 @@ public:
void execute() void execute()
{ {
EthashAux::setCustomDirName(s_dagDir); EthashAux::setDAGDirName(s_dagDir);
EthashAux::setDAGEraseMode(m_eraseMode); EthashAux::setDAGEraseMode(m_eraseMode);
EthashAux::eraseDAGs(); EthashAux::eraseDAGs();
if (m_eraseMode == DAGEraseMode::All) if (m_eraseMode == DAGEraseMode::All)
@ -998,7 +998,7 @@ private:
#endif #endif
uint64_t m_currentBlock = 0; uint64_t m_currentBlock = 0;
static char s_dagDir[256]; 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... unsigned m_extraGPUMemory = 0;// 350000000; don't assume miners run desktops...
/// DAG initialisation param. /// DAG initialisation param.

21
libethcore/EthashAux.cpp

@ -32,6 +32,7 @@
#include <libdevcore/SHA3.h> #include <libdevcore/SHA3.h>
#include <libdevcore/FileSystem.h> #include <libdevcore/FileSystem.h>
#include <libethash/internal.h> #include <libethash/internal.h>
#include <libethash/io.h>
#include "BlockInfo.h" #include "BlockInfo.h"
#include "Exceptions.h" #include "Exceptions.h"
using namespace std; using namespace std;
@ -43,7 +44,7 @@ using namespace boost::filesystem;
const char* DAGChannel::name() { return EthGreen "DAG"; } const char* DAGChannel::name() { return EthGreen "DAG"; }
EthashAux* dev::eth::EthashAux::s_this = nullptr; 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; dev::eth::DAGEraseMode dev::eth::EthashAux::s_dagEraseMode = DAGEraseMode::None;
const unsigned EthashProofOfWork::defaultLocalWorkSize = 64; 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) void EthashAux::setDAGEraseMode(DAGEraseMode mode)
@ -92,7 +99,7 @@ void EthashAux::eraseDAGs()
{ {
if (s_dagEraseMode == DAGEraseMode::None) return; if (s_dagEraseMode == DAGEraseMode::None) return;
path p(s_customDirName); path p(s_dagDirName);
vector<path> files; vector<path> files;
directory_iterator end_itr; directory_iterator end_itr;
@ -207,7 +214,7 @@ bytesConstRef EthashAux::LightAllocation::data() const
EthashAux::FullAllocation::FullAllocation(ethash_light_t _light, ethash_callback_t _cb) EthashAux::FullAllocation::FullAllocation(ethash_light_t _light, ethash_callback_t _cb)
{ {
// cdebug << "About to call ethash_full_new..."; // 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."; // cdebug << "Called OK.";
if (!full) if (!full)
{ {

6
libethcore/EthashAux.h

@ -117,8 +117,8 @@ public:
static uint64_t number(h256 const& _seedHash); static uint64_t number(h256 const& _seedHash);
static uint64_t cacheSize(BlockInfo const& _header); static uint64_t cacheSize(BlockInfo const& _header);
static uint64_t dataSize(uint64_t _blockNumber); static uint64_t dataSize(uint64_t _blockNumber);
static void setCustomDirName(const char * custom_dir_name); static void setDAGDirName(const char * custom_dir_name);
static char * customDirName(); static char * dagDirName();
static void setDAGEraseMode(DAGEraseMode mode); static void setDAGEraseMode(DAGEraseMode mode);
static void EthashAux::eraseDAGs(); static void EthashAux::eraseDAGs();
@ -145,7 +145,7 @@ private:
void killCache(h256 const& _s); void killCache(h256 const& _s);
static EthashAux* s_this; static EthashAux* s_this;
static char s_customDirName[256]; static char s_dagDirName[256];
static DAGEraseMode s_dagEraseMode; static DAGEraseMode s_dagEraseMode;
SharedMutex x_lights; SharedMutex x_lights;

Loading…
Cancel
Save