mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
refactor: cleanup map comparison struct definitions
This commit is contained in:
parent
5faf29d318
commit
5950f7ce35
@ -10,6 +10,7 @@
|
||||
#include <amount.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <tuple>
|
||||
|
||||
namespace AddressType {
|
||||
enum AddressType {
|
||||
@ -71,23 +72,10 @@ struct CMempoolAddressDeltaKey
|
||||
struct CMempoolAddressDeltaKeyCompare
|
||||
{
|
||||
bool operator()(const CMempoolAddressDeltaKey& a, const CMempoolAddressDeltaKey& b) const {
|
||||
if (a.type == b.type) {
|
||||
if (a.addressBytes == b.addressBytes) {
|
||||
if (a.txhash == b.txhash) {
|
||||
if (a.index == b.index) {
|
||||
return a.spending < b.spending;
|
||||
} else {
|
||||
return a.index < b.index;
|
||||
}
|
||||
} else {
|
||||
return a.txhash < b.txhash;
|
||||
}
|
||||
} else {
|
||||
return a.addressBytes < b.addressBytes;
|
||||
}
|
||||
} else {
|
||||
return a.type < b.type;
|
||||
}
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -12,6 +12,8 @@
|
||||
#include <serialize.h>
|
||||
#include <uint256.h>
|
||||
|
||||
#include <tuple>
|
||||
|
||||
struct CSpentIndexKey {
|
||||
uint256 txid;
|
||||
unsigned int outputIndex;
|
||||
@ -80,11 +82,10 @@ struct CSpentIndexValue {
|
||||
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;
|
||||
}
|
||||
auto to_tuple = [](const CSpentIndexKey& obj) {
|
||||
return std::tie(obj.txid, obj.outputIndex);
|
||||
};
|
||||
return to_tuple(a) < to_tuple(b);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user