Skip to content
This repository was archived by the owner on Apr 24, 2022. It is now read-only.

Commit d5618a4

Browse files
committedMay 30, 2017
Remove EthashProofOfWork namespace
1 parent a67ce0c commit d5618a4

11 files changed

+55
-85
lines changed
 

‎ethminer/MinerAux.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ class MinerCLI
613613
sealers["cuda"] = Farm::SealerDescriptor{ &EthashCUDAMiner::instances, [](Miner::ConstructionInfo ci){ return new EthashCUDAMiner(ci); } };
614614
#endif
615615
f.setSealers(sealers);
616-
f.onSolutionFound([&](EthashProofOfWork::Solution) { return false; });
616+
f.onSolutionFound([&](Solution) { return false; });
617617

618618
string platformInfo = _m == MinerType::CPU ? "CPU" : (_m == MinerType::CL ? "CL" : "CUDA");
619619
cout << "Benchmarking on platform: " << platformInfo << endl;
@@ -698,11 +698,11 @@ class MinerCLI
698698

699699
int time = 0;
700700

701-
EthashProofOfWork::WorkPackage current = EthashProofOfWork::WorkPackage(genesis);
701+
WorkPackage current = WorkPackage(genesis);
702702
while (true) {
703703
bool completed = false;
704-
EthashProofOfWork::Solution solution;
705-
f.onSolutionFound([&](EthashProofOfWork::Solution sol)
704+
Solution solution;
705+
f.onSolutionFound([&](Solution sol)
706706
{
707707
solution = sol;
708708
return completed = true;
@@ -776,14 +776,14 @@ class MinerCLI
776776
f.start("opencl", false);
777777
else if (_m == MinerType::CUDA)
778778
f.start("cuda", false);
779-
EthashProofOfWork::WorkPackage current, previous;
779+
WorkPackage current, previous;
780780
std::mutex x_current;
781781
while (m_running)
782782
try
783783
{
784784
bool completed = false;
785-
EthashProofOfWork::Solution solution;
786-
f.onSolutionFound([&](EthashProofOfWork::Solution sol)
785+
Solution solution;
786+
f.onSolutionFound([&](Solution sol)
787787
{
788788
solution = sol;
789789
return completed = true;
@@ -930,7 +930,7 @@ class MinerCLI
930930
}
931931
f.setSealers(sealers);
932932

933-
f.onSolutionFound([&](EthashProofOfWork::Solution sol)
933+
f.onSolutionFound([&](Solution sol)
934934
{
935935
if (client.isConnected()) {
936936
client.submit(sol);
@@ -974,7 +974,7 @@ class MinerCLI
974974
}
975975
f.setSealers(sealers);
976976

977-
f.onSolutionFound([&](EthashProofOfWork::Solution sol)
977+
f.onSolutionFound([&](Solution sol)
978978
{
979979
client.submit(sol);
980980
return false;

‎libethcore/EthashAux.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -107,22 +107,22 @@ bytesConstRef EthashAux::LightAllocation::data() const
107107
return bytesConstRef((byte const*)light->cache, size);
108108
}
109109

110-
EthashProofOfWork::Result EthashAux::LightAllocation::compute(h256 const& _headerHash, Nonce const& _nonce) const
110+
Result EthashAux::LightAllocation::compute(h256 const& _headerHash, Nonce const& _nonce) const
111111
{
112112
ethash_return_value r = ethash_light_compute(light, *(ethash_h256_t*)_headerHash.data(), (uint64_t)(u64)_nonce);
113113
if (!r.success)
114114
BOOST_THROW_EXCEPTION(DAGCreationFailure());
115-
return EthashProofOfWork::Result{h256((uint8_t*)&r.result, h256::ConstructFromPointer), h256((uint8_t*)&r.mix_hash, h256::ConstructFromPointer)};
115+
return Result{h256((uint8_t*)&r.result, h256::ConstructFromPointer), h256((uint8_t*)&r.mix_hash, h256::ConstructFromPointer)};
116116
}
117117

118-
EthashProofOfWork::Result EthashAux::eval(h256 const& _seedHash, h256 const& _headerHash, Nonce const& _nonce) noexcept
118+
Result EthashAux::eval(h256 const& _seedHash, h256 const& _headerHash, Nonce const& _nonce) noexcept
119119
{
120120
try
121121
{
122122
return EthashAux::get()->light(_seedHash)->compute(_headerHash, _nonce);
123123
}
124124
catch(...)
125125
{
126-
return EthashProofOfWork::Result{~h256(), h256()};
126+
return Result{~h256(), h256()};
127127
}
128128
}

‎libethcore/EthashAux.h

+28-32
Original file line numberDiff line numberDiff line change
@@ -32,39 +32,35 @@ namespace dev
3232
namespace eth
3333
{
3434

35-
/// Proof of work definition for Ethash.
36-
struct EthashProofOfWork
35+
struct Solution
3736
{
38-
struct Solution
39-
{
40-
Nonce nonce;
41-
h256 mixHash;
42-
};
37+
Nonce nonce;
38+
h256 mixHash;
39+
};
4340

44-
struct Result
45-
{
46-
h256 value;
47-
h256 mixHash;
48-
};
41+
struct Result
42+
{
43+
h256 value;
44+
h256 mixHash;
45+
};
4946

50-
struct WorkPackage
51-
{
52-
WorkPackage() = default;
53-
WorkPackage(BlockHeader const& _bh) :
54-
boundary(_bh.boundary()),
55-
headerHash(_bh.hashWithout()),
56-
seedHash(_bh.seedHash())
57-
{ }
58-
void reset() { headerHash = h256(); }
59-
operator bool() const { return headerHash != h256(); }
60-
61-
h256 boundary;
62-
h256 headerHash; ///< When h256() means "pause until notified a new work package is available".
63-
h256 seedHash;
64-
65-
uint64_t startNonce = 0;
66-
int exSizeBits = -1;
67-
};
47+
struct WorkPackage
48+
{
49+
WorkPackage() = default;
50+
WorkPackage(BlockHeader const& _bh) :
51+
boundary(_bh.boundary()),
52+
headerHash(_bh.hashWithout()),
53+
seedHash(_bh.seedHash())
54+
{ }
55+
void reset() { headerHash = h256(); }
56+
operator bool() const { return headerHash != h256(); }
57+
58+
h256 boundary;
59+
h256 headerHash; ///< When h256() means "pause until notified a new work package is available".
60+
h256 seedHash;
61+
62+
uint64_t startNonce = 0;
63+
int exSizeBits = -1;
6864
};
6965

7066
class EthashAux
@@ -77,7 +73,7 @@ class EthashAux
7773
LightAllocation(h256 const& _seedHash);
7874
~LightAllocation();
7975
bytesConstRef data() const;
80-
EthashProofOfWork::Result compute(h256 const& _headerHash, Nonce const& _nonce) const;
76+
Result compute(h256 const& _headerHash, Nonce const& _nonce) const;
8177
ethash_light_t light;
8278
uint64_t size;
8379
};
@@ -89,7 +85,7 @@ class EthashAux
8985

9086
static LightType light(h256 const& _seedHash);
9187

92-
static EthashProofOfWork::Result eval(h256 const& _seedHash, h256 const& _headerHash, Nonce const& _nonce) noexcept;
88+
static Result eval(h256 const& _seedHash, h256 const& _headerHash, Nonce const& _nonce) noexcept;
9389

9490
private:
9591
EthashAux() = default;

‎libethcore/EthashCUDAMiner.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ EthashCUDAMiner::~EthashCUDAMiner()
124124
bool EthashCUDAMiner::report(uint64_t _nonce)
125125
{
126126
Nonce n = (Nonce)(u64)_nonce;
127-
EthashProofOfWork::Result r = EthashAux::eval(work().seedHash, work().headerHash, n);
127+
Result r = EthashAux::eval(work().seedHash, work().headerHash, n);
128128
if (r.value < work().boundary)
129129
return submitProof(Solution{ n, r.mixHash });
130130
return false;

‎libethcore/EthashGPUMiner.cpp

+1-18
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ EthashGPUMiner::~EthashGPUMiner()
123123
bool EthashGPUMiner::report(uint64_t _nonce)
124124
{
125125
Nonce n = (Nonce)(u64)_nonce;
126-
EthashProofOfWork::Result r = EthashAux::eval(work().seedHash, work().headerHash, n);
126+
Result r = EthashAux::eval(work().seedHash, work().headerHash, n);
127127
if (r.value < work().boundary)
128128
return submitProof(Solution{n, r.mixHash});
129129
return false;
@@ -158,23 +158,6 @@ void EthashGPUMiner::workLoop()
158158

159159
unsigned device = s_devices[index()] > -1 ? s_devices[index()] : index();
160160

161-
/*
162-
EthashAux::FullType dag;
163-
while (true)
164-
{
165-
if ((dag = EthashAux::full(w.seedHash, true)))
166-
break;
167-
if (shouldStop())
168-
{
169-
delete m_miner;
170-
m_miner = nullptr;
171-
return;
172-
}
173-
cnote << "Awaiting DAG";
174-
this_thread::sleep_for(chrono::milliseconds(500));
175-
}
176-
*/
177-
178161
EthashAux::LightType light;
179162
light = EthashAux::light(w.seedHash);
180163
bytesConstRef lightData = light->data();

‎libethcore/Farm.h

-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ namespace eth
4444
class Farm: public FarmFace
4545
{
4646
public:
47-
using WorkPackage = EthashProofOfWork::WorkPackage;
48-
using Solution = EthashProofOfWork::Solution;
49-
5047
struct SealerDescriptor
5148
{
5249
std::function<unsigned()> instances;

‎libethcore/Miner.h

-6
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,11 @@ class Miner;
119119
class FarmFace
120120
{
121121
public:
122-
using WorkPackage = EthashProofOfWork::WorkPackage;
123-
using Solution = EthashProofOfWork::Solution;
124-
125122
virtual ~FarmFace() = default;
126123

127124
/**
128125
* @brief Called from a Miner to note a WorkPackage has a solution.
129126
* @param _p The solution.
130-
* @param _wp The WorkPackage that the Solution is for; this will be reset if the work is accepted.
131127
* @param _finder The miner that found it.
132128
* @return true iff the solution was good (implying that mining should be .
133129
*/
@@ -141,8 +137,6 @@ class FarmFace
141137
class Miner
142138
{
143139
public:
144-
using WorkPackage = EthashProofOfWork::WorkPackage;
145-
using Solution = EthashProofOfWork::Solution;
146140
using ConstructionInfo = std::pair<FarmFace*, unsigned>;
147141

148142
Miner(ConstructionInfo const& _ci):

‎libstratum/EthStratumClient.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -504,11 +504,11 @@ void EthStratumClient::work_timeout_handler(const boost::system::error_code& ec)
504504
}
505505
}
506506

507-
bool EthStratumClient::submit(EthashProofOfWork::Solution solution) {
507+
bool EthStratumClient::submit(Solution solution) {
508508
x_current.lock();
509-
EthashProofOfWork::WorkPackage tempWork(m_current);
509+
WorkPackage tempWork(m_current);
510510
string temp_job = m_job;
511-
EthashProofOfWork::WorkPackage tempPreviousWork(m_previous);
511+
WorkPackage tempPreviousWork(m_previous);
512512
string temp_previous_job = m_previousJob;
513513
x_current.unlock();
514514

‎libstratum/EthStratumClient.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class EthStratumClient
3232
h256 currentHeaderHash() { return m_current.headerHash; }
3333
bool current() { return m_current; }
3434
unsigned waitState() { return m_waitState; }
35-
bool submit(EthashProofOfWork::Solution solution);
35+
bool submit(Solution solution);
3636
void reconnect();
3737
private:
3838
void connect();
@@ -70,8 +70,8 @@ class EthStratumClient
7070

7171
Farm* p_farm;
7272
std::mutex x_current;
73-
EthashProofOfWork::WorkPackage m_current;
74-
EthashProofOfWork::WorkPackage m_previous;
73+
WorkPackage m_current;
74+
WorkPackage m_previous;
7575

7676
bool m_stale = false;
7777

‎libstratum/EthStratumClientV2.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -446,11 +446,11 @@ void EthStratumClientV2::work_timeout_handler(const boost::system::error_code& e
446446
}
447447
}
448448

449-
bool EthStratumClientV2::submit(EthashProofOfWork::Solution solution) {
449+
bool EthStratumClientV2::submit(Solution solution) {
450450
x_current.lock();
451-
EthashProofOfWork::WorkPackage tempWork(m_current);
451+
WorkPackage tempWork(m_current);
452452
string temp_job = m_job;
453-
EthashProofOfWork::WorkPackage tempPreviousWork(m_previous);
453+
WorkPackage tempPreviousWork(m_previous);
454454
string temp_previous_job = m_previousJob;
455455
x_current.unlock();
456456

‎libstratum/EthStratumClientV2.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class EthStratumClientV2 : public Worker
3333
h256 currentHeaderHash() { return m_current.headerHash; }
3434
bool current() { return m_current; }
3535
unsigned waitState() { return m_waitState; }
36-
bool submit(EthashProofOfWork::Solution solution);
36+
bool submit(Solution solution);
3737
void reconnect();
3838
private:
3939
void workLoop() override;
@@ -66,8 +66,8 @@ class EthStratumClientV2 : public Worker
6666

6767
Farm* p_farm;
6868
mutex x_current;
69-
EthashProofOfWork::WorkPackage m_current;
70-
EthashProofOfWork::WorkPackage m_previous;
69+
WorkPackage m_current;
70+
WorkPackage m_previous;
7171

7272
bool m_stale = false;
7373

0 commit comments

Comments
 (0)
This repository has been archived.