From d74234b4228eade45ed6e5b913589927ea45dbca Mon Sep 17 00:00:00 2001 From: Gregory Sanders Date: Tue, 23 Jan 2018 09:11:59 -0500 Subject: [PATCH] commit genesis block transactions to txindex --- src/validation.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/validation.cpp b/src/validation.cpp index e2f2e57ce5..4f6a318e41 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2557,12 +2557,21 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin if (block.GetHash() == chainparams.GetConsensus().hashGenesisBlock) { if (!fJustCheck) { assert(block.nHeight == 0); + std::vector > vPos; + CDiskTxPos pos(pindex->GetBlockPos(), GetSizeOfCompactSize(block.vtx.size())); for (const auto& tx : block.vtx) { // Directly add new coins to DB view.ModifyNewCoins(tx->GetHash(), tx->IsCoinBase())->FromTx(*tx, pindex->nHeight); + vPos.push_back(std::make_pair(tx->GetHash(), pos)); + pos.nTxOffset += ::GetSerializeSize(tx, SER_DISK, CLIENT_VERSION); } view.SetBestBlock(pindex->GetBlockHash()); + if (fTxIndex) { + if (!pblocktree->WriteTxIndex(vPos)) { + return AbortNode(state, "Failed to write transaction index"); + } + } } return true; }