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

[3.1] validate input of set_whitelist_blacklist, add_greylist_accounts and remove_greylist_accounts #113

Merged
merged 1 commit into from
Sep 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions plugins/producer_plugin/producer_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1335,13 +1335,17 @@ producer_plugin::runtime_options producer_plugin::get_runtime_options() const {
}

void producer_plugin::add_greylist_accounts(const greylist_params& params) {
EOS_ASSERT(params.accounts.size() > 0, chain::invalid_http_request, "At least one account is required");

chain::controller& chain = my->chain_plug->chain();
for (auto &acc : params.accounts) {
chain.add_resource_greylist(acc);
}
}

void producer_plugin::remove_greylist_accounts(const greylist_params& params) {
EOS_ASSERT(params.accounts.size() > 0, chain::invalid_http_request, "At least one account is required");

chain::controller& chain = my->chain_plug->chain();
for (auto &acc : params.accounts) {
chain.remove_resource_greylist(acc);
Expand Down Expand Up @@ -1372,6 +1376,11 @@ producer_plugin::whitelist_blacklist producer_plugin::get_whitelist_blacklist()
}

void producer_plugin::set_whitelist_blacklist(const producer_plugin::whitelist_blacklist& params) {
EOS_ASSERT(params.actor_whitelist || params.actor_blacklist || params.contract_whitelist || params.contract_blacklist || params.action_blacklist || params.key_blacklist,
chain::invalid_http_request,
"At least one of actor_whitelist, actor_blacklist, contract_whitelist, contract_blacklist, action_blacklist, and key_blacklist is required"
);

chain::controller& chain = my->chain_plug->chain();
if(params.actor_whitelist) chain.set_actor_whitelist(*params.actor_whitelist);
if(params.actor_blacklist) chain.set_actor_blacklist(*params.actor_blacklist);
Expand Down