Skip to content

DisconnectBlock() not writing spentIndex to disk #56

@LarryRuane

Description

@LarryRuane

In branch 0.13-bitcore, which is the most recent, the function DisconnectBlock() creates a vector to update the spentIndex database:

spentIndex.push_back(make_pair(CSpentIndexKey(input.prevout.hash, input.prevout.n), CSpentIndexValue()));

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 zcash/zcash#3708.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions