2

After I type

Cleos get account "Account name"

I get the response:

permissions:
     owner     1:    1 EOS8Z5Yu8cRmWKcW85QjWRtgcSJuGRapuKbp3Vkdm69ZcUYA5yYMk
        active     1:    1 EOS8Z5Yu8cRmWKcW85QjWRtgcSJuGRapuKbp3Vkdm69ZcUYA5yYMk
memory:
     quota:       unlimited  used:     1.482 MiB

net bandwidth:
     used:               unlimited
     available:          unlimited
     limit:              unlimited

cpu bandwidth:
     used:               unlimited
     available:          unlimited
     limit:              unlimited

I am interested in RAM and what does this number mean. Does it take into an account the amount of RAM that is necessary to store elements in the tables of smart contracts and everything else or just the amount I have used to call actions?

1

I have figured it out. This number includes elements stored on the table and contract storage.

0

We can explain this question with source code: 1、when we cemplace or modify or erase table use by multi-index,we update the table storage,for example we emplace some data to the table and the function db_store_i64 is excuted:

int apply_context::db_store_i64( uint64_t code, uint64_t scope, uint64_t table, const account_name& payer, uint64_t id, const char* buffer, size_t buffer_size ) {
//   require_write_lock( scope );
   const auto& tab = find_or_create_table( code, scope, table, payer );
   auto tableid = tab.id;

   EOS_ASSERT( payer != account_name(), invalid_table_payer, "must specify a valid account to pay for new record" );

   const auto& obj = db.create<key_value_object>( [&]( auto& o ) {
      o.t_id        = tableid;
      o.primary_key = id;
      o.value.resize( buffer_size );
      o.payer       = payer;
      memcpy( o.value.data(), buffer, buffer_size );
   });

   db.modify( tab, [&]( auto& t ) {
     ++t.count;
   });

   int64_t billable_size = (int64_t)(buffer_size + config::billable_size_v<key_value_object>);
   **update_db_usage**( payer, billable_size);

   keyval_cache.cache_table( tab );
   return keyval_cache.add( obj );
}

2、the payer who change the table pays for the ram consum ,now we can see funtion update_db_usage

void apply_context::update_db_usage( const account_name& payer, int64_t delta ) {
   if( delta > 0 ) {
      if( !(privileged || payer == account_name(receiver)) ) {
         require_authorization( payer );
      }
   }
   trx_context.add_ram_usage(payer, delta);
}

3、in this way,the account who pay for this storage the ram use has changed,only the table is changed the ram use was updated

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.