@@ -218,6 +218,32 @@ namespace eosiosystem {
218218 refunds_table.erase ( it );
219219 }
220220
221+ void system_contract::removetable ( name code, uint64_t scope, name table ) {
222+ require_auth ( code );
223+
224+ auto itr = db_end_i64 ( code.value , scope, table.value );
225+ eosio_assert ( itr != -1 , " table not found" );
226+
227+ for ( uint64_t i = 0 ; i < 0x10 ; ++i ) {
228+ REMOVE_SECONDARY_INDEX ( itr, uint64_t , code.value , scope, table.value | i )
229+ REMOVE_SECONDARY_INDEX ( itr, uint128_t , code.value , scope, table.value | i )
230+ REMOVE_SECONDARY_INDEX ( itr, double , code.value , scope, table.value | i )
231+ REMOVE_SECONDARY_INDEX ( itr, long double , code.value , scope, table.value | i )
232+ REMOVE_SECONDARY_INDEX ( itr, eosio::key256, code.value , scope, table.value | i )
233+ // REMOVE_SECONDARY_INDEX( itr, eosio::digest256, code.value, scope, table.value | i )
234+ }
235+
236+ uint64_t pk;
237+
238+ itr = db_lowerbound_i64 ( code.value , scope, table.value , std::numeric_limits<uint64_t >::min () );
239+
240+ while ( itr >= 0 ) {
241+ auto next_itr = db_next_i64 ( itr, &pk );
242+ db_remove_i64 ( itr );
243+ itr = next_itr;
244+ }
245+ }
246+
221247 /* *
222248 * Called after a new account is created. This code enforces resource-limits rules
223249 * for new accounts as well as new account naming conventions.
@@ -308,7 +334,7 @@ EOSIO_DISPATCH( eosiosystem::system_contract,
308334 // native.hpp (newaccount definition is actually in eosio.system.cpp)
309335 (newaccount)(updateauth)(deleteauth)(linkauth)(unlinkauth)(canceldelay)(onerror)(setabi)
310336 // eosio.system.cpp
311- (init)(setram)(setramrate)(setparams)(setpriv)(setalimits)(rmvproducer)(updtrevision)(bidname)(bidrefund)
337+ (init)(setram)(setramrate)(setparams)(setpriv)(setalimits)(rmvproducer)(updtrevision)(bidname)(bidrefund)(removetable)
312338 // delegate_bandwidth.cpp
313339 (buyrambytes)(buyram)(sellram)(delegatebw)(undelegatebw)(refund)
314340 // voting.cpp
0 commit comments