EOS多索引表使用指南.pdf


立即下载 不浪漫
2026-05-18
limit uint 引表 多索 64 存储 get
194.6 KB

EOS 多索引表使用指南
作者:守护平井一夫【链客】
词汇表
code :是指已公布智能合约的 account_name。
scope:account_name 所涉及数据范围。
table_name: 存储在内存中的表的名称。
代码分解
要存储的结构
要在多索引表中存储的数据是 limit_order 结构。primary_key
(),get_expiration(),get_price()函数用于返回表。返回的表
将根据调用的函数排序。
struct limit_order {
uint64_t id;
uint128_t price;
uint64_t expiration;
account_name owner;
auto primary_key() const { return id; }
uint64_t get_expiration() const { return expiration; }
uint128_t get_price() const { return price; }
EOSLIB_SERIALIZE( limit_order, ( id )( price )( expirati
on )( owner ) )
};
建一个多索引表
auto payer = ilm.get_account();...
payer 是保存帐户的变量,它将账单元素添加到多索引表中,并
修改已经在多索引表中的元素。
...
eosio::multi_index< N( orders ), limit_order, ...
N(orders)是多索引表的名称,limit_order 是要存储在表中的数
据。
...
indexed_by< N( byexp ), const_mem_fun< limit_order,
uint64_t,
&limit_order::get_expiration> >,...
indexed_by< N( byexp ), const_mem_fun< limit_order,
uint64_t, &limit_order::get_expiration> >定义了多索引表
的索引方式。N(byexp)是这个索引的名称。const_mem_fun 表


limit_order/uint/引表/多索/64_t/存储/get_expiration/ limit_order/uint/引表/多索/64_t/存储/get_expiration/
-1 条回复
登录 后才能参与评论
-->