diff --git a/contracts/eosio.system/include/eosio.system/eosio.system.hpp b/contracts/eosio.system/include/eosio.system/eosio.system.hpp index 21be686f..f68d54a2 100644 --- a/contracts/eosio.system/include/eosio.system/eosio.system.hpp +++ b/contracts/eosio.system/include/eosio.system/eosio.system.hpp @@ -500,6 +500,10 @@ namespace eosiosystem { EOSLIB_SERIALIZE( refund_request, (owner)(request_time)(net_amount)(cpu_amount) ) }; + struct [[eosio::table, eosio::contract("eosio.system")]] ram_config { + bool disable_sellram = false; + }; + typedef eosio::singleton< "ramconfig"_n, ram_config > ramconfig_singleton; struct [[eosio::table, eosio::contract("eosio.system")]] gifted_ram { name giftee; @@ -1427,6 +1431,17 @@ namespace eosiosystem { [[eosio::action]] action_return_sellram sellram( const name& account, int64_t bytes ); + /** + * Set ram configuration action, configures RAM-related system settings. + * This action allows the system to enable or disable RAM selling functionality. + * + * @param disable_sellram - if true, disables the sellram action; if false, enables it. + * + * @pre Requires authority of the system contract itself. + */ + [[eosio::action]] + void setramconfig(bool disable_sellram); + /** * Gift ram action, which transfers `bytes` of ram from `gifter` (`from`) to `giftee` (`to`), * with the characteristic that the transfered ram is encumbered, meaning it can only be diff --git a/contracts/eosio.system/src/delegate_bandwidth.cpp b/contracts/eosio.system/src/delegate_bandwidth.cpp index 3434f03a..8173a022 100644 --- a/contracts/eosio.system/src/delegate_bandwidth.cpp +++ b/contracts/eosio.system/src/delegate_bandwidth.cpp @@ -106,6 +106,12 @@ namespace eosiosystem { require_recipient(receiver); } + void system_contract::setramconfig(bool disable_sellram) { + require_auth( get_self() ); + ramconfig_singleton rc(get_self(), get_self().value); + rc.set(ram_config{.disable_sellram = disable_sellram}, get_self()); + } + /** * The system contract now buys and sells RAM allocations at prevailing market prices. * This may result in traders buying RAM today in anticipation of potential shortages @@ -114,6 +120,11 @@ namespace eosiosystem { */ action_return_sellram system_contract::sellram( const name& account, int64_t bytes ) { require_auth( account ); + ramconfig_singleton rc(get_self(), get_self().value); + if (rc.exists()) { + check( rc.get().disable_sellram == false, "sellram is disabled"); + } + update_ram_supply(); require_recipient(account); const int64_t ram_bytes = reduce_ram(account, bytes);