-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Add filter-on ability to accept blank action as wildcard #5670
Conversation
@@ -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.") |
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.
is my read of the code wrong or does this not also allow reciever:0:actor
which is not covered in the output?
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.
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."
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'll buy it
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.
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.
29547e8
to
6b15868
Compare
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.
@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.") |
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.
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.
mongodb-filter-on
&mongodb-filter-out
with ability to wildcard action & receiver.-- Now receiver, action, and actor can be wildcarded.
-- See Add filter-out history config option #4739