Skip to content

Commit c7dff0d

Browse files
MarcoFalkekwvg
MarcoFalke
authored andcommitted
Merge bitcoin#19734: Move CDiskTxPos to its own file
7668db3 Move only: Move CDiskTxPos to its own file (Marcin Jachymiak) Pull request description: Moves `CDiskTxPos` it its own file so it can be used without the `txindex.h` include elsewhere. Originally part of bitcoin#14053. ACKs for top commit: jnewbery: utACK 7668db3 promag: ACK 7668db3. Tree-SHA512: b108e980ad04e43d1323410c3683a82bed70aee7795f5d8a2afbaf32a07ba598571f00b047bdde15048124b17178bcbd10654c48461beac988e9643cb2df664c
1 parent 315650c commit c7dff0d

File tree

3 files changed

+39
-23
lines changed

3 files changed

+39
-23
lines changed

src/Makefile.am

+1
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ BITCOIN_CORE_H = \
178178
httpserver.h \
179179
index/base.h \
180180
index/blockfilterindex.h \
181+
index/disktxpos.h \
181182
index/txindex.h \
182183
indirectmap.h \
183184
init.h \

src/index/disktxpos.h

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (c) 2019 The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
#ifndef BITCOIN_INDEX_DISKTXPOS_H
6+
#define BITCOIN_INDEX_DISKTXPOS_H
7+
8+
#include <chain.h>
9+
#include <flatfile.h>
10+
#include <primitives/block.h>
11+
#include <primitives/transaction.h>
12+
13+
struct CDiskTxPos : public FlatFilePos
14+
{
15+
unsigned int nTxOffset; // after header
16+
17+
SERIALIZE_METHODS(CDiskTxPos, obj)
18+
{
19+
READWRITEAS(FlatFilePos, obj);
20+
READWRITE(VARINT(obj.nTxOffset));
21+
}
22+
23+
CDiskTxPos(const FlatFilePos &blockIn, unsigned int nTxOffsetIn) : FlatFilePos(blockIn.nFile, blockIn.nPos), nTxOffset(nTxOffsetIn) {
24+
}
25+
26+
CDiskTxPos() {
27+
SetNull();
28+
}
29+
30+
void SetNull() {
31+
FlatFilePos::SetNull();
32+
nTxOffset = 0;
33+
}
34+
};
35+
36+
37+
#endif // BITCOIN_INDEX_DISKTXPOS_H

src/index/txindex.cpp

+1-23
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5+
#include <index/disktxpos.h>
56
#include <index/txindex.h>
67
#include <shutdown.h>
78
#include <ui_interface.h>
@@ -16,29 +17,6 @@ constexpr char DB_TXINDEX_BLOCK = 'T';
1617

1718
std::unique_ptr<TxIndex> g_txindex;
1819

19-
struct CDiskTxPos : public FlatFilePos
20-
{
21-
unsigned int nTxOffset; // after header
22-
23-
SERIALIZE_METHODS(CDiskTxPos, obj)
24-
{
25-
READWRITEAS(FlatFilePos, obj);
26-
READWRITE(VARINT(obj.nTxOffset));
27-
}
28-
29-
CDiskTxPos(const FlatFilePos &blockIn, unsigned int nTxOffsetIn) : FlatFilePos(blockIn.nFile, blockIn.nPos), nTxOffset(nTxOffsetIn) {
30-
}
31-
32-
CDiskTxPos() {
33-
SetNull();
34-
}
35-
36-
void SetNull() {
37-
FlatFilePos::SetNull();
38-
nTxOffset = 0;
39-
}
40-
};
41-
4220
/**
4321
* Access to the txindex database (indexes/txindex/)
4422
*

0 commit comments

Comments
 (0)