Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libdap-chain
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
Commits
ab0718a0
Commit
ab0718a0
authored
6 years ago
by
Dmitriy A. Gerasimov
Browse files
Options
Downloads
Patches
Plain Diff
[+] Consensus init API
parent
e4f8c9fb
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dap_chain_cs.c
+41
-1
41 additions, 1 deletion
dap_chain_cs.c
dap_chain_cs.h
+2
-1
2 additions, 1 deletion
dap_chain_cs.h
with
43 additions
and
2 deletions
dap_chain_cs.c
+
41
−
1
View file @
ab0718a0
...
...
@@ -22,11 +22,25 @@
along with any DAP based project. If not, see <http://www.gnu.org/licenses/>.
*/
#include
<string.h>
#include
<stdio.h>
#include
"uthash.h"
#include
"dap_common.h"
#include
"dap_chain_cs.h"
#define LOG_TAG "dap_chain_cs"
typedef
struct
dap_chain_cs_callback_item
{
char
name
[
32
];
dap_chain_cs_callback_t
callback_init
;
UT_hash_handle
hh
;
}
dap_chain_cs_callback_item_t
;
dap_chain_cs_callback_item_t
*
s_cs_callbacks
=
NULL
;
/**
* @brief dap_chain_cs_init
* @return
...
...
@@ -44,7 +58,33 @@ void dap_chain_cs_deinit()
}
int
dap_chain_cs_create
(
dap_chain_t
*
a_chain
,
const
char
*
a_chain_cs_type_str
)
/**
* @brief dap_chain_cs_add
* @param a_cs_str
* @param a_callback_init
*/
void
dap_chain_cs_add
(
const
char
*
a_cs_str
,
dap_chain_cs_callback_t
a_callback_init
)
{
dap_chain_cs_callback_item_t
*
l_item
=
DAP_NEW_Z
(
dap_chain_cs_callback_item_t
);
strncpy
(
l_item
->
name
,
a_cs_str
,
sizeof
(
l_item
->
name
)
);
l_item
->
callback_init
=
a_callback_init
;
HASH_ADD_STR
(
s_cs_callbacks
,
name
,
l_item
);
}
/**
* @brief dap_chain_cs_create
* @param a_chain
* @param a_chain_cs_type_str
* @return
*/
int
dap_chain_cs_create
(
dap_chain_t
*
a_chain
,
const
char
*
a_chain_cs_type_str
)
{
dap_chain_cs_callback_item_t
*
l_item
=
NULL
;
HASH_FIND_STR
(
s_cs_callbacks
,
a_chain_cs_type_str
,
l_item
);
if
(
l_item
)
{
l_item
->
callback_init
(
a_chain
);
return
0
;
}
else
{
return
-
1
;
}
}
This diff is collapsed.
Click to expand it.
dap_chain_cs.h
+
2
−
1
View file @
ab0718a0
...
...
@@ -37,9 +37,10 @@ typedef union dap_chain_cs_type{
uint8_t
raw
[
DAP_CHAIN_CS_TYPE_SIZE
];
}
dap_chain_cs_type_t
;
typedef
void
(
*
dap_chain_callback_t
)(
struct
dap_chain
*
);
typedef
void
(
*
dap_chain_
cs_
callback_t
)(
dap_chain
_t
*
);
int
dap_chain_cs_init
();
void
dap_chain_cs_deinit
();
void
dap_chain_cs_add
(
const
char
*
a_cs_str
,
dap_chain_cs_callback_t
a_callback_init
);
int
dap_chain_cs_create
(
dap_chain_t
*
a_chain
,
const
char
*
a_chain_cs_type_str
);
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