mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +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 <amount.h>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
namespace AddressType {
|
namespace AddressType {
|
||||||
enum AddressType {
|
enum AddressType {
|
||||||
@ -71,23 +72,10 @@ struct CMempoolAddressDeltaKey
|
|||||||
struct CMempoolAddressDeltaKeyCompare
|
struct CMempoolAddressDeltaKeyCompare
|
||||||
{
|
{
|
||||||
bool operator()(const CMempoolAddressDeltaKey& a, const CMempoolAddressDeltaKey& b) const {
|
bool operator()(const CMempoolAddressDeltaKey& a, const CMempoolAddressDeltaKey& b) const {
|
||||||
if (a.type == b.type) {
|
auto to_tuple = [](const CMempoolAddressDeltaKey& obj) {
|
||||||
if (a.addressBytes == b.addressBytes) {
|
return std::tie(obj.type, obj.addressBytes, obj.txhash, obj.index, obj.spending);
|
||||||
if (a.txhash == b.txhash) {
|
};
|
||||||
if (a.index == b.index) {
|
return to_tuple(a) < to_tuple(b);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
#include <serialize.h>
|
#include <serialize.h>
|
||||||
#include <uint256.h>
|
#include <uint256.h>
|
||||||
|
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
struct CSpentIndexKey {
|
struct CSpentIndexKey {
|
||||||
uint256 txid;
|
uint256 txid;
|
||||||
unsigned int outputIndex;
|
unsigned int outputIndex;
|
||||||
@ -80,11 +82,10 @@ struct CSpentIndexValue {
|
|||||||
struct CSpentIndexKeyCompare
|
struct CSpentIndexKeyCompare
|
||||||
{
|
{
|
||||||
bool operator()(const CSpentIndexKey& a, const CSpentIndexKey& b) const {
|
bool operator()(const CSpentIndexKey& a, const CSpentIndexKey& b) const {
|
||||||
if (a.txid == b.txid) {
|
auto to_tuple = [](const CSpentIndexKey& obj) {
|
||||||
return a.outputIndex < b.outputIndex;
|
return std::tie(obj.txid, obj.outputIndex);
|
||||||
} else {
|
};
|
||||||
return a.txid < b.txid;
|
return to_tuple(a) < to_tuple(b);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user