Skip to content

Commit

Permalink
Made changes to table init
Browse files Browse the repository at this point in the history
  • Loading branch information
sg777 committed May 10, 2024
1 parent fd28c7e commit 8a64f50
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
7 changes: 4 additions & 3 deletions privatebet/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,13 +371,14 @@ int32_t bet_parse_verus_player()
sizeof(player_config.verus_pid));
}
//Check if all IDs are valid
if((!player_config.dealer_id) || (!player_config.table_id) || (!player_config.verus_pid) || !is_id_exists(player_config.dealer_id,0) || !is_id_exists(player_config.table_id,0)) {
if ((!player_config.dealer_id) || (!player_config.table_id) || (!player_config.verus_pid) ||
!is_id_exists(player_config.dealer_id, 0) || !is_id_exists(player_config.table_id, 0)) {
return ERR_CONFIG_PLAYER_ARGS;
}
//Check if the node has player IDs priv keys
if(!id_cansignfor(player_config.verus_pid,0,&retval)) {
if (!id_cansignfor(player_config.verus_pid, 0, &retval)) {
return retval;
}

return retval;
}
19 changes: 11 additions & 8 deletions privatebet/dealer.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ int32_t dealer_table_init(struct table t)
return ERR_ID_NOT_FOUND;

game_state = get_game_state(t.table_id);
if (game_state == G_ZEROIZED_STATE) {

switch (game_state) {
case G_ZEROIZED_STATE:
game_id = rand256(0);
dlg_info("Updating %s key...", T_GAME_ID_KEY);
out = append_cmm_from_id_key_data_hex(t.table_id, T_GAME_ID_KEY, bits256_str(hexstr, game_id), false);
Expand All @@ -122,7 +124,8 @@ int32_t dealer_table_init(struct table t)
if (!out)
return ERR_GAME_STATE_UPDATE;
dlg_info("%s", cJSON_Print(out));

// No break is intentional
case G_TABLE_ACTIVE:
dlg_info("Updating %s key...", T_TABLE_INFO_KEY);
out = append_cmm_from_id_key_data_cJSON(
t.table_id, get_key_data_vdxf_id(T_TABLE_INFO_KEY, bits256_str(hexstr, game_id)),
Expand All @@ -136,7 +139,8 @@ int32_t dealer_table_init(struct table t)
if (!out)
return ERR_GAME_STATE_UPDATE;
dlg_info("%s", cJSON_Print(out));
} else {
break;
default:
dlg_info("Table is in game, at state ::%s", game_state_str(game_state));
}
return retval;
Expand Down Expand Up @@ -313,11 +317,10 @@ int32_t dealer_init(struct table t)
}
}

game_state = get_game_state(t.table_id);
if (game_state == G_ZEROIZED_STATE) {
retval = dealer_table_init(t);
if (retval)
return retval;
retval = dealer_table_init(t);
if (retval != OK) {
dlg_info("Table Init is failed");
return retval;
}

while (1) {
Expand Down
1 change: 0 additions & 1 deletion privatebet/err.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ All the errors that come across in bet are defined here. The error numbers are a
#define ERR_NULL_ID 141
#define ERR_TABLE_UNREGISTERED 142


// clang-format on
const char *bet_err_str(int32_t err_no);
#endif

0 comments on commit 8a64f50

Please sign in to comment.