{"action":"created","comment":{"url":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/comments/22469084","id":22469084,"diff_hunk":"@@ -0,0 +1,466 @@\n+/*\n+ This file is part of cpp-ethereum.\n+ \n+ cpp-ethereum is free software: you can redistribute it and/or modify\n+ it under the terms of the GNU General Public License as published by\n+ the Free Software Foundation, either version 3 of the License, or\n+ (at your option) any later version.\n+ \n+ cpp-ethereum is distributed in the hope that it will be useful,\n+ but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+ GNU General Public License for more details.\n+ \n+ You should have received a copy of the GNU General Public License\n+ along with cpp-ethereum.  If not, see <http://www.gnu.org/licenses/>.\n+ */\n+/** @file NodeTable.cpp\n+ * @author Alex Leverington <nessence@gmail.com>\n+ * @date 2014\n+ */\n+\n+#include \"NodeTable.h\"\n+using namespace std;\n+using namespace dev;\n+using namespace dev::p2p;\n+\n+NodeTable::NodeTable(ba::io_service& _io, KeyPair _alias, uint16_t _listenPort):\n+\tm_node(Node(_alias.pub(), bi::udp::endpoint())),\n+\tm_secret(_alias.sec()),\n+\tm_socket(new NodeSocket(_io, *this, _listenPort)),\n+\tm_socketPtr(m_socket.get()),\n+\tm_io(_io),\n+\tm_bucketRefreshTimer(m_io),\n+\tm_evictionCheckTimer(m_io)\n+{\n+\tfor (unsigned i = 0; i < s_bins; i++)\n+\t{\n+\t\tm_state[i].distance = i;\n+\t\tm_state[i].modified = chrono::steady_clock::now() - chrono::seconds(1);\n+\t}\n+\t\n+\tm_socketPtr->connect();\n+\tdoRefreshBuckets(boost::system::error_code());\n+}\n+\t\n+NodeTable::~NodeTable()\n+{\n+\tm_evictionCheckTimer.cancel();\n+\tm_bucketRefreshTimer.cancel();\n+\tm_socketPtr->disconnect();\n+}\n+\n+void NodeTable::join()\n+{\n+\tdoFindNode(m_node.id);\n+}\n+\t\n+std::list<NodeId> NodeTable::nodes() const\n+{\n+\tstd::list<NodeId> nodes;\n+\tGuard l(x_nodes);\n+\tfor (auto& i: m_nodes)\n+\t\tnodes.push_back(i.second->id);\n+\treturn std::move(nodes);\n+}\n+\n+list<NodeTable::NodeEntry> NodeTable::state() const\n+{\n+\tlist<NodeEntry> ret;\n+\tGuard l(x_state);\n+\tfor (auto s: m_state)\n+\t\tfor (auto n: s.nodes)\n+\t\t\tret.push_back(*n.lock());\n+\treturn move(ret);\n+}\n+\n+NodeTable::NodeEntry NodeTable::operator[](NodeId _id)\n+{\n+\tGuard l(x_nodes);\n+\treturn *m_nodes[_id];\n+}\n+\n+void NodeTable::requestNeighbors(NodeEntry const& _node, NodeId _target) const\n+{\n+\tFindNode p(_node.endpoint.udp, _target);\n+\tp.sign(m_secret);\n+\tm_socketPtr->send(p);\n+}\n+\n+void NodeTable::doFindNode(NodeId _node, unsigned _round, std::shared_ptr<std::set<std::shared_ptr<NodeEntry>>> _tried)","path":"libp2p/NodeTable.cpp","position":90,"original_position":90,"commit_id":"6658d5be5f810c6cd2351f347d2f74fed53082bc","original_commit_id":"6658d5be5f810c6cd2351f347d2f74fed53082bc","user":{"login":"LefterisJP","id":1658405,"avatar_url":"https://avatars.githubusercontent.com/u/1658405?v=3","gravatar_id":"","url":"https://api.github.com/users/LefterisJP","html_url":"https://github.com/LefterisJP","followers_url":"https://api.github.com/users/LefterisJP/followers","following_url":"https://api.github.com/users/LefterisJP/following{/other_user}","gists_url":"https://api.github.com/users/LefterisJP/gists{/gist_id}","starred_url":"https://api.github.com/users/LefterisJP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LefterisJP/subscriptions","organizations_url":"https://api.github.com/users/LefterisJP/orgs","repos_url":"https://api.github.com/users/LefterisJP/repos","events_url":"https://api.github.com/users/LefterisJP/events{/privacy}","received_events_url":"https://api.github.com/users/LefterisJP/received_events","type":"User","site_admin":false},"body":"Since you are `using namespace std` on top why not simnply omit `std::` in front of all STL stuff here and in other places to make the code more readable? I have to scroll to the right quite a bit to see the arguments of this function. Another idea is to split arguments into multiple lines. ","created_at":"2015-01-05T16:08:36Z","updated_at":"2015-01-05T16:08:36Z","html_url":"https://github.com/ethereum/cpp-ethereum/pull/720#discussion_r22469084","pull_request_url":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/720","_links":{"self":{"href":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/comments/22469084"},"html":{"href":"https://github.com/ethereum/cpp-ethereum/pull/720#discussion_r22469084"},"pull_request":{"href":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/720"}}},"pull_request":{"url":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/720","id":26829511,"html_url":"https://github.com/ethereum/cpp-ethereum/pull/720","diff_url":"https://github.com/ethereum/cpp-ethereum/pull/720.diff","patch_url":"https://github.com/ethereum/cpp-ethereum/pull/720.patch","issue_url":"https://api.github.com/repos/ethereum/cpp-ethereum/issues/720","number":720,"state":"open","locked":false,"title":"p2p udp nodetable","user":{"login":"subtly","id":6557250,"avatar_url":"https://avatars.githubusercontent.com/u/6557250?v=3","gravatar_id":"","url":"https://api.github.com/users/subtly","html_url":"https://github.com/subtly","followers_url":"https://api.github.com/users/subtly/followers","following_url":"https://api.github.com/users/subtly/following{/other_user}","gists_url":"https://api.github.com/users/subtly/gists{/gist_id}","starred_url":"https://api.github.com/users/subtly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/subtly/subscriptions","organizations_url":"https://api.github.com/users/subtly/orgs","repos_url":"https://api.github.com/users/subtly/repos","events_url":"https://api.github.com/users/subtly/events{/privacy}","received_events_url":"https://api.github.com/users/subtly/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-01-05T15:19:43Z","updated_at":"2015-01-05T16:08:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"411a3e0584423446764c7cacdabfec9fa8b5223d","assignee":{"login":"subtly","id":6557250,"avatar_url":"https://avatars.githubusercontent.com/u/6557250?v=3","gravatar_id":"","url":"https://api.github.com/users/subtly","html_url":"https://github.com/subtly","followers_url":"https://api.github.com/users/subtly/followers","following_url":"https://api.github.com/users/subtly/following{/other_user}","gists_url":"https://api.github.com/users/subtly/gists{/gist_id}","starred_url":"https://api.github.com/users/subtly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/subtly/subscriptions","organizations_url":"https://api.github.com/users/subtly/orgs","repos_url":"https://api.github.com/users/subtly/repos","events_url":"https://api.github.com/users/subtly/events{/privacy}","received_events_url":"https://api.github.com/users/subtly/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/720/commits","review_comments_url":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/720/comments","review_comment_url":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/comments/{number}","comments_url":"https://api.github.com/repos/ethereum/cpp-ethereum/issues/720/comments","statuses_url":"https://api.github.com/repos/ethereum/cpp-ethereum/statuses/6658d5be5f810c6cd2351f347d2f74fed53082bc","head":{"label":"ethereum:p2p-udp-nodetable","ref":"p2p-udp-nodetable","sha":"6658d5be5f810c6cd2351f347d2f74fed53082bc","user":{"login":"ethereum","id":6250754,"avatar_url":"https://avatars.githubusercontent.com/u/6250754?v=3","gravatar_id":"","url":"https://api.github.com/users/ethereum","html_url":"https://github.com/ethereum","followers_url":"https://api.github.com/users/ethereum/followers","following_url":"https://api.github.com/users/ethereum/following{/other_user}","gists_url":"https://api.github.com/users/ethereum/gists{/gist_id}","starred_url":"https://api.github.com/users/ethereum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethereum/subscriptions","organizations_url":"https://api.github.com/users/ethereum/orgs","repos_url":"https://api.github.com/users/ethereum/repos","events_url":"https://api.github.com/users/ethereum/events{/privacy}","received_events_url":"https://api.github.com/users/ethereum/received_events","type":"Organization","site_admin":false},"repo":{"id":15460666,"name":"cpp-ethereum","full_name":"ethereum/cpp-ethereum","owner":{"login":"ethereum","id":6250754,"avatar_url":"https://avatars.githubusercontent.com/u/6250754?v=3","gravatar_id":"","url":"https://api.github.com/users/ethereum","html_url":"https://github.com/ethereum","followers_url":"https://api.github.com/users/ethereum/followers","following_url":"https://api.github.com/users/ethereum/following{/other_user}","gists_url":"https://api.github.com/users/ethereum/gists{/gist_id}","starred_url":"https://api.github.com/users/ethereum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethereum/subscriptions","organizations_url":"https://api.github.com/users/ethereum/orgs","repos_url":"https://api.github.com/users/ethereum/repos","events_url":"https://api.github.com/users/ethereum/events{/privacy}","received_events_url":"https://api.github.com/users/ethereum/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ethereum/cpp-ethereum","description":"Gavin Wood's C++ implementation of the Ethereum yellowpaper.","fork":false,"url":"https://api.github.com/repos/ethereum/cpp-ethereum","forks_url":"https://api.github.com/repos/ethereum/cpp-ethereum/forks","keys_url":"https://api.github.com/repos/ethereum/cpp-ethereum/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ethereum/cpp-ethereum/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ethereum/cpp-ethereum/teams","hooks_url":"https://api.github.com/repos/ethereum/cpp-ethereum/hooks","issue_events_url":"https://api.github.com/repos/ethereum/cpp-ethereum/issues/events{/number}","events_url":"https://api.github.com/repos/ethereum/cpp-ethereum/events","assignees_url":"https://api.github.com/repos/ethereum/cpp-ethereum/assignees{/user}","branches_url":"https://api.github.com/repos/ethereum/cpp-ethereum/branches{/branch}","tags_url":"https://api.github.com/repos/ethereum/cpp-ethereum/tags","blobs_url":"https://api.github.com/repos/ethereum/cpp-ethereum/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ethereum/cpp-ethereum/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ethereum/cpp-ethereum/git/refs{/sha}","trees_url":"https://api.github.com/repos/ethereum/cpp-ethereum/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ethereum/cpp-ethereum/statuses/{sha}","languages_url":"https://api.github.com/repos/ethereum/cpp-ethereum/languages","stargazers_url":"https://api.github.com/repos/ethereum/cpp-ethereum/stargazers","contributors_url":"https://api.github.com/repos/ethereum/cpp-ethereum/contributors","subscribers_url":"https://api.github.com/repos/ethereum/cpp-ethereum/subscribers","subscription_url":"https://api.github.com/repos/ethereum/cpp-ethereum/subscription","commits_url":"https://api.github.com/repos/ethereum/cpp-ethereum/commits{/sha}","git_commits_url":"https://api.github.com/repos/ethereum/cpp-ethereum/git/commits{/sha}","comments_url":"https://api.github.com/repos/ethereum/cpp-ethereum/comments{/number}","issue_comment_url":"https://api.github.com/repos/ethereum/cpp-ethereum/issues/comments/{number}","contents_url":"https://api.github.com/repos/ethereum/cpp-ethereum/contents/{+path}","compare_url":"https://api.github.com/repos/ethereum/cpp-ethereum/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ethereum/cpp-ethereum/merges","archive_url":"https://api.github.com/repos/ethereum/cpp-ethereum/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ethereum/cpp-ethereum/downloads","issues_url":"https://api.github.com/repos/ethereum/cpp-ethereum/issues{/number}","pulls_url":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls{/number}","milestones_url":"https://api.github.com/repos/ethereum/cpp-ethereum/milestones{/number}","notifications_url":"https://api.github.com/repos/ethereum/cpp-ethereum/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ethereum/cpp-ethereum/labels{/name}","releases_url":"https://api.github.com/repos/ethereum/cpp-ethereum/releases{/id}","created_at":"2013-12-26T21:26:06Z","updated_at":"2015-01-05T15:43:08Z","pushed_at":"2015-01-05T15:43:08Z","git_url":"git://github.com/ethereum/cpp-ethereum.git","ssh_url":"git@github.com:ethereum/cpp-ethereum.git","clone_url":"https://github.com/ethereum/cpp-ethereum.git","svn_url":"https://github.com/ethereum/cpp-ethereum","homepage":"www.gavwood.com/Paper.pdf","size":27642,"stargazers_count":375,"watchers_count":375,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":132,"mirror_url":null,"open_issues_count":100,"forks":132,"open_issues":100,"watchers":375,"default_branch":"develop"}},"base":{"label":"ethereum:develop","ref":"develop","sha":"272928e1f05dd3014630551f6bf47140702b6926","user":{"login":"ethereum","id":6250754,"avatar_url":"https://avatars.githubusercontent.com/u/6250754?v=3","gravatar_id":"","url":"https://api.github.com/users/ethereum","html_url":"https://github.com/ethereum","followers_url":"https://api.github.com/users/ethereum/followers","following_url":"https://api.github.com/users/ethereum/following{/other_user}","gists_url":"https://api.github.com/users/ethereum/gists{/gist_id}","starred_url":"https://api.github.com/users/ethereum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethereum/subscriptions","organizations_url":"https://api.github.com/users/ethereum/orgs","repos_url":"https://api.github.com/users/ethereum/repos","events_url":"https://api.github.com/users/ethereum/events{/privacy}","received_events_url":"https://api.github.com/users/ethereum/received_events","type":"Organization","site_admin":false},"repo":{"id":15460666,"name":"cpp-ethereum","full_name":"ethereum/cpp-ethereum","owner":{"login":"ethereum","id":6250754,"avatar_url":"https://avatars.githubusercontent.com/u/6250754?v=3","gravatar_id":"","url":"https://api.github.com/users/ethereum","html_url":"https://github.com/ethereum","followers_url":"https://api.github.com/users/ethereum/followers","following_url":"https://api.github.com/users/ethereum/following{/other_user}","gists_url":"https://api.github.com/users/ethereum/gists{/gist_id}","starred_url":"https://api.github.com/users/ethereum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethereum/subscriptions","organizations_url":"https://api.github.com/users/ethereum/orgs","repos_url":"https://api.github.com/users/ethereum/repos","events_url":"https://api.github.com/users/ethereum/events{/privacy}","received_events_url":"https://api.github.com/users/ethereum/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ethereum/cpp-ethereum","description":"Gavin Wood's C++ implementation of the Ethereum yellowpaper.","fork":false,"url":"https://api.github.com/repos/ethereum/cpp-ethereum","forks_url":"https://api.github.com/repos/ethereum/cpp-ethereum/forks","keys_url":"https://api.github.com/repos/ethereum/cpp-ethereum/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ethereum/cpp-ethereum/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ethereum/cpp-ethereum/teams","hooks_url":"https://api.github.com/repos/ethereum/cpp-ethereum/hooks","issue_events_url":"https://api.github.com/repos/ethereum/cpp-ethereum/issues/events{/number}","events_url":"https://api.github.com/repos/ethereum/cpp-ethereum/events","assignees_url":"https://api.github.com/repos/ethereum/cpp-ethereum/assignees{/user}","branches_url":"https://api.github.com/repos/ethereum/cpp-ethereum/branches{/branch}","tags_url":"https://api.github.com/repos/ethereum/cpp-ethereum/tags","blobs_url":"https://api.github.com/repos/ethereum/cpp-ethereum/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ethereum/cpp-ethereum/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ethereum/cpp-ethereum/git/refs{/sha}","trees_url":"https://api.github.com/repos/ethereum/cpp-ethereum/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ethereum/cpp-ethereum/statuses/{sha}","languages_url":"https://api.github.com/repos/ethereum/cpp-ethereum/languages","stargazers_url":"https://api.github.com/repos/ethereum/cpp-ethereum/stargazers","contributors_url":"https://api.github.com/repos/ethereum/cpp-ethereum/contributors","subscribers_url":"https://api.github.com/repos/ethereum/cpp-ethereum/subscribers","subscription_url":"https://api.github.com/repos/ethereum/cpp-ethereum/subscription","commits_url":"https://api.github.com/repos/ethereum/cpp-ethereum/commits{/sha}","git_commits_url":"https://api.github.com/repos/ethereum/cpp-ethereum/git/commits{/sha}","comments_url":"https://api.github.com/repos/ethereum/cpp-ethereum/comments{/number}","issue_comment_url":"https://api.github.com/repos/ethereum/cpp-ethereum/issues/comments/{number}","contents_url":"https://api.github.com/repos/ethereum/cpp-ethereum/contents/{+path}","compare_url":"https://api.github.com/repos/ethereum/cpp-ethereum/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ethereum/cpp-ethereum/merges","archive_url":"https://api.github.com/repos/ethereum/cpp-ethereum/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ethereum/cpp-ethereum/downloads","issues_url":"https://api.github.com/repos/ethereum/cpp-ethereum/issues{/number}","pulls_url":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls{/number}","milestones_url":"https://api.github.com/repos/ethereum/cpp-ethereum/milestones{/number}","notifications_url":"https://api.github.com/repos/ethereum/cpp-ethereum/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ethereum/cpp-ethereum/labels{/name}","releases_url":"https://api.github.com/repos/ethereum/cpp-ethereum/releases{/id}","created_at":"2013-12-26T21:26:06Z","updated_at":"2015-01-05T15:43:08Z","pushed_at":"2015-01-05T15:43:08Z","git_url":"git://github.com/ethereum/cpp-ethereum.git","ssh_url":"git@github.com:ethereum/cpp-ethereum.git","clone_url":"https://github.com/ethereum/cpp-ethereum.git","svn_url":"https://github.com/ethereum/cpp-ethereum","homepage":"www.gavwood.com/Paper.pdf","size":27642,"stargazers_count":375,"watchers_count":375,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":132,"mirror_url":null,"open_issues_count":100,"forks":132,"open_issues":100,"watchers":375,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/720"},"html":{"href":"https://github.com/ethereum/cpp-ethereum/pull/720"},"issue":{"href":"https://api.github.com/repos/ethereum/cpp-ethereum/issues/720"},"comments":{"href":"https://api.github.com/repos/ethereum/cpp-ethereum/issues/720/comments"},"review_comments":{"href":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/720/comments"},"review_comment":{"href":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/720/commits"},"statuses":{"href":"https://api.github.com/repos/ethereum/cpp-ethereum/statuses/6658d5be5f810c6cd2351f347d2f74fed53082bc"}}}}