Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Add filter-on ability to accept blank action as wildcard #5670

Merged
merged 4 commits into from
Sep 17, 2018
Merged

Conversation

heifner
Copy link
Contributor

@heifner heifner commented Sep 14, 2018

@@ -1421,9 +1423,9 @@ void mongo_db_plugin::set_program_options(options_description& cli, options_desc
("mongodb-store-action-traces", bpo::value<bool>()->default_value(true),
"Enables storing action traces in mongodb.")
("mongodb-filter-on", bpo::value<vector<string>>()->composing(),
"Mongodb: Track actions which match receiver:action:actor. Actor may be blank to include all. Receiver and Action may not be blank. Default is * include everything.")
"Mongodb: Track actions which match receiver:action:actor. Actor may be blank to include all. Action and Actor both blank allows all from Receiver. Receiver may not be blank.")
Copy link
Contributor

Choose a reason for hiding this comment

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

is my read of the code wrong or does this not also allow reciever:0:actor which is not covered in the output?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about:

"Mongodb: Track actions which match receiver:action:actor. Action and/or Actor may be blank to include all. Action and Actor both blank allows all from Receiver. Receiver may not be blank."

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll buy it

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @wanderingbort , @heifner , this implementation does not allow "0:action:actor" code proposed by me in PR #5691 as it was handling all permutations , including ability to leave receiver blank.

if( filter_on_star  ) {
      include = true;
   } else {
      for( const auto& a : action_trace.act.authorization ) {
           auto itr = std::find_if(filter_on.begin(), filter_on.end(), [&action_trace,&a](auto && filter) {
              bool is_found{true};
              if(filter.receiver) {
                  is_found &= action_trace.receipt.receiver == filter.receiver;
              }
              if(filter.action) {
                  is_found &= action_trace.act.name == filter.action;
              }
              if(filter.actor) {
                  is_found &= a.actor == filter.action;
              }
              return is_found;
           });
           if(itr != filter_on.end()) {
               include = true;
               break;
           }
      }
   }

The rationale for "0:action:0" in our project we don't know upfront what coin will be running on the MainNet , so we listen for "0:issue:0 , "0:transfer:0" actions and record them in DB. To work with old solution would require restarting API node , this is not desirable for services we provide as syncing node takes quite some time.

Copy link
Contributor

@venediktov venediktov left a comment

Choose a reason for hiding this comment

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

@heifner , match function is great , it eliminates verbosity , you also took care of mongodb-filter-out looks good !

@@ -1421,9 +1423,9 @@ void mongo_db_plugin::set_program_options(options_description& cli, options_desc
("mongodb-store-action-traces", bpo::value<bool>()->default_value(true),
"Enables storing action traces in mongodb.")
("mongodb-filter-on", bpo::value<vector<string>>()->composing(),
"Mongodb: Track actions which match receiver:action:actor. Actor may be blank to include all. Receiver and Action may not be blank. Default is * include everything.")
"Mongodb: Track actions which match receiver:action:actor. Actor may be blank to include all. Action and Actor both blank allows all from Receiver. Receiver may not be blank.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @wanderingbort , @heifner , this implementation does not allow "0:action:actor" code proposed by me in PR #5691 as it was handling all permutations , including ability to leave receiver blank.

if( filter_on_star  ) {
      include = true;
   } else {
      for( const auto& a : action_trace.act.authorization ) {
           auto itr = std::find_if(filter_on.begin(), filter_on.end(), [&action_trace,&a](auto && filter) {
              bool is_found{true};
              if(filter.receiver) {
                  is_found &= action_trace.receipt.receiver == filter.receiver;
              }
              if(filter.action) {
                  is_found &= action_trace.act.name == filter.action;
              }
              if(filter.actor) {
                  is_found &= a.actor == filter.action;
              }
              return is_found;
           });
           if(itr != filter_on.end()) {
               include = true;
               break;
           }
      }
   }

The rationale for "0:action:0" in our project we don't know upfront what coin will be running on the MainNet , so we listen for "0:issue:0 , "0:transfer:0" actions and record them in DB. To work with old solution would require restarting API node , this is not desirable for services we provide as syncing node takes quite some time.

@heifner heifner merged commit eeeae5b into develop Sep 17, 2018
@heifner heifner deleted the mongo-filter branch September 17, 2018 19:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants