bitcoin icon indicating copy to clipboard operation
bitcoin copied to clipboard

DisconnectBlock() not writing spentIndex to disk

Open LarryRuane opened this issue 6 years ago • 2 comments

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.

LarryRuane avatar Feb 19 '19 16:02 LarryRuane

Well that’s not cool

ghost avatar Nov 27 '24 10:11 ghost

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.

LarryRuane avatar Nov 28 '24 00:11 LarryRuane