Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

KEP-1552 Get Peer Info creates correct ESR request data #341

Merged
merged 3 commits into from Jul 3, 2019

Conversation

rnistuk
Copy link
Contributor

@rnistuk rnistuk commented Jul 3, 2019

No description provided.

@rnistuk rnistuk requested a review from ebruck July 3, 2019 23:02
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


rnistuk seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

std::string result{parameter};
result.insert(result.size(), PADDING_REQUIRED, '0');
return result;
static const size_t REQUIRED_SIZE_MULTIPLE{64};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please stop using statics... move to unnamed namespaces.
You incur a performance hit for every call of a function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

const std::string
data_string_for_get_peer_info(const std::string &swarm_id, const std::string &peer_id)
{
static const off_t PARAMETER_OFFSET{64};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to unnamed namespace

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All statics moved to anonymous namespace where appropriate

// TODO: replace this with a function that uses the ABI to create the request data
// data_string_for_get_peer_info has been moved out of the anonymous namespace to make it possible to
// unit test directly.
const std::string
data_string_for_get_peer_info(const std::string &swarm_id, const std::string &peer_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix coding standard

static const auto PEER_INFO_ABI{str_to_json(GET_PEER_INFO_ABI)};
static const auto GET_PEER_INFO_SIGNATURE{PEER_INFO_ABI["signature"].asCString() + 2};
static const auto GET_PEER_INFO_SIGNATURE{PEER_INFO_ABI["signature"].asString()};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

namespace please

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -394,8 +394,8 @@ namespace
const std::string
data_string_for_get_peers(const std::string &swarm_id)
{
static const auto NODE_LIST_ABI = str_to_json(GET_NODE_LIST_ABI);
static const auto GET_PEERS_ADDRESS{NODE_LIST_ABI["signature"].asCString() + 2}; // 0x46e76d8b -> 46e76d8b
const auto NODE_LIST_ABI = str_to_json(GET_NODE_LIST_ABI);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you were better as a static here... why don;t you add a json version to the consts instead of converting it

static const off_t PARAMETER_OFFSET{64};
static const auto PEER_INFO_ABI{str_to_json(GET_PEER_INFO_ABI)};
static const auto GET_PEER_INFO_SIGNATURE{PEER_INFO_ABI["signature"].asString()};
const auto PEER_INFO_ABI{str_to_json(GET_PEER_INFO_ABI)};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

@amastracci amastracci merged commit d12f2eb into devel Jul 3, 2019
@rnistuk rnistuk deleted the bug/rnistuk/kep-1552 branch July 4, 2019 00:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants