4

I have a table that I'm playing with that I want to have a map that links the id with a specific structure. I tried to use map and the code compiles fine, but when generating the abi file it takes forever, like it's lost in an infinite loop.

So looking into the existing contracts I found the exchange, which has exchange_accounts with a flat_map. The problem with it is that this smart contract has no updated abi, because it does not have all the tables of this smart contract including this flat_map.

Here is my actual dao table with proposal structure:

struct proposal {
    account_name recipient;
    asset amount;
    string description;
    uint64_t min_execution_date;
    bool executed;
    bool proposal_passed;
    uint8_t current_result;
    string proposal_hash;

    map<account_name, vote> votes;
};

// @abi table dao i64
struct dao {
    uuid id;
    account_name owner;
    uint16_t min_quorum;
    uint16_t debating_period_minutes;
    uint16_t majority_margin;

    std::vector<account_name> members;

    flat_map<uuid, proposal> proposals;

    uuid primary_key() const { return id; }
};

typedef eosio::multi_index<N(dao), dao> tb_dao;

Here is my abi https://github.com/leordev/eos-play/blob/master/mydao/mydao.abi

The problem is that when I run cleos get table mydao mydao dao the proposal structure is a messy one and does not show the proposals that I already inserted:

{
  "rows": [{
      "id": 1000000000,
      "owner": "leo",
      "min_quorum": 3,
      "debating_period_minutes": 4320,
      "majority_margin": 66,
      "members": [
        "flavia",
        "leo"
      ],
      "proposals": {
        "m_flat_tree": {
          "m_data": {
            "m_seq": {
              "m_holder": []
            }
          }
        }
      }
    }
  ],
  "more": false
}

So my question really is, should I save deep structures inside a table like above or should I separate them in two different tables and link them, in this case, the children proposals by the parent dao_id?

  • I also have the same problem. How do you generate the abi? Did you generate it use the eosiocpp command? – BruceLingKing Jul 31 '18 at 10:47
1

I would recommend creating a second table to hold the proposal votes as you suggest. This will allow you to quickly add, modify, delete, and find votes based on the indexes that you create.

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.