-Update docs to specify that txindex is necessary for pre-v0.21 nodes
-Gracefully handle getindexinfo failures for old nodes
-Use graceful failure to fallback to assuming that txindex=1 (as docs indicate is necessary)

I'm open to other approaches for identifying absence of txindex, but this should keep older clients functioning at 100% for now.
This commit is contained in:
Dan Janosik 2021-04-07 22:23:33 -04:00
parent 26ec0d2649
commit 00a6a7be4f
No known key found for this signature in database
GPG key ID: 846311D3D259BFF1
3 changed files with 19 additions and 4 deletions

View file

@ -45,7 +45,8 @@ See [CHANGELOG.md](/CHANGELOG.md).
### Note about pruning and indexing configurations
This tool is designed to work best with full transaction indexing enabled (`txindex=1`) and pruning **disabled**. Running Bitcoin Core *without* `txindex` enabled and/or *with* `pruning` enabled works, but some data will be incomplete or missing. Also note that such Bitcoin Core configurations receive less thorough testing.
This tool is designed to work best with full transaction indexing enabled (`txindex=1`) and pruning **disabled**.
However, if you're running Bitcoin Core v0.21+ you can run *without* `txindex` enabled and/or *with* `pruning` enabled and this tool will continue to function, but some data will be incomplete or missing. Also note that such Bitcoin Core configurations receive less thorough testing.
In particular, with `pruning` enabled and/or `txindex` disabled, the following functionality is altered:

5
app.js
View file

@ -276,6 +276,11 @@ function onRpcConnectionVerified(getnetworkinfo, getblockchaininfo, getindexinfo
if (getindexinfo.txindex) {
global.txindexAvailable = true;
} else if (getindexinfo.minRpcVersionNeeded) {
// here we ASSUME that txindex is available because we're targeting pre-v0.21
// and docs specify that txindex is necessary for pre-v0.21 nodes
global.txindexAvailable = true;
}
if (getblockchaininfo.pruned) {

View file

@ -26,7 +26,10 @@ const rpcQueue = async.queue(function(task, callback) {
}, config.rpcConcurrency);
const minRpcVersions = {getblockstats:"0.17.0"};
const minRpcVersions = {
getblockstats: "0.17.0",
getindexinfo: "0.21.0"
};
global.rpcStats = {};
@ -64,7 +67,13 @@ function getMiningInfo() {
}
function getIndexInfo() {
return getRpcData("getindexinfo");
if (semver.gte(global.btcNodeSemver, minRpcVersions.getindexinfo)) {
return getRpcData("getindexinfo");
} else {
// unsupported
return unsupportedPromise(minRpcVersions.getindexinfo);
}
}
function getUptimeSeconds() {
@ -282,7 +291,7 @@ async function noTxIndexTransactionLookup(txid, walletOnly) {
var blockhash = await electrumAddressApi.lookupTxBlockHash(txid);
return await getRawTransaction(txid, blockhash);
} catch (err) {
debugLog(`Electrs blockhash lookup failed for ${txid}:`, err);
}