diff --git a/dap_chain.c b/dap_chain.c index 4bb2fb49fd42a7cd225d18e4b1b8a82d7db4be07..282a01fa4f834e983baf297dc85fc8b6125f8bdc 100644 --- a/dap_chain.c +++ b/dap_chain.c @@ -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; } diff --git a/dap_chain.h b/dap_chain.h index 3260fd79efc6ab54504438398a75a3d55d0fe45c..0f40cec69a69078600446169ccbbf16ff040bb24 100644 --- a/dap_chain.h +++ b/dap_chain.h @@ -1,6 +1,10 @@ /* - 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); diff --git a/dap_chain_block.c b/dap_chain_block.c index cd160264b0a412fb1e8767c475d1582d3ff9f96c..bc4f0834b733ec6b3113478abf6ca18f5a81b44e 100644 --- a/dap_chain_block.c +++ b/dap_chain_block.c @@ -19,7 +19,6 @@ */ #include "dap_common.h" -#include "dap_chain_section_roots.h" #include "dap_chain_block.h" diff --git a/dap_chain_block.h b/dap_chain_block.h index f257726a8d7b660497e85669dd412d2b748c68d8..4e9ee859dcf55ae3339ba9d02eaac721c5249be5 100644 --- a/dap_chain_block.h +++ b/dap_chain_block.h @@ -1,6 +1,10 @@ /* - 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; diff --git a/dap_chain_coin.h b/dap_chain_coin.h index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..8bf7f08772fbac06fe6539f3c2ba86e1479a6506 100644 --- a/dap_chain_coin.h +++ b/dap_chain_coin.h @@ -0,0 +1,24 @@ +/* + * 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 diff --git a/dap_chain_common.h b/dap_chain_common.h index df72b8e518937a62689fa62b53c4e83bfd42b1da..ec0a7b710b62fe4168265b4dfa03f4011ce24b0e 100644 --- a/dap_chain_common.h +++ b/dap_chain_common.h @@ -1,5 +1,28 @@ -#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 diff --git a/dap_chain_internal.h b/dap_chain_internal.h index 720e15bb85bd17210407e94c1c2f7d415c265bed..d5822356b1a67bdd680e0715ea8ccbccf1b899a5 100644 --- a/dap_chain_internal.h +++ b/dap_chain_internal.h @@ -1,6 +1,10 @@ /* - 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 diff --git a/dap_chain_section.h b/dap_chain_section.h index 49e3fcff9aa8b39249428376dd352bf1cd0166d8..655c4a1053622390903f6f4a6f539a3fb3762aa2 100644 --- a/dap_chain_section.h +++ b/dap_chain_section.h @@ -1,6 +1,10 @@ /* - 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 + diff --git a/dap_chain_section_roots.h b/dap_chain_section_roots.h index d0eb6320aa4c7f2cd20996a8f0cdf6e67d859f5a..491a069498880c1f2e5a0101438ce4defafc4d72 100644 --- a/dap_chain_section_roots.h +++ b/dap_chain_section_roots.h @@ -1,6 +1,10 @@ /* - 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 diff --git a/dap_chain_section_tx.h b/dap_chain_section_tx.h index 10bfc026f3d51546a0977a52ce2961ae889a03a0..9d52a97b98da94727c0e8848886fc08746e562ba 100644 --- a/dap_chain_section_tx.h +++ b/dap_chain_section_tx.h @@ -1,6 +1,10 @@ /* - 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 diff --git a/dap_chain_section_tx_in.h b/dap_chain_section_tx_in.h index c2484bacfed09e9c53dd7c70850d64474c12002a..66bbefb5fe605a732b6e30089f669e7a070d70e1 100644 --- a/dap_chain_section_tx_in.h +++ b/dap_chain_section_tx_in.h @@ -1,3 +1,26 @@ +/* + * 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> diff --git a/dap_chain_section_tx_out.h b/dap_chain_section_tx_out.h index e014f19e4df7258111c936f4284632a31a152568..9c90d70a26281af017c39180eeaf047a9918d746 100644 --- a/dap_chain_section_tx_out.h +++ b/dap_chain_section_tx_out.h @@ -1,3 +1,26 @@ +/* + * 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> diff --git a/dap_chain_srv.h b/dap_chain_srv.h index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..a672942990f0be23844bfe82c8fbee1b3ce386ce 100644 --- a/dap_chain_srv.h +++ b/dap_chain_srv.h @@ -0,0 +1,23 @@ +/* + * 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/>. +*/ diff --git a/dap_chain_wallet.h b/dap_chain_wallet.h index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..a672942990f0be23844bfe82c8fbee1b3ce386ce 100644 --- a/dap_chain_wallet.h +++ b/dap_chain_wallet.h @@ -0,0 +1,23 @@ +/* + * 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/>. +*/