mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
refactor: move CAddressIndex* out of spentindex
This commit is contained in:
parent
cc2efac4b4
commit
0cc321cd8c
@ -72,4 +72,146 @@ struct CMempoolAddressDeltaKeyCompare
|
||||
}
|
||||
};
|
||||
|
||||
struct CAddressIndexKey {
|
||||
public:
|
||||
uint8_t m_address_type{AddressType::UNKNOWN};
|
||||
uint160 m_address_bytes;
|
||||
int32_t m_block_height{0};
|
||||
uint32_t m_block_tx_pos{0};
|
||||
uint256 m_tx_hash;
|
||||
uint32_t m_tx_index{0};
|
||||
bool m_tx_spent{false};
|
||||
|
||||
public:
|
||||
CAddressIndexKey() {
|
||||
SetNull();
|
||||
}
|
||||
|
||||
CAddressIndexKey(uint8_t address_type, uint160 address_bytes, int32_t block_height, uint32_t block_tx_pos, uint256 tx_hash,
|
||||
uint32_t tx_index, bool tx_spent) :
|
||||
m_address_type{address_type},
|
||||
m_address_bytes{address_bytes},
|
||||
m_block_height{block_height},
|
||||
m_block_tx_pos{block_tx_pos},
|
||||
m_tx_hash{tx_hash},
|
||||
m_tx_index{tx_index},
|
||||
m_tx_spent{tx_spent} {};
|
||||
|
||||
void SetNull() {
|
||||
m_address_type = AddressType::UNKNOWN;
|
||||
m_address_bytes.SetNull();
|
||||
m_block_height = 0;
|
||||
m_block_tx_pos = 0;
|
||||
m_tx_hash.SetNull();
|
||||
m_tx_index = 0;
|
||||
m_tx_spent = false;
|
||||
}
|
||||
|
||||
public:
|
||||
size_t GetSerializeSize(int nType, int nVersion) const {
|
||||
return 66;
|
||||
}
|
||||
|
||||
template<typename Stream>
|
||||
void Serialize(Stream& s) const {
|
||||
ser_writedata8(s, m_address_type);
|
||||
m_address_bytes.Serialize(s);
|
||||
// Heights are stored big-endian for key sorting in LevelDB
|
||||
ser_writedata32be(s, m_block_height);
|
||||
ser_writedata32be(s, m_block_tx_pos);
|
||||
m_tx_hash.Serialize(s);
|
||||
ser_writedata32(s, m_tx_index);
|
||||
char f = m_tx_spent;
|
||||
ser_writedata8(s, f);
|
||||
}
|
||||
|
||||
template<typename Stream>
|
||||
void Unserialize(Stream& s) {
|
||||
m_address_type = ser_readdata8(s);
|
||||
m_address_bytes.Unserialize(s);
|
||||
m_block_height = ser_readdata32be(s);
|
||||
m_block_tx_pos = ser_readdata32be(s);
|
||||
m_tx_hash.Unserialize(s);
|
||||
m_tx_index = ser_readdata32(s);
|
||||
char f = ser_readdata8(s);
|
||||
m_tx_spent = f;
|
||||
}
|
||||
};
|
||||
|
||||
struct CAddressIndexIteratorKey {
|
||||
public:
|
||||
uint8_t m_address_type{AddressType::UNKNOWN};
|
||||
uint160 m_address_bytes;
|
||||
|
||||
public:
|
||||
CAddressIndexIteratorKey() {
|
||||
SetNull();
|
||||
}
|
||||
|
||||
CAddressIndexIteratorKey(uint8_t address_type, uint160 address_bytes) :
|
||||
m_address_type{address_type}, m_address_bytes{address_bytes} {};
|
||||
|
||||
void SetNull() {
|
||||
m_address_type = AddressType::UNKNOWN;
|
||||
m_address_bytes.SetNull();
|
||||
}
|
||||
|
||||
public:
|
||||
size_t GetSerializeSize(int nType, int nVersion) const {
|
||||
return 21;
|
||||
}
|
||||
|
||||
template<typename Stream>
|
||||
void Serialize(Stream& s) const {
|
||||
ser_writedata8(s, m_address_type);
|
||||
m_address_bytes.Serialize(s);
|
||||
}
|
||||
|
||||
template<typename Stream>
|
||||
void Unserialize(Stream& s) {
|
||||
m_address_type = ser_readdata8(s);
|
||||
m_address_bytes.Unserialize(s);
|
||||
}
|
||||
};
|
||||
|
||||
struct CAddressIndexIteratorHeightKey {
|
||||
public:
|
||||
uint8_t m_address_type{AddressType::UNKNOWN};
|
||||
uint160 m_address_bytes;
|
||||
int32_t m_block_height{0};
|
||||
|
||||
public:
|
||||
CAddressIndexIteratorHeightKey() {
|
||||
SetNull();
|
||||
}
|
||||
|
||||
CAddressIndexIteratorHeightKey(uint8_t address_type, uint160 address_bytes, int32_t block_height) :
|
||||
m_address_type{address_type}, m_address_bytes{address_bytes}, m_block_height{block_height} {};
|
||||
|
||||
void SetNull() {
|
||||
m_address_type = AddressType::UNKNOWN;
|
||||
m_address_bytes.SetNull();
|
||||
m_block_height = 0;
|
||||
}
|
||||
|
||||
public:
|
||||
size_t GetSerializeSize(int nType, int nVersion) const {
|
||||
return 25;
|
||||
}
|
||||
|
||||
template<typename Stream>
|
||||
void Serialize(Stream& s) const {
|
||||
ser_writedata8(s, m_address_type);
|
||||
m_address_bytes.Serialize(s);
|
||||
ser_writedata32be(s, m_block_height);
|
||||
}
|
||||
|
||||
template<typename Stream>
|
||||
void Unserialize(Stream& s) {
|
||||
m_address_type = ser_readdata8(s);
|
||||
m_address_bytes.Unserialize(s);
|
||||
m_block_height = ser_readdata32be(s);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // BITCOIN_ADDRESSINDEX_H
|
||||
|
142
src/spentindex.h
142
src/spentindex.h
@ -174,146 +174,4 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
struct CAddressIndexKey {
|
||||
public:
|
||||
uint8_t m_address_type{AddressType::UNKNOWN};
|
||||
uint160 m_address_bytes;
|
||||
int32_t m_block_height{0};
|
||||
uint32_t m_block_tx_pos{0};
|
||||
uint256 m_tx_hash;
|
||||
uint32_t m_tx_index{0};
|
||||
bool m_tx_spent{false};
|
||||
|
||||
public:
|
||||
CAddressIndexKey() {
|
||||
SetNull();
|
||||
}
|
||||
|
||||
CAddressIndexKey(uint8_t address_type, uint160 address_bytes, int32_t block_height, uint32_t block_tx_pos, uint256 tx_hash,
|
||||
uint32_t tx_index, bool tx_spent) :
|
||||
m_address_type{address_type},
|
||||
m_address_bytes{address_bytes},
|
||||
m_block_height{block_height},
|
||||
m_block_tx_pos{block_tx_pos},
|
||||
m_tx_hash{tx_hash},
|
||||
m_tx_index{tx_index},
|
||||
m_tx_spent{tx_spent} {};
|
||||
|
||||
void SetNull() {
|
||||
m_address_type = AddressType::UNKNOWN;
|
||||
m_address_bytes.SetNull();
|
||||
m_block_height = 0;
|
||||
m_block_tx_pos = 0;
|
||||
m_tx_hash.SetNull();
|
||||
m_tx_index = 0;
|
||||
m_tx_spent = false;
|
||||
}
|
||||
|
||||
public:
|
||||
size_t GetSerializeSize(int nType, int nVersion) const {
|
||||
return 66;
|
||||
}
|
||||
|
||||
template<typename Stream>
|
||||
void Serialize(Stream& s) const {
|
||||
ser_writedata8(s, m_address_type);
|
||||
m_address_bytes.Serialize(s);
|
||||
// Heights are stored big-endian for key sorting in LevelDB
|
||||
ser_writedata32be(s, m_block_height);
|
||||
ser_writedata32be(s, m_block_tx_pos);
|
||||
m_tx_hash.Serialize(s);
|
||||
ser_writedata32(s, m_tx_index);
|
||||
char f = m_tx_spent;
|
||||
ser_writedata8(s, f);
|
||||
}
|
||||
|
||||
template<typename Stream>
|
||||
void Unserialize(Stream& s) {
|
||||
m_address_type = ser_readdata8(s);
|
||||
m_address_bytes.Unserialize(s);
|
||||
m_block_height = ser_readdata32be(s);
|
||||
m_block_tx_pos = ser_readdata32be(s);
|
||||
m_tx_hash.Unserialize(s);
|
||||
m_tx_index = ser_readdata32(s);
|
||||
char f = ser_readdata8(s);
|
||||
m_tx_spent = f;
|
||||
}
|
||||
};
|
||||
|
||||
struct CAddressIndexIteratorKey {
|
||||
public:
|
||||
uint8_t m_address_type{AddressType::UNKNOWN};
|
||||
uint160 m_address_bytes;
|
||||
|
||||
public:
|
||||
CAddressIndexIteratorKey() {
|
||||
SetNull();
|
||||
}
|
||||
|
||||
CAddressIndexIteratorKey(uint8_t address_type, uint160 address_bytes) :
|
||||
m_address_type{address_type}, m_address_bytes{address_bytes} {};
|
||||
|
||||
void SetNull() {
|
||||
m_address_type = AddressType::UNKNOWN;
|
||||
m_address_bytes.SetNull();
|
||||
}
|
||||
|
||||
public:
|
||||
size_t GetSerializeSize(int nType, int nVersion) const {
|
||||
return 21;
|
||||
}
|
||||
|
||||
template<typename Stream>
|
||||
void Serialize(Stream& s) const {
|
||||
ser_writedata8(s, m_address_type);
|
||||
m_address_bytes.Serialize(s);
|
||||
}
|
||||
|
||||
template<typename Stream>
|
||||
void Unserialize(Stream& s) {
|
||||
m_address_type = ser_readdata8(s);
|
||||
m_address_bytes.Unserialize(s);
|
||||
}
|
||||
};
|
||||
|
||||
struct CAddressIndexIteratorHeightKey {
|
||||
public:
|
||||
uint8_t m_address_type{AddressType::UNKNOWN};
|
||||
uint160 m_address_bytes;
|
||||
int32_t m_block_height{0};
|
||||
|
||||
public:
|
||||
CAddressIndexIteratorHeightKey() {
|
||||
SetNull();
|
||||
}
|
||||
|
||||
CAddressIndexIteratorHeightKey(uint8_t address_type, uint160 address_bytes, int32_t block_height) :
|
||||
m_address_type{address_type}, m_address_bytes{address_bytes}, m_block_height{block_height} {};
|
||||
|
||||
void SetNull() {
|
||||
m_address_type = AddressType::UNKNOWN;
|
||||
m_address_bytes.SetNull();
|
||||
m_block_height = 0;
|
||||
}
|
||||
|
||||
public:
|
||||
size_t GetSerializeSize(int nType, int nVersion) const {
|
||||
return 25;
|
||||
}
|
||||
|
||||
template<typename Stream>
|
||||
void Serialize(Stream& s) const {
|
||||
ser_writedata8(s, m_address_type);
|
||||
m_address_bytes.Serialize(s);
|
||||
ser_writedata32be(s, m_block_height);
|
||||
}
|
||||
|
||||
template<typename Stream>
|
||||
void Unserialize(Stream& s) {
|
||||
m_address_type = ser_readdata8(s);
|
||||
m_address_bytes.Unserialize(s);
|
||||
m_block_height = ser_readdata32be(s);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // BITCOIN_SPENTINDEX_H
|
||||
|
Loading…
Reference in New Issue
Block a user