diff --git a/src/Makefile.am b/src/Makefile.am index 9145ad2380..02c80d3e57 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -297,6 +297,7 @@ BITCOIN_CORE_H = \ support/events.h \ support/lockedpool.h \ sync.h \ + timestampindex.h \ threadsafety.h \ threadinterrupt.h \ timedata.h \ diff --git a/src/spentindex.h b/src/spentindex.h index b7b5a60aa4..3c03d66e95 100644 --- a/src/spentindex.h +++ b/src/spentindex.h @@ -99,73 +99,6 @@ struct CSpentIndexTxInfo std::map mSpentInfo; }; -struct CTimestampIndexIteratorKey { -public: - uint32_t m_time; - -public: - CTimestampIndexIteratorKey() { - SetNull(); - } - - CTimestampIndexIteratorKey(uint32_t time) : m_time{time} {}; - - void SetNull() { - m_time = 0; - } - -public: - size_t GetSerializeSize(int nType, int nVersion) const { - return 4; - } - - template - void Serialize(Stream& s) const { - ser_writedata32be(s, m_time); - } - - template - void Unserialize(Stream& s) { - m_time = ser_readdata32be(s); - } -}; - -struct CTimestampIndexKey { -public: - uint32_t m_block_time; - uint256 m_block_hash; - -public: - CTimestampIndexKey() { - SetNull(); - } - - CTimestampIndexKey(uint32_t block_time, uint256 block_hash) : - m_block_time{block_time}, m_block_hash{block_hash} {}; - - void SetNull() { - m_block_time = 0; - m_block_hash.SetNull(); - } - -public: - size_t GetSerializeSize(int nType, int nVersion) const { - return 36; - } - - template - void Serialize(Stream& s) const { - ser_writedata32be(s, m_block_time); - m_block_hash.Serialize(s); - } - - template - void Unserialize(Stream& s) { - m_block_time = ser_readdata32be(s); - m_block_hash.Unserialize(s); - } -}; - struct CAddressUnspentKey { public: uint8_t m_address_type{AddressType::UNKNOWN}; diff --git a/src/timestampindex.h b/src/timestampindex.h new file mode 100644 index 0000000000..a1e300bfda --- /dev/null +++ b/src/timestampindex.h @@ -0,0 +1,80 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2015 The Bitcoin Core developers +// Copyright (c) 2016 BitPay, Inc. +// Copyright (c) 2023 The Dash Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_TIMESTAMPINDEX_H +#define BITCOIN_TIMESTAMPINDEX_H + +#include + +struct CTimestampIndexIteratorKey { +public: + uint32_t m_time; + +public: + CTimestampIndexIteratorKey() { + SetNull(); + } + + CTimestampIndexIteratorKey(uint32_t time) : m_time{time} {}; + + void SetNull() { + m_time = 0; + } + +public: + size_t GetSerializeSize(int nType, int nVersion) const { + return 4; + } + + template + void Serialize(Stream& s) const { + ser_writedata32be(s, m_time); + } + + template + void Unserialize(Stream& s) { + m_time = ser_readdata32be(s); + } +}; + +struct CTimestampIndexKey { +public: + uint32_t m_block_time; + uint256 m_block_hash; + +public: + CTimestampIndexKey() { + SetNull(); + } + + CTimestampIndexKey(uint32_t block_time, uint256 block_hash) : + m_block_time{block_time}, m_block_hash{block_hash} {}; + + void SetNull() { + m_block_time = 0; + m_block_hash.SetNull(); + } + +public: + size_t GetSerializeSize(int nType, int nVersion) const { + return 36; + } + + template + void Serialize(Stream& s) const { + ser_writedata32be(s, m_block_time); + m_block_hash.Serialize(s); + } + + template + void Unserialize(Stream& s) { + m_block_time = ser_readdata32be(s); + m_block_hash.Unserialize(s); + } +}; + +#endif // BITCOIN_TIMESTAMPINDEX_H diff --git a/src/txdb.h b/src/txdb.h index bac6c8bb58..9b73e4780b 100644 --- a/src/txdb.h +++ b/src/txdb.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include