Skip to content
Snippets Groups Projects
Commit 4831d2d5 authored by Dmitriy A. Gerasimov's avatar Dmitriy A. Gerasimov
Browse files

[+] New structs and files

parent 4eee10b3
No related branches found
No related tags found
No related merge requests found
...@@ -21,6 +21,8 @@ set(DAP_CHAIN_HEADERS ...@@ -21,6 +21,8 @@ set(DAP_CHAIN_HEADERS
dap_chain_datum_tx_out.h dap_chain_datum_tx_out.h
dap_chain_datum_tx_pkey.h dap_chain_datum_tx_pkey.h
dap_chain_datum_tx_sig.h dap_chain_datum_tx_sig.h
dap_chain_pkey.h
dap_chain_sign.h
) )
add_library(${PROJECT_NAME} STATIC ${DAP_CHAIN_SRCS} ${DAP_CHAIN_HEADERS}) add_library(${PROJECT_NAME} STATIC ${DAP_CHAIN_SRCS} ${DAP_CHAIN_HEADERS})
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include "dap_chain_internal.h" #include "dap_chain_internal.h"
#include "dap_chain.h" #include "dap_chain.h"
#define LOG_TAG "dap_chain" #define LOG_TAG "chain"
FILE* my_file_to_wite_gold; FILE* my_file_to_wite_gold;
...@@ -185,7 +185,11 @@ void dap_chain_file_open(dap_chain_block_cache_t* last_g, dap_chain_block_cache_ ...@@ -185,7 +185,11 @@ void dap_chain_file_open(dap_chain_block_cache_t* last_g, dap_chain_block_cache_
*/ */
void dap_chain_close(dap_chain_t * a_chain) void dap_chain_close(dap_chain_t * a_chain)
{ {
if(a_chain){
if(a_chain->callback_delete)
a_chain->callback_delete(a_chain);
}else
log_it(L_WARNING,"Tried to close null pointer");
} }
/** /**
......
...@@ -27,6 +27,12 @@ ...@@ -27,6 +27,12 @@
#include "dap_chain_block.h" #include "dap_chain_block.h"
#include "dap_chain_block_cache.h" #include "dap_chain_block_cache.h"
struct dap_chain;
typedef void (*dap_chain_callback_t)(struct dap_chain *);
typedef void (*dap_chain_callback_ptr_t)(struct dap_chain *, void * );
typedef size_t (*dap_chain_callback_dataop_t)(struct dap_chain *, const void * , const size_t ,void *);
typedef struct dap_chain{ typedef struct dap_chain{
dap_chain_id_t id; dap_chain_id_t id;
dap_chain_block_cache_t * block_first; // Mapped area start dap_chain_block_cache_t * block_first; // Mapped area start
...@@ -34,10 +40,13 @@ typedef struct dap_chain{ ...@@ -34,10 +40,13 @@ typedef struct dap_chain{
uint64_t blocks_count; uint64_t blocks_count;
uint64_t difficulty; uint64_t difficulty;
dap_chain_callback_t callback_delete;
void * _internal; void * _internal;
void * _inhertor; void * _inhertor;
} dap_chain_t; } dap_chain_t;
#define DAP_CHAIN(a) ( (dap_chain_t *) (a)->_inheritor)
int dap_chain_init(); int dap_chain_init();
void dap_chain_deinit(); void dap_chain_deinit();
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include "dap_common.h" #include "dap_common.h"
#include "dap_chain_common.h" #include "dap_chain_common.h"
#define LOG_TAG "dap_chain_common" #define LOG_TAG "chain_common"
/** /**
* @brief dap_chain_hash_to_str * @brief dap_chain_hash_to_str
......
/* /*
* Authors: * Authors:
* Dmitriy A. Gearasimov <gerasimov.dmitriy@demlabs.net> * Dmitriy A. Gearasimov <gerasimov.dmitriy@demlabs.net>
* DeM Labs Inc. https://demlabs.net * DeM Labs Inc. https://demlabs.net https:/gitlab.com/demlabs
* Kelvin Project https://github.com/kelvinblockchain * Kelvin Project https://github.com/kelvinblockchain
* Copyright (c) 2017-2018 * Copyright (c) 2017-2018
* All rights reserved. * All rights reserved.
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
#include "dap_common.h" #include "dap_common.h"
#include "dap_math_ops.h" #include "dap_math_ops.h"
#include "dap_chain_sign.h"
#include "dap_chain_pkey.h"
#define DAP_CHAIN_ID_SIZE 8 #define DAP_CHAIN_ID_SIZE 8
#define DAP_CHAIN_NET_ID_SIZE 8 #define DAP_CHAIN_NET_ID_SIZE 8
...@@ -57,18 +59,8 @@ typedef enum dap_chain_hash_kind { ...@@ -57,18 +59,8 @@ typedef enum dap_chain_hash_kind {
} dap_chain_hash_kind_t; } dap_chain_hash_kind_t;
typedef union dap_chain_sig_type{
enum {
SIG_TYPE_NEWHOPE = 0x0000,
SIG_TYPE_KEY_IMAGE = 0xf000, /// @brief key image for anonymous transaction
SIG_TYPE_MULTI = 0xffff /// @brief Has inside subset of different signatures and sign composed with all of them
} type: 16;
uint16_t raw;
} dap_chain_sig_type_t;
typedef struct dap_chain_addr{ typedef struct dap_chain_addr{
dap_chain_sig_type_t sig_type; dap_chain_sign_type_t sig_type;
uint8_t hash[DAP_CHAIN_ADDR_HASH_SIZE]; uint8_t hash[DAP_CHAIN_ADDR_HASH_SIZE];
uint64_t checksum; uint64_t checksum;
} dap_chain_addr_t; } dap_chain_addr_t;
......
...@@ -28,4 +28,4 @@ ...@@ -28,4 +28,4 @@
#include "dap_chain_datum_hashtree_roots.h" #include "dap_chain_datum_hashtree_roots.h"
#include "dap_chain_datum_coin.h" #include "dap_chain_datum_coin.h"
#define LOG_TAG "dap_chain_secion" #define LOG_TAG "chain_datum"
...@@ -74,13 +74,11 @@ typedef union dap_chain_datum_typeid{ ...@@ -74,13 +74,11 @@ typedef union dap_chain_datum_typeid{
*/ */
typedef struct dap_chain_datum{ typedef struct dap_chain_datum{
uint8_t version_id; // Datum version uint8_t version_id; // Datum version
uint8_t hash_type_id; // Hash type id
uint16_t type_id; // Section type id uint16_t type_id; // Section type id
uint16_t hashes_count; // Hashes_number uint8_t data[]; // datum stored data goes after the last sign
uint8_t hashes_n_signs_n_data[]; // datum stored data goes after the last sign // Sign block goes after the last hash, every sign type
// Sign block goes after the last hash, every sign type // has its own predefined size or stores its inside.
// has its own predefined size or stores its inside. // After signs goes data block and and till the end of datum.
// After signs goes data block and and till the end of datum.
} DAP_ALIGN_PACKED dap_chain_datum_t; } DAP_ALIGN_PACKED dap_chain_datum_t;
......
...@@ -37,7 +37,7 @@ typedef struct dap_chain_tx_in{ ...@@ -37,7 +37,7 @@ typedef struct dap_chain_tx_in{
dap_chain_tx_item_type_t type:8; /// @param type @brief Transaction item type dap_chain_tx_item_type_t type:8; /// @param type @brief Transaction item type
dap_chain_hash_t tx_prev_hash; /// @param tx_prev_hash @brief Hash of the previous transaction. 0 for generation TX dap_chain_hash_t tx_prev_hash; /// @param tx_prev_hash @brief Hash of the previous transaction. 0 for generation TX
uint32_t tx_out_prev_idx; /// @param tx_prev_idx @brief Previous tx_out index. 0 for generation TX uint32_t tx_out_prev_idx; /// @param tx_prev_idx @brief Previous tx_out index. 0 for generation TX
dap_chain_sig_type_t sig_type; /// Signature type dap_chain_sign_type_t sig_type; /// Signature type
uint32_t sig_size; /// Signature size uint32_t sig_size; /// Signature size
} header; /// Only header's hash is used for verification } header; /// Only header's hash is used for verification
uint32_t seq_no; /// Sequence number, out of the header so could be changed during reorganization uint32_t seq_no; /// Sequence number, out of the header so could be changed during reorganization
......
/*
* Authors:
* Dmitriy A. Gearasimov <gerasimov.dmitriy@demlabs.net>
* DeM Labs Inc. https://demlabs.net https:/gitlab.com/demlabs
* Kelvin Project https://github.com/kelvinblockchain
* Copyright (c) 2017-2018
* All rights reserved.
This file is part of DAP (Deus Applications Prototypes) the open source project
DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DAP is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with any DAP based project. If not, see <http://www.gnu.org/licenses/>.
*/
#include "dap_common.h"
#include "dap_chain_pkey.h"
#define LOG_TAG "chain_key"
/*
* Authors:
* Dmitriy A. Gearasimov <gerasimov.dmitriy@demlabs.net>
* DeM Labs Inc. https://demlabs.net https:/gitlab.com/demlabs
* Kelvin Project https://github.com/kelvinblockchain
* Copyright (c) 2017-2018
* All rights reserved.
This file is part of DAP (Deus Applications Prototypes) the open source project
DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DAP is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with any DAP based project. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stdint.h>
#include "dap_common.h"
typedef union dap_chain_pkey_type{
enum {
PKEY_TYPE_NEWHOPE = 0x0000,
PKEY_TYPE_MULTI = 0xffff /// @brief Has inside subset of different keys
} type: 16;
uint16_t raw;
} dap_chain_pkey_type_t;
/**
* @struct dap_chain_pkey
* @brief Public keys
*/
typedef struct dap_chain_pkey{
struct {
dap_chain_pkey_type_t type; /// Pkey type
uint32_t size; /// Pkey size
} header; /// Only header's hash is used for verification
uint8_t pkey[]; /// @param pkey @brief raw pkey dat
} DAP_ALIGN_PACKED dap_chain_pkey_t;
/*
* Authors:
* Dmitriy A. Gearasimov <gerasimov.dmitriy@demlabs.net>
* DeM Labs Inc. https://demlabs.net https:/gitlab.com/demlabs
* Kelvin Project https://github.com/kelvinblockchain
* Copyright (c) 2017-2018
* All rights reserved.
This file is part of DAP (Deus Applications Prototypes) the open source project
DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DAP is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with any DAP based project. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stdint.h>
#include "dap_common.h"
typedef union dap_chain_sign_type{
enum {
SIG_TYPE_PICNIC = 0x0000,
SIG_TYPE_DEFO = 0x0001, /// @brief key image for anonymous transaction
SIG_TYPE_MULTI = 0xffff /// @brief Has inside subset of different signatures and sign composed with all of them
} type: 16;
uint16_t raw;
} dap_chain_sign_type_t;
/**
* @struct dap_chain_sign
* @brief Chain storage format for digital signature
*/
typedef struct dap_chain_sign{
struct {
dap_chain_sign_type_t type; /// Signature type
uint16_t sign_size; /// Signature size
uint32_t sign_pkey_size; /// Signature public key size
} header; /// Only header's hash is used for verification
uint8_t pkey_n_sign[]; /// @param sig @brief raw signature data
} DAP_ALIGN_PACKED dap_chain_sign_t;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment