未验证 提交 97d27e22 编写于 作者: A arhag 提交者: GitHub

Merge pull request #5828 from EOSIO/fix-order-of-adding-state-db-indices

add state DB consensus indices during chain_plugin initialize rather than startup; use updated chainbase that ensures undo stacks are in sync among indices
......@@ -1388,12 +1388,11 @@ controller::~controller() {
my->fork_db.close();
}
void controller::startup() {
// ilog( "${c}", ("c",fc::json::to_pretty_string(cfg)) );
void controller::add_indices() {
my->add_indices();
}
void controller::startup() {
my->head = my->fork_db.head();
if( !my->head ) {
elog( "No head block in fork db, perhaps we need to replay" );
......
......@@ -87,6 +87,7 @@ namespace eosio { namespace chain {
controller( const config& cfg );
~controller();
void add_indices();
void startup();
/**
......
Subproject commit bcd8ba5d05f7354590e7496da628acaf400667d5
Subproject commit 4724baf2095cdc1bb1722254874b51070adf0e74
......@@ -348,6 +348,7 @@ namespace eosio { namespace testing {
vcfg.trusted_producers = trusted_producers;
validating_node = std::make_unique<controller>(vcfg);
validating_node->add_indices();
validating_node->startup();
init(true);
......@@ -362,6 +363,7 @@ namespace eosio { namespace testing {
vcfg.state_dir = vcfg.state_dir.parent_path() / std::string("v_").append( vcfg.state_dir.filename().generic_string() );
validating_node = std::make_unique<controller>(vcfg);
validating_node->add_indices();
validating_node->startup();
init(config);
......@@ -406,6 +408,7 @@ namespace eosio { namespace testing {
validating_node.reset();
validating_node = std::make_unique<controller>(vcfg);
validating_node->add_indices();
validating_node->startup();
return ok;
......
......@@ -17,7 +17,7 @@ namespace eosio { namespace testing {
std::ifstream wast_file(fn);
FC_ASSERT( wast_file.is_open(), "wast file cannot be found" );
wast_file.seekg(0, std::ios::end);
std::vector<char> wast;
std::vector<char> wast;
int len = wast_file.tellg();
FC_ASSERT( len >= 0, "wast file length is -1" );
wast.resize(len+1);
......@@ -32,7 +32,7 @@ namespace eosio { namespace testing {
std::ifstream wasm_file(fn, std::ios::binary);
FC_ASSERT( wasm_file.is_open(), "wasm file cannot be found" );
wasm_file.seekg(0, std::ios::end);
std::vector<uint8_t> wasm;
std::vector<uint8_t> wasm;
int len = wasm_file.tellg();
FC_ASSERT( len >= 0, "wasm file length is -1" );
wasm.resize(len);
......@@ -46,7 +46,7 @@ namespace eosio { namespace testing {
std::ifstream abi_file(fn);
FC_ASSERT( abi_file.is_open(), "abi file cannot be found" );
abi_file.seekg(0, std::ios::end);
std::vector<char> abi;
std::vector<char> abi;
int len = abi_file.tellg();
FC_ASSERT( len >= 0, "abi file length is -1" );
abi.resize(len+1);
......@@ -127,6 +127,7 @@ namespace eosio { namespace testing {
void base_tester::open() {
control.reset( new controller(cfg) );
control->add_indices();
control->startup();
chain_transactions.clear();
control->accepted_block.connect([this]( const block_state_ptr& block_state ){
......
......@@ -643,6 +643,8 @@ void chain_plugin::plugin_initialize(const variables_map& options) {
[this]( const header_confirmation& conf ) {
my->accepted_confirmation_channel.publish( conf );
} );
my->chain->add_indices();
} FC_LOG_AND_RETHROW()
}
......@@ -906,11 +908,6 @@ bool chain_plugin::export_reversible_blocks( const fc::path& reversible_dir,
return (end >= start) && ((end - start + 1) == num);
}
controller::config& chain_plugin::chain_config() {
// will trigger optional assert if called before/after plugin_initialize()
return *my->chain_config;
}
controller& chain_plugin::chain() { return *my->chain; }
const controller& chain_plugin::chain() const { return *my->chain; }
......
......@@ -639,11 +639,9 @@ public:
const fc::path& reversible_blocks_file
);
// Only call this in plugin_initialize() to modify controller constructor configuration
controller::config& chain_config();
// Only call this after plugin_startup()!
// Only call this after plugin_initialize()!
controller& chain();
// Only call this after plugin_startup()!
// Only call this after plugin_initialize()!
const controller& chain() const;
chain::chain_id_type get_chain_id() const;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册