Index the genesis block with txindex

This commit is contained in:
Steven Roose 2020-03-23 16:16:39 +00:00
parent 95602ec21f
commit ac9966f655
No known key found for this signature in database
GPG key ID: 2F2A88D7F8D68E87
2 changed files with 4 additions and 2 deletions

View file

@ -246,7 +246,8 @@ bool TxIndex::Init()
bool TxIndex::WriteBlock(const CBlock& block, const CBlockIndex* pindex)
{
// Exclude genesis block transaction because outputs are not spendable.
if (pindex->nHeight == 0) return true;
//ELEMENTS: we do index the genesis block
//if (pindex->nHeight == 0) return true;
CDiskTxPos pos(pindex->GetBlockPos(), GetSizeOfCompactSize(block.vtx.size()));
std::vector<std::pair<uint256, CDiskTxPos>> vPos;

View file

@ -40,9 +40,10 @@ BOOST_FIXTURE_TEST_CASE(txindex_initial_sync, TestChain100Setup)
}
// Check that txindex excludes genesis block transactions.
//ELEMENTS: we do include them
const CBlock& genesis_block = Params().GenesisBlock();
for (const auto& txn : genesis_block.vtx) {
BOOST_CHECK(!txindex.FindTx(txn->GetHash(), block_hash, tx_disk));
BOOST_CHECK(txindex.FindTx(txn->GetHash(), block_hash, tx_disk));
}
// Check that txindex has all txs that were in the chain before it started.