aboutsummaryrefslogtreecommitdiff
path: root/src/db.cpp
diff options
context:
space:
mode:
authorPieter Wuille <[email protected]>2012-06-19 01:36:43 +0200
committerPieter Wuille <[email protected]>2012-10-20 23:08:57 +0200
commit630fd8dcb6662ed167e967625f2715f97ddd2db5 (patch)
tree6cb32ecd892a2d2f0368e57ea424f7efcd601b1a /src/db.cpp
parentAdd CTxUndo: transaction undo information (diff)
downloaddiscoin-630fd8dcb6662ed167e967625f2715f97ddd2db5.tar.xz
discoin-630fd8dcb6662ed167e967625f2715f97ddd2db5.zip
One file per block
Refactor of the block storage code, which now stores one file per block. This will allow easier pruning, as blocks can be removed individually.
Diffstat (limited to 'src/db.cpp')
-rw-r--r--src/db.cpp15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/db.cpp b/src/db.cpp
index 9ad67892f..cef395c44 100644
--- a/src/db.cpp
+++ b/src/db.cpp
@@ -637,12 +637,12 @@ bool CTxDB::LoadBlockIndex()
nCheckDepth = nBestHeight;
printf("Verifying last %i blocks at level %i\n", nCheckDepth, nCheckLevel);
CBlockIndex* pindexFork = NULL;
- map<pair<unsigned int, unsigned int>, CBlockIndex*> mapBlockPos;
for (CBlockIndex* pindex = pindexBest; pindex && pindex->pprev; pindex = pindex->pprev)
{
if (fRequestShutdown || pindex->nHeight < nBestHeight-nCheckDepth)
break;
CBlock block;
+ CDiskBlockPos blockPos = pindex->GetBlockPos();
if (!block.ReadFromDisk(pindex))
return error("LoadBlockIndex() : block.ReadFromDisk failed");
// check level 1: verify block validity
@@ -654,8 +654,6 @@ bool CTxDB::LoadBlockIndex()
// check level 2: verify transaction index validity
if (nCheckLevel>1)
{
- pair<unsigned int, unsigned int> pos = make_pair(pindex->nFile, pindex->nBlockPos);
- mapBlockPos[pos] = pindex;
BOOST_FOREACH(const CTransaction &tx, block.vtx)
{
uint256 hashTx = tx.GetHash();
@@ -663,7 +661,7 @@ bool CTxDB::LoadBlockIndex()
if (ReadTxIndex(hashTx, txindex))
{
// check level 3: checker transaction hashes
- if (nCheckLevel>2 || pindex->nFile != txindex.pos.nFile || pindex->nBlockPos != txindex.pos.nBlockPos)
+ if (nCheckLevel>2 || blockPos != txindex.pos.blockPos)
{
// either an error or a duplicate transaction
CTransaction txFound;
@@ -687,12 +685,6 @@ bool CTxDB::LoadBlockIndex()
{
if (!txpos.IsNull())
{
- pair<unsigned int, unsigned int> posFind = make_pair(txpos.nFile, txpos.nBlockPos);
- if (!mapBlockPos.count(posFind))
- {
- printf("LoadBlockIndex(): *** found bad spend at %d, hashBlock=%s, hashTx=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString().c_str(), hashTx.ToString().c_str());
- pindexFork = pindex->pprev;
- }
// check level 6: check whether spent txouts were spent by a valid transaction that consume them
if (nCheckLevel>5)
{
@@ -795,9 +787,8 @@ bool CTxDB::LoadBlockIndexGuts()
CBlockIndex* pindexNew = InsertBlockIndex(diskindex.GetBlockHash());
pindexNew->pprev = InsertBlockIndex(diskindex.hashPrev);
pindexNew->pnext = InsertBlockIndex(diskindex.hashNext);
- pindexNew->nFile = diskindex.nFile;
- pindexNew->nBlockPos = diskindex.nBlockPos;
pindexNew->nHeight = diskindex.nHeight;
+ pindexNew->nAlternative = diskindex.nAlternative;
pindexNew->nVersion = diskindex.nVersion;
pindexNew->hashMerkleRoot = diskindex.hashMerkleRoot;
pindexNew->nTime = diskindex.nTime;