Skip to content
Open
Show file tree
Hide file tree
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
15 changes: 15 additions & 0 deletions contracts/eosio.system/include/eosio.system/eosio.system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions contracts/eosio.system/src/delegate_bandwidth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down