Skip to content
This repository was archived by the owner on Apr 9, 2021. It is now read-only.

Commit fe7bea8

Browse files
committed
Merge remote-tracking branch 'upstream/master' into sql_plugin
2 parents eaa7c8b + 5e46af0 commit fe7bea8

File tree

2 files changed

+35
-29
lines changed

2 files changed

+35
-29
lines changed

db/actions_table.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,10 @@ void actions_table::add(chain::action action, chain::transaction_id_type transac
8888
return; // no ABI no party. Should we still store it?
8989
}
9090

91-
abis.set_abi(abi);
91+
static const fc::microseconds abi_serializer_max_time;
92+
abis.set_abi(abi, abi_serializer_max_time);
9293

93-
auto abi_data = abis.binary_to_variant(abis.get_action_type(action.name), action.data);
94+
auto abi_data = abis.binary_to_variant(abis.get_action_type(action.name), action.data, abi_serializer_max_time);
9495
string json = fc::json::to_string(abi_data);
9596

9697
boost::uuids::random_generator gen;

sql_db_plugin.cpp

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -40,37 +40,42 @@ void sql_db_plugin::set_program_options(options_description& cli, options_descri
4040
void sql_db_plugin::plugin_initialize(const variables_map& options)
4141
{
4242
ilog("initialize");
43+
try {
44+
std::string uri_str = options.at(SQL_DB_URI_OPTION).as<std::string>();
45+
if (uri_str.empty())
46+
{
47+
wlog("db URI not specified => eosio::sql_db_plugin disabled.");
48+
return;
49+
}
50+
ilog("connecting to ${u}", ("u", uri_str));
51+
uint32_t block_num_start = options.at(BLOCK_START_OPTION).as<uint32_t>();
52+
auto db = std::make_unique<database>(uri_str, block_num_start);
4353

44-
std::string uri_str = options.at(SQL_DB_URI_OPTION).as<std::string>();
45-
if (uri_str.empty())
46-
{
47-
wlog("db URI not specified => eosio::sql_db_plugin disabled.");
48-
return;
49-
}
50-
ilog("connecting to ${u}", ("u", uri_str));
51-
uint32_t block_num_start = options.at(BLOCK_START_OPTION).as<uint32_t>();
52-
auto db = std::make_unique<database>(uri_str, block_num_start);
53-
54-
if (options.at(HARD_REPLAY_OPTION).as<bool>() ||
55-
options.at(REPLAY_OPTION).as<bool>() ||
56-
options.at(RESYNC_OPTION).as<bool>() ||
57-
!db->is_started())
58-
{
59-
if (block_num_start == 0) {
60-
ilog("Resync requested: wiping database");
61-
db->wipe();
54+
if (options.at(HARD_REPLAY_OPTION).as<bool>() ||
55+
options.at(REPLAY_OPTION).as<bool>() ||
56+
options.at(RESYNC_OPTION).as<bool>() ||
57+
!db->is_started())
58+
{
59+
if (block_num_start == 0) {
60+
ilog("Resync requested: wiping database");
61+
if( options.at( RESYNC_OPTION ).as<bool>() ||
62+
options.at( REPLAY_OPTION ).as<bool>()) {
63+
ilog( "Resync requested: wiping database" );
64+
db->wipe();
65+
}
66+
}
6267
}
63-
}
6468

65-
m_block_consumer = std::make_unique<consumer<chain::block_state_ptr>>(std::move(db));
66-
m_irreversible_block_consumer = std::make_unique<consumer<chain::block_state_ptr>>(std::move(db));
69+
m_block_consumer = std::make_unique<consumer<chain::block_state_ptr>>(std::move(db));
70+
m_irreversible_block_consumer = std::make_unique<consumer<chain::block_state_ptr>>(std::move(db));
6771

68-
chain_plugin* chain_plug = app().find_plugin<chain_plugin>();
69-
FC_ASSERT(chain_plug);
70-
auto& chain = chain_plug->chain();
71-
// TODO: irreversible to different queue to just find block & update flag
72-
//m_irreversible_block_connection.emplace(chain.irreversible_block.connect([=](const chain::block_state_ptr& b) {m_irreversible_block_consumer->push(b);}));
73-
m_block_connection.emplace(chain.accepted_block.connect([=](const chain::block_state_ptr& b) {m_block_consumer->push(b);}));
72+
chain_plugin* chain_plug = app().find_plugin<chain_plugin>();
73+
FC_ASSERT(chain_plug);
74+
auto& chain = chain_plug->chain();
75+
// TODO: irreversible to different queue to just find block & update flag
76+
//m_irreversible_block_connection.emplace(chain.irreversible_block.connect([=](const chain::block_state_ptr& b) {m_irreversible_block_consumer->push(b);}));
77+
m_block_connection.emplace(chain.accepted_block.connect([=](const chain::block_state_ptr& b) {m_block_consumer->push(b);}));
78+
} FC_LOG_AND_RETHROW()
7479
}
7580

7681
void sql_db_plugin::plugin_startup()

0 commit comments

Comments
 (0)