diff --git a/CMakeLists.txt b/CMakeLists.txt index d22b714389fc48416863033c9c0018a1d115ded2..edaebb27999b1acb0c43effb8478d3a8e3a89a2e 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8) project (dap_chain_cs_dag) set(DAP_CHAIN_DAG_SRCS - dap_chain_cs_dag.c + dap_chain_cs_dag.c dap_chain_cs_dag_event.c ) @@ -11,8 +11,19 @@ set(DAP_CHAIN_DAG_HEADERS dap_chain_cs_dag_event.h ) -add_library(${PROJECT_NAME} STATIC ${DAP_CHAIN_DAG_SRCS} ${DAP_CHAIN_DAG_HEADERS}) +if(WIN32) + include_directories(../libdap/src/win32/) + include_directories(../3rdparty/libmemcached/) + include_directories(../3rdparty/libmemcached/win32/) + include_directories(../3rdparty/wepoll/include/) + include_directories(../3rdparty/uthash/src/) + include_directories(../3rdparty/libjson-c/) + include_directories(../3rdparty/libmagic/src/) + include_directories(../3rdparty/curl/include/) + include_directories(../3rdparty/libsqlite3/) +endif() +add_library(${PROJECT_NAME} STATIC ${DAP_CHAIN_DAG_SRCS} ${DAP_CHAIN_DAG_HEADERS}) target_link_libraries(dap_chain_cs_dag dap_core dap_crypto dap_chain dap_chain_net dap_chain_crypto dap_chain_global_db) target_include_directories(dap_chain_cs_dag INTERFACE .) diff --git a/dap_chain_cs_dag.c b/dap_chain_cs_dag.c index c014ec16c879f530723124c458c48741a7171f08..5dec5daf203c302b783d68529d0949f2679f4d1f 100755 --- a/dap_chain_cs_dag.c +++ b/dap_chain_cs_dag.c @@ -26,6 +26,17 @@ #include <pthread.h> #include "uthash.h" +#ifdef _WIN32 +#include <winsock2.h> +#include <windows.h> +#include <mswsock.h> +#include <ws2tcpip.h> +#include <io.h> +#include <time.h> +#include <wepoll.h> +#include <pthread.h> +#endif + #include "dap_common.h" #include "dap_string.h" #include "dap_strfuncs.h" @@ -1002,22 +1013,23 @@ static int s_cli_dag(int argc, char ** argv, char **a_str_reply) (strcmp(l_from_events_str,"round.new") == 0) ){ char * l_gdb_group_events = DAP_CHAIN_CS_DAG(l_chain)->gdb_group_events_round_new; dap_string_t * l_str_tmp = dap_string_new(NULL); - dap_global_db_obj_t ** l_objs; + dap_global_db_obj_t * l_objs; size_t l_objs_count = 0; l_objs = dap_chain_global_db_gr_load(l_gdb_group_events,&l_objs_count); dap_string_append_printf(l_str_tmp,"%s.%s: Found %u records :\n",l_net->pub.name,l_chain->name,l_objs_count); for (size_t i = 0; i< l_objs_count; i++){ - dap_chain_cs_dag_event_t * l_event = (dap_chain_cs_dag_event_t *) l_objs[i]->value; + dap_chain_cs_dag_event_t * l_event = (dap_chain_cs_dag_event_t *) l_objs[i].value; char buf[50]; time_t l_ts_create = (time_t) l_event->header.ts_created; dap_string_append_printf(l_str_tmp,"\t%s: ts_create=%s", - l_objs[i]->key, ctime_r( &l_ts_create,buf ) ); + l_objs[i].key, ctime_r( &l_ts_create,buf ) ); } dap_chain_node_cli_set_reply_text(a_str_reply, l_str_tmp->str); dap_string_free(l_str_tmp,false); DAP_DELETE( l_gdb_group_events); + dap_chain_global_db_objs_delete(l_objs, l_objs_count); ret = 0; }else if (l_from_events_str && (strcmp(l_from_events_str,"events") == 0) ){ dap_string_t * l_str_tmp = dap_string_new(NULL); diff --git a/dap_chain_cs_dag_event.c b/dap_chain_cs_dag_event.c index 1875e60ce6cc9bd2f3c4580228c62317245b96e4..468fd7b54fa8952b099567dd64f083b720c81540 100755 --- a/dap_chain_cs_dag_event.c +++ b/dap_chain_cs_dag_event.c @@ -56,7 +56,13 @@ dap_chain_cs_dag_event_t * dap_chain_cs_dag_event_new(dap_chain_id_t a_chain_id, l_event_new = DAP_NEW_Z_SIZE(dap_chain_cs_dag_event_t, l_event_size ); + #ifdef _WIN32 + l_event_new->header.ts_created = (uint64_t) gmtime(NULL); + #else l_event_new->header.ts_created = (uint64_t) timegm(NULL); + #endif + + l_event_new->header.cell_id.uint64 = a_cell_id.uint64; l_event_new->header.chain_id.uint64 = a_chain_id.uint64;