diff --git a/modules/global-db/dap_chain_global_db_driver_mdbx.c b/modules/global-db/dap_chain_global_db_driver_mdbx.c index 41db2c51f594bbbea0e0644265b31e69573636e4..ad14edbce7ae4da0b1464129940aeb8ddd257820 100644 --- a/modules/global-db/dap_chain_global_db_driver_mdbx.c +++ b/modules/global-db/dap_chain_global_db_driver_mdbx.c @@ -111,7 +111,7 @@ struct __record_suffix__ { }; -#if SYS_DEBUG +#if DAP_SYS_DEBUG /* * DESCRIPTION: Dump all records from the table . Is supposed to be used at debug time. * @@ -415,7 +415,7 @@ static int s_db_mdbx_flush(void) * @param a_group a group name * @return If successful, a pointer to item, otherwise NULL. */ -dap_store_obj_t *s_db_mdbx_read_last_store_obj(const char* a_group) +dap_store_obj_t *s_db_mdbx_read_last_store_obj(const char *a_group) { int l_rc; dap_db_ctx_t *l_db_ctx; @@ -479,12 +479,13 @@ dap_store_obj_t *l_obj; l_obj = DAP_NEW_Z(dap_store_obj_t); /* Found ! Allocate memory for <store object> and <value> */ - if ( !(l_obj->key = DAP_CALLOC(1, (l_obj->key_len = (l_last_key.iov_len + 1)))) ) + if ( !(l_obj->key = DAP_CALLOC(1, l_last_key.iov_len + 1)) ) l_rc = MDBX_PROBLEM, log_it (L_ERROR, "Cannot allocate a memory for store object key, errno=%d", errno); else if ( (l_obj->value = DAP_CALLOC(1, (l_last_data.iov_len + 1) - sizeof(struct __record_suffix__))) ) { - /* Fill the <store obj> by data from the retreived record */ + /* Fill the <store obj> by data from the retrieved record */ + l_obj->key_len = l_last_key.iov_len; memcpy((char *) l_obj->key, l_last_key.iov_base, l_obj->key_len); l_obj->value_len = l_last_data.iov_len - sizeof(struct __record_suffix__); @@ -982,9 +983,14 @@ struct __record_suffix__ *l_suff; /* Found ! Allocate memory to <store object> < and <value> */ if ( (l_obj = DAP_CALLOC(1, sizeof( dap_store_obj_t ))) ) { - if ( (l_obj->value = DAP_CALLOC(1, (l_data.iov_len + 1) - sizeof(struct __record_suffix__))) ) + if ( !(l_obj->key = DAP_CALLOC(1, l_key.iov_len + 1)) ) + l_rc = MDBX_PROBLEM, log_it (L_ERROR, "Cannot allocate a memory for store object key, errno=%d", errno); + else if ( (l_obj->value = DAP_CALLOC(1, (l_data.iov_len + 1) - sizeof(struct __record_suffix__))) ) { /* Fill the <store obj> by data from the retreived record */ + l_obj->key_len = l_key.iov_len; + memcpy((char *) l_obj->key, l_key.iov_base, l_obj->key_len); + l_obj->value_len = l_data.iov_len - sizeof(struct __record_suffix__); memcpy(l_obj->value, l_data.iov_base, l_obj->value_len); @@ -1054,18 +1060,18 @@ struct __record_suffix__ *l_suff; break; } - /* Iterate cursor to retrieve records from DB */ l_obj = l_obj_arr; for (int i = l_count_out; i && (MDBX_SUCCESS == (l_rc = mdbx_cursor_get(l_cursor, &l_key, &l_data, MDBX_NEXT))); i--, l_obj++) { - if ( !(l_obj->key = DAP_CALLOC(1, (l_obj->key_len = (l_key.iov_len + 1)))) ) + if ( !(l_obj->key = DAP_CALLOC(1, l_key.iov_len + 1)) ) l_rc = MDBX_PROBLEM, log_it (L_ERROR, "Cannot allocate a memory for store object key, errno=%d", errno); else if ( (l_obj->value = DAP_CALLOC(1, (l_data.iov_len + 1) - sizeof(struct __record_suffix__))) ) { - /* Fill the <store obj> by data from the retreived record */ + /* Fill the <store obj> by data from the retrieved record */ + l_obj->key_len = l_key.iov_len; memcpy((char *) l_obj->key, l_key.iov_base, l_obj->key_len); l_obj->value_len = l_data.iov_len - sizeof(struct __record_suffix__); diff --git a/modules/global-db/include/dap_chain_global_db_driver.h b/modules/global-db/include/dap_chain_global_db_driver.h index 68617b4228e27ef26d28cbe79346fbd008ea5478..2242369d3dbada80146ff88aa657bc8286c861a9 100644 --- a/modules/global-db/include/dap_chain_global_db_driver.h +++ b/modules/global-db/include/dap_chain_global_db_driver.h @@ -36,12 +36,12 @@ #include <stddef.h> #include <stdint.h> -#define DAP_DB$SZ_MAXGROUPNAME (128UL) /* A maximum size of group name */ -#define DAP_DB$K_MAXGROUPS (1024UL) /* A maximum number of groups */ -#define DAP_DB$SZ_MAXKEY (512UL) /* A limit for the key's length in DB */ +#define DAP_DB$SZ_MAXGROUPNAME (128UL) /* A maximum size of group name */ +#define DAP_DB$K_MAXGROUPS (1024UL) /* A maximum number of groups */ +#define DAP_DB$SZ_MAXKEY (512UL) /* A limit for the key's length in DB */ #define DAP_DB$K_MAXOBJS (8192UL) /* A maximum number of objects to be returned by read_srore_obj() */ -#define DAP_DB$SZ_MAXDB (32*1024*1024*1024UL) /* 32 GB */ +#define DAP_DB$SZ_MAXDB (32*1024*1024*1024UL) /* 1 GB */ enum { DAP_DB$K_OPTYPE_ADD = 'a', /* Operation Type = INSERT/ADD */ diff --git a/modules/net/dap_chain_node_cli_cmd.c b/modules/net/dap_chain_node_cli_cmd.c index 0e32685fe008c860178c6eb401ec85366018b2be..b47ec30e3cfc48bf762ae3a61a1962bb14cbb812 100644 --- a/modules/net/dap_chain_node_cli_cmd.c +++ b/modules/net/dap_chain_node_cli_cmd.c @@ -2307,9 +2307,9 @@ void s_com_mempool_list_print_for_chain ( continue; } - char buf[50] = {[0]='\0'}; + char buf[128] = {0}; dap_hash_fast_t l_data_hash; - char l_data_hash_str[70] = {[0]='\0'}; + char l_data_hash_str[128] = {0}; dap_hash_fast(l_datum->data,l_datum->header.data_size,&l_data_hash); dap_hash_fast_to_str(&l_data_hash,l_data_hash_str,sizeof (l_data_hash_str)-1); const char *l_type = NULL;