Skip to content
This repository was archived by the owner on Dec 31, 2022. It is now read-only.

Commit 3a60401

Browse files
authored
Merge pull request #166 from gilnobrega/development
Custom Report Interval and Log Parse Interval
2 parents 92f7396 + 278784e commit 3a60401

File tree

6 files changed

+90
-27
lines changed

6 files changed

+90
-27
lines changed

blockchain/xch.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,7 @@
1313
"fullNode": 8555,
1414
"wallet": 9256,
1515
"daemon": 55400
16-
}
16+
},
17+
"Report Interval": 600,
18+
"Log Parse Interval": 5
1719
}

docs/forks.md

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,25 @@ In the event that your coin is not listed here, you will need to create a templa
1010
1. Create the file with the proper name
1111
1. Place the boilerplate inside of this file
1212
```
13-
{
14-
"Binary Name": "chia",
15-
"Folder Name": ".chia",
16-
"Currency Symbol": "XCH",
17-
"Minor Currency Symbol": "mojo",
18-
"Net": "mainnet",
19-
"Block Rewards": 2.0,
20-
"Blocks Per 10 Minutes": 32.0,
21-
"Config Path": "/home/user/.chia/mainnet/config",
22-
"Log Path": "/home/user/.chia/mainnet/log"
23-
}
13+
{
14+
"Binary Name": "chia",
15+
"Currency Symbol": "XCH",
16+
"Minor Currency Symbol": "mojo",
17+
"Major to Minor Multiplier": 1e12,
18+
"Net": "mainnet",
19+
"Block Rewards": 2.0,
20+
"Blocks Per 10 Minutes": 32.0,
21+
"Online Config": true,
22+
"Ports": {
23+
"harvester": 8560,
24+
"farmer": 8559,
25+
"fullNode": 8555,
26+
"wallet": 9256,
27+
"daemon": 55400
28+
},
29+
"Report Interval": 600,
30+
"Log Parse Interval": 5
31+
}
2432
```
2533
1. Edit the values as shown below. All defaults below are the `Chia-Network/chia-blockchain` values
2634
1. Ensure it is working in [farmr](https://farmr.net/#/)
@@ -68,4 +76,21 @@ OPTIONAL: to the log files.
6876
```
6977
Linux: `/home/user/.chia/mainnet/log`
7078
Windows: `C:\\Users\\USER\\.chia\\mainnet\\log`
71-
```
79+
```
80+
81+
#### Online Config
82+
OPTIONAL: Allows configuring settings through farmr.net dashboard.
83+
Defaults to true.
84+
When false, these can be set in local ```config-###.json``` files.
85+
86+
#### Ports
87+
RPC Service Ports
88+
89+
#### Report Interval
90+
OPTIONAL: Interval between farmr reports in seconds.
91+
Defaults to 10 minutes (600 seconds).
92+
May not be shorter than 1 minute (60 seconds) or higher than 30 minutes (1800 seconds).
93+
94+
#### Log Parse Interval
95+
OPTIONAL: Interval between debug.log parses
96+
Defaults to 5 seconds.

environment_config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ environment_config:
66
fields: # set of fields for command
77
version: # key name
88
const: true # optional, default to TRUE
9-
default: 1.7.8.0beta5 # optional, default value for key, if not provided key will be required during command run
9+
default: 1.8.0.0 # optional, default value for key, if not provided key will be required during command run
1010
dotenv: true # optional, default to FALSE, if this field should be added to .env file
1111

farmr.dart

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ import 'package:dart_console/dart_console.dart' as dartconsole;
2929

3030
final log = Logger('Client');
3131

32-
const Duration delay = Duration(minutes: 10); //10 minutes delay between updates
32+
Duration reportIntervalDuration =
33+
Duration(minutes: 10); //10 minutes delay between updates
3334

3435
// '/home/user/.farmr' for package installs, '.' (project path) for the rest
3536
String rootPath = "";
@@ -112,6 +113,9 @@ List<Blockchain> readBlockchains(ID id, String rootPath, List<String> args) {
112113
Blockchain blockchain = Blockchain(id, rootPath, args,
113114
jsonDecode(io.File(file.path).readAsStringSync()));
114115
blockchains.add(blockchain);
116+
117+
if (blockchain.binaryName == "chia")
118+
reportIntervalDuration = blockchain.reportIntervalDuration;
115119
}
116120
}
117121
}
@@ -284,7 +288,7 @@ Do not close this window or these stats will not show up in farmr.net and farmrB
284288
}
285289

286290
void timeoutIsolate(SendPort timeoutPort) {
287-
final int timeOutMins = delay.inMinutes * 2;
291+
final int timeOutMins = reportIntervalDuration.inMinutes * 2;
288292

289293
io.sleep(Duration(minutes: timeOutMins));
290294

@@ -306,7 +310,7 @@ void spawnBlokchains(List<Object> arguments) async {
306310
int counter = 0;
307311

308312
final int delayBetweenInMilliseconds =
309-
(delay.inMilliseconds / blockchains.length).round();
313+
(reportIntervalDuration.inMilliseconds / blockchains.length).round();
310314

311315
while (true) {
312316
clearLog(); //clears log
@@ -373,7 +377,7 @@ These addresses are NOT reported to farmr.net or farmrBot
373377
});
374378
}
375379

