Post
Topic
Board Development & Technical Discussion
Re: error: txNew does name not a type (.1 BTC reward for solution)
by
twobitcoins
on 11/06/2013, 04:37:13 UTC
Oh... the code was quite different back then.  I think the way to proceed in general is to extract the parts of ConnectBlock that are needed to add the transaction to the index.  I think it will look something like this (without error checking):

Code:
{
    CTxDB txdb;
    txdb.TxnBegin();
    CBlockIndex* pindex = mapBlockIndex.find(hashGenesisBlock)->second;
    unsigned int nTxPos = pindex->nBlockPos + ::GetSerializeSize(CBlock(), SER_DISK, CLIENT_VERSION) - 1 + GetSizeOfCompactSize(block.vtx.size());
    CDiskTxPos posThisTx(pindex->nFile, pindex->nBlockPos, nTxPos);
    txdb.UpdateTxIndex(txNew.GetHash(), CTxIndex(posThisTx, txNew.vout.size()));
    txdb.TxnCommit();
}

You could try putting that in LoadBlockIndex inside "if (mapBlockIndex.empty())" right at the end.  Again, I'm just copying bits of code from here and there, so no guarantees it will work.  Thanks for the coins, though!