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

Commit

Permalink
KEP-486 Peer Can add itself to Peer List
Browse files Browse the repository at this point in the history
  • Loading branch information
rnistuk committed Oct 3, 2018
1 parent 940ae36 commit 6e651ff
Show file tree
Hide file tree
Showing 16 changed files with 919 additions and 25 deletions.
2 changes: 1 addition & 1 deletion node/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ session::do_read()
{
self->handler(msg, self);
}
else if(ss.seekg(0); proto_msg.ParseFromIstream(&ss))
else if (proto_msg.ParseFromIstream(&ss))
{
self->proto_handler(proto_msg, self);
}
Expand Down
7 changes: 7 additions & 0 deletions options/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,10 @@ options::peer_validation_enabled() const
//TODO: Remove this
return this->raw_opts.get<bool>(PEER_VALIDATION_ENABLED);
}


std::string
options::get_signed_key() const
{
return this->raw_opts.get<std::string>(SIGNED_KEY);
}
2 changes: 2 additions & 0 deletions options/options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ namespace bzn

bool peer_validation_enabled() const override;

std::string get_signed_key() const override;

private:
size_t parse_size(const std::string& key) const;

Expand Down
8 changes: 8 additions & 0 deletions options/options_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,19 @@ namespace bzn
* @return port
*/
virtual uint16_t get_http_port() const = 0;


/**
* Temporary toggle for the peer validation while in QA. Defaults to false.
* @return boolean if the peer_validation member is set to true. Default is false.
*/
virtual bool peer_validation_enabled() const = 0;


/**
* Signature for uuid signing verification
* @return string containing the signature
*/
virtual std::string get_signed_key() const = 0;
};
} // bzn
5 changes: 4 additions & 1 deletion options/simple_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ simple_options::build_options()
"use pbft consensus instead of raft (experimental)")
(PEER_VALIDATION_ENABLED.c_str(),
po::value<bool>()->default_value(false),
"require signed key for new peers to join swarm");
"require signed key for new peers to join swarm")
(SIGNED_KEY.c_str(),
po::value<std::string>(),
"signed key for node's uuid");
this->options_root.add(experimental);

po::options_description crypto("Cryptography");
Expand Down
1 change: 1 addition & 0 deletions options/simple_options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ namespace bzn::option_names
const std::string STATE_DIR = "state_dir";
const std::string WS_IDLE_TIMEOUT = "ws_idle_timeout";
const std::string PEER_VALIDATION_ENABLED = "peer_validation_enabled";
const std::string SIGNED_KEY = "signed_key";

const std::string CHAOS_ENABLED = "chaos_testing_enabled";
const std::string CHAOS_NODE_FAILURE_SHAPE = "chaos_node_failure_shape";
Expand Down
2 changes: 2 additions & 0 deletions options/test/options_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ namespace
" \"logfile_rotation_size\" : \"2M\","
" \"logfile_dir\" : \".\","
" \"http_port\" : 80,"
" \"signed_key\" : \"Oo8ZlDQcMlZF4hqnhN/2D...hoEgc0jRUl1b9mHSY7E4puk=\","
" \"mem_storage\" : false";

const std::string DEFAULT_CONFIG_DATA = "{" + DEFAULT_CONFIG_CONTENT + "}";
Expand Down Expand Up @@ -149,6 +150,7 @@ TEST_F(options_file_test, test_that_loading_of_default_config_file)
EXPECT_EQ(uint16_t(80), options.get_http_port());
EXPECT_FALSE(options.peer_validation_enabled());
EXPECT_FALSE(options.get_mem_storage());
EXPECT_EQ("Oo8ZlDQcMlZF4hqnhN/2D...hoEgc0jRUl1b9mHSY7E4puk=",options.get_signed_key());

// defaults..
{
Expand Down
Loading

0 comments on commit 6e651ff

Please sign in to comment.