-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathconfig.cpp
More file actions
139 lines (126 loc) · 2.56 KB
/
config.cpp
File metadata and controls
139 lines (126 loc) · 2.56 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#include "config.h"
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <fstream>
/*
Adapted from @paulscreen's pool config code by HashToBeWild
*/
namespace pt = boost::property_tree;
namespace Core
{
MinerConfig::MinerConfig()
{
strHost = "";
nPort = "9549"; // 9325 for solo
strNxsAddress = "2S4PPSznWfPVLtPJNpi8Ly46Wft3wGbayGkhaGzKLVcepmrhKTP";
nSieveThreads = 0; // 0 = use all threads
nPTestThreads = 0; // 0 = use all threads
nTimeout = 10;
nBitArraySize = 37748736; // 1024*1024*36
primeLimit = 71378571;
nPrimeLimit = 4194304;
nPrimorialEndPrime = 12;
bExperimental = true;
}
void MinerConfig::PrintConfig()
{
printf("Configuration: \n");
printf("-------------\n");
printf("Host: %s \n", strHost.c_str());
printf("Port: %s \n", nPort.c_str());
printf("Address: %s \n", strNxsAddress.c_str());
printf("SieveThreads: %i \n", nSieveThreads);
printf("SieveThreads: %i \n", nPTestThreads);
printf("Timeout: %i \n", nTimeout);
printf("Bit Array Size: %u \n", nBitArraySize);
printf("Prime Limit: %u \n", primeLimit);
printf("N Prime Limit: %u}", nPrimeLimit);
printf("Primorial End Prime: %u \n", nPrimorialEndPrime);
}
bool MinerConfig::ReadConfig()
{
//printf("in read");
bool bSuccess = true;
try
{
//printf("Reading config file miner.conf\n");
std::ifstream lConfigFile("miner.conf");
pt::ptree root;
pt::read_json("miner.conf", root);
// do not beak if a value is missing...
try
{
strHost = root.get<std::string>("host");
}
catch(...)
{}
try
{
nPort = root.get<std::string>("port");
}
catch(...)
{}
try
{
strNxsAddress = root.get<std::string>("nxs_address");
}
catch(...)
{}
try
{
nSieveThreads = root.get<int>("sieve_threads");
}
catch(...)
{}
try
{
nPTestThreads = root.get<int>("ptest_threads");
}
catch (...)
{
}
try
{
nTimeout = root.get<int>("timeout");
}
catch(...)
{}
try
{
nBitArraySize = root.get<unsigned int>("bit_array_size");
}
catch(...)
{}
try
{
primeLimit = root.get<unsigned int>("prime_limit");
}
catch(...)
{}
try
{
nPrimeLimit = root.get<unsigned int>("n_prime_limit");
}
catch(...)
{}
try
{
nPrimorialEndPrime = root.get<unsigned int>("primorial_end_prime");
}
catch(...)
{}
try
{
bExperimental = root.get<bool>("experimental");
}
catch (...)
{
}
}
catch(...)
{
bSuccess = false;
}
return bSuccess;
}
} // end namespace