提交 095e7607 编写于 作者: D Daniel Larimer

Implement regproducer::location to Fix #3090

上级 e632304a
......@@ -152,6 +152,7 @@
{"name":"producer", "type":"account_name"},
{"name":"producer_key", "type":"public_key"},
{"name":"url", "type":"string"}
{"name":"location", "type":"uint16"}
]
},{
"name": "unregprod",
......
......@@ -181,7 +181,7 @@ namespace eosiosystem {
// functions defined in voting.cpp
void regproducer( const account_name producer, const public_key& producer_key, const std::string& url );
void regproducer( const account_name producer, const public_key& producer_key, const std::string& url, uint16_t location );
void unregprod( const account_name producer );
......
......@@ -34,7 +34,7 @@ namespace eosiosystem {
* @pre authority of producer to register
*
*/
void system_contract::regproducer( const account_name producer, const eosio::public_key& producer_key, const std::string& url ) { //, const eosio_parameters& prefs ) {
void system_contract::regproducer( const account_name producer, const eosio::public_key& producer_key, const std::string& url, uint16_t location ) {
eosio_assert( url.size() < 512, "url too long" );
//eosio::print("produce_key: ", producer_key.size(), ", sizeof(public_key): ", sizeof(public_key), "\n");
require_auth( producer );
......@@ -45,15 +45,17 @@ namespace eosiosystem {
if( producer_key != prod->producer_key ) {
_producers.modify( prod, producer, [&]( producer_info& info ){
info.producer_key = producer_key;
info.url = url;
info.url = url;
info.location = location;
});
}
} else {
_producers.emplace( producer, [&]( producer_info& info ){
info.owner = producer;
info.total_votes = 0;
info.producer_key = producer_key;
info.url = url;
info.owner = producer;
info.total_votes = 0;
info.producer_key = producer_key;
info.url = url;
info.location = location;
});
}
}
......
......@@ -450,7 +450,7 @@ chain::action create_delegate(const name& from, const name& receiver, const asse
fc::variant regproducer_variant(const account_name& producer,
public_key_type key,
string url) {
string url, uint16_t location = 0) {
/*
fc::variant_object params = fc::mutable_variant_object()
("max_block_net_usage", config::default_max_block_net_usage)
......@@ -485,7 +485,9 @@ fc::variant regproducer_variant(const account_name& producer,
return fc::mutable_variant_object()
("producer", producer)
("producer_key", key)
("url", url);
("url", url)
("location", 0)
;
}
chain::action create_transfer(const string& contract, const name& sender, const name& recipient, asset amount, const string& memo ) {
......@@ -783,12 +785,14 @@ struct register_producer_subcommand {
string producer_str;
string producer_key_str;
string url;
uint16_t loc = 0;
register_producer_subcommand(CLI::App* actionRoot) {
auto register_producer = actionRoot->add_subcommand("regproducer", localized("Register a new producer"));
register_producer->add_option("account", producer_str, localized("The account to register as a producer"))->required();
register_producer->add_option("producer_key", producer_key_str, localized("The producer's public key"))->required();
register_producer->add_option("url", url, localized("url where info about producer can be found"), true);
register_producer->add_option("location", loc, localized("relative location for purpose of nearest neighbor scheduling"), 0);
add_standard_transaction_options(register_producer);
......@@ -798,7 +802,7 @@ struct register_producer_subcommand {
producer_key = public_key_type(producer_key_str);
} EOS_RETHROW_EXCEPTIONS(public_key_type_exception, "Invalid producer public key: ${public_key}", ("public_key", producer_key_str))
auto regprod_var = regproducer_variant(producer_str, producer_key, url );
auto regprod_var = regproducer_variant(producer_str, producer_key, url, loc );
send_actions({create_action({permission_level{producer_str,config::active_name}}, config::system_account_name, N(regproducer), regprod_var)});
});
}
......
......@@ -278,6 +278,7 @@ BOOST_FIXTURE_TEST_CASE( bootseq_test, bootseq_tester ) {
("producer", name(pro))
("producer_key", get_public_key( pro, "active" ) )
("url", "" )
("location", 0 )
);
}
produce_blocks(10);
......
......@@ -301,6 +301,7 @@ public:
("producer", acnt )
("producer_key", get_public_key( acnt, "active" ) )
("url", "" )
("location", 0 )
);
BOOST_REQUIRE_EQUAL( success(), r);
return r;
......@@ -876,6 +877,7 @@ BOOST_FIXTURE_TEST_CASE( producer_register_unregister, eosio_system_tester ) try
("producer", "alice1111111")
("producer_key", key )
("url", "http://block.one")
("location", "0")
)
);
......@@ -923,6 +925,7 @@ BOOST_FIXTURE_TEST_CASE( vote_for_producer, eosio_system_tester, * boost::unit_t
("producer", "alice1111111")
("producer_key", get_public_key( N(alice1111111), "active") )
("url", "http://block.one")
("location", 0 )
)
);
auto prod = get_producer_info( "alice1111111" );
......@@ -1028,6 +1031,7 @@ BOOST_FIXTURE_TEST_CASE( unregistered_producer_voting, eosio_system_tester, * bo
("producer", "alice1111111")
("producer_key", get_public_key( N(alice1111111), "active") )
("url", "")
("location", 0)
)
);
//and then unregisters
......@@ -1080,6 +1084,7 @@ BOOST_FIXTURE_TEST_CASE( vote_same_producer_30_times, eosio_system_tester ) try
("producer", "alice1111111")
("producer_key", get_public_key(N(alice1111111), "active") )
("url", "")
("location", 0)
)
);
......@@ -1106,6 +1111,7 @@ BOOST_FIXTURE_TEST_CASE( producer_keep_votes, eosio_system_tester, * boost::unit
("producer", "alice1111111")
("producer_key", get_public_key( N(alice1111111), "active") )
("url", "")
("location", 0)
)
);
......@@ -1144,6 +1150,7 @@ BOOST_FIXTURE_TEST_CASE( producer_keep_votes, eosio_system_tester, * boost::unit
("producer", "alice1111111")
("producer_key", get_public_key( N(alice1111111), "active") )
("url", "")
("location", 0)
)
);
prod = get_producer_info( "alice1111111" );
......@@ -1156,6 +1163,7 @@ BOOST_FIXTURE_TEST_CASE( producer_keep_votes, eosio_system_tester, * boost::unit
("producer", "alice1111111")
("producer_key", get_public_key( N(alice1111111), "active") )
("url","")
("location", 0)
)
);
prod = get_producer_info( "alice1111111" );
......@@ -1175,6 +1183,7 @@ BOOST_FIXTURE_TEST_CASE( vote_for_two_producers, eosio_system_tester, * boost::u
("producer", "alice1111111")
("producer_key", get_public_key( N(alice1111111), "active") )
("url","")
("location", 0)
)
);
//bob111111111 becomes a producer
......@@ -1184,6 +1193,7 @@ BOOST_FIXTURE_TEST_CASE( vote_for_two_producers, eosio_system_tester, * boost::u
("producer", "bob111111111")
("producer_key", get_public_key( N(alice1111111), "active") )
("url","")
("location", 0)
)
);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册