Skip to content

Commit

Permalink
Move only: Move CDiskTxPos to its own file
Browse files Browse the repository at this point in the history
  • Loading branch information
marcinja committed Aug 15, 2020
1 parent 3ab2582 commit 7668db3
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 23 deletions.
1 change: 1 addition & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
37 changes: 37 additions & 0 deletions src/index/disktxpos.h
Original file line number Diff line number Diff line change
@@ -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 <chain.h>
#include <flatfile.h>
#include <primitives/block.h>
#include <primitives/transaction.h>

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
24 changes: 1 addition & 23 deletions src/index/txindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <index/disktxpos.h>
#include <index/txindex.h>
#include <node/ui_interface.h>
#include <shutdown.h>
Expand All @@ -15,29 +16,6 @@ constexpr char DB_TXINDEX_BLOCK = 'T';

std::unique_ptr<TxIndex> 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/)
*
Expand Down

0 comments on commit 7668db3

Please sign in to comment.