Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cellframe-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
14
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cellframe
cellframe-sdk
Commits
90bf0dc7
Commit
90bf0dc7
authored
2 days ago
by
roman.padenkov
Browse files
Options
Downloads
Patches
Plain Diff
...
parent
8f5ac56c
No related branches found
No related tags found
1 merge request
!2111
Feature 15561
Pipeline
#52259
failed with stage
in 11 minutes and 57 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/type/dag/dap_chain_cs_dag.c
+53
-7
53 additions, 7 deletions
modules/type/dag/dap_chain_cs_dag.c
modules/type/dag/include/dap_chain_cs_dag.h
+1
-0
1 addition, 0 deletions
modules/type/dag/include/dap_chain_cs_dag.h
with
54 additions
and
7 deletions
modules/type/dag/dap_chain_cs_dag.c
+
53
−
7
View file @
90bf0dc7
...
...
@@ -1680,13 +1680,51 @@ static int s_cli_dag(int argc, char ** argv, void **a_str_reply)
case
SUBCMD_EVENT_LIST
:
{
json_object
*
json_obj_event_list
=
json_object_new_object
();
json_object
*
json_arr_obj_event
=
json_object_new_array
();
const
char
*
l_limit_str
=
NULL
,
*
l_offset_str
=
NULL
,
*
l_head_str
=
NULL
;
const
char
*
l_limit_str
=
NULL
,
*
l_offset_str
=
NULL
,
*
l_head_str
=
NULL
,
*
l_from_date_str
=
NULL
,
*
l_to_date_str
=
NULL
,
*
l_from_hash_str
=
NULL
,
l_to_hash_str
=
NULL
;
dap_hash_fast_t
l_from_hash
=
{},
l_to_hash
=
{};
dap_time_t
l_from_time
=
0
,
l_to_time
=
0
;
dap_cli_server_cmd_find_option_val
(
argv
,
arg_index
,
argc
,
"-limit"
,
&
l_limit_str
);
dap_cli_server_cmd_find_option_val
(
argv
,
arg_index
,
argc
,
"-offset"
,
&
l_offset_str
);
dap_cli_server_cmd_find_option_val
(
argv
,
arg_index
,
argc
,
"-from_date"
,
&
l_from_date_str
);
dap_cli_server_cmd_find_option_val
(
argv
,
arg_index
,
argc
,
"-to_date"
,
&
l_to_date_str
);
dap_cli_server_cmd_find_option_val
(
argv
,
arg_index
,
argc
,
"-from_hash"
,
&
l_from_hash_str
);
dap_cli_server_cmd_find_option_val
(
argv
,
arg_index
,
argc
,
"-to_hash"
,
&
l_to_hash_str
);
bool
l_head
=
dap_cli_server_cmd_find_option_val
(
argv
,
arg_index
,
argc
,
"-head"
,
&
l_head_str
)
?
true
:
false
;
char
*
ptr
;
size_t
l_limit
=
l_limit_str
?
strtoull
(
l_limit_str
,
&
ptr
,
10
)
:
0
;
size_t
l_offset
=
l_offset_str
?
strtoull
(
l_offset_str
,
&
ptr
,
10
)
:
0
;
size_t
l_limit
=
l_limit_str
?
strtoull
(
l_limit_str
,
&
ptr
,
10
)
:
1000
;
size_t
l_offset
=
l_offset_str
?
strtoull
(
l_offset_str
,
&
ptr
,
10
)
:
0
;
if
(
l_from_hash_str
)
{
if
(
dap_chain_hash_fast_from_str
(
l_from_hash_str
,
&
l_from_hash
))
{
dap_json_rpc_error_add
(
*
a_json_arr_reply
,
DAP_CHAIN_NODE_CLI_COM_DAG_CONVERT_ERR
,
"Can't convert
\"
%s
\"
to hash"
,
l_from_hash_str
);
return
DAP_CHAIN_NODE_CLI_COM_DAG_CONVERT_ERR
;
}
}
if
(
l_to_hash_str
)
{
if
(
dap_chain_hash_fast_from_str
(
l_to_hash_str
,
&
l_to_hash
))
{
dap_json_rpc_error_add
(
*
a_json_arr_reply
,
DAP_CHAIN_NODE_CLI_COM_DAG_CONVERT_ERR
,
"Can't convert
\"
%s
\"
to hash"
,
l_to_hash_str
);
return
DAP_CHAIN_NODE_CLI_COM_DAG_CONVERT_ERR
;
}
}
if
(
l_from_date_str
)
{
l_from_time
=
dap_time_from_str_simplified
(
l_from_date_str
);
if
(
!
l_from_time
)
{
dap_json_rpc_error_add
(
*
a_json_arr_reply
,
DAP_CHAIN_NODE_CLI_COM_DAG_CONVERT_ERR
,
"Can't convert
\"
%s
\"
to date"
,
l_from_date_str
);
return
DAP_CHAIN_NODE_CLI_COM_DAG_CONVERT_ERR
;
}
}
if
(
l_to_date_str
)
{
l_to_time
=
dap_time_from_str_simplified
(
l_to_date_str
);
if
(
!
l_to_time
)
{
dap_json_rpc_error_add
(
*
a_json_arr_reply
,
DAP_CHAIN_NODE_CLI_COM_DAG_CONVERT_ERR
,
"Can't convert
\"
%s
\"
to date"
,
l_to_date_str
);
return
DAP_CHAIN_NODE_CLI_COM_DAG_CONVERT_ERR
;
}
struct
tm
*
l_localtime
=
localtime
((
time_t
*
)
&
l_to_time
);
l_localtime
->
tm_mday
+=
1
;
// + 1 day to end date, got it inclusive
l_to_time
=
mktime
(
l_localtime
);
}
if
(
l_from_events_str
&&
strcmp
(
l_from_events_str
,
"round.new"
)
==
0
)
{
char
*
l_gdb_group_events
=
DAP_CHAIN_CS_DAG
(
l_chain
)
->
gdb_group_events_round_new
;
...
...
@@ -1727,7 +1765,9 @@ static int s_cli_dag(int argc, char ** argv, void **a_str_reply)
dap_chain_cs_dag_event_item_t
*
l_event_item
=
NULL
,
*
l_event_item_tmp
=
NULL
;
if
(
l_head
){
HASH_ITER
(
hh
,
PVT
(
l_dag
)
->
events
,
l_event_item
,
l_event_item_tmp
)
{
if
(
i_tmp
<
l_arr_start
||
i_tmp
>=
l_arr_end
)
{
dap_time_t
l_ts
=
l_event_item
->
event
->
header
.
ts_created
;
if
(
i_tmp
<
l_arr_start
||
i_tmp
>=
l_arr_end
||
(
l_from_time
&&
l_ts
<
l_from_time
)
||
(
l_to_time
&&
l_ts
>=
l_to_time
))
{
i_tmp
++
;
}
else
{
i_tmp
++
;
...
...
@@ -1738,7 +1778,9 @@ static int s_cli_dag(int argc, char ** argv, void **a_str_reply)
else
{
l_event_item
=
HASH_LAST
(
PVT
(
l_dag
)
->
events
);
for
(;
l_event_item
;
l_event_item
=
l_event_item
->
hh
.
prev
){
if
(
i_tmp
<
l_arr_start
||
i_tmp
>=
l_arr_end
)
{
dap_time_t
l_ts
=
l_event_item
->
event
->
header
.
ts_created
;
if
(
i_tmp
<
l_arr_start
||
i_tmp
>=
l_arr_end
||
(
l_from_time
&&
l_ts
<
l_from_time
)
||
(
l_to_time
&&
l_ts
>=
l_to_time
))
{
i_tmp
++
;
}
else
{
i_tmp
++
;
...
...
@@ -1766,7 +1808,9 @@ static int s_cli_dag(int argc, char ** argv, void **a_str_reply)
size_t
i_tmp
=
0
;
if
(
l_head
){
HASH_ITER
(
hh
,
PVT
(
l_dag
)
->
events_treshold
,
l_event_item
,
l_event_item_tmp
)
{
if
(
i_tmp
<
l_arr_start
||
i_tmp
>=
l_arr_end
)
{
dap_time_t
l_ts
=
l_event_item
->
event
->
header
.
ts_created
;
if
(
i_tmp
<
l_arr_start
||
i_tmp
>=
l_arr_end
||
(
l_from_time
&&
l_ts
<
l_from_time
)
||
(
l_to_time
&&
l_ts
>=
l_to_time
))
{
i_tmp
++
;
}
else
{
i_tmp
++
;
...
...
@@ -1777,7 +1821,9 @@ static int s_cli_dag(int argc, char ** argv, void **a_str_reply)
else
{
l_event_item
=
HASH_LAST
(
PVT
(
l_dag
)
->
events
);
for
(;
l_event_item
;
l_event_item
=
l_event_item
->
hh
.
prev
){
if
(
i_tmp
<
l_arr_start
||
i_tmp
>=
l_arr_end
)
{
dap_time_t
l_ts
=
l_event_item
->
event
->
header
.
ts_created
;
if
(
i_tmp
<
l_arr_start
||
i_tmp
>=
l_arr_end
||
(
l_from_time
&&
l_ts
<
l_from_time
)
||
(
l_to_time
&&
l_ts
>=
l_to_time
))
{
i_tmp
++
;
}
else
{
i_tmp
++
;
...
...
This diff is collapsed.
Click to expand it.
modules/type/dag/include/dap_chain_cs_dag.h
+
1
−
0
View file @
90bf0dc7
...
...
@@ -85,6 +85,7 @@ typedef enum s_com_dag_err{
DAP_CHAIN_NODE_CLI_COM_DAG_CERT_ERR
,
DAP_CHAIN_NODE_CLI_COM_DAG_FIND_EVENT_ERR
,
DAP_CHAIN_NODE_CLI_COM_DAG_UNDEF_SUB_ERR
,
DAP_CHAIN_NODE_CLI_COM_DAG_CONVERT_ERR
,
/* add custom codes here */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment