-
Notifications
You must be signed in to change notification settings - Fork 0
/
EthashProofOfWork.cpp
60 lines (52 loc) · 1.91 KB
/
EthashProofOfWork.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file EthashProofOfWork.cpp
* @author Gav Wood <[email protected]>
* @date 2014
*
* Determines the PoW algorithm.
*/
#include "EthashProofOfWork.h"
#include "Ethash.h"
using namespace std;
using namespace chrono;
using namespace dev;
using namespace eth;
const unsigned EthashProofOfWork::defaultLocalWorkSize = 64;
const unsigned EthashProofOfWork::defaultGlobalWorkSizeMultiplier = 4096; // * CL_DEFAULT_LOCAL_WORK_SIZE
const unsigned EthashProofOfWork::defaultMSPerBatch = 0;
const EthashProofOfWork::WorkPackage EthashProofOfWork::NullWorkPackage = EthashProofOfWork::WorkPackage();
EthashProofOfWork::WorkPackage::WorkPackage(BlockHeader const& _bh):
boundary(Ethash::boundary(_bh)),
seedHash(Ethash::seedHash(_bh)),
m_headerHash(_bh.hash(WithoutSeal))
{}
EthashProofOfWork::WorkPackage::WorkPackage(WorkPackage const& _other):
boundary(_other.boundary),
seedHash(_other.seedHash),
m_headerHash(_other.headerHash())
{}
EthashProofOfWork::WorkPackage& EthashProofOfWork::WorkPackage::operator=(EthashProofOfWork::WorkPackage const& _other)
{
if (this == &_other)
return *this;
boundary = _other.boundary;
seedHash = _other.seedHash;
h256 headerHash = _other.headerHash();
{
Guard l(m_headerHashLock);
m_headerHash = std::move(headerHash);
}
return *this;
}