Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Commit

Permalink
Avoid global dynamically initialized object to save start-up time
Browse files Browse the repository at this point in the history
  • Loading branch information
gumb0 committed Apr 8, 2019
1 parent 5607e64 commit 16de129
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions libp2p/ENR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@
#include "ENR.h"
#include <libdevcore/SHA3.h>

static std::string const c_keyID = "id";
static std::string const c_keySec256k1 = "secp256k1";
static std::string const c_keyIP = "ip";
static std::string const c_keyTCP = "tcp";
static std::string const c_keyUDP = "udp";
static dev::bytes const c_IDV4 = {'v', '4'};
static size_t const c_ENRMaxSize = 300;

namespace dev
{
namespace p2p
{
namespace
{
constexpr char c_keyID[] = "id";
constexpr char c_keySec256k1[] = "secp256k1";
constexpr char c_keyIP[] = "ip";
constexpr char c_keyTCP[] = "tcp";
constexpr char c_keyUDP[] = "udp";
constexpr char c_IDV4[] = "v4";
constexpr size_t c_ENRMaxSize = 300;


// Address can be either boost::asio::ip::address_v4 or boost::asio::ip::address_v6
template <class Address>
bytes addressToBytes(Address const& _address)
Expand Down Expand Up @@ -115,7 +116,7 @@ ENR parseV4ENR(RLP _rlp)
auto itID = _keyValues.find(c_keyID);
if (itID == _keyValues.end())
return false;
auto id = RLP(itID->second).toBytes(RLP::VeryStrict);
auto id = RLP(itID->second).toString(RLP::VeryStrict);
if (id != c_IDV4)
return false;

Expand Down

0 comments on commit 16de129

Please sign in to comment.