From 5ba78eec47c9baa46b53e813b3887a19b5b13693 Mon Sep 17 00:00:00 2001 From: sg777 Date: Thu, 16 Nov 2023 20:41:22 +0530 Subject: [PATCH] Making mandatory checks for player join --- privatebet/err.c | 2 ++ privatebet/err.h | 1 + privatebet/player.c | 4 ++++ privatebet/vdxf.c | 17 +++++++++++++++++ privatebet/vdxf.h | 2 ++ 5 files changed, 26 insertions(+) diff --git a/privatebet/err.c b/privatebet/err.c index 061bdf49..29d3e48a 100644 --- a/privatebet/err.c +++ b/privatebet/err.c @@ -172,6 +172,8 @@ const char *bet_err_str(int32_t err_no) return "Error in cashier config args, check if all the necessary args are confiured in verus_cashier.ini"; case ERR_CONFIG_BLOCKCHAIN_ARGS: return "Error in blockchain config args, check if all the necessary args are confiured in blockchain_config.ini"; + case ERR_IDS_NOT_CONFIGURED: + return "The mandatory IDs needed to play poker are not created on CHAIN"; default: return "This error is not handled yet..."; } diff --git a/privatebet/err.h b/privatebet/err.h index 51aa37d7..b9d4abc3 100644 --- a/privatebet/err.h +++ b/privatebet/err.h @@ -120,6 +120,7 @@ All the errors that come across in bet are defined here. The error numbers are a #define ERR_CONFIG_DEALER_ARGS 133 #define ERR_CONFIG_CASHIER_ARGS 134 #define ERR_CONFIG_BLOCKCHAIN_ARGS 135 +#define ERR_IDS_NOT_CONFIGURED 136 // clang-format on const char *bet_err_str(int32_t err_no); diff --git a/privatebet/player.c b/privatebet/player.c index 57bcdca8..aae99323 100644 --- a/privatebet/player.c +++ b/privatebet/player.c @@ -134,6 +134,10 @@ int32_t handle_verus_player() { int32_t retval = OK; + if((retval = check_poker_ready()) != OK) { + return retval; + } + bet_parse_verus_player(); if ((retval = find_table()) != OK) diff --git a/privatebet/vdxf.c b/privatebet/vdxf.c index 5e1b68d9..8448c354 100644 --- a/privatebet/vdxf.c +++ b/privatebet/vdxf.c @@ -1239,3 +1239,20 @@ void list_tables() } } } + +int32_t check_poker_ready() +{ + int32_t retval = OK; + cJSON *dealers = NULL; + + if((!is_id_exists(CASHIERS_ID, 1)) || (!is_id_exists(DEALERS_ID, 1))) { + return ERR_IDS_NOT_CONFIGURED; + } + + dealers = cJSON_CreateObject(); + dealers = get_cJSON_from_id_key("dealers", DEALERS_KEY); + if(!dealers) { + return ERR_NO_DEALERS_FOUND; + } + return retval; +} diff --git a/privatebet/vdxf.h b/privatebet/vdxf.h index e8ae0b56..6c6476cb 100644 --- a/privatebet/vdxf.h +++ b/privatebet/vdxf.h @@ -89,6 +89,7 @@ Any entity in the bet ecosystem can register the identities under chips, like fo under chips as sg777.chips@ which basically been used to hold the tokens. */ #define CASHIERS_ID "cashiers.poker.chips10sec@" +#define DEALERS_ID "dealers.poker.chips10sec@" #define POKER_CHIPS_VDXF_ID "poker.chips10sec@" #define ID_UPDATE_ESTIMATE_NO 50 @@ -156,4 +157,5 @@ int32_t do_payin_tx_checks(char *txid, cJSON *payin_tx_data); void process_block(char *block_hash); void list_dealers(); void list_tables(); +int32_t check_poker_ready(); #endif