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
16
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
3def28b8
Commit
3def28b8
authored
6 years ago
by
Dmitriy A. Gerasimov
Browse files
Options
Downloads
Patches
Plain Diff
[*] Net organization code
parent
c503e42a
No related branches found
No related tags found
1 merge request
!24
Support 3689
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dap_chain_net.c
+17
-3
17 additions, 3 deletions
dap_chain_net.c
dap_chain_net.h
+2
-1
2 additions, 1 deletion
dap_chain_net.h
dap_chain_node_ctl.c
+4
-1
4 additions, 1 deletion
dap_chain_node_ctl.c
with
23 additions
and
5 deletions
dap_chain_net.c
+
17
−
3
View file @
3def28b8
...
...
@@ -28,6 +28,7 @@
#include
"dap_common.h"
#include
"dap_config.h"
//#include "dap_
#include
"dap_chain_net.h"
#include
"dap_chain_node_ctl.h"
#include
"dap_module.h"
...
...
@@ -42,6 +43,7 @@ typedef struct dap_chain_net_pvt{
pthread_t
proc_tid
;
pthread_cond_t
proc_cond
;
dap_chain_node_role_t
node_role
;
//dap_client_t client;
dap_chain_node_ctl_t
*
node
;
}
dap_chain_net_pvt_t
;
...
...
@@ -49,6 +51,8 @@ typedef struct dap_chain_net_pvt{
#define PVT_S(a) ( (dap_chain_net_pvt_t *) a.pvt )
size_t
s_net_configs_count
=
0
;
pthread_cond_t
s_net_proc_loop_cond
=
PTHREAD_COND_INITIALIZER
;
pthread_mutex_t
s_net_proc_loop_mutex
=
PTHREAD_MUTEX_INITIALIZER
;
/**
* @brief s_net_proc_thread
...
...
@@ -59,6 +63,7 @@ size_t s_net_configs_count = 0;
static
void
*
s_net_proc_thread
(
void
*
a_net
)
{
dap_chain_net_t
*
l_net
=
(
dap_chain_net_t
*
)
a_net
;
return
NULL
;
}
...
...
@@ -114,9 +119,11 @@ static void s_net_proc_kill( dap_chain_net_t * a_net )
* @param a_id
* @param a_name
* @param a_node_role
* @param a_node_name
* @return
*/
dap_chain_net_t
*
dap_chain_net_new
(
const
char
*
a_id
,
const
char
*
a_name
,
const
char
*
a_node_role
)
dap_chain_net_t
*
dap_chain_net_new
(
const
char
*
a_id
,
const
char
*
a_name
,
const
char
*
a_node_role
,
const
char
*
a_node_name
)
{
dap_chain_net_t
*
ret
=
DAP_NEW_Z_SIZE
(
dap_chain_net_t
,
sizeof
(
ret
->
pub
)
+
sizeof
(
dap_chain_net_pvt_t
)
);
ret
->
pub
.
name
=
strdup
(
a_name
);
...
...
@@ -126,10 +133,16 @@ dap_chain_net_t * dap_chain_net_new(const char * a_id, const char * a_name , con
log_it
(
L_NOTICE
,
"Node role
\"
root
\"
selected"
);
}
PVT
(
ret
)
->
node
=
dap_chain_node_ctl_new
();
PVT
(
ret
)
->
node
=
dap_chain_node_ctl_open
(
a_node_name
);
if
(
PVT
(
ret
)
->
node
){
}
else
{
log_it
(
L_ERROR
,
"Can't open
\"
%s
\"
node's config"
,
a_node_name
);
}
}
else
{
log_it
(
L_ERROR
,
"Wrong id format (
\"
%s
\"
). Must be like
\"
0x0123456789ABCDE
\"
"
,
a_id
);
}
return
ret
;
}
...
...
@@ -158,7 +171,8 @@ int dap_chain_net_init()
dap_chain_net_t
*
l_net
=
dap_chain_net_new
(
dap_config_get_item_str
(
l_cfg
,
"general"
,
"id"
),
dap_config_get_item_str
(
l_cfg
,
"general"
,
"name"
),
dap_config_get_item_str
(
l_cfg
,
"general"
,
"node-role"
)
dap_config_get_item_str
(
l_cfg
,
"general"
,
"node-role"
),
dap_config_get_item_str
(
l_cfg
,
"general"
,
"node-default"
)
);
switch
(
PVT
(
l_net
)
->
node_role
.
enums
)
{
case
ROOT
:
...
...
This diff is collapsed.
Click to expand it.
dap_chain_net.h
+
2
−
1
View file @
3def28b8
...
...
@@ -40,6 +40,7 @@ typedef struct dap_chain_net{
int
dap_chain_net_init
();
void
dap_chain_net_deinit
();
dap_chain_net_t
*
dap_chain_net_new
(
const
char
*
a_id
,
const
char
*
a_name
,
const
char
*
a_node_role
);
dap_chain_net_t
*
dap_chain_net_new
(
const
char
*
a_id
,
const
char
*
a_name
,
const
char
*
a_node_role
,
const
char
*
a_node_name
);
void
dap_chain_net_delete
(
dap_chain_net_t
*
a_net
);
This diff is collapsed.
Click to expand it.
dap_chain_node_ctl.c
+
4
−
1
View file @
3def28b8
...
...
@@ -22,6 +22,8 @@
#include
<sys/socket.h>
#include
<netinet/in.h>
#include
<string.h>
#include
"dap_config.h"
#include
"dap_chain_net.h"
#include
"dap_chain_node_ctl.h"
...
...
@@ -65,12 +67,13 @@ dap_chain_node_ctl_t * dap_chain_node_ctl_open( const char * a_name )
{
dap_chain_node_ctl_t
*
l_node
=
NULL
;
const
char
c_node_folder
[]
=
"node"
;
size_t
buf_size
=
2
+
s
izeof
(
a_name
)
+
s
izeof
(
c_node_folder
);
size_t
buf_size
=
2
+
s
trlen
(
a_name
)
+
s
trlen
(
c_node_folder
);
char
*
buf
=
DAP_NEW_SIZE
(
char
,
buf_size
);
snprintf
(
buf
,
buf_size
,
"%s/%s"
,
c_node_folder
,
a_name
);
dap_config_t
*
l_node_cfg
=
dap_config_open
(
buf
);
if
(
l_node_cfg
){
//dap_config_get_item_str_default()
l_node
=
dap_chain_node_ctl_new
();
}
else
{
log_it
(
L_ERROR
,
"Can't open node
\"
%s
\"
. Check the configuration files path."
,
a_name
);
}
...
...
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