mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 13:32:47 +01:00
8a1ec935a0
* scripted-diff: Replace #include "" with #include <> (ryanofsky) -BEGIN VERIFY SCRIPT- for f in \ src/*.cpp \ src/*.h \ src/bench/*.cpp \ src/bench/*.h \ src/compat/*.cpp \ src/compat/*.h \ src/consensus/*.cpp \ src/consensus/*.h \ src/crypto/*.cpp \ src/crypto/*.h \ src/crypto/ctaes/*.h \ src/policy/*.cpp \ src/policy/*.h \ src/primitives/*.cpp \ src/primitives/*.h \ src/qt/*.cpp \ src/qt/*.h \ src/qt/test/*.cpp \ src/qt/test/*.h \ src/rpc/*.cpp \ src/rpc/*.h \ src/script/*.cpp \ src/script/*.h \ src/support/*.cpp \ src/support/*.h \ src/support/allocators/*.h \ src/test/*.cpp \ src/test/*.h \ src/wallet/*.cpp \ src/wallet/*.h \ src/wallet/test/*.cpp \ src/wallet/test/*.h \ src/zmq/*.cpp \ src/zmq/*.h do base=${f%/*}/ relbase=${base#src/} sed -i "s:#include \"\(.*\)\"\(.*\):if test -e \$base'\\1'; then echo \"#include <\"\$relbase\"\\1>\\2\"; else echo \"#include <\\1>\\2\"; fi:e" $f done -END VERIFY SCRIPT- Signed-off-by: Pasta <pasta@dashboost.org> * scripted-diff: Replace #include "" with #include <> (Dash Specific) -BEGIN VERIFY SCRIPT- for f in \ src/bls/*.cpp \ src/bls/*.h \ src/evo/*.cpp \ src/evo/*.h \ src/governance/*.cpp \ src/governance/*.h \ src/llmq/*.cpp \ src/llmq/*.h \ src/masternode/*.cpp \ src/masternode/*.h \ src/privatesend/*.cpp \ src/privatesend/*.h do base=${f%/*}/ relbase=${base#src/} sed -i "s:#include \"\(.*\)\"\(.*\):if test -e \$base'\\1'; then echo \"#include <\"\$relbase\"\\1>\\2\"; else echo \"#include <\\1>\\2\"; fi:e" $f done -END VERIFY SCRIPT- Signed-off-by: Pasta <pasta@dashboost.org> * build: Remove -I for everything but project root Remove -I from build system for everything but the project root, and built-in dependencies. Signed-off-by: Pasta <pasta@dashboost.org> # Conflicts: # src/Makefile.test.include * qt: refactor: Use absolute include paths in .ui files * qt: refactor: Changes to make include paths absolute This makes all include paths in the GUI absolute. Many changes are involved as every single source file in src/qt/ assumes to be able to use relative includes. Signed-off-by: Pasta <pasta@dashboost.org> # Conflicts: # src/qt/dash.cpp # src/qt/optionsmodel.cpp # src/qt/test/rpcnestedtests.cpp * test: refactor: Use absolute include paths for test data files * Recommend #include<> syntax in developer notes * refactor: Include obj/build.h instead of build.h * END BACKPORT #11651 Remove trailing whitespace causing travis failure * fix backport 11651 Signed-off-by: Pasta <pasta@dashboost.org> * More of 11651 * fix blockchain.cpp Signed-off-by: pasta <pasta@dashboost.org> * Add missing "qt/" in includes * Add missing "test/" in includes * Fix trailing whitespaces Co-authored-by: Wladimir J. van der Laan <laanwj@gmail.com> Co-authored-by: Russell Yanofsky <russ@yanofsky.org> Co-authored-by: MeshCollider <dobsonsa68@gmail.com> Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
380 lines
8.4 KiB
C++
380 lines
8.4 KiB
C++
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
|
// Copyright (c) 2009-2015 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_SPENTINDEX_H
|
|
#define BITCOIN_SPENTINDEX_H
|
|
|
|
#include <uint256.h>
|
|
#include <amount.h>
|
|
#include <script/script.h>
|
|
#include <serialize.h>
|
|
|
|
struct CSpentIndexKey {
|
|
uint256 txid;
|
|
unsigned int outputIndex;
|
|
|
|
ADD_SERIALIZE_METHODS;
|
|
|
|
template <typename Stream, typename Operation>
|
|
inline void SerializationOp(Stream& s, Operation ser_action) {
|
|
READWRITE(txid);
|
|
READWRITE(outputIndex);
|
|
}
|
|
|
|
CSpentIndexKey(uint256 t, unsigned int i) {
|
|
txid = t;
|
|
outputIndex = i;
|
|
}
|
|
|
|
CSpentIndexKey() {
|
|
SetNull();
|
|
}
|
|
|
|
void SetNull() {
|
|
txid.SetNull();
|
|
outputIndex = 0;
|
|
}
|
|
|
|
};
|
|
|
|
struct CSpentIndexValue {
|
|
uint256 txid;
|
|
unsigned int inputIndex;
|
|
int blockHeight;
|
|
CAmount satoshis;
|
|
int addressType;
|
|
uint160 addressHash;
|
|
|
|
ADD_SERIALIZE_METHODS;
|
|
|
|
template <typename Stream, typename Operation>
|
|
inline void SerializationOp(Stream& s, Operation ser_action) {
|
|
READWRITE(txid);
|
|
READWRITE(inputIndex);
|
|
READWRITE(blockHeight);
|
|
READWRITE(satoshis);
|
|
READWRITE(addressType);
|
|
READWRITE(addressHash);
|
|
}
|
|
|
|
CSpentIndexValue(uint256 t, unsigned int i, int h, CAmount s, int type, uint160 a) {
|
|
txid = t;
|
|
inputIndex = i;
|
|
blockHeight = h;
|
|
satoshis = s;
|
|
addressType = type;
|
|
addressHash = a;
|
|
}
|
|
|
|
CSpentIndexValue() {
|
|
SetNull();
|
|
}
|
|
|
|
void SetNull() {
|
|
txid.SetNull();
|
|
inputIndex = 0;
|
|
blockHeight = 0;
|
|
satoshis = 0;
|
|
addressType = 0;
|
|
addressHash.SetNull();
|
|
}
|
|
|
|
bool IsNull() const {
|
|
return txid.IsNull();
|
|
}
|
|
};
|
|
|
|
struct CSpentIndexKeyCompare
|
|
{
|
|
bool operator()(const CSpentIndexKey& a, const CSpentIndexKey& b) const {
|
|
if (a.txid == b.txid) {
|
|
return a.outputIndex < b.outputIndex;
|
|
} else {
|
|
return a.txid < b.txid;
|
|
}
|
|
}
|
|
};
|
|
|
|
struct CSpentIndexTxInfo
|
|
{
|
|
std::map<CSpentIndexKey, CSpentIndexValue, CSpentIndexKeyCompare> mSpentInfo;
|
|
};
|
|
|
|
struct CTimestampIndexIteratorKey {
|
|
unsigned int timestamp;
|
|
|
|
size_t GetSerializeSize(int nType, int nVersion) const {
|
|
return 4;
|
|
}
|
|
template<typename Stream>
|
|
void Serialize(Stream& s) const {
|
|
ser_writedata32be(s, timestamp);
|
|
}
|
|
template<typename Stream>
|
|
void Unserialize(Stream& s) {
|
|
timestamp = ser_readdata32be(s);
|
|
}
|
|
|
|
CTimestampIndexIteratorKey(unsigned int time) {
|
|
timestamp = time;
|
|
}
|
|
|
|
CTimestampIndexIteratorKey() {
|
|
SetNull();
|
|
}
|
|
|
|
void SetNull() {
|
|
timestamp = 0;
|
|
}
|
|
};
|
|
|
|
struct CTimestampIndexKey {
|
|
unsigned int timestamp;
|
|
uint256 blockHash;
|
|
|
|
size_t GetSerializeSize(int nType, int nVersion) const {
|
|
return 36;
|
|
}
|
|
template<typename Stream>
|
|
void Serialize(Stream& s) const {
|
|
ser_writedata32be(s, timestamp);
|
|
blockHash.Serialize(s);
|
|
}
|
|
template<typename Stream>
|
|
void Unserialize(Stream& s) {
|
|
timestamp = ser_readdata32be(s);
|
|
blockHash.Unserialize(s);
|
|
}
|
|
|
|
CTimestampIndexKey(unsigned int time, uint256 hash) {
|
|
timestamp = time;
|
|
blockHash = hash;
|
|
}
|
|
|
|
CTimestampIndexKey() {
|
|
SetNull();
|
|
}
|
|
|
|
void SetNull() {
|
|
timestamp = 0;
|
|
blockHash.SetNull();
|
|
}
|
|
};
|
|
|
|
struct CAddressUnspentKey {
|
|
unsigned int type;
|
|
uint160 hashBytes;
|
|
uint256 txhash;
|
|
size_t index;
|
|
|
|
size_t GetSerializeSize(int nType, int nVersion) const {
|
|
return 57;
|
|
}
|
|
template<typename Stream>
|
|
void Serialize(Stream& s) const {
|
|
ser_writedata8(s, type);
|
|
hashBytes.Serialize(s);
|
|
txhash.Serialize(s);
|
|
ser_writedata32(s, index);
|
|
}
|
|
template<typename Stream>
|
|
void Unserialize(Stream& s) {
|
|
type = ser_readdata8(s);
|
|
hashBytes.Unserialize(s);
|
|
txhash.Unserialize(s);
|
|
index = ser_readdata32(s);
|
|
}
|
|
|
|
CAddressUnspentKey(unsigned int addressType, uint160 addressHash, uint256 txid, size_t indexValue) {
|
|
type = addressType;
|
|
hashBytes = addressHash;
|
|
txhash = txid;
|
|
index = indexValue;
|
|
}
|
|
|
|
CAddressUnspentKey() {
|
|
SetNull();
|
|
}
|
|
|
|
void SetNull() {
|
|
type = 0;
|
|
hashBytes.SetNull();
|
|
txhash.SetNull();
|
|
index = 0;
|
|
}
|
|
};
|
|
|
|
struct CAddressUnspentValue {
|
|
CAmount satoshis;
|
|
CScript script;
|
|
int blockHeight;
|
|
|
|
ADD_SERIALIZE_METHODS;
|
|
|
|
template <typename Stream, typename Operation>
|
|
inline void SerializationOp(Stream& s, Operation ser_action) {
|
|
READWRITE(satoshis);
|
|
READWRITE(script);
|
|
READWRITE(blockHeight);
|
|
}
|
|
|
|
CAddressUnspentValue(CAmount sats, CScript scriptPubKey, int height) {
|
|
satoshis = sats;
|
|
script = scriptPubKey;
|
|
blockHeight = height;
|
|
}
|
|
|
|
CAddressUnspentValue() {
|
|
SetNull();
|
|
}
|
|
|
|
void SetNull() {
|
|
satoshis = -1;
|
|
script.clear();
|
|
blockHeight = 0;
|
|
}
|
|
|
|
bool IsNull() const {
|
|
return (satoshis == -1);
|
|
}
|
|
};
|
|
|
|
struct CAddressIndexKey {
|
|
unsigned int type;
|
|
uint160 hashBytes;
|
|
int blockHeight;
|
|
unsigned int txindex;
|
|
uint256 txhash;
|
|
size_t index;
|
|
bool spending;
|
|
|
|
size_t GetSerializeSize(int nType, int nVersion) const {
|
|
return 66;
|
|
}
|
|
template<typename Stream>
|
|
void Serialize(Stream& s) const {
|
|
ser_writedata8(s, type);
|
|
hashBytes.Serialize(s);
|
|
// Heights are stored big-endian for key sorting in LevelDB
|
|
ser_writedata32be(s, blockHeight);
|
|
ser_writedata32be(s, txindex);
|
|
txhash.Serialize(s);
|
|
ser_writedata32(s, index);
|
|
char f = spending;
|
|
ser_writedata8(s, f);
|
|
}
|
|
template<typename Stream>
|
|
void Unserialize(Stream& s) {
|
|
type = ser_readdata8(s);
|
|
hashBytes.Unserialize(s);
|
|
blockHeight = ser_readdata32be(s);
|
|
txindex = ser_readdata32be(s);
|
|
txhash.Unserialize(s);
|
|
index = ser_readdata32(s);
|
|
char f = ser_readdata8(s);
|
|
spending = f;
|
|
}
|
|
|
|
CAddressIndexKey(unsigned int addressType, uint160 addressHash, int height, int blockindex,
|
|
uint256 txid, size_t indexValue, bool isSpending) {
|
|
type = addressType;
|
|
hashBytes = addressHash;
|
|
blockHeight = height;
|
|
txindex = blockindex;
|
|
txhash = txid;
|
|
index = indexValue;
|
|
spending = isSpending;
|
|
}
|
|
|
|
CAddressIndexKey() {
|
|
SetNull();
|
|
}
|
|
|
|
void SetNull() {
|
|
type = 0;
|
|
hashBytes.SetNull();
|
|
blockHeight = 0;
|
|
txindex = 0;
|
|
txhash.SetNull();
|
|
index = 0;
|
|
spending = false;
|
|
}
|
|
|
|
};
|
|
|
|
struct CAddressIndexIteratorKey {
|
|
unsigned int type;
|
|
uint160 hashBytes;
|
|
|
|
size_t GetSerializeSize(int nType, int nVersion) const {
|
|
return 21;
|
|
}
|
|
template<typename Stream>
|
|
void Serialize(Stream& s) const {
|
|
ser_writedata8(s, type);
|
|
hashBytes.Serialize(s);
|
|
}
|
|
template<typename Stream>
|
|
void Unserialize(Stream& s) {
|
|
type = ser_readdata8(s);
|
|
hashBytes.Unserialize(s);
|
|
}
|
|
|
|
CAddressIndexIteratorKey(unsigned int addressType, uint160 addressHash) {
|
|
type = addressType;
|
|
hashBytes = addressHash;
|
|
}
|
|
|
|
CAddressIndexIteratorKey() {
|
|
SetNull();
|
|
}
|
|
|
|
void SetNull() {
|
|
type = 0;
|
|
hashBytes.SetNull();
|
|
}
|
|
};
|
|
|
|
struct CAddressIndexIteratorHeightKey {
|
|
unsigned int type;
|
|
uint160 hashBytes;
|
|
int blockHeight;
|
|
|
|
size_t GetSerializeSize(int nType, int nVersion) const {
|
|
return 25;
|
|
}
|
|
template<typename Stream>
|
|
void Serialize(Stream& s) const {
|
|
ser_writedata8(s, type);
|
|
hashBytes.Serialize(s);
|
|
ser_writedata32be(s, blockHeight);
|
|
}
|
|
template<typename Stream>
|
|
void Unserialize(Stream& s) {
|
|
type = ser_readdata8(s);
|
|
hashBytes.Unserialize(s);
|
|
blockHeight = ser_readdata32be(s);
|
|
}
|
|
|
|
CAddressIndexIteratorHeightKey(unsigned int addressType, uint160 addressHash, int height) {
|
|
type = addressType;
|
|
hashBytes = addressHash;
|
|
blockHeight = height;
|
|
}
|
|
|
|
CAddressIndexIteratorHeightKey() {
|
|
SetNull();
|
|
}
|
|
|
|
void SetNull() {
|
|
type = 0;
|
|
hashBytes.SetNull();
|
|
blockHeight = 0;
|
|
}
|
|
};
|
|
|
|
|
|
#endif // BITCOIN_SPENTINDEX_H
|