Skip to content

Commit 4cdb82a

Browse files
committed
Added a configuration assistant, rieMiner.conf no longer provided
Signed-off-by: Pttn <28868425+Pttn@users.noreply.github.com>
1 parent ebc8633 commit 4cdb82a

File tree

6 files changed

+136
-22
lines changed

6 files changed

+136
-22
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# rieMiner 0.9β1.5
1+
# rieMiner 0.9β2
22

33
rieMiner is a Riecoin miner supporting both solo and pooled mining, and using the latest known mining algorithm. It was originally adapted and refactored from gatra's cpuminer-rminerd (https://github.com/gatra/cpuminer-rminerd) and dave-andersen's fastrie (https://github.com/dave-andersen/fastrie).
44

@@ -98,13 +98,15 @@ Then, follow the instructions for 64 bits systems. If you do not do this, the co
9898

9999
## Run this program
100100

101-
First of all, open or create a file named "rieMiner.conf" next to the executable, in order to provide options to the miner. The rieMiner.conf syntax is very simple: each option is given by a line such
101+
If no "rieMiner.conf" next to the executable was found, you will be assisted to configure rieMiner. Answer to its questions to start mining. If there is a "rieMiner.conf" file next to the executable with incorrect information, you can delete this to get the assisted configuration.
102+
103+
Alternatively, you can create or edit this "rieMiner.conf" file next to the executable, in order to provide options to the miner. The rieMiner.conf syntax is very simple: each option is given by a line such
102104

103105
```
104106
Option type = Option value
105107
```
106108

107-
It is case sensitive, but spaces and invalid lines are ignored. If an option or the file is missing, the default value(s) will be used. If there are duplicate lines, the last one will be used. The available options are:
109+
It is case sensitive, but spaces and invalid lines are ignored. **Do not put ; at the end or use other delimiters than =** for each line, and **do not confuse rieMiner.conf with riecoin.conf**! If an option or the file is missing, the default value(s) will be used. If there are duplicate lines, the last one will be used. The available options are:
108110

109111
* Host : IP of the Riecoin wallet/server or pool. Default: 127.0.0.1 (your computer);
110112
* Port : port of the Riecoin wallet/server or pool. Default: 28332 (default port for Riecoin-Qt);
@@ -159,6 +161,7 @@ Note that other ways for solo mining (protocol proxies,...) were never tested wi
159161
To solo mine with the official Riecoin-Qt wallet, you have to configure it.
160162

161163
* Find the riecoin.conf configuration file. It should be located in /home/username/.riecoin or equivalent in Windows;
164+
* **Do not confuse this file with the rieMiner.conf**!
162165
* An example of riecoin.conf content suitable for mining is
163166

164167
```

gbtclient.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ void GetBlockTemplateData::coinBaseGen() {
6262
// Output Count [s + 4]
6363
coinbase.push_back(1);
6464
// Output Value [s + 5 -> s + 12]
65-
uint64_t coinbasevalue2(coinbasevalue);
65+
uint64_t reward(coinbasevalue);
6666
for (uint32_t i(0) ; i < 8 ; i++) {
67-
coinbase.push_back(coinbasevalue2 % 256);
68-
coinbasevalue2 /= 256;
67+
coinbase.push_back(reward % 256);
68+
reward /= 256;
6969
}
7070
coinbase.push_back(25); // Output Length [s + 13]
7171
coinbase.push_back(0x76); // OP_DUP [s + 14]

main.cpp

Lines changed: 124 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ void WorkManager::manage() {
110110
if (!_miningStarted && _client->workData().height != 0) {
111111
_stats.startTimer();
112112
_stats.updateHeight(_client->workData().height - 1);
113+
std::cout << "-----------------------------------------------------------" << std::endl;
113114
std::cout << "[0000:00:00] Started mining at block " << _client->workData().height << std::endl;
114115
_miningStarted = true;
115116
}
@@ -157,6 +158,125 @@ void Options::parseLine(std::string line, std::string& key, std::string& value)
157158
}
158159
}
159160

161+
void Options::askConf() {
162+
std::string value;
163+
std::ofstream file("rieMiner.conf");
164+
if (file) {
165+
std::cout << "Solo mining (solo), pooled mining (pool), or benchmarking (benchmark)? ";
166+
std::cin >> value;
167+
if (value == "solo") {
168+
file << "Protocol = GetBlockTemplate" << std::endl;
169+
_protocol = "GetBlockTemplate";
170+
}
171+
else if (value == "pool") {
172+
file << "Protocol = Stratum" << std::endl;
173+
_protocol = "Stratum";
174+
}
175+
else if (value == "benchmark") {
176+
file << "Protocol = Benchmark" << std::endl;
177+
_protocol = "Benchmark";
178+
}
179+
else {
180+
std::cerr << "Invalid choice! Please answer solo, pool, or benchmark." << std::endl;
181+
std::remove("rieMiner.conf");
182+
exit(0);
183+
}
184+
185+
if (_protocol != "Benchmark") {
186+
if (_protocol == "GetBlockTemplate") {
187+
std::cout << "Riecoin Core (wallet) IP: ";
188+
std::cin >> value;
189+
#ifndef _WIN32
190+
struct sockaddr_in sa;
191+
if (inet_pton(AF_INET, value.c_str(), &(sa.sin_addr)) != 1) {
192+
std::cerr << "Invalid IP address!" << std::endl;
193+
std::remove("rieMiner.conf");
194+
exit(0);
195+
}
196+
else {
197+
file << "Host = " << value << std::endl;
198+
_host = value;
199+
}
200+
#else
201+
file << "Host = " << value << std::endl;
202+
_host = value;
203+
#endif
204+
std::cout << "RPC port: ";
205+
}
206+
else {
207+
std::cout << "Current pools " << std::endl;
208+
std::cout << " XPoolX: mining.xpoolx.com:5000" << std::endl;
209+
std::cout << " riePool: riepool.ovh:8000" << std::endl;
210+
std::cout << " Block.it: mine.ublock.it:5000" << std::endl;
211+
std::cout << "Pool address (without port): ";
212+
std::cin >> value;
213+
file << "Host = " << value << std::endl;
214+
_host = value;
215+
std::cout << "Pool port (example: 5000): ";
216+
}
217+
218+
std::cin >> value;
219+
try {
220+
_port = std::stoi(value);
221+
file << "Port = " << value << std::endl;
222+
}
223+
catch (...) {
224+
std::cerr << "Invalid port !" << std::endl;
225+
std::remove("rieMiner.conf");
226+
exit(0);
227+
}
228+
229+
if (_protocol == "GetBlockTemplate") std::cout << "RPC username: ";
230+
else std::cout << "Pool username.worker: ";
231+
232+
std::cin >> value;
233+
file << "User = " << value << std::endl;
234+
_user = value;
235+
236+
if (_protocol == "GetBlockTemplate") std::cout << "RPC password: ";
237+
else std::cout << "Worker password: ";
238+
239+
std::cin >> value;
240+
file << "Pass = " << value << std::endl;
241+
_pass = value;
242+
243+
if (_protocol == "GetBlockTemplate") {
244+
uint8_t scriptPubKeyTest[20];
245+
std::cout << "Payout address: ";
246+
std::cin >> value;
247+
if (!addrToScriptPubKey(value, scriptPubKeyTest)) {
248+
std::cerr << "Invalid payout address!" << std::endl;
249+
std::remove("rieMiner.conf");
250+
exit(0);
251+
}
252+
else {
253+
file << "Address = " << value << std::endl;
254+
_address = value;
255+
}
256+
}
257+
}
258+
else std::cout << "Standard Benchmark values loaded. Edit the rieMiner.conf file if needed." << std::endl;
259+
260+
std::cout << "Number of threads: ";
261+
std::cin >> value;
262+
try {
263+
_threads = std::stoi(value);
264+
file << "Threads = " << value << std::endl;
265+
}
266+
catch (...) {
267+
std::cerr << "Invalid thread number!" << std::endl;
268+
std::remove("rieMiner.conf");
269+
exit(0);
270+
}
271+
272+
if (_protocol != "Benchmark") std::cout << "Thank you, happy mining :D !" << std::endl;
273+
else std::cout << "Thank you :D !" << std::endl;
274+
std::cout << "-----------------------------------------------------------" << std::endl;
275+
file.close();
276+
}
277+
else std::cerr << "Unable to create rieMiner.conf :|, values for standard benchmark loaded." << std::endl;
278+
}
279+
160280
void Options::loadConf() {
161281
std::ifstream file("rieMiner.conf", std::ios::in);
162282
std::cout << "Opening rieMiner.conf..." << std::endl;
@@ -222,8 +342,10 @@ void Options::loadConf() {
222342
}
223343
file.close();
224344
}
225-
else
226-
std::cerr << "rieMiner.conf not found or unreadable, values for standard benchmark loaded." << std::endl;
345+
else {
346+
std::cerr << "rieMiner.conf not found or unreadable, please configure rieMiner now." << std::endl;
347+
askConf();
348+
}
227349

228350
std::cout << "Host = " << _host << std::endl;
229351
std::cout << "Port = " << _port << std::endl;

main.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#ifndef HEADER_GLOBAL_H
44
#define HEADER_GLOBAL_H
55

6-
#define minerVersionString "rieMiner 0.9-beta1.5"
6+
#define minerVersionString "rieMiner 0.9-beta2"
77
#define BITS 64
88

99
#include <unistd.h>
@@ -164,6 +164,7 @@ class Options {
164164
}
165165

166166
void loadConf();
167+
void askConf();
167168

168169
std::string host() const {return _host;}
169170
uint16_t port() const {return _port;}

rieMiner.conf

Lines changed: 0 additions & 12 deletions
This file was deleted.

stratumclient.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "main.h"
44
#include "stratumclient.h"
55

6-
#define USER_AGENT "rieMiner/0.9b1"
6+
#define USER_AGENT "rieMiner/0.9b2"
77

88
void StratumData::merkleRootGen() {
99
std::vector<uint8_t> coinbase;

0 commit comments

Comments
 (0)