Skip to content

Commit

Permalink
Index the genesis block with txindex
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenroose committed Mar 23, 2020
1 parent 95602ec commit ac9966f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/index/txindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/test/txindex_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit ac9966f

Please sign in to comment.