Skip to content
Snippets Groups Projects
Commit f60848a4 authored by Dmitriy Gerasimov's avatar Dmitriy Gerasimov
Browse files

[*] Small and big fixes

parent 114a8820
No related branches found
No related tags found
1 merge request!24Support 3689
......@@ -45,16 +45,17 @@ void dap_chain_deinit()
/**
* @brief dap_chain_open
* @param a_file_name
* @param a_file_storage
* @param a_file_cache
* @return
*/
dap_chain_t * dap_chain_open(const char * a_file_cache,const char * a_file_storage )
dap_chain_t * dap_chain_open(const char * a_file_storage,const char * a_file_cache)
{
dap_chain_t * l_chain = DAP_NEW_Z(dap_chain_t);
DAP_CHAIN_INTERNAL_LOCAL_NEW(l_chain);
l_chain_internal->file_storage_type = 0x0000; // TODO compressed format
l_chain_internal->file_storage blockhain_file = fopen(a_file_name,"a+");
l_chain_internal->file_storage = fopen(a_file_storage,"a+");
return l_chain;
}
......
/*
Copyright (c) 2017-2018 (c) Project "DeM Labs Inc" https://github.com/demlabsinc
All rights reserved.
* Authors:
* Dmitriy A. Gearasimov <kahovski@gmail.com>
* DeM Labs Inc. https://demlabs.net
* DeM Labs Open source community https://github.com/demlabsinc
* Copyright (c) 2017-2018
* All rights reserved.
This file is part of DAP (Deus Applications Prototypes) the open source project
......@@ -17,7 +21,6 @@
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 "dap_chain_block.h"
......@@ -33,7 +36,7 @@ typedef struct dap_chain{
int dap_chain_init();
void dap_chain_deinit();
dap_chain_t * dap_chain_open(const char * a_file_name);
dap_chain_t * dap_chain_open(const char * a_file_storage,const char * a_file_cache);
void dap_chain_remap(dap_chain_t * a_chain, size_t a_offset);
void dap_chain_save(dap_chain_t * a_chain);
......
......@@ -19,7 +19,6 @@
*/
#include "dap_common.h"
#include "dap_chain_section_roots.h"
#include "dap_chain_block.h"
......
/*
Copyright (c) 2017-2018 (c) Project "DeM Labs Inc" https://github.com/demlabsinc
All rights reserved.
* Authors:
* Dmitriy A. Gearasimov <kahovski@gmail.com>
* DeM Labs Inc. https://demlabs.net
* DeM Labs Open source community https://github.com/demlabsinc
* Copyright (c) 2017-2018
* All rights reserved.
This file is part of DAP (Deus Applications Prototypes) the open source project
......@@ -34,7 +38,7 @@
* @brief The dap_chain_block struct
*/
typedef struct dap_chain_block{
struct {
struct block_header{
uint32_t signature; /// @param signature @brief Magic number, always equels to DAP_CHAIN_BLOCK_SIGNATURE
int32_t version; /// @param version @brief block version (be carefull, signed value, as Bitcoin has)
dap_chain_hash_t prev_block; /// @param prev_block Hash of the previous block
......@@ -42,7 +46,7 @@ typedef struct dap_chain_block{
uint64_t difficulty; /// difficulty level
uint64_t nonce; /// Nonce value to allow header variation for mining
dap_chain_hash_t root_sections;/// @param root_main Main tree's root for all sections's hashes
} header;
} DAP_ALIGN_PACKED header;
dap_chain_block_section_t section[];
} DAP_ALIGN_PACKED dap_chain_block_t;
......
/*
* Authors:
* Dmitriy A. Gearasimov <kahovski@gmail.com>
* DeM Labs Inc. https://demlabs.net
* DeM Labs Open source community https://github.com/demlabsinc
* 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
#ifndef _DAP_CHAIN_COMMON_H_
#define _DAP_CHAIN_COMMON_H_
/*
* Authors:
* Dmitriy A. Gearasimov <kahovski@gmail.com>
* DeM Labs Inc. https://demlabs.net
* DeM Labs Open source community https://github.com/demlabsinc
* 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"
......@@ -11,12 +34,13 @@ typedef union dap_chain_hash{
uint8_t data[DAP_CHAIN_HASH_SIZE];
} dap_chain_hash_t;
typedef union dap_chain_sig_type{
uint16_t raw;
enum {
SIG_TYPE_NEWHOPE = 0x0000,
SIG_TYPE_MULTI = 0xffff /// @brief Has inside subset of different signatures and sign composed with all of them
} type;
enum {
SIG_TYPE_NEWHOPE = 0x0000,
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;
#endif
/*
Copyright (c) 2017-2018 (c) Project "DeM Labs Inc" https://github.com/demlabsinc
All rights reserved.
* Authors:
* Dmitriy A. Gearasimov <kahovski@gmail.com>
* DeM Labs Inc. https://demlabs.net
* DeM Labs Open source community https://github.com/demlabsinc
* Copyright (c) 2017-2018
* All rights reserved.
This file is part of DAP (Deus Applications Prototypes) the open source project
......@@ -36,6 +40,8 @@ typedef struct dap_chain_file_header
/**
* @struct dap_chain_internal
* @brief Internal blochain data, mostly aggregated
*
*/
typedef struct dap_chain_internal
{
FILE * file_cache_idx_blocks; /// @param file_cache @brief Index for blocks
......@@ -45,8 +51,8 @@ typedef struct dap_chain_internal
uint8_t file_storage_type; /// @param file_storage_type @brief Is file_storage is raw, compressed or smth else
} dap_chain_internal_t;
#define DAP_CHAIN_INTERNAL(a) ((dap_chain_internal_t *) a->_inheritor )
#define DAP_CHAIN_INTERNAL(a) ((dap_chain_internal_t *) a->_internal )
#define DAP_CHAIN_INTERNAL_LOCAL(a) dap_chain_internal_t * l_chain_internal = DAP_CHAIN_INTERNAL(a)
#define DAP_CHAIN_INTERNAL_LOCAL_NEW(a) dap_chain_internal_t * l_chain_internal = DAP_NEW_Z(dap_chain_internal_t); a->_inheritor = l_chain_internal
#define DAP_CHAIN_INTERNAL_LOCAL_NEW(a) dap_chain_internal_t * l_chain_internal = DAP_NEW_Z(dap_chain_internal_t); a->_internal = l_chain_internal
/*
Copyright (c) 2017-2018 (c) Project "DeM Labs Inc" https://github.com/demlabsinc
All rights reserved.
* Authors:
* Dmitriy A. Gearasimov <kahovski@gmail.com>
* DeM Labs Inc. https://demlabs.net
* DeM Labs Open source community https://github.com/demlabsinc
* Copyright (c) 2017-2018
* All rights reserved.
This file is part of DAP (Deus Applications Prototypes) the open source project
......@@ -17,8 +21,6 @@
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/>.
*/
/**
* @struct dap_chain_block_section
* @brief section inside the block
......@@ -48,7 +50,7 @@
#define DAP_CHAIN_SECTION_EVM_CODE 0x0910
/// Smart contract: EVM data section
#define DAP_CHAIN_SECTION_EVM_CODE 0x0911
#define DAP_CHAIN_SECTION_EVM_DATA 0x0911
/// Pub key section, with sign and address
#define DAP_CHAIN_SECTION_PKEY 0x0c00
......@@ -67,4 +69,4 @@ typedef struct dap_chain_block_section{
uint8_t data[]; // data
} DAP_ALIGN_PACKED dap_chain_block_section_t;
inline uint32_t
/*
Copyright (c) 2017-2018 (c) Project "DeM Labs Inc" https://github.com/demlabsinc
All rights reserved.
* Authors:
* Dmitriy A. Gearasimov <kahovski@gmail.com>
* DeM Labs Inc. https://demlabs.net
* DeM Labs Open source community https://github.com/demlabsinc
* Copyright (c) 2017-2018
* All rights reserved.
This file is part of DAP (Deus Applications Prototypes) the open source project
......
/*
Copyright (c) 2017-2018 (c) Project "DeM Labs Inc" https://github.com/demlabsinc
All rights reserved.
* Authors:
* Dmitriy A. Gearasimov <kahovski@gmail.com>
* DeM Labs Inc. https://demlabs.net
* DeM Labs Open source community https://github.com/demlabsinc
* Copyright (c) 2017-2018
* All rights reserved.
This file is part of DAP (Deus Applications Prototypes) the open source project
......
/*
* Authors:
* Dmitriy A. Gearasimov <kahovski@gmail.com>
* DeM Labs Inc. https://demlabs.net
* DeM Labs Open source community https://github.com/demlabsinc
* 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>
......
/*
* Authors:
* Dmitriy A. Gearasimov <kahovski@gmail.com>
* DeM Labs Inc. https://demlabs.net
* DeM Labs Open source community https://github.com/demlabsinc
* 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>
......
/*
* Authors:
* Dmitriy A. Gearasimov <kahovski@gmail.com>
* DeM Labs Inc. https://demlabs.net
* DeM Labs Open source community https://github.com/demlabsinc
* 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/>.
*/
/*
* Authors:
* Dmitriy A. Gearasimov <kahovski@gmail.com>
* DeM Labs Inc. https://demlabs.net
* DeM Labs Open source community https://github.com/demlabsinc
* 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/>.
*/
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