376-
await Future.delayed(delay);
380+
await Future.delayed(reportIntervalDuration);
377381
if (onetime) io.exit(0);
378382
}
379383
}
@@ -403,7 +407,10 @@ void handleBlockchainReport(List<Object> arguments) async {
403407
int blockchainDelay = arguments[5] as int;
404408

405409
//kills isolate after 20 minutes
406-
Future.delayed(Duration(minutes: (!onetime) ? (delay.inMinutes * 2) : 1), () {
410+
Future.delayed(
411+
Duration(
412+
minutes: (!onetime) ? (reportIntervalDuration.inMinutes * 2) : 1),
413+
() {
407414
sendPort.send([
408415
"${blockchain.currencySymbol} report killed. Are ${blockchain.binaryName} services running?",
409416
"",
@@ -638,7 +645,7 @@ Future<void> sendReport(
638645
: "for id " + id + blockchain.fileExtension;
639646
String timestamp = DateFormat.Hms().format(DateTime.now());
640647
previousOutput +=
641-
"\n$timestamp - Sent ${blockchain.binaryName} $type report to server $idText\nResending it in ${delay.inMinutes} minutes";
648+
"\n$timestamp - Sent ${blockchain.binaryName} $type report to server $idText\nResending it in ${reportIntervalDuration.inMinutes} minutes";
642649

643650
checkIfLinked(
644651
contents,

lib/blockchain.dart

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ class Blockchain {
9494
late final ClientType type;
9595
String get typeName => type.toString().split('.')[1];
9696

97+
int _reportInterval = 600;
98+
int get reportInterval => reportInterval;
99+
Duration get reportIntervalDuration => Duration(seconds: _reportInterval);
100+
101+
int _logParseInterval = 5;
102+
int get logParseInterval => reportInterval;
103+
Duration get logParsingIntervalDuration =>
104+
Duration(seconds: _logParseInterval);
105+
97106
Blockchain(this.id, this._rootPath, this._args, [dynamic json]) {
98107
_fromJson(json); //loads properties from serialized blokchain
99108

@@ -137,8 +146,14 @@ class Blockchain {
137146
_onlineConfig = json['Online Config'] ?? true;
138147
_majorToMinorMultiplier = json['Major to Minor Multiplier'] ?? 1e12;
139148
_checkPlotSize = json['Check for Complete Plots'] ?? true;
149+
_reportInterval = json['Report Interval'] ?? 600;
150+
_logParseInterval = json['Log Parse Interval'] ?? 5;
140151
}
141152

153+
//sets limits of report interval
154+
if (_reportInterval < 60) _reportInterval = 60;
155+
if (_reportInterval > 1800) _reportInterval = 1800;
156+
142157
//initializes default rpc ports for xch
143158
if (currencySymbol == "xch") {
144159
const defaultMap = const {
@@ -228,8 +243,15 @@ class Blockchain {
228243
await this.config.init(this.onlineConfig,
229244
this._args.contains("headless") || this._args.contains("hpool"));
230245

231-
this.log = new Log(this.logPath, this.cache, this.config.parseLogs,
232-
this.binaryName, this.config.type, configPath, firstInit);
246+
this.log = new Log(
247+
this.logPath,
248+
this.cache,
249+
this.config.parseLogs,
250+
this.binaryName,
251+
this.config.type,
252+
configPath,
253+
firstInit,
254+
this.logParsingIntervalDuration);
233255
}
234256

235257
/** Returns configPath & logPath for the coin based on platform */

lib/debug.dart

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,17 @@ class Log {
4646

4747
late final String dbPath;
4848

49-
final Duration _refreshLogsInterval = Duration(seconds: 5);
50-
51-
Log(String logPath, this._cache, bool parseLogs, this._binaryName, this._type,
52-
String configPath, bool firstInit) {
49+
late final Duration logParseIntervalDuration;
50+
51+
Log(
52+
String logPath,
53+
this._cache,
54+
bool parseLogs,
55+
this._binaryName,
56+
this._type,
57+
String configPath,
58+
bool firstInit,
59+
Duration this.logParseIntervalDuration) {
5360
_filters = _cache.filters; //loads cached filters
5461
signagePoints = _cache.signagePoints; //loads cached subslots
5562
shortSyncs = _cache.shortSyncs;
@@ -200,7 +207,7 @@ class Log {
200207
harvesterErrors.addAll(
201208
newErrors.where((element) => element.type == ErrorType.Harvester));
202209

203-
await Future.delayed(_refreshLogsInterval);
210+
await Future.delayed(logParseIntervalDuration);
204211

205212
if (onetime) break;
206213
}

0 commit comments

Comments
 (0)