-
Notifications
You must be signed in to change notification settings - Fork 0
/
EthashProofOfWork.h
79 lines (64 loc) · 2.05 KB
/
EthashProofOfWork.h
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
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.h
* @author Gav Wood <[email protected]>
* @date 2015
*
* Determines the PoW algorithm.
*/
#pragma once
#include <libethcore/BlockHeader.h>
#include <libdevcore/Guards.h>
namespace dev
{
namespace eth
{
/// Proof of work definition for Ethash.
struct EthashProofOfWork
{
struct Solution
{
Nonce nonce;
h256 mixHash;
};
struct Result
{
h256 value;
h256 mixHash;
};
struct WorkPackage
{
WorkPackage() {}
WorkPackage(BlockHeader const& _bh);
WorkPackage(WorkPackage const& _other);
WorkPackage& operator=(WorkPackage const& _other);
void reset() { Guard l(m_headerHashLock); m_headerHash = h256(); }
operator bool() const { Guard l(m_headerHashLock); return m_headerHash != h256(); }
h256 headerHash() const { Guard l(m_headerHashLock); return m_headerHash; }
h256 boundary;
h256 seedHash;
private:
h256 m_headerHash; ///< When h256() means "pause until notified a new work package is available".
mutable Mutex m_headerHashLock;
};
static const WorkPackage NullWorkPackage;
/// Default value of the local work size. Also known as workgroup size.
static const unsigned defaultLocalWorkSize;
/// Default value of the global work size as a multiplier of the local work size
static const unsigned defaultGlobalWorkSizeMultiplier;
/// Default value of the milliseconds per global work size (per batch)
static const unsigned defaultMSPerBatch;
};
}
}