Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
* 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>
#include "dap_common.h"
#include "dap_chain_common.h"
/**
* @struct Node address
*
*/
typedef union dap_chain_node_addr{
uint64_t uint64;
uint8_t raw[sizeof(uint64_t)]; // Access to selected octects
} dap_chain_node_addr_t;
/**
* Node Declaration request
*
*/
#define DAP_CHAIN_NODE_DECL_REQ_INFO_SIZE 32
typedef struct dap_chain_node_delc_req{
dap_chain_node_addr_t node_address;
uint64_t create_ts;
union{
uint8_t raw[DAP_CHAIN_NODE_DECL_REQ_INFO_SIZE];
char str[DAP_CHAIN_NODE_DECL_REQ_INFO_SIZE];
} info;
} DAP_ALIGN_PACKED dap_chain_decl_req_t;
/**
* @struct dap_chain_node decl
* @details New node declaration
*
*/
#define DAP_CHAIN_NODE_DECL_ACCEPT_INFO_SIZE 32
typedef struct dap_chain_node_decl{
dap_chain_decl_req_t request;
uint64_t accept_ts;
struct in_addr accept_addr_v4;
struct in6_addr accept_addr_v6;
union{
uint8_t raw[DAP_CHAIN_NODE_DECL_ACCEPT_INFO_SIZE];
char str[DAP_CHAIN_NODE_DECL_ACCEPT_INFO_SIZE];
} accept_info;
} DAP_ALIGN_PACKED dap_chain_node_decl_t;
typedef struct dap_chain_node_info
{
struct {
dap_chain_node_addr_t address;
dap_chain_shard_id_t shard_id;
uint32_t uplinks_number;
struct in_addr ext_addr_v4;
struct in6_addr ext_addr_v6;
} DAP_ALIGN_PACKED hdr;
dap_chain_addr_t uplinks[];
} DAP_ALIGN_PACKED dap_chain_node_info_t;
typedef struct dap_chain_node_publ{
dap_chain_hash_fast_t decl_hash;
dap_chain_node_info_t node_info;
} DAP_ALIGN_PACKED dap_chain_node_publ_t;