Skip to content

Commit

Permalink
Merge bitcoin#10749: Use compile-time constants instead of unnamed en…
Browse files Browse the repository at this point in the history
…umerations (remove "enum hack")

1e65f0f Use compile-time constants instead of unnamed enumerations (remove "enum hack") (practicalswift)

Pull request description:

  Use compile-time constants instead of unnamed enumerations (remove "enum hack").

Tree-SHA512: 1b6ebb2755398c5ebab6cce125b1dfc39cbd1504d98d55136b32703fe935c4070360ab3b2f52b1da48ba9f3b01082d204f3d87c92ccb5c8c333731f7f972e128
  • Loading branch information
MarcoFalke authored and PastaPastaPasta committed Jan 16, 2020
1 parent e272cee commit 2307488
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/arith_uint256.h
Expand Up @@ -25,7 +25,7 @@ template<unsigned int BITS>
class base_uint
{
protected:
enum { WIDTH=BITS/32 };
static constexpr int WIDTH = BITS / 32;
uint32_t pn[WIDTH];
public:

Expand Down
2 changes: 1 addition & 1 deletion src/chain.h
Expand Up @@ -304,7 +304,7 @@ class CBlockIndex
return (int64_t)nTimeMax;
}

enum { nMedianTimeSpan=11 };
static constexpr int nMedianTimeSpan = 11;

int64_t GetMedianTimePast() const
{
Expand Down
11 changes: 4 additions & 7 deletions src/consensus/consensus.h
Expand Up @@ -24,12 +24,9 @@ static const unsigned int MAX_TX_EXTRA_PAYLOAD = 10000;
static const int COINBASE_MATURITY = 100;

/** Flags for nSequence and nLockTime locks */
enum {
/* Interpret sequence numbers as relative lock-time constraints. */
LOCKTIME_VERIFY_SEQUENCE = (1 << 0),

/* Use GetMedianTimePast() instead of nTime for end point timestamp. */
LOCKTIME_MEDIAN_TIME_PAST = (1 << 1),
};
/** Interpret sequence numbers as relative lock-time constraints. */
static constexpr unsigned int LOCKTIME_VERIFY_SEQUENCE = (1 << 0);
/** Use GetMedianTimePast() instead of nTime for end point timestamp. */
static constexpr unsigned int LOCKTIME_MEDIAN_TIME_PAST = (1 << 1);

#endif // BITCOIN_CONSENSUS_CONSENSUS_H
17 changes: 7 additions & 10 deletions src/protocol.h
Expand Up @@ -27,16 +27,13 @@
class CMessageHeader
{
public:
enum {
MESSAGE_START_SIZE = 4,
COMMAND_SIZE = 12,
MESSAGE_SIZE_SIZE = 4,
CHECKSUM_SIZE = 4,

MESSAGE_SIZE_OFFSET = MESSAGE_START_SIZE + COMMAND_SIZE,
CHECKSUM_OFFSET = MESSAGE_SIZE_OFFSET + MESSAGE_SIZE_SIZE,
HEADER_SIZE = MESSAGE_START_SIZE + COMMAND_SIZE + MESSAGE_SIZE_SIZE + CHECKSUM_SIZE
};
static constexpr size_t MESSAGE_START_SIZE = 4;
static constexpr size_t COMMAND_SIZE = 12;
static constexpr size_t MESSAGE_SIZE_SIZE = 4;
static constexpr size_t CHECKSUM_SIZE = 4;
static constexpr size_t MESSAGE_SIZE_OFFSET = MESSAGE_START_SIZE + COMMAND_SIZE;
static constexpr size_t CHECKSUM_OFFSET = MESSAGE_SIZE_OFFSET + MESSAGE_SIZE_SIZE;
static constexpr size_t HEADER_SIZE = MESSAGE_START_SIZE + COMMAND_SIZE + MESSAGE_SIZE_SIZE + CHECKSUM_SIZE;
typedef unsigned char MessageStartChars[MESSAGE_START_SIZE];

explicit CMessageHeader(const MessageStartChars& pchMessageStartIn);
Expand Down
2 changes: 1 addition & 1 deletion src/uint256.h
Expand Up @@ -20,7 +20,7 @@ template<unsigned int BITS>
class base_blob
{
protected:
enum { WIDTH=BITS/8 };
static constexpr int WIDTH = BITS / 8;
uint8_t data[WIDTH];
public:
base_blob()
Expand Down

0 comments on commit 2307488

Please sign in to comment.