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 the query_txid_plugin as a option on the develop branch #1957

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from

Conversation

bijianing97
Copy link

The pull request is the solution for the #1954, I rebased on the current develop.

@oxarbitrage oxarbitrage self-requested a review August 23, 2019 16:03
Copy link
Member

@oxarbitrage oxarbitrage 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, i am going to test it and comment/review further.

In the meantime if you want to fix some minor style adjustments i sent will be great. Thanks!

@abitmore abitmore added this to the 4.1.0 - Feature Release milestone Aug 24, 2019
@bijianing97
Copy link
Author

ok,I will fix them and should I create a new pull request?

@bijianing97
Copy link
Author

I have fixed the above questions and hope you will like it.

@oxarbitrage
Copy link
Member

Thank you @bijianing97. Looking good.

I noticed that the new plugin files like https://github.com/bitshares/bitshares-core/blob/32ba6bbf1f2ee9b7b781ac7bf53d2eeae1c01cbf/libraries/plugins/query_txid/query_txid_plugin.cpp the indentation is 4 spaces while the Bitshares project use 3 (almost) everywhere. Will be good if you can change these.

I sent also a few more comments. Adding more commits into this pull request is fine and what you should do, by now your commits have all the same name. Will be good if next ones haves a more descriptive name at least to differentiate them.

Overall great work, i am downloading the requirements and testing further. Will send some more comments once there.

CMakeLists.txt Outdated Show resolved Hide resolved
@bijianing97
Copy link
Author

OK,I will try to keep it in few days because i have other work to do

@oxarbitrage
Copy link
Member

There are some compiler warnings about signed/unsigned comparisons that i think it should be easy to remove:

[ 64%] Building CXX object libraries/plugins/query_txid/CMakeFiles/graphene_query_txid.dir/query_txid_plugin.cpp.o
/home/oxarbitrage/CLionProjects/pull1957/bitshares-core/libraries/plugins/query_txid/query_txid_plugin.cpp: In member function ‘void graphene::query_txid::detail::query_txid_plugin_impl::collect_txid_index(const graphene::protocol::signed_block&)’:
/home/oxarbitrage/CLionProjects/pull1957/bitshares-core/libraries/plugins/query_txid/query_txid_plugin.cpp:102:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for (auto idx = 0; idx < b.transactions.size(); idx++) {
                          ~~~~^~~~~~~~~~~~~~~~~~~~~~~
/home/oxarbitrage/CLionProjects/pull1957/bitshares-core/libraries/plugins/query_txid/query_txid_plugin.cpp: In member function ‘void graphene::query_txid::detail::query_txid_plugin_impl::consume_block()’:
/home/oxarbitrage/CLionProjects/pull1957/bitshares-core/libraries/plugins/query_txid/query_txid_plugin.cpp:128:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       while (number > limit_batch) {
              ~~~~~~~^~~~~~~~~~~~~
/home/oxarbitrage/CLionProjects/pull1957/bitshares-core/libraries/plugins/query_txid/query_txid_plugin.cpp:131:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
          for (auto idx = 0; idx < limit_batch; idx++) {
                             ~~~~^~~~~~~~~~~~~
/home/oxarbitrage/CLionProjects/pull1957/bitshares-core/libraries/plugins/query_txid/query_txid_plugin.cpp:149:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       if (backupnum > limit_batch)
           ~~~~~~~~~~^~~~~~~~~~~~~
[ 64%] Linking CXX static library libgraphene_query_txid.a
[ 64%] Built target graphene_query_txid

@bijianing97
Copy link
Author

I add the plugin to .travis.yml and Dockerfile ,but failed in the docker ,i can’t see the details and modify it

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.

Please add some unit tests. Need a separate test suite though that gets only built if the plugin is enabled.

.travis.yml Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
Dockerfile Outdated Show resolved Hide resolved
@@ -1888,6 +1893,28 @@ std::string database_api::get_transaction_hex_without_sig(
{
return my->get_transaction_hex_without_sig(trx);
}
optional<query_trx_info> database_api_impl::get_transaction_by_txid(transaction_id_type txid)const
{
#ifdef QUERY_TXID_PLUGIN_ABLE
Copy link
Contributor

Choose a reason for hiding this comment

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

If the plugin is not enabled the method doesn't return anything. IMO it should throw.

#ifdef QUERY_TXID_PLUGIN_ABLE
auto &txid_index = _db.get_index_type<trx_entry_index>().indices().get<by_txid>();
auto itor = txid_index.find(txid);
auto trx_entry = *itor;
Copy link
Contributor

Choose a reason for hiding this comment

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

*itor is undefined if itor == txid_index.end()

@pmconrad
Copy link
Contributor

pmconrad commented Sep 5, 2019

but failed in the docker ,i can’t see the details and modify it

Currently it fails because the container doesn't have wget.
But it makes no sense to implement this blindly, if you don't have a local docker installation for testing you can leave it out.

@bijianing97
Copy link
Author

bijianing97 commented Sep 6, 2019

I'm sorry that I don't know how to add some unit tests, could you give me some example, I will try to do it in few days.

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.

graphene_chain fc graphene_db graphene_net graphene_utilities graphene_debug_witness )
target_include_directories( graphene_app
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include"
"${CMAKE_CURRENT_SOURCE_DIR}/../egenesis/include" )
"${CMAKE_CURRENT_SOURCE_DIR}/../egenesis/include"
"${CMAKE_CURRENT_SOURCE_DIR}/../plugins/query_txid_object/include")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is superfluous. The library dependency above should make the plugin include files available to app.

Copy link
Contributor

Choose a reason for hiding this comment

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

Now I get it. You need the include even when the plugin is disabled, because it declares the structure that is used in the return value of the API calls.

You can work around this by typedefing query_trx_info to some other known structure in that case (the API call should always throw an error, so the actual return type will not be used).

@@ -96,6 +100,9 @@ int main(int argc, char** argv) {
auto es_objects_plug = node->register_plugin<es_objects::es_objects_plugin>();
auto grouped_orders_plug = node->register_plugin<grouped_orders::grouped_orders_plugin>();
auto api_helper_indexes_plug = node->register_plugin<api_helper_indexes::api_helper_indexes>();
#ifdef QUERY_TXID_PLUGIN_ABLE
Copy link
Contributor

Choose a reason for hiding this comment

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

Please let precompiler directives always start at the first column, don't indent them.

@@ -4,7 +4,7 @@ set -e
programs/build_helpers/buildstep -s 3500
ccache -s
programs/build_helpers/buildstep Prepare 1 "sed -i '/tests/d' libraries/fc/CMakeLists.txt"
programs/build_helpers/buildstep cmake 5 "cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=--coverage -DCMAKE_CXX_FLAGS=--coverage -DBoost_USE_STATIC_LIBS=OFF -DCMAKE_CXX_OUTPUT_EXTENSION_REPLACE=ON ."
programs/build_helpers/buildstep cmake 5 "cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=--coverage -DCMAKE_CXX_FLAGS=--coverage -DBoost_USE_STATIC_LIBS=OFF -DCMAKE_CXX_OUTPUT_EXTENSION_REPLACE=ON -DLOAD_QUERY_TXID_PLUGIN=ON."
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a space missing after =ON.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants