Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct [[eosio::table]] _prices {
- symbol base;
- symbol quote;
- float value = 0.0;
- uint64_t primary_key() const {
- return base.code().raw();
- }
- uint128_t uniquekey() const {
- return ((uint128_t) base.code().raw()) << 64 | quote.code().raw();
- }
- };
- typedef eosio::multi_index<name("prices"), _prices,
- indexed_by<
- name("uniquekey"),
- const_mem_fun<
- _prices, uint128_t, &_prices::uniquekey
- >
- >
- > prices;
- symbol base("TTF", 2), quote("USD", 2);
- float val = 1.0;
- prices p(_self, _self.value);
- auto m = p.get_index<name("uniquekey")>();
- auto o = m.find((((uint128_t) base.code().raw()) << 64) | quote.code().raw());
- if (o == m.end())
- p.emplace(_self, [&](auto &r) {
- r.base = base;
- r.quote = quote;
- r.value = val;
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement