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

[+] dap_chain_srv, dap_chain_node and some others objects skelet

[*] Build errors fixed
[-] libconfig usage in libdap-server. TODO: replace static declaration with dap_config object calls
parent a4133845
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,9 @@ set(DAP_CHAIN_SRCS ...@@ -14,7 +14,9 @@ set(DAP_CHAIN_SRCS
dap_chain.c dap_chain.c
dap_chain_ops.c dap_chain_ops.c
dap_chain_coin.c dap_chain_coin.c
dap_chain_node.c
dap_chain_srv.c dap_chain_srv.c
dap_chain_srv_pkt.c
dap_hash.c dap_hash.c
dap_hash_fusion.c dap_hash_fusion.c
dap_hash_keccak.c dap_hash_keccak.c
...@@ -32,7 +34,9 @@ set(DAP_CHAIN_HEADERS ...@@ -32,7 +34,9 @@ set(DAP_CHAIN_HEADERS
dap_chain_internal.h dap_chain_internal.h
dap_chain_common.h dap_chain_common.h
dap_chain_coin.h dap_chain_coin.h
dap_chain_node.h
dap_chain_srv.h dap_chain_srv.h
dap_chain_srv_pkt.h
dap_chain_section.h dap_chain_section.h
dap_chain_section_roots.h dap_chain_section_roots.h
dap_chain_section_tx.h dap_chain_section_tx.h
......
...@@ -138,7 +138,7 @@ void dap_chain_save(dap_chain_t * a_chain) ...@@ -138,7 +138,7 @@ void dap_chain_save(dap_chain_t * a_chain)
*/ */
void dap_chain_file_write(dap_chain_block_cache_t *l_block_cache){ void dap_chain_file_write(dap_chain_block_cache_t *l_block_cache){
if (dap_chain_hash_kind_check(l_block_cache, l_block_cache->block->header.difficulty)==HASH_GOLD){ if (dap_chain_hash_kind_check(&l_block_cache->block_hash, l_block_cache->block->header.difficulty)==HASH_GOLD){
fwrite(l_block_cache->block->header.size, 64, 1, my_file_to_wite_gold); fwrite(l_block_cache->block->header.size, 64, 1, my_file_to_wite_gold);
fwrite(l_block_cache->block, l_block_cache->block->header.size, 1, my_file_to_wite_gold); fwrite(l_block_cache->block, l_block_cache->block->header.size, 1, my_file_to_wite_gold);
blocks_mined_gold += 1; blocks_mined_gold += 1;
......
...@@ -44,22 +44,22 @@ typedef struct dap_chain_block{ ...@@ -44,22 +44,22 @@ typedef struct dap_chain_block{
int32_t version; /// @param version @brief block version (be carefull, signed value, as Bitcoin has) int32_t version; /// @param version @brief block version (be carefull, signed value, as Bitcoin has)
uint32_t size; /// @param size of the whole block uint32_t size; /// @param size of the whole block
uint64_t timestamp; /// @param timestamp @brief Block create time timestamp uint64_t timestamp; /// @param timestamp @brief Block create time timestamp
uint64_t difficulty; /// difficulty level uint64_t difficulty; /// difficulty level
uint64_t nonce; /// Nonce value to allow header variation for mining uint64_t nonce; /// Nonce value to allow header variation for mining
union{ union{
struct{ // Zero-level block without sharding struct{ // Zero-level block without sharding
dap_chain_hash_t prev_block; /// @param prev_block Hash of the previous block dap_chain_hash_t prev_block; /// @param prev_block Hash of the previous block
dap_chain_hash_t padding0; // dap_chain_hash_t padding0; //
uint32_t padding1; // uint32_t padding1; //
uint64_t padding2; // Always zero (should be well compresed) uint64_t padding2; // Always zero (should be well compresed)
}; };
struct{ struct{
dap_chain_hash_t prev_block_0lvl; /// @param prev_block Hash of the previous block dap_chain_hash_t prev_block_0lvl; /// @param prev_block Hash of the previous block
dap_chain_hash_t prev_block_shard; /// @param prev_block Hash of the previous block dap_chain_hash_t prev_block_shard; /// @param prev_block Hash of the previous block
uint32_t shard_id; // Shard id uint32_t shard_id; // Shard id
uint64_t nonce2; // Second NonCE for block mining inside the shard uint64_t nonce2; // Second NonCE for block mining inside the shard
} };
} };
dap_chain_hash_t root_sections;/// @param root_main Main tree's root for all sections's hashes dap_chain_hash_t root_sections;/// @param root_main Main tree's root for all sections's hashes
} DAP_ALIGN_PACKED header; } DAP_ALIGN_PACKED header;
uint8_t sections[]; // Sections uint8_t sections[]; // Sections
......
/*
* 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 #pragma once
......
/*
* Authors:
* Dmitriy A. Gearasimov <naeper@demlabs.net>
* DeM Labs Inc. https://demlabs.net
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_node.h"
/*
* Authors:
* Dmitriy A. Gearasimov <naeper@demlabs.net>
* DeM Labs Inc. https://demlabs.net
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 <stddef.h>
#include <sys/socket.h>
#include <netinet/in.h>
typedef union dap_chain_node_addr{
uint64_t addr_raw;
uint8_t addr_oct[sizeof(uint64_t)]; // Access to selected octects
} dap_chain_node_addr_t;
typedef struct dap_chain_node{
dap_chain_node_addr_t addr;
dap_chain_node_addr_t *uplinks;
dap_chain_node_addr_t *downlinks;
struct in_addr *ipv4_addrs;
struct in6_addr *ipv6_addrs;
} dap_chain_node_t;
...@@ -22,5 +22,67 @@ ...@@ -22,5 +22,67 @@
along with any DAP based project. If not, see <http://www.gnu.org/licenses/>. along with any DAP based project. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "utlist.h"
#include "dap_chain_srv.h" #include "dap_chain_srv.h"
#define LOG_TAG "chain_srv"
size_t m_uid_count;
dap_chain_srv_uid_t * m_uid;
/**
* @brief dap_chain_srv_init
* @return
*/
int dap_chain_srv_init()
{
m_uid = NULL;
m_uid_count = NULL;
return 0;
}
/**
* @brief dap_chain_srv_deinit
*/
void dap_chain_srv_deinit()
{
}
/**
* @brief dap_chain_srv_add
* @param a_srv
*/
void dap_chain_srv_add(dap_chain_srv_t * a_srv)
{
}
/**
* @brief dap_chain_srv_get
* @param a_uid
* @return
*/
dap_chain_srv_t * dap_chain_srv_get( dap_chain_srv_uid_t a_uid)
{
}
/**
* @brief dap_chain_srv_count
* @return
*/
const size_t dap_chain_srv_count()
{
}
/**
* @brief dap_chain_srv_list
* @return
*/
const dap_chain_srv_uid_t * dap_chain_srv_list()
{
}
...@@ -22,3 +22,24 @@ ...@@ -22,3 +22,24 @@
along with any DAP based project. If not, see <http://www.gnu.org/licenses/>. along with any DAP based project. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include "dap_chain_node.h"
#include "dap_chain_srv_pkt.h"
typedef struct dap_chain_srv
{
dap_chain_node_t * node;
dap_chain_srv_uid_t uid; // Unique ID for service.
void * _internal;
void * _inhertor;
} dap_chain_srv_t;
int dap_chain_srv_init();
void dap_chain_srv_deinit();
void dap_chain_srv_add(dap_chain_srv_t * a_srv);
dap_chain_srv_t * dap_chain_srv_get( dap_chain_srv_uid_t a_uid);
const size_t dap_chain_srv_count();
const dap_chain_srv_uid_t * dap_chain_srv_list();
#include "dap_chain_srv_pkt.h"
#define LOG_TAG "srv_pkt"
/*
* 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>
typedef uint64_t dap_chain_srv_uid_t;
typedef struct dap_chain_srv_pkt{
struct {
dap_chain_srv_uid_t uid;
} __attribute__((packed)) header ;
uint8_t data[];
} __attribute__((packed)) dap_chain_srv_pkt_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