Skip to content

Commit 6b82fc5

Browse files
committed
Use const in COutPoint class
1 parent 60b20c8 commit 6b82fc5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/primitives/transaction.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ class COutPoint
2121
uint256 hash;
2222
uint32_t n;
2323

24-
COutPoint(): n((uint32_t) -1) { }
24+
static constexpr uint32_t NULL_INDEX = std::numeric_limits<uint32_t>::max();
25+
26+
COutPoint(): n(NULL_INDEX) { }
2527
COutPoint(const uint256& hashIn, uint32_t nIn): hash(hashIn), n(nIn) { }
2628

2729
ADD_SERIALIZE_METHODS;
@@ -32,8 +34,8 @@ class COutPoint
3234
READWRITE(n);
3335
}
3436

35-
void SetNull() { hash.SetNull(); n = (uint32_t) -1; }
36-
bool IsNull() const { return (hash.IsNull() && n == (uint32_t) -1); }
37+
void SetNull() { hash.SetNull(); n = NULL_INDEX; }
38+
bool IsNull() const { return (hash.IsNull() && n == NULL_INDEX); }
3739

3840
friend bool operator<(const COutPoint& a, const COutPoint& b)
3941
{

0 commit comments

Comments
 (0)