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

Commit

Permalink
Merge pull request #166 from gilnobrega/development
Browse files Browse the repository at this point in the history
Custom Report Interval and Log Parse Interval
  • Loading branch information
gilnobrega authored Jan 7, 2022
2 parents 92f7396 + 278784e commit 3a60401
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 27 deletions.
4 changes: 3 additions & 1 deletion blockchain/xch.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@
"fullNode": 8555,
"wallet": 9256,
"daemon": 55400
}
},
"Report Interval": 600,
"Log Parse Interval": 5
}
49 changes: 37 additions & 12 deletions docs/forks.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,25 @@ In the event that your coin is not listed here, you will need to create a templa
1. Create the file with the proper name
1. Place the boilerplate inside of this file
```
{
"Binary Name": "chia",
"Folder Name": ".chia",
"Currency Symbol": "XCH",
"Minor Currency Symbol": "mojo",
"Net": "mainnet",
"Block Rewards": 2.0,
"Blocks Per 10 Minutes": 32.0,
"Config Path": "/home/user/.chia/mainnet/config",
"Log Path": "/home/user/.chia/mainnet/log"
}
{
"Binary Name": "chia",
"Currency Symbol": "XCH",
"Minor Currency Symbol": "mojo",
"Major to Minor Multiplier": 1e12,
"Net": "mainnet",
"Block Rewards": 2.0,
"Blocks Per 10 Minutes": 32.0,
"Online Config": true,
"Ports": {
"harvester": 8560,
"farmer": 8559,
"fullNode": 8555,
"wallet": 9256,
"daemon": 55400
},
"Report Interval": 600,
"Log Parse Interval": 5
}
```
1. Edit the values as shown below. All defaults below are the `Chia-Network/chia-blockchain` values
1. Ensure it is working in [farmr](https://farmr.net/#/)
Expand Down Expand Up @@ -68,4 +76,21 @@ OPTIONAL: to the log files.
```
Linux: `/home/user/.chia/mainnet/log`
Windows: `C:\\Users\\USER\\.chia\\mainnet\\log`
```
```

#### Online Config
OPTIONAL: Allows configuring settings through farmr.net dashboard.
Defaults to true.
When false, these can be set in local ```config-###.json``` files.

#### Ports
RPC Service Ports

#### Report Interval
OPTIONAL: Interval between farmr reports in seconds.
Defaults to 10 minutes (600 seconds).
May not be shorter than 1 minute (60 seconds) or higher than 30 minutes (1800 seconds).

#### Log Parse Interval
OPTIONAL: Interval between debug.log parses
Defaults to 5 seconds.
2 changes: 1 addition & 1 deletion environment_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ environment_config:
fields: # set of fields for command
version: # key name
const: true # optional, default to TRUE
default: 1.7.8.0beta5 # optional, default value for key, if not provided key will be required during command run
default: 1.8.0.0 # optional, default value for key, if not provided key will be required during command run
dotenv: true # optional, default to FALSE, if this field should be added to .env file

19 changes: 13 additions & 6 deletions farmr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import 'package:dart_console/dart_console.dart' as dartconsole;

final log = Logger('Client');

const Duration delay = Duration(minutes: 10); //10 minutes delay between updates
Duration reportIntervalDuration =
Duration(minutes: 10); //10 minutes delay between updates

// '/home/user/.farmr' for package installs, '.' (project path) for the rest
String rootPath = "";
Expand Down Expand Up @@ -112,6 +113,9 @@ List<Blockchain> readBlockchains(ID id, String rootPath, List<String> args) {
Blockchain blockchain = Blockchain(id, rootPath, args,
jsonDecode(io.File(file.path).readAsStringSync()));
blockchains.add(blockchain);

if (blockchain.binaryName == "chia")
reportIntervalDuration = blockchain.reportIntervalDuration;
}
}
}
Expand Down Expand Up @@ -284,7 +288,7 @@ Do not close this window or these stats will not show up in farmr.net and farmrB
}

