aboutsummaryrefslogtreecommitdiff
path: root/src/txdb.h
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2016-04-05 15:14:48 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2016-04-15 17:48:38 +0200
commit99e70751f23aa59ac297f6746dd8f09a140d48ae (patch)
tree2be46a38d1150ab1a07ba6871931194661464f0f /src/txdb.h
parent73fc922ed64333d45f18d8a448f30cfa2ae0281e (diff)
downloadbitcoin-99e70751f23aa59ac297f6746dd8f09a140d48ae.tar.xz
Break circular dependency main ↔ txdb
Break the circular dependency between main and txdb by: - Moving `CBlockFileInfo` from `main.h` to `chain.h`. I think this makes sense, as the other block-file stuff is there too. - Moving `CDiskTxPos` from `main.h` to `txdb.h`. This type seems specific to txdb. - Pass a functor `insertBlockIndex` to `LoadBlockIndexGuts`. This leaves it up to the caller how to insert block indices.
Diffstat (limited to 'src/txdb.h')
-rw-r--r--src/txdb.h33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/txdb.h b/src/txdb.h
index 749802f0e5..ce3c39d7fe 100644
--- a/src/txdb.h
+++ b/src/txdb.h
@@ -8,15 +8,17 @@
#include "coins.h"
#include "dbwrapper.h"
+#include "chain.h"
#include <map>
#include <string>
#include <utility>
#include <vector>
-class CBlockFileInfo;
+#include <boost/function.hpp>
+
class CBlockIndex;
-struct CDiskTxPos;
+class CCoinsViewDBCursor;
class uint256;
//! -dbcache default (MiB)
@@ -26,7 +28,30 @@ static const int64_t nMaxDbCache = sizeof(void*) > 4 ? 16384 : 1024;
//! min. -dbcache in (MiB)
static const int64_t nMinDbCache = 4;
-class CCoinsViewDBCursor;
+struct CDiskTxPos : public CDiskBlockPos
+{
+ unsigned int nTxOffset; // after header
+
+ ADD_SERIALIZE_METHODS;
+
+ template <typename Stream, typename Operation>
+ inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
+ READWRITE(*(CDiskBlockPos*)this);
+ READWRITE(VARINT(nTxOffset));
+ }
+
+ CDiskTxPos(const CDiskBlockPos &blockIn, unsigned int nTxOffsetIn) : CDiskBlockPos(blockIn.nFile, blockIn.nPos), nTxOffset(nTxOffsetIn) {
+ }
+
+ CDiskTxPos() {
+ SetNull();
+ }
+
+ void SetNull() {
+ CDiskBlockPos::SetNull();
+ nTxOffset = 0;
+ }
+};
/** CCoinsView backed by the coin database (chainstate/) */
class CCoinsViewDB : public CCoinsView
@@ -83,7 +108,7 @@ public:
bool WriteTxIndex(const std::vector<std::pair<uint256, CDiskTxPos> > &list);
bool WriteFlag(const std::string &name, bool fValue);
bool ReadFlag(const std::string &name, bool &fValue);
- bool LoadBlockIndexGuts();
+ bool LoadBlockIndexGuts(boost::function<CBlockIndex*(const uint256&)> insertBlockIndex);
};
#endif // BITCOIN_TXDB_H