mirror of
https://github.com/Retropex/knots-startos.git
synced 2025-05-12 19:30:45 +02:00
Update setConfig.ts for coinstatsindex
This commit is contained in:
parent
eabdcb071b
commit
0ff4a3f566
@ -1,36 +1,39 @@
|
||||
import {
|
||||
matches,
|
||||
compat,
|
||||
types,
|
||||
YAML
|
||||
} from "../dependencies.ts";
|
||||
const { number, shape, boolean } = matches;
|
||||
import { matches, types, YAML } from "../dependencies.ts";
|
||||
const { number } = matches;
|
||||
|
||||
export const setConfig: types.ExpectedExports.setConfig = async (
|
||||
effects: types.Effects,
|
||||
// deno-lint-ignore no-explicit-any
|
||||
newConfig: any,
|
||||
newConfig: any
|
||||
) => {
|
||||
if (!(newConfig?.rpc?.enable || !(newConfig.advanced?.pruning?.mode === "manual"))) {
|
||||
if (newConfig.advanced.pruning.mode === "manual" && !newConfig.rpc.enable) {
|
||||
return {
|
||||
error: "RPC must be enabled for manual.",
|
||||
error: "RPC must be enabled for manual pruning.",
|
||||
};
|
||||
}
|
||||
if (
|
||||
!(!newConfig.txindex || (newConfig.advanced?.pruning?.mode === "disabled"))
|
||||
) {
|
||||
|
||||
if (newConfig.txindex && newConfig.advanced.pruning.mode !== "disabled") {
|
||||
return {
|
||||
error: "Txindex not allowed on pruned nodes.",
|
||||
};
|
||||
}
|
||||
// true, false only fail case
|
||||
|
||||
if (
|
||||
!(!newConfig.advanced.blockfilters.peerblockfilters ||
|
||||
(newConfig.advanced.blockfilters.blockfilterindex))
|
||||
newConfig.coinstatsindex &&
|
||||
newConfig.advanced.pruning.mode !== "disabled"
|
||||
) {
|
||||
return {
|
||||
error: "Coinstats index not allowed on pruned nodes.",
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
newConfig.advanced.blockfilters.peerblockfilters &&
|
||||
!newConfig.advanced.blockfilters.blockfilterindex
|
||||
) {
|
||||
return {
|
||||
error:
|
||||
"'Compute Compact Block Filters' must be enabled if 'Serve Compact Block Filters to Peers' is enabled.",
|
||||
'"Compute Compact Block Filters" must be enabled if "Serve Compact Block Filters to Peers" is enabled.',
|
||||
};
|
||||
}
|
||||
|
||||
@ -41,10 +44,12 @@ export const setConfig: types.ExpectedExports.setConfig = async (
|
||||
|
||||
// config-set.sh
|
||||
|
||||
const oldConfig = await effects.readFile({
|
||||
path: "start9/config.yaml",
|
||||
volumeId: "main",
|
||||
}).catch(() => null);
|
||||
const oldConfig = await effects
|
||||
.readFile({
|
||||
path: "start9/config.yaml",
|
||||
volumeId: "main",
|
||||
})
|
||||
.catch(() => null);
|
||||
if (oldConfig) {
|
||||
await effects.writeFile({
|
||||
path: "start9/config-old.yaml",
|
||||
@ -56,7 +61,7 @@ export const setConfig: types.ExpectedExports.setConfig = async (
|
||||
let oldPruningSize = 0;
|
||||
if (oldPruningTl !== "disabled") {
|
||||
oldPruningSize = number.unsafeCast(
|
||||
oldConfigParsed?.advanced?.pruning?.size,
|
||||
oldConfigParsed?.advanced?.pruning?.size
|
||||
);
|
||||
}
|
||||
const newPruningTl = newConfig.advanced.pruning.mode;
|
||||
@ -67,7 +72,8 @@ export const setConfig: types.ExpectedExports.setConfig = async (
|
||||
if (oldPruningTl == "disabled" || !oldPruningTl) {
|
||||
effects.debug("No reindex required");
|
||||
} else if (
|
||||
oldPruningTl === newPruningTl && oldPruningSize >= newPruningSize
|
||||
oldPruningTl === newPruningTl &&
|
||||
oldPruningSize >= newPruningSize
|
||||
) {
|
||||
effects.debug("No reindex required");
|
||||
} else {
|
||||
@ -81,7 +87,7 @@ export const setConfig: types.ExpectedExports.setConfig = async (
|
||||
} else {
|
||||
effects.debug("No reindex required");
|
||||
}
|
||||
|
||||
|
||||
await effects.writeFile({
|
||||
path: "start9/config.yaml",
|
||||
toWrite: YAML.stringify(newConfig),
|
||||
|
Loading…
Reference in New Issue
Block a user