assertion failure with message: read , help
915-nistor-robert opened this issue · 1 comments
915-nistor-robert commented
My contract gives assertion failure with message: read
My action code is:
ACTION waxrng::getrandom(name nm/, uint64_t customer_id, uint64_t signing_value/){
auto itrCustomer = rngcustomers.find(nm.value);
if (itrCustomer == rngcustomers.end()){
rngcustomers.emplace(_self, [&](auto &rec){
//rec.customer_id = customer_id;
rec.nm = nm;
});
} else {
rngcustomers.modify(itrCustomer, _self, [&](auto &rec){
rec.nm = nm;
});
}
action(
{get_self(), "active"_n},
"orng.wax"_n,
"requestrand"_n,
std::tuple{nm.value,/customer_id, signing_value,/ get_self()}
).send();
}
ACTION waxrng::receiverand(/*uint64_t customer_id,*/name nm , checksum256& random_value){
uint64_t max_value = 1000;
auto byte_array = random_value.extract_as_byte_array();
uint64_t random_int = 0;
for (int i = 0; i<8; i++){
random_int <<= 8;
random_int |= (uint64_t)byte_array[i];
}
uint64_t num1 = random_int % max_value;
auto itrCustomer = rngcustomers.find(nm.value);
check(itrCustomer != rngcustomers.end(), "customer table not set");
rngcustomers.modify(itrCustomer, _self, [&](auto& rec){
rec.random_value = random_value;
rec.finalnumber = num1;
});
}
crazybits commented
you probably update your table struct without data cleanup before change.