提交 3b446c03 编写于 作者: K Kevin Heifner

Update get_active_producers for gh#2132

上级 10ea0ac4
......@@ -23,7 +23,7 @@ extern "C" {
/**
* Return the set of active producers
* @param producers - a pointer to an buffer of account_names
* @param datalen - byte length of buffer
* @param datalen - byte length of buffer, 0 to report required size
* @return the number of bytes actually populated
*
* Example:
......
......@@ -249,7 +249,8 @@ namespace identity {
static bool is_trusted( account_name acnt ) {
account_name active_producers[21];
auto count = get_active_producers( active_producers, sizeof(active_producers) );
auto active_prod_size = get_active_producers( active_producers, sizeof(active_producers) );
auto count = active_prod_size / sizeof(account_name);
for( size_t i = 0; i < count; ++i ) {
if( active_producers[i] == acnt )
return true;
......
......@@ -676,12 +676,17 @@ class producer_api : public context_aware_api {
public:
using context_aware_api::context_aware_api;
int get_active_producers(array_ptr<chain::account_name> producers, size_t datalen) {
int get_active_producers(array_ptr<chain::account_name> producers, size_t buffer_size) {
auto active_producers = context.get_active_producers();
size_t len = active_producers.size();
size_t cpy_len = std::min(datalen, len);
memcpy(producers, active_producers.data(), cpy_len * sizeof(chain::account_name));
return len;
auto s = len * sizeof(chain::account_name);
if( buffer_size == 0 ) return s;
auto copy_size = std::min( buffer_size, s );
memcpy( producers, active_producers.data(), copy_size );
return copy_size;
}
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册