mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
commit genesis block transactions to txindex
This commit is contained in:
parent
d207f2754b
commit
d74234b422
1 changed files with 9 additions and 0 deletions
|
|
@ -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<std::pair<uint256, CDiskTxPos> > 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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue