Skip to content

Commit

Permalink
Implement cCurl-compatibile interface
Browse files Browse the repository at this point in the history
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 <jserv.tw@gmail.com>
  • Loading branch information
Chen Wei and jserv committed Mar 23, 2018
1 parent bbd694a commit 5a0671d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 3 additions & 0 deletions mk/defs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
29 changes: 29 additions & 0 deletions src/compat-ccurl.c
Original file line number Diff line number Diff line change
@@ -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 <stdbool.h>

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 */
}

0 comments on commit 5a0671d

Please sign in to comment.