2016-04-04 22:37:43 +02:00
|
|
|
// 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_ADDRESSINDEX_H
|
|
|
|
#define BITCOIN_ADDRESSINDEX_H
|
|
|
|
|
2020-03-19 23:46:56 +01:00
|
|
|
#include <uint256.h>
|
|
|
|
#include <amount.h>
|
2016-04-04 22:37:43 +02:00
|
|
|
|
2019-10-02 16:55:03 +02:00
|
|
|
#include <chrono>
|
2023-09-25 16:49:30 +02:00
|
|
|
#include <tuple>
|
2019-10-02 16:55:03 +02:00
|
|
|
|
2023-09-18 20:39:11 +02:00
|
|
|
namespace AddressType {
|
|
|
|
enum AddressType {
|
|
|
|
P2PK = 1,
|
|
|
|
P2PKH = 1,
|
|
|
|
P2SH = 2,
|
|
|
|
|
|
|
|
UNKNOWN = 0
|
|
|
|
};
|
|
|
|
}; /* namespace AddressType */
|
|
|
|
|
2016-04-04 22:37:43 +02:00
|
|
|
struct CMempoolAddressDelta
|
|
|
|
{
|
2019-10-02 16:55:03 +02:00
|
|
|
std::chrono::seconds time;
|
2016-04-04 22:37:43 +02:00
|
|
|
CAmount amount;
|
|
|
|
uint256 prevhash;
|
|
|
|
unsigned int prevout;
|
|
|
|
|
2019-10-02 16:55:03 +02:00
|
|
|
CMempoolAddressDelta(std::chrono::seconds t, CAmount a, uint256 hash, unsigned int out) {
|
2016-04-04 22:37:43 +02:00
|
|
|
time = t;
|
|
|
|
amount = a;
|
|
|
|
prevhash = hash;
|
|
|
|
prevout = out;
|
|
|
|
}
|
|
|
|
|
2019-10-02 16:55:03 +02:00
|
|
|
CMempoolAddressDelta(std::chrono::seconds t, CAmount a) {
|
2016-04-04 22:37:43 +02:00
|
|
|
time = t;
|
|
|
|
amount = a;
|
|
|
|
prevhash.SetNull();
|
|
|
|
prevout = 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CMempoolAddressDeltaKey
|
|
|
|
{
|
|
|
|
int type;
|
|
|
|
uint160 addressBytes;
|
|
|
|
uint256 txhash;
|
|
|
|
unsigned int index;
|
refactor: use boolean for transaction state, rename variable
there are two problems with "int spending;"
- the integer, which implies that there are gradient states when
there is none, only boolean (vin is spent, vout is UTXO)
- the name, "spending" implies the existence of a middle state,
there is none
a reason why int may have been used is due to needing it in the
comparison struct CMempoolAddressDeltaKeyCompare, though, using
an int isn't necessary as when used with a comparison operator,
a bool is implicitly converted to an int.
see, https://en.cppreference.com/w/cpp/language/implicit_conversion
(Integral promotion)
2023-09-13 19:24:19 +02:00
|
|
|
bool is_spent;
|
2016-04-04 22:37:43 +02:00
|
|
|
|
refactor: use boolean for transaction state, rename variable
there are two problems with "int spending;"
- the integer, which implies that there are gradient states when
there is none, only boolean (vin is spent, vout is UTXO)
- the name, "spending" implies the existence of a middle state,
there is none
a reason why int may have been used is due to needing it in the
comparison struct CMempoolAddressDeltaKeyCompare, though, using
an int isn't necessary as when used with a comparison operator,
a bool is implicitly converted to an int.
see, https://en.cppreference.com/w/cpp/language/implicit_conversion
(Integral promotion)
2023-09-13 19:24:19 +02:00
|
|
|
CMempoolAddressDeltaKey(int addressType, uint160 addressHash, uint256 hash, unsigned int i, bool s) {
|
2016-04-04 22:37:43 +02:00
|
|
|
type = addressType;
|
|
|
|
addressBytes = addressHash;
|
|
|
|
txhash = hash;
|
|
|
|
index = i;
|
refactor: use boolean for transaction state, rename variable
there are two problems with "int spending;"
- the integer, which implies that there are gradient states when
there is none, only boolean (vin is spent, vout is UTXO)
- the name, "spending" implies the existence of a middle state,
there is none
a reason why int may have been used is due to needing it in the
comparison struct CMempoolAddressDeltaKeyCompare, though, using
an int isn't necessary as when used with a comparison operator,
a bool is implicitly converted to an int.
see, https://en.cppreference.com/w/cpp/language/implicit_conversion
(Integral promotion)
2023-09-13 19:24:19 +02:00
|
|
|
is_spent = s;
|
2016-04-04 22:37:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CMempoolAddressDeltaKey(int addressType, uint160 addressHash) {
|
|
|
|
type = addressType;
|
|
|
|
addressBytes = addressHash;
|
|
|
|
txhash.SetNull();
|
|
|
|
index = 0;
|
refactor: use boolean for transaction state, rename variable
there are two problems with "int spending;"
- the integer, which implies that there are gradient states when
there is none, only boolean (vin is spent, vout is UTXO)
- the name, "spending" implies the existence of a middle state,
there is none
a reason why int may have been used is due to needing it in the
comparison struct CMempoolAddressDeltaKeyCompare, though, using
an int isn't necessary as when used with a comparison operator,
a bool is implicitly converted to an int.
see, https://en.cppreference.com/w/cpp/language/implicit_conversion
(Integral promotion)
2023-09-13 19:24:19 +02:00
|
|
|
is_spent = false;
|
2016-04-04 22:37:43 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CMempoolAddressDeltaKeyCompare
|
|
|
|
{
|
2016-04-13 05:25:55 +02:00
|
|
|
bool operator()(const CMempoolAddressDeltaKey& a, const CMempoolAddressDeltaKey& b) const {
|
2023-09-25 16:49:30 +02:00
|
|
|
auto to_tuple = [](const CMempoolAddressDeltaKey& obj) {
|
refactor: use boolean for transaction state, rename variable
there are two problems with "int spending;"
- the integer, which implies that there are gradient states when
there is none, only boolean (vin is spent, vout is UTXO)
- the name, "spending" implies the existence of a middle state,
there is none
a reason why int may have been used is due to needing it in the
comparison struct CMempoolAddressDeltaKeyCompare, though, using
an int isn't necessary as when used with a comparison operator,
a bool is implicitly converted to an int.
see, https://en.cppreference.com/w/cpp/language/implicit_conversion
(Integral promotion)
2023-09-13 19:24:19 +02:00
|
|
|
return std::tie(obj.type, obj.addressBytes, obj.txhash, obj.index, obj.is_spent);
|
2023-09-25 16:49:30 +02:00
|
|
|
};
|
|
|
|
return to_tuple(a) < to_tuple(b);
|
2016-04-04 22:37:43 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // BITCOIN_ADDRESSINDEX_H
|