diff --git a/CMakeLists.txt b/CMakeLists.txt index 557fe00054279c6bef64b7c471796335221becce..99425837f55e93f9448712c64ea9fa867a3003d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,23 @@ cmake_minimum_required(VERSION 2.8) project (libdap-chain) -set(DAP_CHAIN_SRCS dap_chain.c) - -add_library(${PROJECT_NAME} STATIC ${DAP_CHAIN_SRCS}) +set(DAP_CHAIN_SRCS dap_chain_block.c dap_chain_block_section.c dap_chain.c dap_chain_coin.c dap_chain_srv.c dap_chain_tx.c) +set(DAP_CHAIN_HEADERS + dap_chain_block.h + dap_chain_block_section.h + dap_chain.h + dap_chain_coin.h + dap_chain_srv.h + dap_chain_tx.h + ) + +include_directories("${dap_core_INCLUDE_DIRS}") +add_definitions ("${dap_core_DEFINITIONS}") + +include_directories("${dap_crypto_INCLUDE_DIRS}") +add_definitions ("${dap_crypto_DEFINITIONS}") + +add_library(${PROJECT_NAME} STATIC ${DAP_CHAIN_SRCS} ${DAP_CHAIN_HEADERS}) set(${PROJECT_NAME}_DEFINITIONS CACHE INTERNAL "${PROJECT_NAME}: Definitions" FORCE) diff --git a/dap_chain_block.c b/dap_chain_block.c new file mode 100644 index 0000000000000000000000000000000000000000..dc73e8291897f5c1a9171485d1db22ba5acf8be7 --- /dev/null +++ b/dap_chain_block.c @@ -0,0 +1,38 @@ +/* + Copyright (c) 2017-2018 (c) Project "DeM Labs Inc" https://github.com/demlabsinc + 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_chain_block.h" + +/** + * @brief dap_chain_block_init + * @return + */ +int dap_chain_block_init() +{ + +} + +/** + * @brief dap_chain_block_deinit + */ +void dap_chain_block_deinit() +{ + +} diff --git a/dap_chain_block.h b/dap_chain_block.h new file mode 100644 index 0000000000000000000000000000000000000000..2eb5e794ed9d87accc1d18f4a520f808e99277aa --- /dev/null +++ b/dap_chain_block.h @@ -0,0 +1,43 @@ +/* + Copyright (c) 2017-2018 (c) Project "DeM Labs Inc" https://github.com/demlabsinc + 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/>. +*/ +#ifndef _DAP_CHAIN_BLOCK_H_ +#define _DAP_CHAIN_BLOCK_H_ +#include <stdalign.h> +#include <stdint.h> +#include <stddef.h> +#include "dap_common.h" +#include "dap_math_ops.h" +#include "dap_chain_block_section.h" + +/** + * @brief The dap_chain_block struct + */ +typedef struct dap_chain_block{ + struct { + dap_uint128_t id; /// @param Block ID uniqie identificator of the block + size_t size; + } header; + dap_chain_block_section_t section[]; +} DAP_ALIGN_PACKED dap_chain_block_t; + +int dap_chain_block_init(); +void dap_chain_block_deinit(); + +#endif diff --git a/dap_chain_block_section.c b/dap_chain_block_section.c new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/dap_chain_block_section.h b/dap_chain_block_section.h new file mode 100644 index 0000000000000000000000000000000000000000..f4328cf8f035a2c63f82a45e8ba569513bc5713f --- /dev/null +++ b/dap_chain_block_section.h @@ -0,0 +1,44 @@ +/** + * @struct dap_chain_block_section + * @brief section inside the block + */ +#ifndef _DAP_CHAIN_BLOCK_SECTION_H_ +#define _DAP_CHAIN_BLOCK_SECTION_H_ +#include <stdint.h> +#include "dap_common.h" +#include "dap_math_ops.h" + +/// End section, means all the rest of the block is empty +#define DAP_CHAIN_BLOCK_SECTION_END 0x0000 + +/// Transaction section +#define DAP_CHAIN_BLOCK_SECTION_TX 0x0100 + +/// Smart contract: code section +#define DAP_CHAIN_BLOCK_SECTION_TX 0x0200 + +/// Smart contract: data section +#define DAP_CHAIN_BLOCK_SECTION_TX 0x0201 + +/// Public key +#define DAP_CHAIN_BLOCK_SECTION_PKEY 0x0300 + +/// Coin: gold +#define DAP_CHAIN_BLOCK_SECTION_COIN_GOLD 0xff00 + +/// Coin: copper +#define DAP_CHAIN_BLOCK_SECTION_COIN_COPPER 0xff01 + +/// Coin: silver +#define DAP_CHAIN_BLOCK_SECTION_COIN_SILVER 0xff02 + + +typedef struct dap_chain_block_section{ + struct{ + uint16_t type; // Section type + size_t size; // section size + } header; + uint8_t data[]; // data +} DAP_ALIGN_PACKED dap_chain_block_section_t; + +#endif diff --git a/dap_chain_coin.c b/dap_chain_coin.c new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/dap_chain_coin.h b/dap_chain_coin.h new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/dap_chain_srv.c b/dap_chain_srv.c new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/dap_chain_srv.h b/dap_chain_srv.h new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/dap_chain_tx.c b/dap_chain_tx.c new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/dap_chain_tx.h b/dap_chain_tx.h new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391