Skip to content

Commit

Permalink
Merge pull request #118 from snazzybytes/coinstatsindex
Browse files Browse the repository at this point in the history
Add coinstatsindex (optional) config option
  • Loading branch information
MattDHill authored Mar 12, 2024
2 parents 5aa62fe + 109a0c5 commit 8bb65f2
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 1 deletion.
5 changes: 5 additions & 0 deletions assets/compat/bitcoin.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ zmqpubsequence=tcp://0.0.0.0:28333
txindex=1
}}

## COINSTATSINDEX
{{#IF coinstatsindex
coinstatsindex=1
}}

## BIP37
{{#IF advanced.bloomfilters.peerbloomfilters
peerbloomfilters=1
Expand Down
8 changes: 8 additions & 0 deletions manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ actions:
- stopped
implementation:
type: script
delete-coinstatsindex:
name: "Delete Coinstats Index"
description: "Deletes the Coinstats Index (coinstatsindex) in case it gets corrupted."
warning: The Coinstats Index will be rebuilt once Bitcoin Core is started again, unless you deactivate it in the config settings. Please don't do this unless instructed to by Start9 support staff.
allowed-statuses:
- stopped
implementation:
type: script
delete-peers:
name: "Delete Peer List"
description: "Deletes the Peer List (peers.dat) in case it gets corrupted."
Expand Down
28 changes: 28 additions & 0 deletions scripts/services/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,32 @@ export const action = {
},
};
},
async "delete-coinstatsindex"(
effect: T.Effects,
_input?: T.Config,
): Promise<T.ResultType<T.ActionResult>> {
const coinstatsinfoLocation = {
path: "indexes/coinstats",
volumeId: "main",
};
if (await util.exists(effect, coinstatsinfoLocation) === false) {
return {
result: {
copyable: false,
message: "coinstatsindex doesn't exist",
version: "0",
qr: false,
},
};
}
await effect.removeDir(coinstatsinfoLocation);
return {
result: {
copyable: false,
message: "Deleted coinstatsindex",
version: "0",
qr: false,
},
};
},
};
6 changes: 6 additions & 0 deletions scripts/services/getConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ export const getConfig: T.ExpectedExports.getConfig = async (effects) => {
description: "Enable the Transaction Index (txindex)",
default: allowUnpruned,
},
coinstatsindex: {
type: "boolean",
name: "Coinstats Index",
description: "Enable the Coinstats Index (coinstatsindex)",
default: false,
},
wallet: {
type: "object",
name: "Wallet",
Expand Down
9 changes: 8 additions & 1 deletion scripts/services/setConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ export const setConfig: types.ExpectedExports.setConfig = async (
error: "Txindex not allowed on pruned nodes.",
};
}
if (
!(!newConfig.coinstatsindex || (newConfig.advanced?.pruning?.mode === "disabled"))
) {
return {
error: "Coinstats index not allowed on pruned nodes.",
};
}
// true, false only fail case
if (
!(!newConfig.advanced.blockfilters.peerblockfilters ||
Expand Down Expand Up @@ -81,7 +88,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),
Expand Down

0 comments on commit 8bb65f2

Please sign in to comment.