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
934711e1
Unverified
Commit
934711e1
authored
5 years ago
by
Aleksandr Lysikov
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #13 from kelvinblockchain/master
master->feature2272
parents
386c4f04
c328ebef
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
dap_chain.h
+1
-1
1 addition, 1 deletion
dap_chain.h
dap_chain_common.c
+22
-0
22 additions, 0 deletions
dap_chain_common.c
dap_chain_common.h
+8
-7
8 additions, 7 deletions
dap_chain_common.h
dap_chain_datum.h
+17
-4
17 additions, 4 deletions
dap_chain_datum.h
dap_chain_utxo.c
+1
-1
1 addition, 1 deletion
dap_chain_utxo.c
with
49 additions
and
13 deletions
dap_chain.h
+
1
−
1
View file @
934711e1
...
...
@@ -63,7 +63,7 @@ typedef dap_chain_atom_ptr_t* (*dap_chain_callback_atom_iter_get_first_t)(dap_ch
typedef
dap_chain_atom_ptr_t
*
(
*
dap_chain_callback_atom_iter_get_next_t
)(
dap_chain_atom_iter_t
*
);
typedef
void
(
*
dap_chain_callback_atom_iter_delete_t
)(
dap_chain_atom_iter_t
*
);
typedef
size_t
(
*
dap_chain_datum_callback_datum_pool_proc_add_t
)(
dap_chain_t
*
,
dap_chain_cell_id_t
,
dap_chain_datum_t
**
,
size_t
);
typedef
size_t
(
*
dap_chain_datum_callback_datum_pool_proc_add_t
)(
dap_chain_t
*
,
dap_chain_datum_t
**
,
size_t
);
...
...
This diff is collapsed.
Click to expand it.
dap_chain_common.c
+
22
−
0
View file @
934711e1
...
...
@@ -73,6 +73,28 @@ size_t dap_chain_hash_fast_to_str(dap_chain_hash_fast_t * a_hash, char * a_str,
return
strlen
(
a_str
);
}
/**
* @brief dap_chain_str_to_hash_fast_to_str
* @param a_hash_str
* @param a_hash
* @return
*/
int
dap_chain_str_to_hash_fast
(
const
char
*
a_hash_str
,
dap_chain_hash_fast_t
*
a_hash
)
{
const
size_t
c_hash_str_size
=
sizeof
(
*
a_hash
)
*
2
+
1
/*trailing zero*/
+
2
/* heading 0x */
;
size_t
l_hash_str_len
=
strlen
(
a_hash_str
);
if
(
l_hash_str_len
==
c_hash_str_size
){
for
(
size_t
l_offset
=
2
;
l_offset
<
c_hash_str_size
;
l_offset
+=
2
){
if
(
(
sscanf
(
a_hash_str
+
l_offset
,
"%02hhx"
,
a_hash
->
raw
+
l_offset
-
2
)
!=
1
)
||
(
sscanf
(
a_hash_str
+
l_offset
,
"%02hhX"
,
a_hash
->
raw
+
l_offset
-
2
)
!=
1
)
)
return
-
10
*
((
int
)
l_offset
);
// Wrong char
}
return
0
;
}
else
// Wromg string len
return
-
1
;
}
/**
* @brief dap_chain_addr_to_str
* @param a_addr
...
...
This diff is collapsed.
Click to expand it.
dap_chain_common.h
+
8
−
7
View file @
934711e1
...
...
@@ -60,13 +60,13 @@ typedef union dap_chain_cell_id{
*/
typedef
union
dap_chain_node_role
{
enum
{
ROOT_MASTER
=
0x00
,
ROOT
=
0x01
,
ARCHIVE
=
0x02
,
CELL_MASTER
=
0x10
,
MASTER
=
0x20
,
FULL
=
0xf0
,
LIGHT
=
0xff
}
enums
;
NODE_ROLE_
ROOT_MASTER
=
0x00
,
NODE_ROLE_
ROOT
=
0x01
,
NODE_ROLE_
ARCHIVE
=
0x02
,
NODE_ROLE_
CELL_MASTER
=
0x10
,
NODE_ROLE_
MASTER
=
0x20
,
NODE_ROLE_
FULL
=
0xf0
,
NODE_ROLE_
LIGHT
=
0xff
}
enums
;
uint8_t
raw
[
DAP_CHAIN_NODE_ROLE_SIZE
];
}
DAP_ALIGN_PACKED
dap_chain_node_role_t
;
...
...
@@ -145,6 +145,7 @@ typedef struct dap_chain_addr{
size_t
dap_chain_hash_slow_to_str
(
dap_chain_hash_slow_t
*
a_hash
,
char
*
a_str
,
size_t
a_str_max
);
size_t
dap_chain_hash_fast_to_str
(
dap_chain_hash_fast_t
*
a_hash
,
char
*
a_str
,
size_t
a_str_max
);
int
dap_chain_str_to_hash_fast
(
const
char
*
a_hash_str
,
dap_chain_hash_fast_t
*
a_hash
);
char
*
dap_chain_addr_to_str
(
const
dap_chain_addr_t
*
a_addr
);
dap_chain_addr_t
*
dap_chain_str_to_addr
(
const
char
*
str
);
...
...
This diff is collapsed.
Click to expand it.
dap_chain_datum.h
+
17
−
4
View file @
934711e1
...
...
@@ -31,9 +31,9 @@
#define DAP_CHAIN_DATUM_VERSION 0x00
/// End section, means all the rest of the block is empty
#define
dap_chain_datum
_END 0x0000
#define
DAP_CHAIN_DATUM_BLOCK
_END 0x0000
/// Section with additional roots, for example transaction roots
#define
dap_chain_datum_hashtree_roots
0x0001
#define
DAP_CHAIN_DATUM_BLOCK_ROOTS
0x0001
/// Transaction header section
#define DAP_CHAIN_DATUM_TX 0x0100
...
...
@@ -42,9 +42,9 @@
#define DAP_CHAIN_DATUM_TX_REQUEST 0x0300
/// Smart contract: DVM code section
#define DAP_CHAIN_DATUM_
DV
M_CODE 0x0900
#define DAP_CHAIN_DATUM_
WAS
M_CODE 0x0900
/// Smart contract: DVM code section
#define DAP_CHAIN_DATUM_
DV
M_DATA 0x0901
#define DAP_CHAIN_DATUM_
WAS
M_DATA 0x0901
/// Smart contract: EVM code section
#define DAP_CHAIN_DATUM_EVM_CODE 0x0910
...
...
@@ -60,6 +60,17 @@
#define DAP_CHAIN_DATUM_TOKEN_DECL 0xf000
#define DAP_CHAIN_DATUM_TOKEN_EMISSION 0xf100
static
const
char
*
c_datum_type_str
[]
=
{
[
DAP_CHAIN_DATUM_TX
]
=
"DATUM_TX"
,
[
DAP_CHAIN_DATUM_TX_REQUEST
]
=
"DATUM_TX_REQUEST"
,
[
DAP_CHAIN_DATUM_WASM_CODE
]
=
"DATUM_WASM_CODE"
,
[
DAP_CHAIN_DATUM_WASM_DATA
]
=
"DATUM_WASM_DATA"
,
[
DAP_CHAIN_DATUM_EVM_CODE
]
=
"DATUM_EVM_CODE"
,
[
DAP_CHAIN_DATUM_EVM_DATA
]
=
"DATUM_EVM_DATA"
,
[
DAP_CHAIN_DATUM_PKEY
]
=
"DATUM_PKEY"
,
[
DAP_CHAIN_DATUM_TOKEN_DECL
]
=
"DATUM_TOKEN_DECL"
,
[
DAP_CHAIN_DATUM_TOKEN_EMISSION
]
=
"DATUM_TOKEN_EMISSION"
,
};
#define DAP_CHAIN_DATUM_ID_SIZE 4
...
...
@@ -86,6 +97,7 @@ typedef struct dap_chain_datum{
// After signs goes data block and and till the end of datum.
}
DAP_ALIGN_PACKED
dap_chain_datum_t
;
struct
dap_chain
;
typedef
struct
dap_chain
dap_chain_t
;
...
...
@@ -110,3 +122,4 @@ static inline size_t dap_chain_datum_size(dap_chain_datum_t * a_datum)
}
dap_chain_datum_t
*
dap_chain_datum_create
(
uint16_t
a_type_id
,
const
void
*
a_data
,
size_t
a_data_size
);
This diff is collapsed.
Click to expand it.
dap_chain_utxo.c
+
1
−
1
View file @
934711e1
...
...
@@ -144,7 +144,7 @@ int dap_chain_utxo_load(void)
l_datum_list
=
dap_list_prepend
(
l_datum_list
,
data
[
i
]
->
value
);
}
// sort list by time
l_datum_list
=
dap_list_sort
(
l_datum_list
,
(
D
ap
C
ompare
Func
)
compare_datum_items
);
l_datum_list
=
dap_list_sort
(
l_datum_list
,
(
d
ap
_callback_c
ompare
_t
)
compare_datum_items
);
l_list_tmp
=
l_datum_list
;
// add datum_tx from list to utxo
while
(
l_list_tmp
)
{
...
...
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