Because name is no longer a uint64_t
type I created my struct like this:
struct [[eosio::table]] game
{
uint64_t id; //auto increment
name host;
name guest= name("none");
name player_to_play =name("none");
name winner = name("none");
string2dvector game_state;
string game_name;
uint64_t primary_key() const { return id; }
uint64_t by_host() const { return host.value; }
EOSLIB_SERIALIZE(game, (id)(host)(guest)(player_to_play)(winner)(game_state)(game_name))
};
// table definition
typedef eosio::multi_index<"game"_n, game,
indexed_by<"host"_n, const_mem_fun<game, uint64_t, &game::by_host>>
> games;
Then I try to get the table indexed by secondary key like this:
auto host_games = existing_games.get_index<"host"_n>();
but when I try to compile I get the following error:
error: no matching member function for call to 'find' auto iterator = host_games.find(host);
/usr/local/eosio.cdt/bin/../include/eosiolib/multi_index.hpp:429:28: note: candidate function not viable: no known conversion from 'const eosio::name' to 'eosio::multi_index<7035924439720001536, tablegame::game, eosio::indexed_by<7868228353667366912, eosio::const_mem_fun > >::index<7868228353667366912, eosio::const_mem_fun, 0, false>::secondary_key_type' (aka 'unsigned long long') for 1st argument const_iterator find( secondary_key_type&& secondary )const {
I tried to change the host type to uint64_t
and return host;
from by_host() or try auto host_games = existing_games.get_index<"host.value"_n>();
but didn't work.
Any thoughts?
P.S the new CDT is a pain in the ass. I should not have updated :P.