Skip to content

Commit b93851e

Browse files
committed
Small C++11 refactorings.
Modernise the code a bit for c++11: Use constexpr instead of "static const" and an anonymous namespace instead of a function with static linkage.
1 parent 19e348d commit b93851e

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/names/main.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
#include <util/strencodings.h>
1919
#include <validation.h>
2020

21+
namespace
22+
{
23+
2124
/**
2225
* Check whether a name at nPrevHeight is expired at nHeight. Also
2326
* heights of MEMPOOL_HEIGHT are supported. For nHeight == MEMPOOL_HEIGHT,
@@ -26,7 +29,7 @@
2629
* @param nHeight The height at which it should be updated.
2730
* @return True iff the name is expired.
2831
*/
29-
static bool
32+
bool
3033
isExpired (unsigned nPrevHeight, unsigned nHeight)
3134
{
3235
assert (nHeight != MEMPOOL_HEIGHT);
@@ -37,6 +40,8 @@ isExpired (unsigned nPrevHeight, unsigned nHeight)
3740
return nPrevHeight + params.rules->NameExpirationDepth (nHeight) <= nHeight;
3841
}
3942

43+
} // anonymous namespace
44+
4045
/* ************************************************************************** */
4146
/* CNameData. */
4247

src/names/main.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2014-2017 Daniel Kraft
1+
// Copyright (c) 2014-2019 Daniel Kraft
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

@@ -25,13 +25,13 @@ class CTxMemPoolEntry;
2525
class CValidationState;
2626

2727
/* Some constants defining name limits. */
28-
static const unsigned MAX_VALUE_LENGTH = 1023;
29-
static const unsigned MAX_NAME_LENGTH = 255;
30-
static const unsigned MIN_FIRSTUPDATE_DEPTH = 12;
31-
static const unsigned MAX_VALUE_LENGTH_UI = 520;
28+
constexpr unsigned MAX_VALUE_LENGTH = 1023;
29+
constexpr unsigned MAX_NAME_LENGTH = 255;
30+
constexpr unsigned MIN_FIRSTUPDATE_DEPTH = 12;
31+
constexpr unsigned MAX_VALUE_LENGTH_UI = 520;
3232

3333
/** The amount of coins to lock in created transactions. */
34-
static const CAmount NAME_LOCKED_AMOUNT = COIN / 100;
34+
constexpr CAmount NAME_LOCKED_AMOUNT = COIN / 100;
3535

3636
/* ************************************************************************** */
3737
/* CNameTxUndo. */

0 commit comments

Comments
 (0)