DisconnectBlock() not writing spentIndex to disk
In branch 0.13-bitcore, which is the most recent, the function DisconnectBlock() creates a vector to update the spentIndex database:
https://github.com/bitpay/bitcoin/blob/1f0598705c3176f70325cd56a5446fec3ca4f13c/src/main.cpp#L2312
but never writes it to disk. It's computed without being used. It seems the following code should be added at line 2362 of main.cpp (this is what ConnectBlock() does).
if (fSpentIndex) {
if (!pblocktree->UpdateSpentIndex(spentIndex)) {
return AbortNode(state, "Failed to write transaction index");
}
}
Unfortunately, it's hard to write a unit test for this part of the code; an RPC test may be able to reproduce the problem. I have not reproduced the problem; I found it by code inspection while working on https://github.com/zcash/zcash/issues/3708.
Well that’s not cool
Well that’s not cool
You're right, it's not cool! I submitted a fix (#57) but no one seems to be around to merge it. (I forgot all about this myself.) I think this is a dead repo.