提交 3b123f10 编写于 作者: B Brian Johnson

Provide a more natural interface in apply_context and have wasm_interface...

Provide a more natural interface in apply_context and have wasm_interface provide the shim code to accommodate the contract API.
上级 6e813776
......@@ -224,16 +224,13 @@ const contracts::table_id_object& apply_context::find_or_create_table( name scop
});
}
size_t apply_context::get_active_producers(account_name* producers, size_t len) {
vector<account_name> apply_context::get_active_producers() const {
const auto& gpo = controller.get_global_properties();
int index = 0;
vector<account_name> accounts;
for(const auto& producer : gpo.active_producers.producers)
{
*(producers + index) = producer.producer_name;
if (++index >= len)
break;
}
return index;
accounts.push_back(producer.producer_name);
return accounts;
}
} } /// eosio::chain
......@@ -94,7 +94,7 @@ class apply_context {
bool all_authorizations_used()const;
vector<permission_level> unused_authorizations()const;
size_t get_active_producers(account_name* producers, size_t len);
vector<account_name> get_active_producers() const;
const chain_controller& controller;
const chainbase::database& db; ///< database where state is stored
......
......@@ -449,8 +449,10 @@ class producer_api : public context_aware_api {
using context_aware_api::context_aware_api;
int get_active_producers(array_ptr<chain::account_name> producers, size_t datalen) {
auto actual_num_prod = context.get_active_producers(producers, datalen / sizeof(chain::account_name));
return actual_num_prod * sizeof(chain::account_name);
auto active_producers = context.get_active_producers();
size_t len = std::min(datalen / sizeof(chain::account_name), active_producers.size());
memcpy(producers, active_producers.data(), len);
return active_producers.size() * sizeof(chain::account_name);
}
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册