Rework StartOS config to support non-pooled mining properly

Co-authored-by: Shadowy Super Coder <musashidisciple@proton.me>
This commit is contained in:
Luke Dashjr 2025-01-22 19:31:49 +00:00
parent 5ab4b200bb
commit b5e35f71bb
4 changed files with 76 additions and 10 deletions

View File

@ -11,7 +11,23 @@ else
echo "blocknotify is set to: $blocknotify"
fi
yq eval -o=json /root/start9/config.yaml > /root/data/datum_gateway_config.json
filter='.'
case $(yq eval .datum.reward_sharing /root/start9/config.yaml) in
require)
filter="${filter}"'|.datum.pooled_mining_only=true'
;;
prefer)
filter="${filter}"'|.datum.pooled_mining_only=false'
;;
never)
filter="${filter}"'|.datum.pooled_mining_only=false'
filter="${filter}"'|.datum.pool_host=""'
;;
esac
yq eval -o=json \
"${filter}" \
/root/start9/config.yaml \
> /root/data/datum_gateway_config.json
printf "\n\n [i] Starting Datum Gateway ...\n\n"
exec datum_gateway -c /root/data/datum_gateway_config.json

View File

@ -5,7 +5,7 @@ id: datum
# A human readable service title
title: "Datum Gateway"
# Service version - accepts up to four digits, where the last confirms to revisions necessary for StartOS - see documentation: https://github.com/Start9Labs/emver-rs. This value will change with each release of the service.
version: 0.2.2
version: 0.2.2.1
# Release notes for the update - can be a string, paragraph or URL
release-notes: |
- Bug Fixes

View File

@ -335,12 +335,21 @@ export const getConfig: T.ExpectedExports.getConfig = compat.getConfig({
// default: false,
// nullable: true,
// },
pooled_mining_only: {
type: "boolean",
name: "Pooled Mining Only",
description: "If the DATUM pool server becomes unavailable, terminate miner connections (otherwise, 100% of any blocks you find pay mining.pool_address) (boolean, default: true)",
default: true,
nullable: true,
reward_sharing: {
type: "enum",
values: [
"require",
"prefer",
"never",
],
name: "Collaborative reward sharing (pooled mining)",
description: "You can share rewards and share in others' rewards - or only get rewarded when you find a block yourself.",
"value-names": {
require: "require (pooled mining only)",
prefer: "prefer (failover to non-pooled)",
never: "never (non-pooled only)",
},
default: "require",
},
},
},

View File

@ -1,5 +1,34 @@
import { compat, matches, types as T } from "../deps.ts";
function migrate_022_to_0221(config: any) {
if (config.datum.pooled_mining_only) {
config.datum.reward_sharing = 'require';
} else if (config.datum.pool_host) {
config.datum.reward_sharing = 'prefer';
} else {
config.datum.reward_sharing = 'never';
}
delete config.datum.pooled_mining_only;
return config;
}
function migrate_0221_to_022(config: any) {
if (config.datum.reward_sharing == 'require') {
config.datum.pooled_mining_only = true;
} else {
config.datum.pooled_mining_only = false;
if (config.datum.reward_sharing == 'prefer') {
if (!config.datum.pool_host) {
config.datum.pool_host = 'datum-beta1.mine.ocean.xyz';
}
} else { // config.datum.reward_sharing == 'never'
config.datum.pool_host = null;
}
}
delete config.datum.reward_sharing;
return config;
}
export const migration: T.ExpectedExports.migration =
compat.migrations.fromMapping(
{
@ -19,6 +48,18 @@ export const migration: T.ExpectedExports.migration =
{ version: "0.2.1", type: "down" }
),
},
"0.2.2.1": {
up: compat.migrations.updateConfig(
migrate_022_to_0221,
true,
{ version: "0.2.2.1", type: "up"}
),
down: compat.migrations.updateConfig(
migrate_0221_to_022,
true,
{ version: "0.2.2.1", type: "down"}
)
}
},
"0.2.2"
"0.2.2.1"
);