diff --git a/libraries/chain/controller.cpp b/libraries/chain/controller.cpp index cb824cf45ba..dd5a85ba2df 100644 --- a/libraries/chain/controller.cpp +++ b/libraries/chain/controller.cpp @@ -741,10 +741,17 @@ struct controller_impl { void sync_name_list(list_type list,bool isMerge=false) { - const auto &gpo2 = db.get(); - db.modify(gpo2, [&](auto &gprops2) { - sync_list_and_db(list, gprops2,isMerge); - }); + try + { + const auto &gpo2 = db.get(); + db.modify(gpo2, [&](auto &gprops2) { + sync_list_and_db(list, gprops2, isMerge); + }); + } + catch (...) + { + wlog("plugin initialize sync list ignore before initialize database"); + } } // "bos end" diff --git a/programs/cleos/main.cpp b/programs/cleos/main.cpp index 7124357f158..af70e0683b8 100644 --- a/programs/cleos/main.cpp +++ b/programs/cleos/main.cpp @@ -1285,33 +1285,38 @@ struct bidname_subcommand { struct bidname_info_subcommand { bool print_json = false; - string newname_str; + name newname; bidname_info_subcommand(CLI::App* actionRoot) { auto list_producers = actionRoot->add_subcommand("bidnameinfo", localized("Get bidname info")); list_producers->add_flag("--json,-j", print_json, localized("Output in JSON format")); - list_producers->add_option("newname", newname_str, localized("The bidding name"))->required(); + list_producers->add_option("newname", newname, localized("The bidding name"))->required(); list_producers->set_callback([this] { auto rawResult = call(get_table_func, fc::mutable_variant_object("json", true) ("code", "eosio")("scope", "eosio")("table", "namebids") - ("lower_bound", eosio::chain::string_to_name(newname_str.c_str()))("limit", 1)); + ("lower_bound", newname.value)("limit", 1)); if ( print_json ) { std::cout << fc::json::to_pretty_string(rawResult) << std::endl; return; } auto result = rawResult.as(); - if ( result.rows.empty() ) { + // Condition in if statement below can simply be res.rows.empty() when cleos no longer needs to support nodeos versions older than 1.5.0 + if( result.rows.empty() || result.rows[0].get_object()["newname"].as_string() != newname.to_string() ) { std::cout << "No bidname record found" << std::endl; return; } - for ( auto& row : result.rows ) { - fc::time_point time(fc::microseconds(row["last_bid_time"].as_uint64())); - int64_t bid = row["high_bid"].as_int64(); - std::cout << std::left << std::setw(18) << "bidname:" << std::right << std::setw(24) << row["newname"].as_string() << "\n" - << std::left << std::setw(18) << "highest bidder:" << std::right << std::setw(24) << row["high_bidder"].as_string() << "\n" - << std::left << std::setw(18) << "highest bid:" << std::right << std::setw(24) << (bid > 0 ? bid : -bid) << "\n" - << std::left << std::setw(18) << "last bid time:" << std::right << std::setw(24) << ((std::string)time).c_str() << std::endl; - if (bid < 0) std::cout << "This auction has already closed" << std::endl; + const auto& row = result.rows[0]; + string time = row["last_bid_time"].as_string(); + try { + time = (string)fc::time_point(fc::microseconds(to_uint64(time))); + } catch (fc::parse_error_exception&) { } + int64_t bid = row["high_bid"].as_int64(); + std::cout << std::left << std::setw(18) << "bidname:" << std::right << std::setw(24) << row["newname"].as_string() << "\n" + << std::left << std::setw(18) << "highest bidder:" << std::right << std::setw(24) << row["high_bidder"].as_string() << "\n" + << std::left << std::setw(18) << "highest bid:" << std::right << std::setw(24) << (bid > 0 ? bid : -bid) << "\n" + << std::left << std::setw(18) << "last bid time:" << std::right << std::setw(24) << time << std::endl; + if (bid < 0) std::cout << "This auction has already closed" << std::endl; + }); } }; diff --git a/unittests/database_gmr_blklst_tests.cpp b/unittests/database_gmr_blklst_tests.cpp index f448ba5a172..148a7d7bace 100644 --- a/unittests/database_gmr_blklst_tests.cpp +++ b/unittests/database_gmr_blklst_tests.cpp @@ -73,20 +73,25 @@ BOOST_AUTO_TEST_CASE(set_name_list_test) vector list = parse_list_string(str); flat_set nameset(list.begin(), list.end()); + // Create an account + db.create([](account_object &a) { + a.name = "alice"; + }); - test.control->set_actor_blacklist(nameset); + + test.control->add_resource_greylist(N(alice)); // Make sure we can retrieve that account by name const global_property2_object &ptr = db.get(); // Create an account db.modify(ptr, [&](global_property2_object &a) { - a.cfg.actor_blacklist = {N(a)}; - a.cfg.contract_blacklist = {N(a)}; - a.cfg.resource_greylist = {N(a)}; + // a.cfg.actor_blacklist = {N(a)}; + // a.cfg.contract_blacklist = {N(a)}; + // a.cfg.resource_greylist = {N(a)}; }); - int64_t lt = static_cast(list_type::actor_blacklist_type); + int64_t lt = static_cast(list_type::resource_greylist_type); int64_t lat = static_cast(list_action_type::insert_type); test.control->set_name_list(lt, lat, list); @@ -114,24 +119,24 @@ BOOST_AUTO_TEST_CASE(set_name_list_test) const global_property2_object &ptr1 = db.get(); chain_config2 c = ptr1.cfg; - BOOST_TEST(c.actor_blacklist.size() == 4); - BOOST_TEST(ab.size() == 4); + BOOST_TEST(c.resource_greylist.size() == 1); + BOOST_TEST(rg.size() == 1); convert_names(c.actor_blacklist, aab); convert_names(c.contract_blacklist, acb); convert_names(c.resource_greylist, arg); - if (c.actor_blacklist.size() == 4) + if (c.resource_greylist.size() == 1) { - bool b = (aab.find(N(a)) != aab.end()); - BOOST_TEST(b); + // bool b = (aab.find(N(a)) != aab.end()); + // BOOST_TEST(b); } - bool d = ab.find(N(a)) != ab.end(); - BOOST_TEST(d); - bool m = aab.find(N(alice)) != aab.end(); + // bool d = ab.find(N(a)) != ab.end(); + // BOOST_TEST(d); + bool m = arg.find(N(alice)) != arg.end(); BOOST_TEST(m); // Undo creation of the account