0

I've got a multi-index table going with two secondary indices:

TABLE entry {
   uint64_t                id = 0;
   eosio::name             player;
   std::vector<uint16_t>   allocation;
   uint64_t                starttime;
   uint64_t                betroundid;
   double                  talliedpoints;
   bool                    funded;

   uint64_t primary_key() const { return id; }
   uint64_t by_secondary() const { return betroundid; }
   uint64_t by_tertiary() const { return player.value; }

   EOSLIB_SERIALIZE( entry, (id)(player)(allocation)(starttime)(betroundid)(talliedpoints)(funded) )
};


typedef eosio::multi_index<eosio::name("entry"), entry,
  eosio::indexed_by<eosio::name("betroundid"),
    eosio::const_mem_fun<entry, uint64_t, &entry::by_secondary>
  >,
  eosio::indexed_by<eosio::name("playerval"),
    eosio::const_mem_fun<entry, uint64_t, &entry::by_tertiary>
  >
> entry_index;


entry_index entries;

Creating, modifying, and getting entries as usual with entries.find(id) works fine. But when I try to pull the playerval index and find an eosio::name.value in it, I get an iterator in end state:

auto get_unfunded_entry_by_player( const name player_to_get, 
                                   const asset &funding )
{
   auto entries_idx = entries.get_index<name("playerval")>();
   auto entry_itr = entries_idx.find( player_to_get.value );

   eosio_assert( entry_itr != entries_idx.end(), "No entries found for this player!" );

   while ( entry_itr->funded == true || 
           entry_itr->totalbet != funding.amount )
   {
      eosio_assert( ++entry_itr != entries_idx.end(), "No matching unfunded entries found!" );
   }
   return get_entry( entry_itr->id );
}

"No entries found for this player!" is always thrown, even though by using eosio::print and cleos get table, I've verified that the player_to_get is the same name as the player in the table.

Does anything seem to be amiss? Appreciate any help in advance, been fighting with this for hours now:)

New contributor
bitgenstein is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

bitgenstein is a new contributor. Be nice, and check out our Code of Conduct.

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.