0

I'm trying to implement kv_table in my smart contract. Here is my sample code.

#include <eosio/eosio.hpp>
#include <eosio/system.hpp>
#include <eosio/time.hpp>
#include <string>
#include <eosio/table.hpp>

using namespace eosio;
using namespace std;

struct ipfsfile {
  uint64_t id;
  name creator;
  string filename;
  string hash;
  uint64_t size;
  string description;
};

CONTRACT ipfsstoreooo : public contract {

  public:
     using contract::contract;

  struct [[eosio::table]] file_table : eosio::kv::table<ipfsfile, "kvipfsbook"_n> {

    index<uint64_t> idx {
      name{"idx"_n},
      &ipfsfile::id };

    index<name> creator {
      name{"creator"_n},
      &ipfsfile::creator };

    file_table(name id_value) {
      init(id_value, idx);
    }

  };

  ACTION addfile (name creator, string filename, string hash, uint64_t size, string description) {
    file_table files{"kvipfsbook"_n};
    files.put({1, creator, filename, hash, size, description}, get_self());
  }
}

Compilation goes fine. Setting contract to eosin account too.

But when I try to get kv table, using cleos:

cleos get kv_table ipfsstoreooo kvipfsbook idx

I'm receiving following error:

Error 3160012: Bad key-value iterator Error Details: Too many iterators

Can someone advise me what I'm doing wrong.

Thanks in advance!

1 Answer 1

1

kv_tables are not activated on public networks. Are you trying to use this on a public network or a private network you created for yourself.

Also kv_tables will be removed/reworked in future releases, so best not to use them.

1
  • Thank you for the answer. I'm trying this on private network. The main reason to try kv_tables is to find way to avoid using of external DB.
    – Boni
    May 24, 2022 at 4:49

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .