From 5a0671d28057f730a499fedf6f87a6aa58aaf5a8 Mon Sep 17 00:00:00 2001 From: Chen Wei Date: Fri, 23 Mar 2018 03:13:55 +0800 Subject: [PATCH] Implement cCurl-compatibile interface Once `BUILD_COMPAT` is set, cCurl-specific interface will be built accordingly. However, Configuration of dcurl is hardcored to [ CPU_TASK = 1, GPU_TASK = 0 ] because IOTA wallet has no chance to compute 2 more PoW tasks at the same time currently. Co-authored-by: Jim Huang --- Makefile | 5 +++++ mk/defs.mk | 3 +++ src/compat-ccurl.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 src/compat-ccurl.c diff --git a/Makefile b/Makefile index b50fae2..ea5f49d 100644 --- a/Makefile +++ b/Makefile @@ -70,6 +70,11 @@ OBJS += \ jni/iri-pearldiver-exlib.o endif +ifeq ("$(BUILD_COMPAT)", "1") +OBJS += \ + compat-ccurl.o +endif + OBJS := $(addprefix $(OUT)/, $(OBJS)) #deps := $(OBJS:%.o=%.o.d) diff --git a/mk/defs.mk b/mk/defs.mk index 34334e7..313f1e7 100644 --- a/mk/defs.mk +++ b/mk/defs.mk @@ -6,3 +6,6 @@ BUILD_GPU ?= 0 # Build JNI glue as the bridge between dcurl and IRI BUILD_JNI ?= 0 + +# Build cCurl compatible interface +BUILD_COMPAT ?= 0 diff --git a/src/compat-ccurl.c b/src/compat-ccurl.c new file mode 100644 index 0000000..ca17c2c --- /dev/null +++ b/src/compat-ccurl.c @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2018 dcurl Developers. + * Use of this source code is governed by MIT license that can be + * found in the LICENSE file. + */ + +#include "dcurl.h" +#include + +static bool isInitialized = false; + +char *ccurl_pow(char *trytes, int mwm) +{ + if (!isInitialized) { + dcurl_init(1, 0); + isInitialized = true; + } + return (char *) dcurl_entry((int8_t *) trytes, mwm); +} + +void ccurl_pow_finalize(void) +{ + dcurl_destroy(); +} + +void ccurl_pow_interrupt(void) +{ + /* Do Nothing */ +}