aboutsummaryrefslogtreecommitdiff
path: root/src/flatfile.h
diff options
context:
space:
mode:
authorJim Posen <jim.posen@gmail.com>2019-01-06 11:43:38 -0800
committerJim Posen <jim.posen@gmail.com>2019-02-22 17:38:45 -0800
commitd6d8a78f26f52fdfe43293686135e2fc6919926c (patch)
tree88e7fdae60dcacd7cede677273556a4c69c4544f /src/flatfile.h
parente0380933e3745214331d358bda8c5e79299c84d2 (diff)
downloadbitcoin-d6d8a78f26f52fdfe43293686135e2fc6919926c.tar.xz
Move CDiskBlockPos from chain to flatfile.
Diffstat (limited to 'src/flatfile.h')
-rw-r--r--src/flatfile.h43
1 files changed, 41 insertions, 2 deletions
diff --git a/src/flatfile.h b/src/flatfile.h
index eea41ddf84..d599b8cc42 100644
--- a/src/flatfile.h
+++ b/src/flatfile.h
@@ -1,12 +1,51 @@
-// Copyright (c) 2019 The Bitcoin Core developers
+// Copyright (c) 2009-2010 Satoshi Nakamoto
+// Copyright (c) 2009-2019 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_FLATFILE_H
#define BITCOIN_FLATFILE_H
-#include <chain.h>
+#include <string>
+
#include <fs.h>
+#include <serialize.h>
+
+struct CDiskBlockPos
+{
+ int nFile;
+ unsigned int nPos;
+
+ ADD_SERIALIZE_METHODS;
+
+ template <typename Stream, typename Operation>
+ inline void SerializationOp(Stream& s, Operation ser_action) {
+ READWRITE(VARINT(nFile, VarIntMode::NONNEGATIVE_SIGNED));
+ READWRITE(VARINT(nPos));
+ }
+
+ CDiskBlockPos() {
+ SetNull();
+ }
+
+ CDiskBlockPos(int nFileIn, unsigned int nPosIn) {
+ nFile = nFileIn;
+ nPos = nPosIn;
+ }
+
+ friend bool operator==(const CDiskBlockPos &a, const CDiskBlockPos &b) {
+ return (a.nFile == b.nFile && a.nPos == b.nPos);
+ }
+
+ friend bool operator!=(const CDiskBlockPos &a, const CDiskBlockPos &b) {
+ return !(a == b);
+ }
+
+ void SetNull() { nFile = -1; nPos = 0; }
+ bool IsNull() const { return (nFile == -1); }
+
+ std::string ToString() const;
+};
/**
* FlatFileSeq represents a sequence of numbered files storing raw data. This class facilitates