From b0d266dfb456f0b1e857323ff2ae6b2a925b80bf Mon Sep 17 00:00:00 2001 From: Wang Zhi Date: Wed, 8 May 2019 11:07:25 +0800 Subject: [PATCH] trick solutation for get total account in YTA chain trick solutation for get total account in YTA chain . it will remove when final soulation is ready. (The total accounts should hold on yta browser system) --- contracts/eosio.system/eosio.system.abi | 12 ++++++++++++ contracts/eosio.system/eosio.system.cpp | 11 +++++++++++ contracts/eosio.system/eosio.system.hpp | 12 ++++++++++++ 3 files changed, 35 insertions(+) diff --git a/contracts/eosio.system/eosio.system.abi b/contracts/eosio.system/eosio.system.abi index 87937c787..2f0a18d60 100644 --- a/contracts/eosio.system/eosio.system.abi +++ b/contracts/eosio.system/eosio.system.abi @@ -260,6 +260,12 @@ {"name":"total_producer_vote_weight", "type":"float64"}, {"name":"last_name_close", "type":"block_timestamp_type"} ] + },{ + "name": "eosio_global_count", + "base": "", + "fields": [ + {"name":"total_accounts", "type":"uint64"} + ] },{ "name": "producer_info", "base": "", @@ -535,6 +541,12 @@ "index_type": "i64", "key_names" : [], "key_types" : [] + },{ + "name": "gcount", + "type": "eosio_global_count", + "index_type": "i64", + "key_names" : [], + "key_types" : [] },{ "name": "voters", "type": "voter_info", diff --git a/contracts/eosio.system/eosio.system.cpp b/contracts/eosio.system/eosio.system.cpp index daf40efbb..84bf6ef85 100644 --- a/contracts/eosio.system/eosio.system.cpp +++ b/contracts/eosio.system/eosio.system.cpp @@ -179,6 +179,17 @@ namespace eosiosystem { }); set_resource_limits( newact, 0, 0, 0 ); + + //##YTA-Change start: + global_count_singleton global(_self, _self); + eosio_global_count gstate; + if(global.exists()) { + gstate = global.get(); + } + gstate.total_accounts += 1; + global.set( gstate, _self ); + //##YTA-Change end: + } } /// eosio.system diff --git a/contracts/eosio.system/eosio.system.hpp b/contracts/eosio.system/eosio.system.hpp index f66375aef..0a7fdcd87 100644 --- a/contracts/eosio.system/eosio.system.hpp +++ b/contracts/eosio.system/eosio.system.hpp @@ -61,6 +61,14 @@ namespace eosiosystem { (last_producer_schedule_size)(total_producer_vote_weight)(last_name_close) ) }; + //##YTA-Change start: + struct eosio_global_count { + uint64_t total_accounts = 1; + + EOSLIB_SERIALIZE( eosio_global_count, (total_accounts) ) + }; + //##YTA-Change end: + struct producer_info { account_name owner; double total_votes = 0; @@ -121,6 +129,10 @@ namespace eosiosystem { typedef eosio::singleton global_state_singleton; + //##YTA-Change start: + typedef eosio::singleton global_count_singleton; + //##YTA-Change end: + // static constexpr uint32_t max_inflation_rate = 5; // 5% annual inflation static constexpr uint32_t seconds_per_day = 24 * 3600; static constexpr uint64_t system_token_symbol = CORE_SYMBOL; -- GitLab