void timeoutIsolate(SendPort timeoutPort) {
final int timeOutMins = delay.inMinutes * 2;
final int timeOutMins = reportIntervalDuration.inMinutes * 2;

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

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

final int delayBetweenInMilliseconds =
(delay.inMilliseconds / blockchains.length).round();
(reportIntervalDuration.inMilliseconds / blockchains.length).round();

while (true) {
clearLog(); //clears log
Expand Down Expand Up @@ -373,7 +377,7 @@ These addresses are NOT reported to farmr.net or farmrBot
});
}

await Future.delayed(delay);
await Future.delayed(reportIntervalDuration);
if (onetime) io.exit(0);
}
}
Expand Down Expand Up @@ -403,7 +407,10 @@ void handleBlockchainReport(List<Object> arguments) async {
int blockchainDelay = arguments[5] as int;

//kills isolate after 20 minutes
Future.delayed(Duration(minutes: (!onetime) ? (delay.inMinutes * 2) : 1), () {
Future.delayed(
Duration(
minutes: (!onetime) ? (reportIntervalDuration.inMinutes * 2) : 1),
() {
sendPort.send([
"${blockchain.currencySymbol} report killed. Are ${blockchain.binaryName} services running?",
"",
Expand Down Expand Up @@ -638,7 +645,7 @@ Future<void> sendReport(
: "for id " + id + blockchain.fileExtension;
String timestamp = DateFormat.Hms().format(DateTime.now());
previousOutput +=
"\n$timestamp - Sent ${blockchain.binaryName} $type report to server $idText\nResending it in ${delay.inMinutes} minutes";
"\n$timestamp - Sent ${blockchain.binaryName} $type report to server $idText\nResending it in ${reportIntervalDuration.inMinutes} minutes";

checkIfLinked(
contents,
Expand Down
26 changes: 24 additions & 2 deletions lib/blockchain.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ class Blockchain {
late final ClientType type;
String get typeName => type.toString().split('.')[1];

int _reportInterval = 600;
int get reportInterval => reportInterval;
Duration get reportIntervalDuration => Duration(seconds: _reportInterval);

int _logParseInterval = 5;
int get logParseInterval => reportInterval;
Duration get logParsingIntervalDuration =>
Duration(seconds: _logParseInterval);

Blockchain(this.id, this._rootPath, this._args, [dynamic json]) {
_fromJson(json); //loads properties from serialized blokchain

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

//sets limits of report interval
if (_reportInterval < 60) _reportInterval = 60;
if (_reportInterval > 1800) _reportInterval = 1800;

//initializes default rpc ports for xch
if (currencySymbol == "xch") {
const defaultMap = const {
Expand Down Expand Up @@ -228,8 +243,15 @@ class Blockchain {
await this.config.init(this.onlineConfig,
this._args.contains("headless") || this._args.contains("hpool"));

this.log = new Log(this.logPath, this.cache, this.config.parseLogs,
this.binaryName, this.config.type, configPath, firstInit);
this.log = new Log(
this.logPath,
this.cache,
this.config.parseLogs,
this.binaryName,
this.config.type,
configPath,
firstInit,
this.logParsingIntervalDuration);
}

/** Returns configPath & logPath for the coin based on platform */
Expand Down
17 changes: 12 additions & 5 deletions lib/debug.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,17 @@ class Log {

late final String dbPath;

final Duration _refreshLogsInterval = Duration(seconds: 5);

Log(String logPath, this._cache, bool parseLogs, this._binaryName, this._type,
String configPath, bool firstInit) {
late final Duration logParseIntervalDuration;

Log(
String logPath,
this._cache,
bool parseLogs,
this._binaryName,
this._type,
String configPath,
bool firstInit,
Duration this.logParseIntervalDuration) {
_filters = _cache.filters; //loads cached filters
signagePoints = _cache.signagePoints; //loads cached subslots
shortSyncs = _cache.shortSyncs;
Expand Down Expand Up @@ -200,7 +207,7 @@ class Log {
harvesterErrors.addAll(
newErrors.where((element) => element.type == ErrorType.Harvester));

await Future.delayed(_refreshLogsInterval);
await Future.delayed(logParseIntervalDuration);

if (onetime) break;
}
Expand Down

0 comments on commit 3a60401

Please sign in to comment.