From 8bd1d9e065ef8f2a2c94da941dbc054f937b97f3 Mon Sep 17 00:00:00 2001 From: SnazzyBytes Date: Thu, 4 May 2023 11:41:02 -0500 Subject: [PATCH 1/3] add coinstatsindex (optional) config option --- assets/compat/bitcoin.conf.template | 5 +++++ docs/instructions.md | 2 +- manifest.yaml | 8 ++++++++ scripts/services/action.ts | 30 ++++++++++++++++++++++++++++- scripts/services/getConfig.ts | 6 ++++++ scripts/services/setConfig.ts | 9 ++++++++- 6 files changed, 57 insertions(+), 3 deletions(-) diff --git a/assets/compat/bitcoin.conf.template b/assets/compat/bitcoin.conf.template index 9e6c6c9..f244755 100644 --- a/assets/compat/bitcoin.conf.template +++ b/assets/compat/bitcoin.conf.template @@ -118,6 +118,11 @@ zmqpubsequence=tcp://0.0.0.0:28333 txindex=1 }} +## COINSTATSINDEX +{{#IF coinstatsindex +coinstatsindex=1 +}} + ## BIP37 {{#IF advanced.bloomfilters.peerbloomfilters peerbloomfilters=1 diff --git a/docs/instructions.md b/docs/instructions.md index 9e56668..da87b94 100644 --- a/docs/instructions.md +++ b/docs/instructions.md @@ -16,7 +16,7 @@ Enter your QuickConnect QR code **OR** your raw RPC credentials (both located in ## Pruning -Beginning in EOS v0.3.0, Bitcoin is now set to be an "archival" node by default. This means that it will download and verify the entire blockchain, and will not "prune." Be aware that this takes approximately 400GB as of early 2022. If you enable the `txindex,` this will require an additional ~40GB. +Beginning in EOS v0.3.0, Bitcoin is now set to be an "archival" node by default. This means that it will download and verify the entire blockchain, and will not "prune." Be aware that this takes approximately 400GB as of early 2022. If you enable the `txindex,` this will require an additional ~40GB. Also, if you enable `coinstatsindex,` this will require an additional ~150MB. Pruning is a process by which your node discards old blocks and transactions after it verifies them. Pruned nodes and archival nodes are both "full nodes" in that they are fully validating - they validate every block and transaction. Archival nodes store the entire blockchain and are useful to people interested in doing general or historical analysis, or being a provider of blockchain data to others (eg. a blockexplorer). They are also required for the best experience with many popular wallets and other Bitcoin tools. diff --git a/manifest.yaml b/manifest.yaml index 28e8335..9934061 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -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." diff --git a/scripts/services/action.ts b/scripts/services/action.ts index 4b8104e..0e87a20 100644 --- a/scripts/services/action.ts +++ b/scripts/services/action.ts @@ -57,4 +57,32 @@ export const action = { }, }; }, -}; + async "delete-coinstatsindex"( + effect: T.Effects, + _input?: T.Config, + ): Promise> { + const coinstatsinfoLocation = { + path: "indexes/coinstats", + volumeId: "main", + }; + if (await 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, + }, + }; + }, +}; \ No newline at end of file diff --git a/scripts/services/getConfig.ts b/scripts/services/getConfig.ts index 4dc1312..5d142bc 100644 --- a/scripts/services/getConfig.ts +++ b/scripts/services/getConfig.ts @@ -137,6 +137,12 @@ export const getConfig: T.ExpectedExports.getConfig = compat.getConfig({ "description": "Enable the Transaction Index (txindex)", "default": true, }, + "coinstatsindex": { + "type": "boolean", + "name": "Coinstats Index", + "description": "Enable the Coinstats Index (coinstatsindex)", + "default": false, + }, "wallet": { "type": "object", "name": "Wallet", diff --git a/scripts/services/setConfig.ts b/scripts/services/setConfig.ts index 5917c61..ced7808 100644 --- a/scripts/services/setConfig.ts +++ b/scripts/services/setConfig.ts @@ -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 || @@ -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), From e1a81524dedef87874315595f5a1de5df0d7f56c Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Tue, 12 Mar 2024 11:24:33 -0600 Subject: [PATCH 2/3] fix manifest --- manifest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.yaml b/manifest.yaml index e5d1495..24f4e59 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -157,7 +157,7 @@ actions: - stopped implementation: type: script - delete-coinstatsindex: + 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. From 109a0c5fc26d7f52ef1ff3bbaf533159c438f3e8 Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Tue, 12 Mar 2024 14:45:57 -0600 Subject: [PATCH 3/3] fix script --- scripts/services/action.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/services/action.ts b/scripts/services/action.ts index 6ba65d3..1697ee7 100644 --- a/scripts/services/action.ts +++ b/scripts/services/action.ts @@ -65,7 +65,7 @@ export const action = { path: "indexes/coinstats", volumeId: "main", }; - if (await exists(effect, coinstatsinfoLocation) === false) { + if (await util.exists(effect, coinstatsinfoLocation) === false) { return { result: { copyable: false, @@ -85,4 +85,4 @@ export const action = { }, }; }, -}; \ No newline at end of file +};