forked from bhamon/gpuPlotGenerator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenerationContext.h
91 lines (67 loc) · 2.54 KB
/
GenerationContext.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
80
81
82
83
84
85
86
87
88
89
90
91
/*
GPU plot generator for Burst coin.
Author: Cryo
Bitcoin: 138gMBhCrNkbaiTCmUhP9HLU9xwn5QKZgD
Burst: BURST-YA29-QCEW-QXC3-BKXDL
Based on the code of the official miner and dcct's plotgen.
*/
#ifndef CRYO_GPU_PLOT_GENERATOR_GENERATION_CONTEXT_H
#define CRYO_GPU_PLOT_GENERATOR_GENERATION_CONTEXT_H
#include <memory>
#include <list>
#include "GenerationConfig.h"
#include "PlotsFile.h"
#include "GenerationWork.h"
#include "GenerationDevice.h"
namespace cryo {
namespace gpuPlotGenerator {
class GenerationContext {
protected:
std::shared_ptr<GenerationConfig> m_config;
std::shared_ptr<PlotsFile> m_plotsFile;
unsigned int m_noncesDistributed;
unsigned int m_noncesWritten;
std::list<std::shared_ptr<GenerationWork>> m_pendingWorks;
public:
GenerationContext(const std::shared_ptr<GenerationConfig>& p_config, const std::shared_ptr<PlotsFile>& p_plotsFile);
GenerationContext(const GenerationContext& p_other) = delete;
virtual ~GenerationContext() throw ();
GenerationContext& operator=(const GenerationContext& p_other) = delete;
inline const std::shared_ptr<GenerationConfig>& getConfig() const;
inline const std::shared_ptr<PlotsFile>& getPlotsFile() const;
inline unsigned int getNoncesDistributed() const;
inline unsigned int getNoncesWritten() const;
inline unsigned int getPendingNonces() const;
inline bool hasPendingWork() const;
inline const std::shared_ptr<GenerationWork>& getLastPendingWork() const;
const std::shared_ptr<GenerationWork>& requestWork(const std::shared_ptr<GenerationDevice>& p_device) throw (std::exception);
void popLastPendingWork() throw (std::exception);
virtual std::size_t getMemorySize() const = 0;
virtual void writeNonces(std::shared_ptr<GenerationWork>& p_work) throw (std::exception) = 0;
};
}}
namespace cryo {
namespace gpuPlotGenerator {
inline const std::shared_ptr<GenerationConfig>& GenerationContext::getConfig() const {
return m_config;
}
inline const std::shared_ptr<PlotsFile>& GenerationContext::getPlotsFile() const {
return m_plotsFile;
}
inline unsigned int GenerationContext::getNoncesDistributed() const {
return m_noncesDistributed;
}
inline unsigned int GenerationContext::getNoncesWritten() const {
return m_noncesWritten;
}
inline unsigned int GenerationContext::getPendingNonces() const {
return m_noncesDistributed - m_noncesWritten;
}
inline bool GenerationContext::hasPendingWork() const {
return m_pendingWorks.size() > 0;
}
inline const std::shared_ptr<GenerationWork>& GenerationContext::getLastPendingWork() const {
return m_pendingWorks.back();
}
}}
#endif