Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libdap-chain-net-srv
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
cellframe
libdap-chain-net-srv
Commits
e8b12880
Commit
e8b12880
authored
5 years ago
by
Dmitriy A. Gerasimov
Browse files
Options
Downloads
Patches
Plain Diff
[*] Fixed orders dump
parent
de7dfea1
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dap_chain_net_srv.c
+8
-8
8 additions, 8 deletions
dap_chain_net_srv.c
dap_chain_net_srv_common.h
+3
-1
3 additions, 1 deletion
dap_chain_net_srv_common.h
dap_chain_net_srv_order.c
+7
-7
7 additions, 7 deletions
dap_chain_net_srv_order.c
with
18 additions
and
16 deletions
dap_chain_net_srv.c
+
8
−
8
View file @
e8b12880
...
@@ -91,7 +91,7 @@ int dap_chain_net_srv_init(void)
...
@@ -91,7 +91,7 @@ int dap_chain_net_srv_init(void)
"net_srv -net <chain net name> order dump -hash <Order hash>
\n
"
"net_srv -net <chain net name> order dump -hash <Order hash>
\n
"
"
\t
Order dump info
\n
"
"
\t
Order dump info
\n
"
"net_srv -net <chain net name> order create -direction <sell|buy> -srv_uid <Service UID> -srv_class <Service Class> -price <Price>
\\\n
"
"net_srv -net <chain net name> order create -direction <sell|buy> -srv_uid <Service UID> -srv_class <Service Class> -price <Price>
\\\n
"
" -price_unit <Price Unit> -price_t
ic
ke
r
<Token ticker> -node_addr <Node Address> -tx_cond <TX Cond Hash>
\\\n
"
" -price_unit <Price Unit> -price_t
o
ke
n
<Token ticker> -node_addr <Node Address> -tx_cond <TX Cond Hash>
\\\n
"
" [-expires <Unix time when expires>]
\\\n
"
" [-expires <Unix time when expires>]
\\\n
"
"
\t
Order create
\n
"
);
"
\t
Order create
\n
"
);
...
@@ -224,11 +224,9 @@ static int s_cli_net_srv( int argc, char **argv, char **a_str_reply)
...
@@ -224,11 +224,9 @@ static int s_cli_net_srv( int argc, char **argv, char **a_str_reply)
uint64_t
l_price_min
=
0
,
l_price_max
=
0
;
uint64_t
l_price_min
=
0
,
l_price_max
=
0
;
dap_chain_net_srv_price_unit_uid_t
l_price_unit
=
{{
0
}};
dap_chain_net_srv_price_unit_uid_t
l_price_unit
=
{{
0
}};
dap_chain_net_srv_order_direction_t
l_direction
=
SERV_DIR_UNDEFINED
;
dap_chain_net_srv_order_direction_t
l_direction
=
SERV_DIR_UNDEFINED
;
char
l_price_token
[
DAP_CHAIN_TICKER_SIZE_MAX
]
=
{
0
};
if
(
dap_chain_net_srv_order_find_all_by
(
l_net
,
l_direction
,
l_srv_uid
,
l_srv_class
,
l_price_unit
,
l_price_token
,
l_price_min
,
l_price_max
,
&
l_orders
,
&
l_orders_size
)
==
0
){
if
(
dap_chain_net_srv_order_find_all_by
(
l_net
,
l_direction
,
l_srv_uid
,
l_srv_class
,
l_price_unit
,
NULL
,
l_price_min
,
l_price_max
,
&
l_orders
,
&
l_orders_size
)
==
0
){
dap_string_append_printf
(
l_string_ret
,
"Found %
u
orders:
\n
"
,
l_orders_size
);
dap_string_append_printf
(
l_string_ret
,
"Found %
zd
orders:
\n
"
,
l_orders_size
);
for
(
size_t
i
=
0
;
i
<
l_orders_size
;
i
++
){
for
(
size_t
i
=
0
;
i
<
l_orders_size
;
i
++
){
dap_chain_net_srv_order_dump_to_string
(
l_orders
+
i
,
l_string_ret
);
dap_chain_net_srv_order_dump_to_string
(
l_orders
+
i
,
l_string_ret
);
dap_string_append
(
l_string_ret
,
"
\n
"
);
dap_string_append
(
l_string_ret
,
"
\n
"
);
...
@@ -287,7 +285,7 @@ static int s_cli_net_srv( int argc, char **argv, char **a_str_reply)
...
@@ -287,7 +285,7 @@ static int s_cli_net_srv( int argc, char **argv, char **a_str_reply)
const
char
*
l_comments
=
NULL
;
const
char
*
l_comments
=
NULL
;
dap_chain_node_cli_find_option_val
(
argv
,
arg_index
,
argc
,
"-comments"
,
&
l_comments
);
dap_chain_node_cli_find_option_val
(
argv
,
arg_index
,
argc
,
"-comments"
,
&
l_comments
);
if
(
l_srv_uid_str
&&
l_srv_class_str
&&
l_
node_addr_str
&&
l_tx_cond_hash
_str
&&
l_price_str
)
{
if
(
l_srv_uid_str
&&
l_srv_class_str
&&
l_
price_str
&&
l_price_token
_str
&&
l_price_
unit_
str
)
{
dap_chain_net_srv_uid_t
l_srv_uid
=
{{
0
}};
dap_chain_net_srv_uid_t
l_srv_uid
=
{{
0
}};
dap_chain_net_srv_class_t
l_srv_class
=
SERV_CLASS_UNDEFINED
;
dap_chain_net_srv_class_t
l_srv_class
=
SERV_CLASS_UNDEFINED
;
dap_chain_node_addr_t
l_node_addr
=
{
0
};
dap_chain_node_addr_t
l_node_addr
=
{
0
};
...
@@ -309,8 +307,10 @@ static int s_cli_net_srv( int argc, char **argv, char **a_str_reply)
...
@@ -309,8 +307,10 @@ static int s_cli_net_srv( int argc, char **argv, char **a_str_reply)
l_expires
=
(
dap_chain_time_t
)
atoll
(
l_expires_str
);
l_expires
=
(
dap_chain_time_t
)
atoll
(
l_expires_str
);
l_srv_uid
.
uint64
=
(
uint64_t
)
atoll
(
l_srv_uid_str
);
l_srv_uid
.
uint64
=
(
uint64_t
)
atoll
(
l_srv_uid_str
);
l_srv_class
=
(
dap_chain_net_srv_class_t
)
atoi
(
l_srv_class_str
);
l_srv_class
=
(
dap_chain_net_srv_class_t
)
atoi
(
l_srv_class_str
);
dap_chain_node_addr_from_str
(
&
l_node_addr
,
l_node_addr_str
);
if
(
l_node_addr_str
)
dap_chain_str_to_hash_fast
(
l_tx_cond_hash_str
,
&
l_tx_cond_hash
);
dap_chain_node_addr_from_str
(
&
l_node_addr
,
l_node_addr_str
);
if
(
l_tx_cond_hash_str
)
dap_chain_str_to_hash_fast
(
l_tx_cond_hash_str
,
&
l_tx_cond_hash
);
l_price
=
(
uint64_t
)
atoll
(
l_price_str
);
l_price
=
(
uint64_t
)
atoll
(
l_price_str
);
l_price_unit
.
uint32
=
(
uint32_t
)
atol
(
l_price_unit_str
);
l_price_unit
.
uint32
=
(
uint32_t
)
atol
(
l_price_unit_str
);
...
...
This diff is collapsed.
Click to expand it.
dap_chain_net_srv_common.h
+
3
−
1
View file @
e8b12880
...
@@ -44,6 +44,7 @@ typedef union {
...
@@ -44,6 +44,7 @@ typedef union {
#endif
#endif
}
dap_chain_net_srv_uid_t
;
}
dap_chain_net_srv_uid_t
;
#define DAP_CHAIN_NET_SRV_PRICE_UNIT_UNDEFINED 0x00000000
#define DAP_CHAIN_NET_SRV_PRICE_UNIT_BYTE 0x00000001
#define DAP_CHAIN_NET_SRV_PRICE_UNIT_BYTE 0x00000001
#define DAP_CHAIN_NET_SRV_PRICE_UNIT_SECOND 0x00000010
#define DAP_CHAIN_NET_SRV_PRICE_UNIT_SECOND 0x00000010
#define DAP_CHAIN_NET_SRV_PRICE_UNIT_BYTE_PER_SECOND 0x00000100
#define DAP_CHAIN_NET_SRV_PRICE_UNIT_BYTE_PER_SECOND 0x00000100
...
@@ -70,7 +71,8 @@ typedef enum dap_chain_net_srv_order_direction{
...
@@ -70,7 +71,8 @@ typedef enum dap_chain_net_srv_order_direction{
//Types of services
//Types of services
enum
{
enum
{
SERV_ID_VPN
=
1
,
SERV_ID_UNDEFINED
=
0x00000000
,
SERV_ID_VPN
=
0x00000001
,
};
};
//Units of service
//Units of service
...
...
This diff is collapsed.
Click to expand it.
dap_chain_net_srv_order.c
+
7
−
7
View file @
e8b12880
...
@@ -88,7 +88,6 @@ char* dap_chain_net_srv_order_create(
...
@@ -88,7 +88,6 @@ char* dap_chain_net_srv_order_create(
return
NULL
;
return
NULL
;
}
}
DAP_DELETE
(
l_order_hash
);
DAP_DELETE
(
l_order_hash
);
DAP_DELETE
(
l_order_hash_str
);
DAP_DELETE
(
l_order
);
DAP_DELETE
(
l_order
);
DAP_DELETE
(
l_gdb_group_str
);
DAP_DELETE
(
l_gdb_group_str
);
return
l_order_hash_str
;
return
l_order_hash_str
;
...
@@ -142,7 +141,7 @@ int dap_chain_net_srv_order_find_all_by(dap_chain_net_t * a_net,const dap_chain_
...
@@ -142,7 +141,7 @@ int dap_chain_net_srv_order_find_all_by(dap_chain_net_t * a_net,const dap_chain_
char
*
l_gdb_group_str
=
dap_chain_net_srv_order_get_gdb_group
(
a_net
);
char
*
l_gdb_group_str
=
dap_chain_net_srv_order_get_gdb_group
(
a_net
);
size_t
l_orders_count
=
0
;
size_t
l_orders_count
=
0
;
dap_global_db_obj_t
*
l_orders
=
dap_chain_global_db_gr_load
(
l_gdb_group_str
,
&
l_orders_count
);
dap_global_db_obj_t
*
l_orders
=
dap_chain_global_db_gr_load
(
l_gdb_group_str
,
&
l_orders_count
);
log_it
(
L_DEBUG
,
"Loaded %zd orders"
,
l_orders_count
);
bool
l_order_pass_first
=
true
;
bool
l_order_pass_first
=
true
;
size_t
l_order_passed_index
;
size_t
l_order_passed_index
;
lb_order_pass:
lb_order_pass:
...
@@ -151,10 +150,11 @@ lb_order_pass:
...
@@ -151,10 +150,11 @@ lb_order_pass:
dap_chain_net_srv_order_t
*
l_order
=
(
dap_chain_net_srv_order_t
*
)
l_orders
[
i
].
value
;
dap_chain_net_srv_order_t
*
l_order
=
(
dap_chain_net_srv_order_t
*
)
l_orders
[
i
].
value
;
// Check direction
// Check direction
if
(
a_direction
!=
SERV_DIR_UNDEFINED
)
if
(
a_direction
!=
SERV_DIR_UNDEFINED
)
if
(
l_order
->
direction
=
=
a_direction
)
if
(
l_order
->
direction
!
=
a_direction
)
continue
;
continue
;
// Check srv uid
// Check srv uid
if
(
a_srv_uid
.
uint64
)
if
(
a_srv_uid
.
uint64
)
if
(
l_order
->
srv_uid
.
uint64
!=
a_srv_uid
.
uint64
)
if
(
l_order
->
srv_uid
.
uint64
!=
a_srv_uid
.
uint64
)
continue
;
continue
;
// Check srv class
// Check srv class
...
@@ -175,12 +175,12 @@ lb_order_pass:
...
@@ -175,12 +175,12 @@ lb_order_pass:
continue
;
continue
;
// Check ticker
// Check ticker
if
(
a_price_ticker
)
if
(
a_price_ticker
)
if
(
strcmp
(
l_order
->
price_ticker
,
a_price_ticker
)
=
=
0
)
if
(
strcmp
(
l_order
->
price_ticker
,
a_price_ticker
)
!
=
0
)
continue
;
continue
;
if
(
!
l_order_pass_first
){
if
(
!
l_order_pass_first
){
memcpy
(
a_output_orders
[
l_order_passed_index
],
l_order
,
sizeof
(
dap_chain_net_srv_order_t
));
memcpy
(
a_output_orders
[
l_order_passed_index
],
l_order
,
sizeof
(
dap_chain_net_srv_order_t
));
}
}
else
l_order_passed_index
++
;
l_order_passed_index
++
;
}
}
// Dirty goto usage ho ho ho
// Dirty goto usage ho ho ho
if
(
l_order_pass_first
)
{
if
(
l_order_pass_first
)
{
...
...
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