0
enum house_status: uint64_t {
    NEW = 10,
    FULL = 20,
    ONGOING = 30,
    OVER = 40
};

struct  [[eosio::table, eosio::contract("game")]] house{
    uint64_t id;
    uint64_t owner_player_id;
    uint64_t max_player_count;
    uint64_t status = NEW;
    uint32_t create_time;
    uint32_t start_time;
    uint32_t end_time;

    auto primary_key() const { return id; };

    uint64_t get_owner_player_id() const { return owner_player_id; };

    uint64_t get_status() const { return status; };

    EOSLIB_SERIALIZE(house, (id)(owner_player_id)(max_player_count)(status)(create_time)(start_time)(end_time))
};

I had insert two rows in table of house, then i get table data !

cleos get table xxx xxx house > data/house.txt

Error 3015013: Unpack data exception
Error Details:
Unable to unpack built-in type 'uint64' while processing 'house.status'
read datastream of length 29 over by -4
error unpacking uint64_t
1
  • I didn't change the data structure! I replay the node before deploying the contract, it's not working!
    – lijianwei
    Commented May 8, 2019 at 9:33

1 Answer 1

0

Finally!!! I found out!

   auto player = _players.get(player_id, "xxx");
   _players.modify(player, username, [&](auto& p){
        p.status = status;
   });

This code will run successful, but run twice the data is wrong, and cleos get table will get error!
The fllowing code is correcty!!

   auto player = _players.require_find(player_id, "xxx");
   _players.modify(player, username, [&](auto& p){
        p.status = status;
   });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.