From 7668db3b08531a590089d66cc5c91f1fb3afbfcc Mon Sep 17 00:00:00 2001 From: Marcin Jachymiak Date: Sun, 20 Jan 2019 14:17:17 -0500 Subject: [PATCH] Move only: Move CDiskTxPos to its own file --- src/Makefile.am | 1 + src/index/disktxpos.h | 37 +++++++++++++++++++++++++++++++++++++ src/index/txindex.cpp | 24 +----------------------- 3 files changed, 39 insertions(+), 23 deletions(-) create mode 100644 src/index/disktxpos.h diff --git a/src/Makefile.am b/src/Makefile.am index f52e9e581..175501d4a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -140,6 +140,7 @@ BITCOIN_CORE_H = \ httpserver.h \ index/base.h \ index/blockfilterindex.h \ + index/disktxpos.h \ index/txindex.h \ indirectmap.h \ init.h \ diff --git a/src/index/disktxpos.h b/src/index/disktxpos.h new file mode 100644 index 000000000..8cd227002 --- /dev/null +++ b/src/index/disktxpos.h @@ -0,0 +1,37 @@ +// Copyright (c) 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_INDEX_DISKTXPOS_H +#define BITCOIN_INDEX_DISKTXPOS_H + +#include +#include +#include +#include + +struct CDiskTxPos : public FlatFilePos +{ + unsigned int nTxOffset; // after header + + SERIALIZE_METHODS(CDiskTxPos, obj) + { + READWRITEAS(FlatFilePos, obj); + READWRITE(VARINT(obj.nTxOffset)); + } + + CDiskTxPos(const FlatFilePos &blockIn, unsigned int nTxOffsetIn) : FlatFilePos(blockIn.nFile, blockIn.nPos), nTxOffset(nTxOffsetIn) { + } + + CDiskTxPos() { + SetNull(); + } + + void SetNull() { + FlatFilePos::SetNull(); + nTxOffset = 0; + } +}; + + +#endif // BITCOIN_INDEX_DISKTXPOS_H diff --git a/src/index/txindex.cpp b/src/index/txindex.cpp index 64472714c..104b05d4b 100644 --- a/src/index/txindex.cpp +++ b/src/index/txindex.cpp @@ -2,6 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include #include #include #include @@ -15,29 +16,6 @@ constexpr char DB_TXINDEX_BLOCK = 'T'; std::unique_ptr g_txindex; -struct CDiskTxPos : public FlatFilePos -{ - unsigned int nTxOffset; // after header - - SERIALIZE_METHODS(CDiskTxPos, obj) - { - READWRITEAS(FlatFilePos, obj); - READWRITE(VARINT(obj.nTxOffset)); - } - - CDiskTxPos(const FlatFilePos &blockIn, unsigned int nTxOffsetIn) : FlatFilePos(blockIn.nFile, blockIn.nPos), nTxOffset(nTxOffsetIn) { - } - - CDiskTxPos() { - SetNull(); - } - - void SetNull() { - FlatFilePos::SetNull(); - nTxOffset = 0; - } -}; - /** * Access to the txindex database (indexes/txindex/) *