TransWikia.com

read datastream of length 29 over by -4

EOS.IO Asked by lijianwei on February 16, 2021

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

One Answer

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;
   });

Answered by lijianwei on February 16, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP