Skip to content
Snippets Groups Projects
Commit 620a43c7 authored by dmitriy.gerasimov's avatar dmitriy.gerasimov
Browse files

[-] Removed node ctl object

[+] Placed back all net init calls
parent 8b970465
No related branches found
No related tags found
1 merge request!24Support 3689
......@@ -4,7 +4,6 @@ project (dap_chain_net)
set(DAP_CHAIN_NET_SRCS
dap_chain_net.c
dap_chain_node.c
dap_chain_node_ctl.c
dap_chain_node_cli.c
dap_chain_node_cli_cmd.c
dap_chain_node_client.c
......@@ -14,7 +13,6 @@ set(DAP_CHAIN_NET_SRCS
set(DAP_CHAIN_NET_HEADERS
dap_chain_net.h
dap_chain_node.h
dap_chain_node_ctl.h
dap_chain_node_cli.h
dap_chain_node_cli_cmd.h
dap_chain_node_client.h
......
......@@ -33,7 +33,6 @@
#include "dap_config.h"
#include "dap_chain_utxo.h"
#include "dap_chain_net.h"
#include "dap_chain_node_ctl.h"
#include "dap_module.h"
#define _XOPEN_SOURCE 700
......@@ -53,7 +52,6 @@ typedef struct dap_chain_net_pvt{
dap_chain_node_role_t node_role;
uint8_t padding[4];
//dap_client_t client;
dap_chain_node_ctl_t * node;
} dap_chain_net_pvt_t;
typedef struct dap_chain_net_item{
......@@ -146,7 +144,7 @@ static void s_net_proc_kill( dap_chain_net_t * a_net )
* @return
*/
dap_chain_net_t * dap_chain_net_new(const char * a_id, const char * a_name ,
const char * a_node_role, const char * a_node_name)
const char * a_node_role)
{
dap_chain_net_t * ret = DAP_NEW_Z_SIZE (dap_chain_net_t, sizeof (ret->pub)+ sizeof (dap_chain_net_pvt_t) );
ret->pub.name = strdup( a_name );
......@@ -155,13 +153,6 @@ dap_chain_net_t * dap_chain_net_new(const char * a_id, const char * a_name ,
PVT(ret)->node_role.enums = ROOT;
log_it (L_NOTICE, "Node role \"root\" selected");
}
PVT(ret)->node = dap_chain_node_ctl_open(a_node_name);
if ( PVT(ret)->node ){
} else {
log_it( L_ERROR, "Can't open \"%s\" node's config",a_node_name);
}
} else {
log_it (L_ERROR, "Wrong id format (\"%s\"). Must be like \"0x0123456789ABCDE\"" , a_id );
}
......@@ -175,7 +166,6 @@ dap_chain_net_t * dap_chain_net_new(const char * a_id, const char * a_name ,
*/
void dap_chain_net_delete( dap_chain_net_t * a_net )
{
DAP_DELETE( PVT(a_net)->node);
DAP_DELETE( PVT(a_net) );
}
......@@ -194,8 +184,7 @@ int dap_chain_net_init()
dap_chain_net_t * l_net = dap_chain_net_new(
dap_config_get_item_str(l_cfg , "general" , "id" ),
dap_config_get_item_str(l_cfg , "general" , "name" ),
dap_config_get_item_str(l_cfg , "general" , "node-role" ),
dap_config_get_item_str(l_cfg , "general" , "node-alias" )
dap_config_get_item_str(l_cfg , "general" , "node-role" )
);
// Do specific actions
switch ( PVT( l_net )->node_role.enums ) {
......
......@@ -3,7 +3,7 @@
* Dmitriy A. Gearasimov <gerasimov.dmitriy@demlabs.net>
* DeM Labs Inc. https://demlabs.net
* Kelvin Project https://github.com/kelvinblockchain
* Copyright (c) 2017-2018
* Copyright (c) 2017-2019
* All rights reserved.
This file is part of DAP (Deus Applications Prototypes) the open source project
......@@ -45,7 +45,7 @@ int dap_chain_net_init(void);
void dap_chain_net_deinit(void);
dap_chain_net_t * dap_chain_net_new (const char * a_id, const char * a_name,
const char* a_node_role , const char* a_node_name );
const char* a_node_role );
void dap_chain_net_delete( dap_chain_net_t * a_net);
......
/*
* 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 <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include "dap_config.h"
#include "dap_chain_net.h"
#include "dap_chain_node_ctl.h"
#define LOG_TAG "chain_node_ctl"
typedef struct dap_chain_node_ctl_pvt{
uint_fast64_t padding;
} dap_chain_node_ctl_pvt_t;
#define PVT(a) ( (dap_chain_node_ctl_pvt_t *) (a)->pvt )
#define PVT_S(a) ( (dap_chain_node_ctl_pvt_t *) (a).pvt )
/**
* @brief dap_chain_node_new
* @return
*/
dap_chain_node_ctl_t * dap_chain_node_ctl_new()
{
dap_chain_node_ctl_t * ret = DAP_NEW_Z_SIZE(dap_chain_node_ctl_t, sizeof(ret->pub) + sizeof(dap_chain_node_ctl_pvt_t) );
return ret;
}
/**
* @brief dap_chain_node_delete
* @param a_node
*/
void dap_chain_node_ctl_delete(dap_chain_node_ctl_t * a_node)
{
DAP_DELETE(a_node);
}
/**
* @brief dap_chain_node_ctl_open
* @param a_name
* @return
*/
dap_chain_node_ctl_t * dap_chain_node_ctl_open( const char * a_name )
{
dap_chain_node_ctl_t * l_node = NULL;
const char c_node_folder[]="node";
size_t buf_size = 2+strlen(a_name)+strlen(c_node_folder);
char *buf= DAP_NEW_SIZE(char, buf_size);
snprintf(buf,buf_size,"%s/%s",c_node_folder,a_name);
dap_config_t * l_node_cfg = dap_config_open(buf);
if ( l_node_cfg ){
//dap_config_get_item_str_default()
l_node = dap_chain_node_ctl_new();
} else {
log_it(L_ERROR,"Can't open node \"%s\". Check the configuration files path.",a_name);
}
DAP_DELETE(buf);
return l_node;
}
/*
* 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 "dap_chain_common.h"
#include "dap_chain_node.h"
typedef struct dap_chain_node_ctl{
struct {
dap_chain_node_addr_t addr;
struct in_addr *ipv4_addrs;
size_t ipv4_addrs_size;
struct in6_addr *ipv6_addrs;
size_t ipv6_addrs_size;
} pub;
uint8_t pvt[];
} dap_chain_node_ctl_t;
dap_chain_node_ctl_t * dap_chain_node_ctl_new();
dap_chain_node_ctl_t * dap_chain_node_ctl_open( const char * a_name );
void dap_chain_node_ctl_delete(dap_chain_node_ctl_t * a_node);
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