diff --git a/modules/net/srv/dap_chain_net_srv.c b/modules/net/srv/dap_chain_net_srv.c index c2009ca4c1a53083b854c4a186467a2a7d8ccc74..9766b0920a1782e0111166133c8d034db4ad1801 100644 --- a/modules/net/srv/dap_chain_net_srv.c +++ b/modules/net/srv/dap_chain_net_srv.c @@ -43,6 +43,7 @@ #include "uthash.h" #include "utlist.h" #include "dap_common.h" +#include "dap_enc_base58.h" #include "dap_list.h" #include "dap_string.h" #include "dap_file_utils.h" @@ -376,7 +377,7 @@ static int s_cli_net_srv( int argc, char **argv, void *arg_func, char **a_str_re size_t l_orders_size = 0; for (size_t i = 0; i< l_orders_num; i++){ dap_chain_net_srv_order_t *l_order =(dap_chain_net_srv_order_t *) (((byte_t*) l_orders) + l_orders_size); - dap_chain_net_srv_order_dump_to_string(l_order, l_string_ret); + dap_chain_net_srv_order_dump_to_string(l_order, l_string_ret, l_hash_out_type); l_orders_size += dap_chain_net_srv_order_get_size(l_order); dap_string_append(l_string_ret,"\n"); } @@ -392,7 +393,7 @@ static int s_cli_net_srv( int argc, char **argv, void *arg_func, char **a_str_re if ( l_order_hash_str ){ dap_chain_net_srv_order_t * l_order = dap_chain_net_srv_order_find_by_hash_str( l_net, l_order_hash_hex_str ); if (l_order){ - dap_chain_net_srv_order_dump_to_string(l_order,l_string_ret); + dap_chain_net_srv_order_dump_to_string(l_order,l_string_ret, l_hash_out_type); ret = 0; }else{ ret = -7 ; @@ -415,7 +416,7 @@ static int s_cli_net_srv( int argc, char **argv, void *arg_func, char **a_str_re size_t l_orders_size = 0; for(size_t i = 0; i < l_orders_num; i++) { dap_chain_net_srv_order_t *l_order =(dap_chain_net_srv_order_t *) (((byte_t*) l_orders) + l_orders_size); - dap_chain_net_srv_order_dump_to_string(l_order, l_string_ret); + dap_chain_net_srv_order_dump_to_string(l_order, l_string_ret, l_hash_out_type); l_orders_size += dap_chain_net_srv_order_get_size(l_order); dap_string_append(l_string_ret, "\n"); } diff --git a/modules/net/srv/dap_chain_net_srv_order.c b/modules/net/srv/dap_chain_net_srv_order.c index 63c5012756368e04858614e3be5555be0b7dcd98..9d536c535ac465ede1ecfc1315a0b0690169dc5c 100644 --- a/modules/net/srv/dap_chain_net_srv_order.c +++ b/modules/net/srv/dap_chain_net_srv_order.c @@ -28,6 +28,7 @@ #include "dap_chain_net_srv_order.h" #include "dap_hash.h" +#include "dap_enc_base58.h" #include "dap_chain_global_db.h" #include "dap_chain_net_srv_countries.h" //#include "dap_chain_net_srv_geoip.h" @@ -439,13 +440,18 @@ int dap_chain_net_srv_order_delete_by_hash_str(dap_chain_net_t * a_net, const ch * @param a_orders * @param a_str_out */ -void dap_chain_net_srv_order_dump_to_string(dap_chain_net_srv_order_t *a_order,dap_string_t * a_str_out) +void dap_chain_net_srv_order_dump_to_string(dap_chain_net_srv_order_t *a_order,dap_string_t * a_str_out, const char *a_hash_out_type) { if (a_order && a_str_out ){ dap_chain_hash_fast_t l_hash; - char l_hash_str[DAP_CHAIN_HASH_FAST_SIZE * 2 + 4]; + char *l_hash_str;//[DAP_CHAIN_HASH_FAST_SIZE * 2 + 4]; dap_hash_fast(a_order, dap_chain_net_srv_order_get_size(a_order), &l_hash); - dap_chain_hash_fast_to_str(&l_hash,l_hash_str,sizeof(l_hash_str)-1); + //dap_chain_hash_fast_to_str(&l_hash,l_hash_str,sizeof(l_hash_str)-1); + if(!dap_strcmp(a_hash_out_type,"hex")) + l_hash_str = dap_chain_hash_fast_to_str_new(&l_hash); + else + l_hash_str = dap_enc_base58_encode_hash_to_str(&l_hash); + dap_string_append_printf(a_str_out, "== Order %s ==\n", l_hash_str); dap_string_append_printf(a_str_out, " version: %u\n", a_order->version ); @@ -469,8 +475,13 @@ void dap_chain_net_srv_order_dump_to_string(dap_chain_net_srv_order_t *a_order,d l_continent_str = dap_chain_net_srv_order_continent_to_str(l_continent_num); dap_string_append_printf(a_str_out, " node_location: %s - %s\n", l_continent_str ? l_continent_str : "None" , l_region ? l_region : "None"); DAP_DELETE(l_region); + DAP_DELETE(l_hash_str); - dap_chain_hash_fast_to_str(&a_order->tx_cond_hash,l_hash_str, sizeof(l_hash_str)-1); + if(!dap_strcmp(a_hash_out_type, "hex")) + l_hash_str = dap_chain_hash_fast_to_str_new(&a_order->tx_cond_hash); + else + l_hash_str = dap_enc_base58_encode_hash_to_str(&a_order->tx_cond_hash); + //dap_chain_hash_fast_to_str(&a_order->tx_cond_hash,l_hash_str, sizeof(l_hash_str)-1); dap_string_append_printf(a_str_out, " tx_cond_hash: %s\n", l_hash_str ); char *l_ext_out = a_order->ext_size ? DAP_NEW_Z_SIZE(char, a_order->ext_size * 2 + 1) : NULL; dap_bin2hex(l_ext_out, a_order->ext, a_order->ext_size); @@ -478,7 +489,7 @@ void dap_chain_net_srv_order_dump_to_string(dap_chain_net_srv_order_t *a_order,d dap_string_append_printf(a_str_out, " ext: 0x%s\n", l_ext_out); else dap_string_append_printf(a_str_out, " ext: 0x0\n"); - + DAP_DELETE(l_hash_str); DAP_DELETE(l_ext_out); } } diff --git a/modules/net/srv/include/dap_chain_net_srv_order.h b/modules/net/srv/include/dap_chain_net_srv_order.h index aa695855af8500fb8a961ab15e74272b1d5aba7c..f4a65545ea90428e278f79e85c0bdab4fda83b7e 100644 --- a/modules/net/srv/include/dap_chain_net_srv_order.h +++ b/modules/net/srv/include/dap_chain_net_srv_order.h @@ -109,7 +109,7 @@ char *dap_chain_net_srv_order_create(dap_chain_net_t * a_net, ); int dap_chain_net_srv_order_save(dap_chain_net_t * a_net, dap_chain_net_srv_order_t *a_order); -void dap_chain_net_srv_order_dump_to_string(dap_chain_net_srv_order_t *a_order,dap_string_t * a_str_out); +void dap_chain_net_srv_order_dump_to_string(dap_chain_net_srv_order_t *a_order,dap_string_t * a_str_out, const char *a_hash_out_type); /** * @brief dap_chain_net_srv_order_get_gdb_group_mempool