Changeset View
Changeset View
Standalone View
Standalone View
src/primitives/transaction.h
Show All 19 Lines | |||||
* vout. | * vout. | ||||
*/ | */ | ||||
class COutPoint { | class COutPoint { | ||||
private: | private: | ||||
TxId txid; | TxId txid; | ||||
uint32_t n; | uint32_t n; | ||||
public: | public: | ||||
COutPoint() : txid(), n(-1) {} | static constexpr uint32_t NULL_INDEX = std::numeric_limits<uint32_t>::max(); | ||||
COutPoint() : txid(), n(NULL_INDEX) {} | |||||
COutPoint(TxId txidIn, uint32_t nIn) : txid(txidIn), n(nIn) {} | COutPoint(TxId txidIn, uint32_t nIn) : txid(txidIn), n(nIn) {} | ||||
ADD_SERIALIZE_METHODS; | ADD_SERIALIZE_METHODS; | ||||
template <typename Stream, typename Operation> | template <typename Stream, typename Operation> | ||||
inline void SerializationOp(Stream &s, Operation ser_action) { | inline void SerializationOp(Stream &s, Operation ser_action) { | ||||
READWRITE(txid); | READWRITE(txid); | ||||
READWRITE(n); | READWRITE(n); | ||||
} | } | ||||
bool IsNull() const { return txid.IsNull() && n == uint32_t(-1); } | bool IsNull() const { return txid.IsNull() && n == NULL_INDEX; } | ||||
const TxId &GetTxId() const { return txid; } | const TxId &GetTxId() const { return txid; } | ||||
uint32_t GetN() const { return n; } | uint32_t GetN() const { return n; } | ||||
friend bool operator<(const COutPoint &a, const COutPoint &b) { | friend bool operator<(const COutPoint &a, const COutPoint &b) { | ||||
int cmp = a.txid.Compare(b.txid); | int cmp = a.txid.Compare(b.txid); | ||||
return cmp < 0 || (cmp == 0 && a.n < b.n); | return cmp < 0 || (cmp == 0 && a.n < b.n); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 312 Lines • Show Last 20 Lines |