Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add genesis data to es_objects #1717

Merged
merged 7 commits into from Apr 23, 2019
Merged

Conversation

oxarbitrage
Copy link
Member

For issue #1652

Provides option es-objects-load-genesis enabled by default to save accounts, assets and balances from the genesis file to ES.

1652

@abitmore abitmore added this to In development in Feature Release (3.1.0) via automation Apr 12, 2019
@abitmore abitmore added this to the 3.1.0 - Feature Release milestone Apr 12, 2019

block_number = 1;
auto block1 = db.fetch_block_by_number(1);
if(block1.valid())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better always use head_block_num and head_block_time

@@ -260,6 +316,7 @@ void es_objects_plugin::plugin_set_program_options(
("es-objects-index-prefix", boost::program_options::value<std::string>(), "Add a prefix to the index(objects-)")
("es-objects-keep-only-current", boost::program_options::value<bool>(), "Keep only current state of the objects(true)")
("es-objects-start-es-after-block", boost::program_options::value<uint32_t>(), "Start doing ES job after block(0)")
("es-objects-load-genesis", boost::program_options::value<bool>(), "Load genesis data to ES(true)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation string is misleading. The option will index whatever is in the database on startup.
Also, genesis() is called after the first change, which includes changes that were applied after genesis.

@pmconrad
Copy link
Contributor

How about connecting database::applied_block to genesis()? You could use block number 1 as the trigger, which is almost identical to genesis state. It is also triggered during replay, unlike new/changed/removed_objects .

@oxarbitrage
Copy link
Member Author

Good idea, i think there is going to be less problems that way as we make sure genesis is only done at block 1.

Applied at 5c2692d

FC_THROW_EXCEPTION(graphene::chain::plugin_exception, "Error inserting genesis data.");
else {
bulk.clear();
return true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This return is superfluous

@@ -260,12 +313,21 @@ void es_objects_plugin::plugin_set_program_options(
("es-objects-index-prefix", boost::program_options::value<std::string>(), "Add a prefix to the index(objects-)")
("es-objects-keep-only-current", boost::program_options::value<bool>(), "Keep only current state of the objects(true)")
("es-objects-start-es-after-block", boost::program_options::value<uint32_t>(), "Start doing ES job after block(0)")
("es-objects-load-genesis", boost::program_options::value<bool>(), "Index whatever is in the database on startup."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this option make much sense? Under which circumstances would you want to turn that off?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed, removed.

@@ -266,6 +315,13 @@ void es_objects_plugin::plugin_set_program_options(

void es_objects_plugin::plugin_initialize(const boost::program_options::variables_map& options)
{
database().applied_block.connect([&](const signed_block &b) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please capture only what's required.

Copy link
Contributor

@pmconrad pmconrad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Haven't tested.

@oxarbitrage oxarbitrage merged commit 47b4082 into bitshares:develop Apr 23, 2019
Feature Release (3.1.0) automation moved this from In development to Done Apr 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants