aboutsummaryrefslogtreecommitdiff
path: root/src/db.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/db.cpp')
-rw-r--r--src/db.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/db.cpp b/src/db.cpp
index cef395c444..53be48cb0f 100644
--- a/src/db.cpp
+++ b/src/db.cpp
@@ -546,6 +546,22 @@ bool CTxDB::WriteBlockIndex(const CDiskBlockIndex& blockindex)
return Write(make_pair(string("blockindex"), blockindex.GetBlockHash()), blockindex);
}
+bool CTxDB::WriteBlockFileInfo(int nFile, const CBlockFileInfo &info) {
+ return Write(make_pair(string("blockfile"), nFile), info);
+}
+
+bool CTxDB::ReadBlockFileInfo(int nFile, CBlockFileInfo &info) {
+ return Read(make_pair(string("blockfile"), nFile), info);
+}
+
+bool CTxDB::WriteLastBlockFile(int nFile) {
+ return Write(string("lastblockfile"), nFile);
+}
+
+bool CTxDB::ReadLastBlockFile(int &nFile) {
+ return Read(string("lastblockfile"), nFile);
+}
+
bool CTxDB::ReadHashBestChain(uint256& hashBestChain)
{
return Read(string("hashBestChain"), hashBestChain);
@@ -609,6 +625,12 @@ bool CTxDB::LoadBlockIndex()
pindex->bnChainWork = (pindex->pprev ? pindex->pprev->bnChainWork : 0) + pindex->GetBlockWork();
}
+ // Load block file info
+ ReadLastBlockFile(nLastBlockFile);
+ printf("LoadBlockIndex(): last block file = %i\n", nLastBlockFile);
+ if (ReadBlockFileInfo(nLastBlockFile, infoLastBlockFile))
+ printf("LoadBlockIndex(): last block file: %s\n", infoLastBlockFile.ToString().c_str());
+
// Load hashBestChain pointer to end of best chain
if (!ReadHashBestChain(hashBestChain))
{
@@ -788,7 +810,8 @@ bool CTxDB::LoadBlockIndexGuts()
pindexNew->pprev = InsertBlockIndex(diskindex.hashPrev);
pindexNew->pnext = InsertBlockIndex(diskindex.hashNext);
pindexNew->nHeight = diskindex.nHeight;
- pindexNew->nAlternative = diskindex.nAlternative;
+ pindexNew->pos = diskindex.pos;
+ pindexNew->nUndoPos = diskindex.nUndoPos;
pindexNew->nVersion = diskindex.nVersion;
pindexNew->hashMerkleRoot = diskindex.hashMerkleRoot;
pindexNew->nTime = diskindex.nTime;