Skip to content

Commit

Permalink
Some refactoring and renamings (#485)
Browse files Browse the repository at this point in the history
* Location of some files was changes, crc and sha256 moved to client/algorithms, string_utils file

* Linux compilation is fixed
  • Loading branch information
jonano614 authored and xrdavies committed Dec 17, 2018
1 parent 82e9c00 commit bf6b3bb
Show file tree
Hide file tree
Showing 55 changed files with 344 additions and 396 deletions.
38 changes: 15 additions & 23 deletions automake/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@

SRCROOT = ..
client = $(SRCROOT)/client
dnet = $(SRCROOT)/dnet
dfstools = $(SRCROOT)/dus/programs/dfstools/source
dfslib = $(dfstools)/dfslib
dar = $(SRCROOT)/dus/programs/dar/source
ldusinc = $(SRCROOT)/ldus/source/include/ldus
dnet = $(SRCROOT)/dnet
dfslib = $(SRCROOT)/dfslib
ldusinc = $(SRCROOT)/ldus
utils = $(SRCROOT)/client/utils
jsonrpc = $(SRCROOT)/client/json-rpc
http = $(SRCROOT)/client/http
moving_statistics = $(SRCROOT)/client/utils/moving_statistics
algorithms = $(SRCROOT)/client/algorithms
secp256k1 = $(SRCROOT)/secp256k1


sources = \
$(client)/sha256-mb-x86_64$(HOST_SUFFIX).s \
$(algorithms)/sha256-mb-x86_64$(HOST_SUFFIX).s \
$(client)/x86_64cpuid$(HOST_SUFFIX).s \
$(client)/address.c \
$(client)/block.c \
Expand All @@ -30,7 +29,6 @@ sources = \
$(client)/netdb.c \
$(client)/pool.c \
$(client)/mining_common.c \
$(client)/sha256.c \
$(client)/storage.c \
$(client)/sync.c \
$(client)/transport.c \
Expand All @@ -43,12 +41,14 @@ sources = \
$(dfslib)/dfslib_crypt.c \
$(dfslib)/dfslib_random.c \
$(dfslib)/dfslib_string.c \
$(dfstools)/lib/dfsrsa.c \
$(dar)/lib/crc_c.c \
$(dfslib)/dfsrsa.c \
$(algorithms)/sha256.c \
$(algorithms)/crc.c \
$(utils)/log.c \
$(utils)/utils.c \
$(utils)/linenoise.c \
$(utils)/dirname.c \
$(utils)/string_utils.c \
$(moving_statistics)/moving_average.c \
$(jsonrpc)/cJSON.c \
$(jsonrpc)/cJSON_Utils.c \
Expand All @@ -73,7 +73,6 @@ headers = \
$(client)/pool.h \
$(client)/miner.h \
$(client)/mining_common.h \
$(client)/sha256.h \
$(client)/state.h \
$(client)/storage.h \
$(client)/sync.h \
Expand All @@ -82,29 +81,24 @@ headers = \
$(client)/commands.h \
$(client)/terminal.h \
$(dnet)/dnet_crypt.h \
$(dnet)/dnet_database.h \
$(dnet)/dnet_history.h \
$(dnet)/dnet_threads.h \
$(dnet)/dnet_connection.h \
$(dnet)/dnet_stream.h \
$(dnet)/dnet_main.h \
$(dnet)/dnet_packet.h \
$(dnet)/dnet_command.h \
$(dnet)/dnet_log.h \
$(dnet)/dnet_files.h \
$(dnet)/dnet_tap.h \
$(dnet)/dthread.h \
$(dnet)/dnet_system.h \
$(dfslib)/dfslib_crypt.h \
$(dfslib)/dfslib_random.h \
$(dfslib)/dfslib_string.h \
$(dfslib)/dfslib_types.h \
$(dfstools)/include/dfsrsa.h \
$(dar)/include/crc.h \
$(dfslib)/dfsrsa.h \
$(ldusinc)/atomic.h \
$(ldusinc)/list.h \
$(ldusinc)/rbtree.h \
$(algorithms)/sha256.h \
$(algorithms)/include/crc.h \
$(utils)/log.h \
$(utils)/utils.h \
$(utils)/linenoise.h \
$(utils)/string_utils.h \
$(moving_statistics)/moving_average.h \
$(jsonrpc)/cJSON.h \
$(jsonrpc)/cJSON_Utils.h \
Expand All @@ -131,8 +125,6 @@ _INCLUDES = \
-I$(SRCROOT) \
-I$(dnet) \
-I$(dfslib) \
-I$(dfstools)/include \
-I$(dar) \
-I$(ldusinc) \
-I$(utils) \
-I$(moving_statistics) \
Expand Down
55 changes: 29 additions & 26 deletions client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@

SRCROOT = ..
dnet = ../dnet
dfstools = ../dus/programs/dfstools/source
dfslib = $(dfstools)/dfslib
dar = ../dus/programs/dar/source
ldusinc = ../ldus/source/include/ldus
dfslib = ../dfslib
ldusinc = ../ldus
utils = ./utils
moving_statistics = ./utils/moving_statistics
algorithms = ./algorithms
json-rpc = ./json-rpc
secp256k1 = ../secp256k1
OS := $(shell uname)
use_openssl_ec := $(shell if grep --quiet -e 'define USE_OPTIMIZED_EC 1' -e 'define USE_OPTIMIZED_EC 2' crypt.h; then echo false; else echo true; fi)
lgmp_installed := $(shell if cc -lgmp 2>&1 | grep --quiet main; then echo true; else echo false; fi)

ifeq ($(OS), Darwin)
asm_src = \
sha256-mb-x86_64-mac.s \
$(algorithms)/sha256-mb-x86_64-mac.s\
x86_64cpuid-mac.s
else
asm_src = \
sha256-mb-x86_64.s \
$(algorithms)/sha256-mb-x86_64.s \
x86_64cpuid.s
endif

Expand All @@ -35,7 +35,6 @@ sources = \
pool.c \
miner.c \
mining_common.c \
sha256.c \
storage.c \
sync.c \
transport.c \
Expand All @@ -52,20 +51,22 @@ sources = \
$(dfslib)/dfslib_crypt.c \
$(dfslib)/dfslib_random.c \
$(dfslib)/dfslib_string.c \
$(dfstools)/lib/dfsrsa.c \
$(dar)/lib/crc_c.c \
$(dfslib)/dfsrsa.c \
$(algorithms)/crc.c \
$(algorithms)/sha256.c \
$(utils)/utils.c \
$(utils)/log.c \
$(utils)/linenoise.c \
$(utils)/dirname.c \
$(utils)/string_utils.c \
$(moving_statistics)/moving_average.c \
./json-rpc/cJSON.c \
./json-rpc/cJSON_Utils.c \
./json-rpc/rpc_procedure.c \
./json-rpc/rpc_procedures.c \
./json-rpc/rpc_service.c \
./json-rpc/rpc_wrapper.c \
./json-rpc/rpc_commands.c \
$(json-rpc)/cJSON.c \
$(json-rpc)/cJSON_Utils.c \
$(json-rpc)/rpc_procedure.c \
$(json-rpc)/rpc_procedures.c \
$(json-rpc)/rpc_service.c \
$(json-rpc)/rpc_wrapper.c \
$(json-rpc)/rpc_commands.c \
./http/url.c \
./http/http.c \

Expand All @@ -81,7 +82,6 @@ headers = \
pool.h \
miner.h \
mining_common.h \
sha256.h \
state.h \
storage.h \
sync.h \
Expand All @@ -99,27 +99,30 @@ headers = \
$(dnet)/dnet_history.h \
$(dnet)/dnet_main.h \
$(dnet)/dnet_packet.h \
$(dnet)/dnet_system.h \
$(dfslib)/dfslib_crypt.h \
$(dfslib)/dfslib_random.h \
$(dfslib)/dfslib_string.h \
$(dfslib)/dfslib_types.h \
$(dfstools)/include/dfsrsa.h \
$(dar)/include/crc.h \
$(dfslib)/dfsrsa.h \
$(ldusinc)/atomic.h \
$(ldusinc)/list.h \
$(ldusinc)/rbtree.h \
$(algorithms)/crc.h \
$(algorithms)/sha256.h \
$(utils)/utils.h \
$(utils)/log.h \
$(utils)/linenoise.h \
$(utils)/dirname.h \
$(utils)/string_utils.h \
$(moving_statistics)/moving_average.h \
./json-rpc/cJSON.h \
./json-rpc/cJSON_Utils.h \
./json-rpc/rpc_procedure.h \
./json-rpc/rpc_procedures.h \
./json-rpc/rpc_service.h \
./json-rpc/rpc_wrapper.h \
./json-rpc/rpc_commands.h \
$(json-rpc)/cJSON.h \
$(json-rpc)/cJSON_Utils.h \
$(json-rpc)/rpc_procedure.h \
$(json-rpc)/rpc_procedures.h \
$(json-rpc)/rpc_service.h \
$(json-rpc)/rpc_wrapper.h \
$(json-rpc)/rpc_commands.h \
./http/url.h \
./http/http.h \

Expand Down
10 changes: 3 additions & 7 deletions dus/programs/dar/source/lib/crc_c.c → client/algorithms/crc.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,10 @@

#include <stdlib.h> /* T5.245 */
#include <stdio.h>
#ifdef __DuS__
#include <dus/error.h>
#else
#define _errn(n) return ((n) << 1 | 1)
#include "../include/crc.h"
#endif

static const char version[] = "CRC library, ...-T4.046-T11.609"; /* $DVS:time$ */
#include "crc.h"

#define _errn(n) return ((n) << 1 | 1)

unsigned *crc_table = NULL;

Expand Down
28 changes: 28 additions & 0 deletions client/algorithms/crc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef _CRC_H
#define _CRC_H

// header file of CRC-library

#include <stdio.h>

/* initialization of the internal CRC-table (with memory allocation) */
extern int crc_init(void);

/* creation of the table in the external array of length of 256 double words */
extern int crc_makeTable(unsigned table[256]);

/* добавить к накопленному CRC новые данные, содержащиеся в массиве buf
длины len; возвращает новый CRC; начальное значение CRC=0 */
extern unsigned crc_addArray(unsigned char *buf, unsigned len, unsigned crc);

/* добавить к накопленному CRC новые данные, содержащиеся в файле f, но не
более len байт; возвращает новый CRC; начальное значение CRC=0 */
extern unsigned crc_addFile(FILE *f, unsigned len, unsigned crc);

/* calculates CRC of the array */
#define crc_of_array(buf,len) crc_addArray(buf,len,0)

/* calculates CRC of the file */
#define crc_of_file(f) crc_addFile(f,-1,0)

#endif
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion client/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <unistd.h>
#include <math.h>
#include "system.h"
#include "../ldus/source/include/ldus/rbtree.h"
#include "../ldus/rbtree.h"
#include "block.h"
#include "crypt.h"
#include "global.h"
Expand Down
11 changes: 4 additions & 7 deletions client/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@
#include "crypt.h"
#include "json-rpc/rpc_commands.h"
#include "math.h"
#if !defined(_WIN32) && !defined(_WIN64)
#ifndef _WIN32
#include "utils/linenoise.h"
#endif

#if !defined(_WIN32) && !defined(_WIN64)
#include <unistd.h>
#endif

Expand Down Expand Up @@ -1005,7 +1002,7 @@ double xdagGetHashRate(void)

int read_command(char *cmd)
{
#if !defined(_WIN32) && !defined(_WIN64)
#ifndef _WIN32
char* line = linenoise("xdag> ");
if(line == NULL) return 0;

Expand All @@ -1031,7 +1028,7 @@ int read_command(char *cmd)
return 0;
}

#if !defined(_WIN32) && !defined(_WIN64)
#ifndef _WIN32
static void xdag_com_completion(const char *buf, linenoiseCompletions *lc)
{
for(int index = 0; commands[index].name; index++) {
Expand All @@ -1044,7 +1041,7 @@ static void xdag_com_completion(const char *buf, linenoiseCompletions *lc)

void xdag_init_commands(void)
{
#if !defined(_WIN32) && !defined(_WIN64)
#ifndef _WIN32
linenoiseSetCompletionCallback(xdag_com_completion); //set completion
linenoiseHistorySetMaxLen(50); //set max line for history
linenoiseHistoryLoad(COMMAND_HISTORY); //load history
Expand Down
2 changes: 1 addition & 1 deletion client/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#ifdef SHA256_OPENSSL_MBLOCK
#include <arpa/inet.h>
#endif
#include "sha256.h"
#include "algorithms/sha256.h"
#include "hash.h"
#include "system.h"

Expand Down
2 changes: 1 addition & 1 deletion client/http/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <openssl/err.h>
#include <openssl/x509v3.h>

#if !defined(_WIN32) && !defined(_WIN64)
#ifndef _WIN32
#include <errno.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
Expand Down
Loading

0 comments on commit bf6b3bb

Please sign in to comment.