Browse Source

Place ethash cache in a more clearly shared folder.

cl-refactor
Gav Wood 10 years ago
parent
commit
1f161895fd
  1. 9
      libdevcrypto/FileSystem.cpp
  2. 2
      libdevcrypto/FileSystem.h
  3. 4
      libethcore/Ethasher.cpp

9
libdevcrypto/FileSystem.cpp

@ -32,12 +32,15 @@
using namespace std;
using namespace dev;
std::string dev::getDataDir()
std::string dev::getDataDir(std::string _prefix)
{
if (_prefix.empty())
_prefix = "ethereum";
#ifdef _WIN32
_prefix[0] = toupper(_prefix[0]);
char path[1024] = "";
if (SHGetSpecialFolderPathA(NULL, path, CSIDL_APPDATA, true))
return (boost::filesystem::path(path) / "Ethereum").string();
return (boost::filesystem::path(path) / _prefix).string();
else
{
#ifndef _MSC_VER // todo?
@ -57,7 +60,7 @@ std::string dev::getDataDir()
// This eventually needs to be put in proper wrapper (to support sandboxing)
return (dataDirPath / "Library/Application Support/Ethereum").string();
#else
return (dataDirPath / ".ethereum").string();
return (dataDirPath / ("." + _prefix)).string();
#endif
#endif
}

2
libdevcrypto/FileSystem.h

@ -30,6 +30,6 @@ namespace dev
{
/// @returns the path for user data.
std::string getDataDir();
std::string getDataDir(std::string _prefix = "ethereum");
}

4
libethcore/Ethasher.cpp

@ -71,10 +71,10 @@ bytesConstRef Ethasher::full(BlockInfo const& _header)
m_fulls.erase(m_fulls.begin());
}
try {
boost::filesystem::create_directories(getDataDir() + "/ethashcache");
boost::filesystem::create_directories(getDataDir("ethash"));
} catch (...) {}
std::string memoFile = getDataDir() + "/ethashcache/full";
std::string memoFile = getDataDir("ethash") + "/full";
auto info = rlpList(c_ethashRevision, _header.seedHash());
if (boost::filesystem::exists(memoFile) && contents(memoFile + ".info") != info)
boost::filesystem::remove(memoFile);

Loading…
Cancel
Save