Skip to content
Snippets Groups Projects
Commit 24dccd17 authored by alexander.lysikov's avatar alexander.lysikov
Browse files

renamed timestamp to id

parent 3821514d
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,7 @@
#define GROUP_LOCAL_HISTORY "global.history"
#define GROUP_LOCAL_NODE_LAST_TS "local.node.last_ts"
#define GROUP_LOCAL_NODE_LAST_ID "local.node.last_id"
#define GROUP_LOCAL_GENERAL "local.general"
typedef struct dap_global_db_obj {
......
......@@ -75,7 +75,9 @@ uint8_t* dap_db_log_pack(dap_global_db_obj_t *a_obj, size_t *a_data_size_out)
// add record - read record
if(l_rec.type == 'a'){
l_obj = (dap_store_obj_t*) dap_chain_global_db_obj_get(l_keys[i], l_rec.group);
l_obj->id = a_obj->id;
// l_obj may be NULL, if this record has been deleted but it is present in history
if(l_obj)
l_obj->id = a_obj->id;
}
// delete record - save only key for record
else if(l_rec.type == 'd') { // //section=strdup("kelvin_nodes");
......
......@@ -32,31 +32,31 @@ uint64_t dap_db_get_cur_node_addr(void)
}
/**
* Set last timestamp for remote node
* Set last id for remote node
*/
bool dap_db_log_set_last_timestamp_remote(uint64_t a_node_addr, time_t a_timestamp)
bool dap_db_log_set_last_id_remote(uint64_t a_node_addr, uint64_t a_id)
{
dap_global_db_obj_t l_objs;
l_objs.key = dap_strdup_printf("%lld", a_node_addr);
l_objs.value = (uint8_t*) &a_timestamp;
l_objs.value_len = sizeof(time_t);
bool l_ret = dap_chain_global_db_gr_save(&l_objs, 1, GROUP_LOCAL_NODE_LAST_TS);
l_objs.value = (uint8_t*) &a_id;
l_objs.value_len = sizeof(uint64_t);
bool l_ret = dap_chain_global_db_gr_save(&l_objs, 1, GROUP_LOCAL_NODE_LAST_ID);
DAP_DELETE(l_objs.key);
log_it( L_NOTICE, "Node 0x%016X set last synced timestamp %llu",a_timestamp);
log_it( L_NOTICE, "Node 0x%016X set last synced timestamp %llu",a_id);
return l_ret;
}
/**
* Get last timestamp for remote node
* Get last id for remote node
*/
time_t dap_db_log_get_last_timestamp_remote(uint64_t a_node_addr)
uint64_t dap_db_log_get_last_id_remote(uint64_t a_node_addr)
{
char *l_node_addr_str = dap_strdup_printf("%lld", a_node_addr);
size_t l_timestamp_len = 0;
uint8_t *l_timestamp = dap_chain_global_db_gr_get((const char*) l_node_addr_str, &l_timestamp_len,
GROUP_LOCAL_NODE_LAST_TS);
time_t l_ret_timestamp = 0;
if(l_timestamp && l_timestamp_len == sizeof(time_t))
GROUP_LOCAL_NODE_LAST_ID);
uint64_t l_ret_timestamp = 0;
if(l_timestamp && l_timestamp_len == sizeof(uint64_t))
memcpy(&l_ret_timestamp, l_timestamp, l_timestamp_len);
DAP_DELETE(l_node_addr_str);
DAP_DELETE(l_timestamp);
......
......@@ -9,8 +9,8 @@ bool dap_db_set_cur_node_addr(uint64_t a_address);
// Get addr for current node
uint64_t dap_db_get_cur_node_addr(void);
// Set last timestamp for remote node
bool dap_db_log_set_last_timestamp_remote(uint64_t a_node_addr, time_t a_timestamp);
// Get last timestamp for remote node
time_t dap_db_log_get_last_timestamp_remote(uint64_t a_node_addr);
// Set last id for remote node
bool dap_db_log_set_last_id_remote(uint64_t a_node_addr, uint64_t a_id);
// Get last id for remote node
uint64_t dap_db_log_get_last_id_remote(uint64_t a_node_addr);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment