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;
|
2016-06-10 20:41:51 +02:00
|
|
|
int spending;
|
2016-04-04 22:37:43 +02:00
|
|
|
|
2016-06-10 20:41:51 +02:00
|
|
|
CMempoolAddressDeltaKey(int addressType, uint160 addressHash, uint256 hash, unsigned int i, int s) {
|
2016-04-04 22:37:43 +02:00
|
|
|
type = addressType;
|
|
|
|
addressBytes = addressHash;
|
|
|
|
txhash = hash;
|
|
|
|
index = i;
|
|
|
|
spending = s;
|
|
|
|
}
|
|
|
|
|
|
|
|
CMempoolAddressDeltaKey(int addressType, uint160 addressHash) {
|
|
|
|
type = addressType;
|
|
|
|
addressBytes = addressHash;
|
|
|
|
txhash.SetNull();
|
|
|
|
index = 0;
|
2016-06-10 20:41:51 +02:00
|
|
|
spending = 0;
|
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) {
|
|
|
|
return std::tie(obj.type, obj.addressBytes, obj.txhash, obj.index, obj.spending);
|
|
|
|
};
|
|
|
|
return to_tuple(a) < to_tuple(b);
|
2016-04-04 22:37:43 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // BITCOIN_ADDRESSINDEX_H
|