-
Notifications
You must be signed in to change notification settings - Fork 646
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
base: develop
Are you sure you want to change the base?
Conversation
libraries/chain/include/graphene/chain/transaction_entry_object.hpp
Outdated
Show resolved
Hide resolved
libraries/chain/include/graphene/chain/transaction_entry_object.hpp
Outdated
Show resolved
Hide resolved
libraries/plugins/query_txid/include/graphene/query_txid/query_txid_plugin.hpp
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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!
libraries/plugins/query_txid/include/graphene/query_txid/query_txid_plugin.hpp
Show resolved
Hide resolved
libraries/plugins/query_txid/include/graphene/query_txid/query_txid_plugin.hpp
Show resolved
Hide resolved
ok,I will fix them and should I create a new pull request? |
I have fixed the above questions and hope you will like it. |
libraries/chain/include/graphene/chain/transcation_entry_object.hpp
Outdated
Show resolved
Hide resolved
libraries/chain/include/graphene/chain/transcation_entry_object.hpp
Outdated
Show resolved
Hide resolved
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. |
OK,I will try to keep it in few days because i have other work to do |
There are some compiler warnings about signed/unsigned comparisons that i think it should be easy to remove:
|
I add the plugin to |
There was a problem hiding this 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.
libraries/app/database_api.cpp
Outdated
@@ -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 |
There was a problem hiding this comment.
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.
libraries/app/database_api.cpp
Outdated
#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; |
There was a problem hiding this comment.
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()
Currently it fails because the container doesn't have |
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's an example for a unit test suite: https://github.com/bitshares/bitshares-core/blob/3.3.1/tests/performance/performance_tests.cpp
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") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 typedef
ing 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 |
There was a problem hiding this comment.
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." |
There was a problem hiding this comment.
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
.
The pull request is the solution for the #1954, I rebased on the current develop.