提交 0248988d 编写于 作者: A Anton Perkov 提交者: arhag

proxy contract switched to new DB API (C api)

上级 a7db1a7e
......@@ -11,16 +11,27 @@ namespace proxy {
using namespace eosio;
namespace configs {
typedef multi_index<N(config), config> config_table;
bool get(config &out, const account_name &self) {
auto read = load_i64(self, self, N(config), (char*)&out, sizeof(config));
if (read < 0) {
auto it = db_find_i64(self, self, N(config), config::key);
if (it != -1) {
auto size = db_get_i64(it, (char*)&out, sizeof(config));
eosio_assert(size == sizeof(config), "Wrong record size");
return true;
} else {
return false;
}
return true;
}
void store(const config &in, const account_name &self) {
store_i64(self, N(config), self, (const char *)&in, sizeof(config));
auto it = db_find_i64(self, self, N(config), config::key);
if (it != -1) {
db_update_i64(it, self, (const char *)&in, sizeof(config));
} else {
db_store_i64(self, N(config), self, config::key, (const char *)&in, sizeof(config));
}
}
};
......
......@@ -15,7 +15,7 @@ namespace proxy {
//@abi table
struct config {
config(){}
const uint64_t key = N(config);
constexpr static uint64_t key = N(config);
account_name owner = 0;
uint32_t delay = 0;
uint32_t next_id = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册