From 695b7ebe7b08a4ed0eb48e47560b2ff1450e6388 Mon Sep 17 00:00:00 2001 From: Jim Huang Date: Tue, 25 Jun 2019 01:33:55 +0800 Subject: [PATCH 01/15] Explicitly mention copyright notice in each source file --- LICENSE | 1 + jni/iri-pearldiver-exlib.c | 8 ++++++ src/clcontext.c | 10 +++++--- src/clcontext.h | 9 ++++--- src/common.c | 8 ++++++ src/common.h | 11 +++++++- src/compat-ccurl.c | 8 +++--- src/constants.c | 8 ++++++ src/constants.h | 8 ++++++ src/cpu-utils.h | 8 +++--- src/curl.c | 8 +++--- src/curl.h | 8 ++++++ src/dcurl.c | 8 +++--- src/dcurl.h | 8 ++++++ src/implcontext.c | 10 +++++++- src/implcontext.h | 8 ++++++ src/list.h | 8 +++--- src/pow_avx.c | 22 ++++++++-------- src/pow_c.c | 10 +++++--- src/pow_c.h | 8 ++++++ src/pow_cl.c | 10 +++++--- src/pow_cl.h | 8 ++++++ src/pow_fpga_accel.c | 10 +++++--- src/pow_fpga_accel.h | 8 ++++++ src/pow_kernel.cl | 8 +++--- src/pow_sse.c | 10 +++++--- src/pow_sse.h | 8 ++++++ src/remote_common.c | 51 ++++++++++++++++++++------------------ src/remote_common.h | 8 ++++++ src/remote_interface.c | 26 ++++++++++--------- src/remote_interface.h | 8 ++++++ src/remote_worker.c | 24 ++++++++++-------- src/trinary.c | 8 +++--- src/trinary.h | 8 ++++++ src/trinary_sse42.h | 8 ++++++ tests/common.h | 8 ++++++ tests/test-curl.c | 8 ++++++ tests/test-dcurl.c | 8 ++++++ tests/test-multi-pow.c | 14 ++++++++--- tests/test-pow.c | 8 ++++++ tests/test-trinary.c | 8 ++++++ 41 files changed, 328 insertions(+), 106 deletions(-) diff --git a/LICENSE b/LICENSE index b9ed260..3d2d9ab 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,5 @@ Copyright (C) 2018-2019 BiiLabs Co., Ltd. and Contributors. +Copyright (C) 2018 Ievgen Korokyi. Copyright (C) 2017 IOTA AS, IOTA Foundation and Developers. Copyright (C) 2016 Shinya Yagyu. diff --git a/jni/iri-pearldiver-exlib.c b/jni/iri-pearldiver-exlib.c index bc1deba..fe0bf3c 100644 --- a/jni/iri-pearldiver-exlib.c +++ b/jni/iri-pearldiver-exlib.c @@ -1,3 +1,11 @@ +/* + * Copyright (C) 2018-2019 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. + */ + #include "iri-pearldiver-exlib.h" #include #include diff --git a/src/clcontext.c b/src/clcontext.c index 438b221..c817740 100644 --- a/src/clcontext.c +++ b/src/clcontext.c @@ -1,8 +1,10 @@ /* - * Copyright (C) 2018 dcurl Developers. - * Copyright (C) 2017 IOTA AS, IOTA Foundation and Developers. - * Use of this source code is governed by MIT license that can be - * found in the LICENSE file. + * Copyright (C) 2018 BiiLabs Co., Ltd. and Contributors + * Copyright (C) 2017 IOTA AS, IOTA Foundation and Developers + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. */ #include "clcontext.h" diff --git a/src/clcontext.h b/src/clcontext.h index 05bdc0d..434bf7c 100644 --- a/src/clcontext.h +++ b/src/clcontext.h @@ -1,7 +1,10 @@ /* - * Copyright (C) 2018 dcurl Developers. - * Use of this source code is governed by MIT license that can be - * found in the LICENSE file. + * Copyright (C) 2018 BiiLabs Co., Ltd. and Contributors + * Copyright (C) 2017 IOTA AS, IOTA Foundation and Developers + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. */ #ifndef CLCONTEXT_H_ diff --git a/src/common.c b/src/common.c index 0094fdf..e2e39a1 100644 --- a/src/common.c +++ b/src/common.c @@ -1,3 +1,11 @@ +/* + * Copyright (C) 2018 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. + */ + #include "common.h" double diff_in_second(struct timespec t1, struct timespec t2) diff --git a/src/common.h b/src/common.h index c675118..f7dd479 100644 --- a/src/common.h +++ b/src/common.h @@ -1,3 +1,11 @@ +/* + * Copyright (C) 2018-2019 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. + */ + #ifndef COMMON_H_ #define COMMON_H_ @@ -12,7 +20,8 @@ double diff_in_second(struct timespec t1, struct timespec t2); -static inline void ddprintf(const char *format, ...) { +static inline void ddprintf(const char *format, ...) +{ #if defined(ENABLE_DEBUG) va_list ap; va_start(ap, format); diff --git a/src/compat-ccurl.c b/src/compat-ccurl.c index 94d559c..423de15 100644 --- a/src/compat-ccurl.c +++ b/src/compat-ccurl.c @@ -1,7 +1,9 @@ /* - * Copyright (C) 2018 dcurl Developers. - * Use of this source code is governed by MIT license that can be - * found in the LICENSE file. + * Copyright (C) 2018 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. */ #include diff --git a/src/constants.c b/src/constants.c index 38ba2e7..668e12b 100644 --- a/src/constants.c +++ b/src/constants.c @@ -1,3 +1,11 @@ +/* + * Copyright (C) 2018 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. + */ + char TryteAlphabet[] = "9ABCDEFGHIJKLMNOPQRSTUVWXYZ"; const int indices[] = { diff --git a/src/constants.h b/src/constants.h index 04ef2f8..42b96be 100644 --- a/src/constants.h +++ b/src/constants.h @@ -1,3 +1,11 @@ +/* + * Copyright (C) 2018-2019 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. + */ + #ifndef CONSTANTS_H_ #define CONSTANTS_H_ diff --git a/src/cpu-utils.h b/src/cpu-utils.h index 5d06150..52f308c 100644 --- a/src/cpu-utils.h +++ b/src/cpu-utils.h @@ -1,7 +1,9 @@ /* - * Copyright (C) 2018 dcurl Developers. - * Use of this source code is governed by MIT license that can be - * found in the LICENSE file. + * Copyright (C) 2018 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. */ #include diff --git a/src/curl.c b/src/curl.c index e587340..bc18a59 100644 --- a/src/curl.c +++ b/src/curl.c @@ -1,7 +1,9 @@ /* - * Copyright (C) 2018 dcurl Developers. - * Use of this source code is governed by MIT license that can be - * found in the LICENSE file. + * Copyright (C) 2018-2019 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. */ #include "curl.h" diff --git a/src/curl.h b/src/curl.h index 94d775c..c431855 100644 --- a/src/curl.h +++ b/src/curl.h @@ -1,3 +1,11 @@ +/* + * Copyright (C) 2018 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. + */ + #ifndef CURL_H_ #define CURL_H_ diff --git a/src/dcurl.c b/src/dcurl.c index 88235da..cb54bec 100644 --- a/src/dcurl.c +++ b/src/dcurl.c @@ -1,7 +1,9 @@ /* - * Copyright (C) 2018 dcurl Developers. - * Use of this source code is governed by MIT license that can be - * found in the LICENSE file. + * Copyright (C) 2018-2019 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. */ #include "dcurl.h" diff --git a/src/dcurl.h b/src/dcurl.h index fbf36bf..f5b67e5 100644 --- a/src/dcurl.h +++ b/src/dcurl.h @@ -1,3 +1,11 @@ +/* + * Copyright (C) 2018-2019 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. + */ + #ifndef DCURL_H_ #define DCURL_H_ diff --git a/src/implcontext.c b/src/implcontext.c index 711f884..999bac3 100644 --- a/src/implcontext.c +++ b/src/implcontext.c @@ -1,3 +1,11 @@ +/* + * Copyright (C) 2018-2019 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. + */ + #include "implcontext.h" #include @@ -16,7 +24,7 @@ bool initializeImplContext(ImplContext *impl_ctx) bool res = impl_ctx->initialize(impl_ctx); if (res) { ddprintf(MSG_PREFIX "Implementation %s is initialized successfully\n", - impl_ctx->description); + impl_ctx->description); } return res; } diff --git a/src/implcontext.h b/src/implcontext.h index 9a406ce..65495e7 100644 --- a/src/implcontext.h +++ b/src/implcontext.h @@ -1,3 +1,11 @@ +/* + * Copyright (C) 2018-2019 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. + */ + #ifndef IMPL_CTX_H_ #define IMPL_CTX_H_ diff --git a/src/list.h b/src/list.h index dd8f2aa..8630c46 100644 --- a/src/list.h +++ b/src/list.h @@ -1,7 +1,9 @@ /* - * Copyright (C) 2018 dcurl Developers. - * Use of this source code is governed by MIT license that can be - * found in the LICENSE file. + * Copyright (C) 2018-2019 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. */ /* Linux-like double-linked list implementation */ diff --git a/src/pow_avx.c b/src/pow_avx.c index 1feb72b..dbc7325 100644 --- a/src/pow_avx.c +++ b/src/pow_avx.c @@ -1,8 +1,10 @@ /* - * Copyright (C) 2018 dcurl Developers. - * Copyright (C) 2016 Shinya Yagyu. - * Use of this source code is governed by MIT license that can be - * found in the LICENSE file. + * Copyright (C) 2018-2019 BiiLabs Co., Ltd. and Contributors + * Copyright (C) 2016 Shinya Yagyu + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. */ #include "pow_avx.h" @@ -29,8 +31,8 @@ static void transform256(__m256i *lmid, __m256i *hmid) alpha = lfrom[t1]; beta = hfrom[t1]; - delta = _mm256_and_si256( alpha, _mm256_xor_si256(lfrom[t2], beta)); - /* alpha & (lfrom[t2] ^ beta) */ + delta = _mm256_and_si256(alpha, _mm256_xor_si256(lfrom[t2], beta)); + /* alpha & (lfrom[t2] ^ beta) */ lto[j] = _mm256_andnot_si256(delta, one); /* ~delta */ hto[j] = _mm256_or_si256(_mm256_xor_si256(alpha, hfrom[t2]), delta); /* (alpha ^ hfrom[t2]) | delta */ @@ -46,8 +48,8 @@ static void transform256(__m256i *lmid, __m256i *hmid) t2 = indices[j + 1]; alpha = lfrom[t1]; beta = hfrom[t1]; - delta = _mm256_and_si256( alpha, _mm256_xor_si256(lfrom[t2], beta)); - /* alpha & (lfrom[t2] ^ beta) */ + delta = _mm256_and_si256(alpha, _mm256_xor_si256(lfrom[t2], beta)); + /* alpha & (lfrom[t2] ^ beta) */ lto[j] = _mm256_andnot_si256(delta, one); /* ~delta */ hto[j] = _mm256_or_si256(_mm256_xor_si256(alpha, hfrom[t2]), delta); /* (alpha ^ hfrom[t2]) | delta */ @@ -226,7 +228,7 @@ static void transform256(__m256d *lmid, __m256d *hmid) alpha = lfrom[t1]; beta = hfrom[t1]; delta = _mm256_and_pd(alpha, _mm256_xor_pd(lfrom[t2], beta)); - /* alpha & (lfrom[t2] ^ beta) */ + /* alpha & (lfrom[t2] ^ beta) */ lto[j] = _mm256_andnot_pd(delta, one); /* ~delta */ hto[j] = _mm256_or_pd(_mm256_xor_pd(alpha, hfrom[t2]), delta); /* (alpha ^ hfrom[t2]) | delta */ @@ -244,7 +246,7 @@ static void transform256(__m256d *lmid, __m256d *hmid) alpha = lfrom[t1]; beta = hfrom[t1]; delta = _mm256_and_pd(alpha, _mm256_xor_pd(lfrom[t2], beta)); - /* alpha & (lfrom[t2] ^ beta) */ + /* alpha & (lfrom[t2] ^ beta) */ lto[j] = _mm256_andnot_pd(delta, one); /* ~delta */ hto[j] = _mm256_or_pd(_mm256_xor_pd(alpha, hfrom[t2]), delta); /* (alpha ^ hfrom[t2]) | delta */ diff --git a/src/pow_c.c b/src/pow_c.c index 640b659..910bcdb 100644 --- a/src/pow_c.c +++ b/src/pow_c.c @@ -1,8 +1,10 @@ /* - * Copyright (C) 2018 dcurl Developers. - * Copyright (C) 2016 Shinya Yagyu. - * Use of this source code is governed by MIT license that can be - * found in the LICENSE file. + * Copyright (C) 2018-2019 BiiLabs Co., Ltd. and Contributors + * Copyright (C) 2016 Shinya Yagyu + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. */ #include "pow_c.h" diff --git a/src/pow_c.h b/src/pow_c.h index 546a6db..bab7478 100644 --- a/src/pow_c.h +++ b/src/pow_c.h @@ -1,3 +1,11 @@ +/* + * Copyright (C) 2018-2019 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. + */ + #ifndef POW_C_H_ #define POW_C_H_ diff --git a/src/pow_cl.c b/src/pow_cl.c index 429d94a..a73d6a0 100644 --- a/src/pow_cl.c +++ b/src/pow_cl.c @@ -1,8 +1,10 @@ /* - * Copyright (C) 2018 dcurl Developers. - * Copyright (C) 2017 IOTA AS, IOTA Foundation and Developers. - * Use of this source code is governed by MIT license that can be - * found in the LICENSE file. + * Copyright (C) 2018-2019 BiiLabs Co., Ltd. and Contributors + * Copyright (C) 2017 IOTA AS, IOTA Foundation and Developers + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. */ #include "pow_cl.h" diff --git a/src/pow_cl.h b/src/pow_cl.h index 50d5876..34c2cd7 100644 --- a/src/pow_cl.h +++ b/src/pow_cl.h @@ -1,3 +1,11 @@ +/* + * Copyright (C) 2018-2019 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. + */ + #ifndef POW_CL_H_ #define POW_CL_H_ diff --git a/src/pow_fpga_accel.c b/src/pow_fpga_accel.c index eb4a644..1f20499 100644 --- a/src/pow_fpga_accel.c +++ b/src/pow_fpga_accel.c @@ -1,8 +1,10 @@ /* - * Copyright (C) 2018 dcurl Developers. - * Copyright (c) 2018 Ievgen Korokyi. - * Use of this source code is governed by MIT license that can be - * found in the LICENSE file. + * Copyright (C) 2018-2019 BiiLabs Co., Ltd. and Contributors + * Copyright (c) 2018 Ievgen Korokyi + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. */ #include "pow_fpga_accel.h" diff --git a/src/pow_fpga_accel.h b/src/pow_fpga_accel.h index bb1eaa0..119018c 100644 --- a/src/pow_fpga_accel.h +++ b/src/pow_fpga_accel.h @@ -1,3 +1,11 @@ +/* + * Copyright (C) 2018-2019 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. + */ + #ifndef POW_FPGA_ACCEL_H_ #define POW_FPGA_ACCEL_H_ diff --git a/src/pow_kernel.cl b/src/pow_kernel.cl index 32b7946..55295b1 100644 --- a/src/pow_kernel.cl +++ b/src/pow_kernel.cl @@ -1,7 +1,9 @@ /* - * Copyright (C) 2017 IOTA AS, IOTA Foundation and Developers. - * Use of this source code is governed by MIT license that can be - * found in the LICENSE file. + * Copyright (C) 2017 IOTA AS, IOTA Foundation and Developers + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. */ #define HASH_TRITS_LENGTH 243 diff --git a/src/pow_sse.c b/src/pow_sse.c index cec30d1..a6a0a2a 100644 --- a/src/pow_sse.c +++ b/src/pow_sse.c @@ -1,8 +1,10 @@ /* - * Copyright (C) 2018 dcurl Developers. - * Copyright (C) 2016 Shinya Yagyu. - * Use of this source code is governed by MIT license that can be - * found in the LICENSE file. + * Copyright (C) 2018-2019 BiiLabs Co., Ltd. and Contributors + * Copyright (C) 2016 Shinya Yagyu + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. */ #include "pow_sse.h" diff --git a/src/pow_sse.h b/src/pow_sse.h index 73e5af7..4216b59 100644 --- a/src/pow_sse.h +++ b/src/pow_sse.h @@ -1,3 +1,11 @@ +/* + * Copyright (C) 2018-2019 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. + */ + #ifndef POW_SSE_H_ #define POW_SSE_H_ diff --git a/src/remote_common.c b/src/remote_common.c index 9a39669..2847af9 100644 --- a/src/remote_common.c +++ b/src/remote_common.c @@ -1,7 +1,9 @@ /* - * Copyright (C) 2019 dcurl Developers. - * Use of this source code is governed by MIT license that can be - * found in the LICENSE file. + * Copyright (C) 2019 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. */ #include "remote_common.h" @@ -21,8 +23,7 @@ bool die_on_amqp_error(amqp_rpc_reply_t x, char const *context) break; case AMQP_RESPONSE_LIBRARY_EXCEPTION: - ddprintf("%s: %s\n", context, - amqp_error_string2(x.library_error)); + ddprintf("%s: %s\n", context, amqp_error_string2(x.library_error)); break; case AMQP_RESPONSE_SERVER_EXCEPTION: @@ -31,20 +32,20 @@ bool die_on_amqp_error(amqp_rpc_reply_t x, char const *context) amqp_connection_close_t *m = (amqp_connection_close_t *) x.reply.decoded; ddprintf("%s: server connection error %uh, message: %.*s\n", - context, m->reply_code, (int) m->reply_text.len, - (char *) m->reply_text.bytes); + context, m->reply_code, (int) m->reply_text.len, + (char *) m->reply_text.bytes); break; } case AMQP_CHANNEL_CLOSE_METHOD: { amqp_channel_close_t *m = (amqp_channel_close_t *) x.reply.decoded; - ddprintf("%s: server channel error %uh, message: %.*s\n", - context, m->reply_code, (int) m->reply_text.len, - (char *) m->reply_text.bytes); + ddprintf("%s: server channel error %uh, message: %.*s\n", context, + m->reply_code, (int) m->reply_text.len, + (char *) m->reply_text.bytes); break; } default: - ddprintf("%s: unknown server error, method id 0x%08X\n", - context, x.reply.id); + ddprintf("%s: unknown server error, method id 0x%08X\n", context, + x.reply.id); break; } break; @@ -84,8 +85,7 @@ bool connect_broker(amqp_connection_state_t *conn) /* Open the channel in the rabbitmq broker */ amqp_channel_open(*conn, 1); - if (!(die_on_amqp_error(amqp_get_rpc_reply(*conn), - "Opennng the channel"))) + if (!(die_on_amqp_error(amqp_get_rpc_reply(*conn), "Opennng the channel"))) goto channel_close; return true; @@ -196,12 +196,14 @@ bool wait_response_message(amqp_connection_state_t *conn, if (!die_on_amqp_error(amqp_get_rpc_reply(*conn), "Wait method frame")) return false; - ddprintf(MSG_PREFIX "Frame type: %u channel: %u\n", frame.frame_type, frame.channel); + ddprintf(MSG_PREFIX "Frame type: %u channel: %u\n", frame.frame_type, + frame.channel); if (frame.frame_type != AMQP_FRAME_METHOD) continue; - ddprintf(MSG_PREFIX "Method: %s\n", amqp_method_name(frame.payload.method.id)); + ddprintf(MSG_PREFIX "Method: %s\n", + amqp_method_name(frame.payload.method.id)); if (frame.payload.method.id != AMQP_BASIC_DELIVER_METHOD) continue; @@ -209,9 +211,9 @@ bool wait_response_message(amqp_connection_state_t *conn, #if defined(ENABLE_DEBUG) d = (amqp_basic_deliver_t *) frame.payload.method.decoded; ddprintf(MSG_PREFIX "Delivery: %u exchange: %.*s routingkey: %.*s\n", - (unsigned) d->delivery_tag, (int) d->exchange.len, - (char *) d->exchange.bytes, (int) d->routing_key.len, - (char *) d->routing_key.bytes); + (unsigned) d->delivery_tag, (int) d->exchange.len, + (char *) d->exchange.bytes, (int) d->routing_key.len, + (char *) d->routing_key.bytes); #endif amqp_maybe_release_buffers(*conn); @@ -231,8 +233,8 @@ bool wait_response_message(amqp_connection_state_t *conn, #if defined(ENABLE_DEBUG) p = (amqp_basic_properties_t *) frame.payload.properties.decoded; if (p->_flags & AMQP_BASIC_CONTENT_TYPE_FLAG) { - ddprintf(MSG_PREFIX "Content-type: %.*s\n", (int) p->content_type.len, - (char *) p->content_type.bytes); + ddprintf(MSG_PREFIX "Content-type: %.*s\n", + (int) p->content_type.len, (char *) p->content_type.bytes); } #endif ddprintf("---\n"); @@ -241,7 +243,7 @@ bool wait_response_message(amqp_connection_state_t *conn, body_received = 0; while (body_received < body_target) { if (!die_on_error(amqp_simple_wait_frame_noblock(*conn, &frame, &t), - "RPC timeout")) + "RPC timeout")) return false; if (!die_on_amqp_error(amqp_get_rpc_reply(*conn), @@ -263,8 +265,9 @@ bool wait_response_message(amqp_connection_state_t *conn, memcpy(frame_body, (char *) frame.payload.body_fragment.bytes, body_len); - ddprintf(MSG_PREFIX "PoW result: %.*s", (int) frame.payload.body_fragment.len, - (char *) frame.payload.body_fragment.bytes); + ddprintf(MSG_PREFIX "PoW result: %.*s", + (int) frame.payload.body_fragment.len, + (char *) frame.payload.body_fragment.bytes); /* everything was fine, we can quit now because we received the reply */ return true; diff --git a/src/remote_common.h b/src/remote_common.h index a063601..cb1805e 100644 --- a/src/remote_common.h +++ b/src/remote_common.h @@ -1,3 +1,11 @@ +/* + * Copyright (C) 2019 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. + */ + #ifndef REMOTE_COMMON_H_ #define REMOTE_COMMON_H_ diff --git a/src/remote_interface.c b/src/remote_interface.c index 76f0c6f..da326c4 100644 --- a/src/remote_interface.c +++ b/src/remote_interface.c @@ -1,7 +1,9 @@ /* - * Copyright (C) 2019 dcurl Developers. - * Use of this source code is governed by MIT license that can be - * found in the LICENSE file. + * Copyright (C) 2019 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. */ #include "remote_interface.h" @@ -13,7 +15,7 @@ bool initializeRemoteContext(RemoteImplContext *remote_ctx) bool res = remote_ctx->initialize(remote_ctx); if (res) { ddprintf(MSG_PREFIX "Implementation %s is initialized successfully\n", - remote_ctx->description); + remote_ctx->description); } return res; } @@ -109,16 +111,17 @@ static bool Remote_doPoW(RemoteImplContext *remote_ctx, void *pow_ctx) sprintf(buf, "%d", ctx->mwm); memcpy(messagebody + TRANSACTION_TRYTES_LENGTH, buf, 4); - if (!declare_callback_queue(&remote_ctx->conn[ctx->indexOfContext], 1, &reply_to_queue)) + if (!declare_callback_queue(&remote_ctx->conn[ctx->indexOfContext], 1, + &reply_to_queue)) goto fail; - if (!publish_message_with_reply_to(&remote_ctx->conn[ctx->indexOfContext], 1, - "incoming_queue", reply_to_queue, + if (!publish_message_with_reply_to(&remote_ctx->conn[ctx->indexOfContext], + 1, "incoming_queue", reply_to_queue, messagebody)) goto fail; - if (!wait_response_message(&remote_ctx->conn[ctx->indexOfContext], 1, reply_to_queue, - (char *) (ctx->output_trytes), + if (!wait_response_message(&remote_ctx->conn[ctx->indexOfContext], 1, + reply_to_queue, (char *) (ctx->output_trytes), TRANSACTION_TRYTES_LENGTH)) goto fail; @@ -142,8 +145,7 @@ static bool Remote_init(RemoteImplContext *remote_ctx) memset(remote_ctx->slots, 0, remote_ctx->num_max_thread * sizeof(bool)); - for(int i = 0 ; i < CONN_MAX; i++) - { + for (int i = 0; i < CONN_MAX; i++) { if (!connect_broker(&remote_ctx->conn[i])) goto fail_to_init; } @@ -164,7 +166,7 @@ static void Remote_destroy(RemoteImplContext *remote_ctx) { PoW_Remote_Context *ctx = (PoW_Remote_Context *) remote_ctx->context; - for(int i = 0; i < CONN_MAX; i++) + for (int i = 0; i < CONN_MAX; i++) disconnect_broker(&remote_ctx->conn[i]); free(ctx); diff --git a/src/remote_interface.h b/src/remote_interface.h index 0851984..07c5411 100644 --- a/src/remote_interface.h +++ b/src/remote_interface.h @@ -1,3 +1,11 @@ +/* + * Copyright (C) 2019 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. + */ + #ifndef REMOTE_INTERFACE_H_ #define REMOTE_INTERFACE_H_ diff --git a/src/remote_worker.c b/src/remote_worker.c index 12c9136..f8df527 100644 --- a/src/remote_worker.c +++ b/src/remote_worker.c @@ -1,13 +1,15 @@ /* - * Copyright (C) 2019 dcurl Developers. - * Use of this source code is governed by MIT license that can be - * found in the LICENSE file. + * Copyright (C) 2019 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. */ +#include "common.h" #include "constants.h" #include "dcurl.h" #include "remote_common.h" -#include "common.h" int main(int argc, char const *const *argv) { @@ -30,7 +32,9 @@ int main(int argc, char const *const *argv) if (!consume_message(&conn, 1, &envelope)) goto fail; - ddprintf(MSG_PREFIX "Delivery %u, exchange %.*s, routingkey %.*s, callback queue: %s " + ddprintf( + MSG_PREFIX + "Delivery %u, exchange %.*s, routingkey %.*s, callback queue: %s " "\n", (unsigned) envelope.delivery_tag, (int) envelope.exchange.len, (char *) envelope.exchange.bytes, (int) envelope.routing_key.len, @@ -38,8 +42,8 @@ int main(int argc, char const *const *argv) (char *) envelope.message.properties.reply_to.bytes); if (envelope.message.properties._flags & AMQP_BASIC_CONTENT_TYPE_FLAG) { ddprintf(MSG_PREFIX "Content-type: %.*s\n", - (int) envelope.message.properties.content_type.len, - (char *) envelope.message.properties.content_type.bytes); + (int) envelope.message.properties.content_type.len, + (char *) envelope.message.properties.content_type.bytes); } /* Message body format: transacton | mwm */ @@ -59,14 +63,14 @@ int main(int argc, char const *const *argv) /* Publish a message of remote PoW result */ if (!publish_message( - &conn, 1, - (char *) envelope.message.properties.reply_to.bytes, + &conn, 1, (char *) envelope.message.properties.reply_to.bytes, (char *) ret_trytes)) goto fail; free(ret_trytes); amqp_destroy_envelope(&envelope); - ddprintf(MSG_PREFIX "Publishing PoW result to callback queue is done\n"); + ddprintf(MSG_PREFIX + "Publishing PoW result to callback queue is done\n"); ddprintf(MSG_PREFIX "---\n"); } diff --git a/src/trinary.c b/src/trinary.c index ac12e87..ad75e85 100644 --- a/src/trinary.c +++ b/src/trinary.c @@ -1,7 +1,9 @@ /* - * Copyright (C) 2018 dcurl Developers. - * Use of this source code is governed by MIT license that can be - * found in the LICENSE file. + * Copyright (C) 2018-2019 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. */ #include "trinary.h" diff --git a/src/trinary.h b/src/trinary.h index 44dacc9..f01cffc 100644 --- a/src/trinary.h +++ b/src/trinary.h @@ -1,3 +1,11 @@ +/* + * Copyright (C) 2018 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. + */ + #ifndef TRINARY_H_ #define TRINARY_H_ diff --git a/src/trinary_sse42.h b/src/trinary_sse42.h index 33f3c3e..9f4684f 100644 --- a/src/trinary_sse42.h +++ b/src/trinary_sse42.h @@ -1,3 +1,11 @@ +/* + * Copyright (C) 2019 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. + */ + #ifndef TRINARY_SSE42_H_ #define TRINARY_SSE42_H_ diff --git a/tests/common.h b/tests/common.h index 2543ec0..62f3ad0 100644 --- a/tests/common.h +++ b/tests/common.h @@ -1,3 +1,11 @@ +/* + * Copyright (C) 2018-2019 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. + */ + #ifndef TEST_COMMON_H #define TEST_COMMON_H diff --git a/tests/test-curl.c b/tests/test-curl.c index 81f1315..dca9a96 100644 --- a/tests/test-curl.c +++ b/tests/test-curl.c @@ -1,3 +1,11 @@ +/* + * Copyright (C) 2018-2019 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. + */ + #include "common.h" int main() diff --git a/tests/test-dcurl.c b/tests/test-dcurl.c index fcee3bd..3fb5a10 100644 --- a/tests/test-dcurl.c +++ b/tests/test-dcurl.c @@ -1,3 +1,11 @@ +/* + * Copyright (C) 2018-2019 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. + */ + /* Test program for dcurl */ #include "common.h" #include "dcurl.h" diff --git a/tests/test-multi-pow.c b/tests/test-multi-pow.c index ac9a876..df77c72 100644 --- a/tests/test-multi-pow.c +++ b/tests/test-multi-pow.c @@ -1,3 +1,11 @@ +/* + * Copyright (C) 2019 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. + */ + /* Test program for thread-safe dcurl */ #include #include "common.h" @@ -16,8 +24,7 @@ void *dcurl_entry_cb(void *arg) { dcurl_item *item = (dcurl_item *) arg; /* test dcurl Implementation with mwm = 14 */ - int8_t *ret_trytes = - dcurl_entry(item->input_trytes, item->mwm, 8); + int8_t *ret_trytes = dcurl_entry(item->input_trytes, item->mwm, 8); assert(ret_trytes && "dcurl_entry() failed"); memcpy(item->output_trytes, ret_trytes, TRANSACTION_TRYTES_LENGTH); free(ret_trytes); @@ -77,8 +84,7 @@ int main() for (int i = 0; i < THREAD_MAX; i++) { memcpy(items[i].input_trytes, trytes, TRANSACTION_TRYTES_LENGTH); items[i].mwm = mwm; - pthread_create(&threads[i], NULL, dcurl_entry_cb, - (void *) &items[i]); + pthread_create(&threads[i], NULL, dcurl_entry_cb, (void *) &items[i]); } for (int i = 0; i < THREAD_MAX; i++) diff --git a/tests/test-pow.c b/tests/test-pow.c index 522a169..9666914 100644 --- a/tests/test-pow.c +++ b/tests/test-pow.c @@ -1,3 +1,11 @@ +/* + * Copyright (C) 2018-2019 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. + */ + /* Test program for pow_*.c */ #include "common.h" #include "implcontext.h" diff --git a/tests/test-trinary.c b/tests/test-trinary.c index d5cfbc2..b69079a 100644 --- a/tests/test-trinary.c +++ b/tests/test-trinary.c @@ -1,3 +1,11 @@ +/* + * Copyright (C) 2018-2019 BiiLabs Co., Ltd. and Contributors + * All Rights Reserved. + * This is free software; you can redistribute it and/or modify it under the + * terms of the MIT license. A copy of the license can be found in the file + * "LICENSE" at the root of this distribution. + */ + #include "common.h" int main() From d99addb6b0d64ff35f29bd5c6f4bf43722d486fb Mon Sep 17 00:00:00 2001 From: marktwtn Date: Fri, 28 Jun 2019 15:02:22 +0800 Subject: [PATCH 02/15] fix: fix build error with BUILD_REMOTE and BUILD_JNI enabled The JNI related object file is included in the remote worker related object files if the build options BUILD_REMOTE and BUILD_JNI are enabled. This should not happen and it causes the building error. The commit make sure the un-related object files would not be included. Close #166. --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6c4d100..ebd4766 100644 --- a/Makefile +++ b/Makefile @@ -152,7 +152,11 @@ OBJS += \ remote_common.o \ remote_interface.o -WORKER_OBJS := $(addprefix $(OUT)/worker-,$(filter-out remote_interface.o, $(OBJS))) +WORKER_EXCLUDE_OBJS := remote_interface.o +ifeq ("$(BUILD_JNI)", "1") +WORKER_EXCLUDE_OBJS += jni/iri-pearldiver-exlib.o +endif +WORKER_OBJS := $(addprefix $(OUT)/worker-,$(filter-out $(WORKER_EXCLUDE_OBJS), $(OBJS))) WORKER_CFLAGS := $(filter-out -DENABLE_REMOTE, $(CFLAGS)) endif From 5f881fa2454e762f3ede266d2f34362563c9dc42 Mon Sep 17 00:00:00 2001 From: marktwtn Date: Wed, 3 Jul 2019 22:08:26 +0800 Subject: [PATCH 03/15] fix(build): Use RabbitMQ object files instead of shared library The final generated libdcurl.so should be able to use the submodule projects directly without any dynamic linking. Otherwise, the integration with IRI would fail. Since dcurl builds with the object files of the submodule projects, the variable naming is changed from _LIBRARY to _OBJS. Close #152. --- Makefile | 8 ++++---- mk/remote.mk | 4 ++-- mk/submodule.mk | 18 +++++------------- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index ebd4766..8d76a3c 100644 --- a/Makefile +++ b/Makefile @@ -170,13 +170,13 @@ $(OUT)/%.o: $(SRC)/%.c $(LIBTUV_PATH)/include $(LIBRABBITMQ_PATH)/build/include $(VECHO) " CC\t$@\n" $(Q)$(CC) -o $@ $(CFLAGS) $(LIBTUV_INCLUDE) $(LIBRABBITMQ_INCLUDE) -c -MMD -MF $@.d $< -$(OUT)/test-%: $(OUT)/test-%.o $(OBJS) $(LIBTUV_LIBRARY) $(LIBRABBITMQ_LIBRARY) +$(OUT)/test-%: $(OUT)/test-%.o $(OBJS) $(LIBTUV_OBJS) $(LIBRABBITMQ_OBJS) $(VECHO) " LD\t$@\n" - $(Q)$(CC) -o $@ $^ $(LDFLAGS) $(LIBRABBITMQ_LINK) + $(Q)$(CC) -o $@ $^ $(LDFLAGS) -$(OUT)/libdcurl.so: $(OBJS) $(LIBTUV_LIBRARY) $(LIBRABBITMQ_LIBRARY) +$(OUT)/libdcurl.so: $(OBJS) $(LIBTUV_OBJS) $(LIBRABBITMQ_OBJS) $(VECHO) " LD\t$@\n" - $(Q)$(CC) -shared -o $@ $^ $(LDFLAGS) $(LIBRABBITMQ_LINK) + $(Q)$(CC) -shared -o $@ $^ $(LDFLAGS) ifeq ("$(BUILD_REMOTE)", "1") include mk/remote.mk diff --git a/mk/remote.mk b/mk/remote.mk index 667f8e7..06f1a9a 100644 --- a/mk/remote.mk +++ b/mk/remote.mk @@ -3,6 +3,6 @@ $(OUT)/worker-%.o: $(SRC)/%.c $(LIBTUV_PATH)/include $(LIBRABBITMQ_PATH)/build/i $(VECHO) " CC\t$@\n" $(Q)$(CC) -o $@ $(WORKER_CFLAGS) $(LIBTUV_INCLUDE) $(LIBRABBITMQ_INCLUDE) -c -MMD -MF $@.d $< -$(OUT)/remote-worker: $(OUT)/remote_worker.o $(WORKER_OBJS) $(LIBTUV_LIBRARY) $(LIBRABBITMQ_LIBRARY) +$(OUT)/remote-worker: $(OUT)/remote_worker.o $(WORKER_OBJS) $(LIBTUV_OBJS) $(LIBRABBITMQ_OBJS) $(VECHO) " LD\t$@\n" - $(Q)$(CC) -o $@ $^ $(LDFLAGS) $(LIBRABBITMQ_LINK) + $(Q)$(CC) -o $@ $^ $(LDFLAGS) diff --git a/mk/submodule.mk b/mk/submodule.mk index 12c7164..65274d5 100644 --- a/mk/submodule.mk +++ b/mk/submodule.mk @@ -18,27 +18,19 @@ LIBTUV_PATH = deps/libtuv LIBTUV_INCLUDE := -I $(LIBTUV_PATH)/include LIBTUV_PLATFORM := $(UNAME_M)-$(UNAME_S) LIBTUV_BOARD := $(BOARD) -# PIC (Position-Independent-Code) library -LIBTUV_LIBRARY := $(LIBTUV_PATH)/build/$(LIBTUV_PLATFORM)/release/lib/libtuv.o +# PIC (Position-Independent-Code) object file +LIBTUV_OBJS := $(LIBTUV_PATH)/build/$(LIBTUV_PLATFORM)/release/lib/libtuv.o $(LIBTUV_PATH)/include: git submodule update --init $(LIBTUV_PATH) -$(LIBTUV_LIBRARY): +$(LIBTUV_OBJS): $(MAKE) -C $(LIBTUV_PATH) TUV_BUILD_TYPE=release TUV_CREATE_PIC_LIB=yes TUV_PLATFORM=$(LIBTUV_PLATFORM) TUV_BOARD=$(LIBTUV_BOARD) # librabbitmq related variables LIBRABBITMQ_PATH = deps/rabbitmq-c LIBRABBITMQ_INCLUDE := -I $(LIBRABBITMQ_PATH)/build/include -LIBRABBITMQ_LIB_PATH := $(LIBRABBITMQ_PATH)/build/librabbitmq/ -ifeq ($(UNAME_S),darwin) - # macOS - LIBRABBITMQ_LINK := -Wl,-rpath,$(LIBRABBITMQ_LIB_PATH) -L$(LIBRABBITMQ_LIB_PATH) -lrabbitmq - LIBRABBITMQ_LIBRARY := $(LIBRABBITMQ_LIB_PATH)/librabbitmq.dylib -else - LIBRABBITMQ_LINK := -Wl,-rpath=$(LIBRABBITMQ_LIB_PATH) -L$(LIBRABBITMQ_LIB_PATH) -lrabbitmq - LIBRABBITMQ_LIBRARY := $(LIBRABBITMQ_LIB_PATH)/librabbitmq.so -endif +LIBRABBITMQ_OBJS := $(LIBRABBITMQ_PATH)/build/librabbitmq/CMakeFiles/rabbitmq.dir/*.o $(LIBRABBITMQ_PATH)/build/include: git submodule update --init $(LIBRABBITMQ_PATH) @@ -54,6 +46,6 @@ else cmake --build . --target install endif -$(LIBRABBITMQ_LIBRARY): +$(LIBRABBITMQ_OBJS): cd $(LIBRABBITMQ_PATH)/build && \ cmake --build . From 75d24484b984f8bf8f2fc8742dd0e90565b2f6f8 Mon Sep 17 00:00:00 2001 From: marktwtn Date: Sat, 6 Jul 2019 00:36:31 +0800 Subject: [PATCH 04/15] build(macOS): Set the correct linker flags for macOS --- mk/submodule.mk | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mk/submodule.mk b/mk/submodule.mk index 65274d5..25b4c40 100644 --- a/mk/submodule.mk +++ b/mk/submodule.mk @@ -31,6 +31,10 @@ $(LIBTUV_OBJS): LIBRABBITMQ_PATH = deps/rabbitmq-c LIBRABBITMQ_INCLUDE := -I $(LIBRABBITMQ_PATH)/build/include LIBRABBITMQ_OBJS := $(LIBRABBITMQ_PATH)/build/librabbitmq/CMakeFiles/rabbitmq.dir/*.o +ifeq ($(UNAME_S),darwin) + OPENSSL_PATH := /usr/local/opt/openssl + LDFLAGS += -L$(OPENSSL_PATH)/lib -lcrypto -lssl +endif $(LIBRABBITMQ_PATH)/build/include: git submodule update --init $(LIBRABBITMQ_PATH) @@ -38,7 +42,7 @@ $(LIBRABBITMQ_PATH)/build/include: ifeq ($(UNAME_S),darwin) # macOS cd $(LIBRABBITMQ_PATH)/build && \ - cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/ -DCMAKE_INSTALL_PREFIX=. .. && \ + cmake -DOPENSSL_ROOT_DIR=$(OPENSSL_PATH) -DCMAKE_INSTALL_PREFIX=. .. && \ cmake --build . --target install else cd $(LIBRABBITMQ_PATH)/build && \ From 590d37c4720544e0793c1bddd0587ff5e1e7a9a6 Mon Sep 17 00:00:00 2001 From: marktwtn Date: Fri, 19 Jul 2019 11:38:17 +0800 Subject: [PATCH 05/15] docs: Add new and mark deprecated build option --- docs/build-n-test.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/build-n-test.md b/docs/build-n-test.md index 04982b8..ce2e615 100644 --- a/docs/build-n-test.md +++ b/docs/build-n-test.md @@ -17,9 +17,10 @@ - ``BUILD_SSE``: build the Intel SSE-accelerated Curl backend. - ``BUILD_GPU``: build the OpenCL-based GPU accelerations. - ``BUILD_FPGA_ACCEL``: build the interface interacting with the Cyclone V FPGA based accelerator. Verified on DE10-nano board and Arrow SoCKit board. + - ``BUILD_REMOTE``: build with the remote interface and create the remote worker executable for calculating PoW on remote devices. - ``BUILD_JNI``: build a JAR file including the shared library and the JAVA bytecode for IRI. The build system would generate JNI header file downloading from [latest JAVA source](https://github.com/DLTcollab/iri). - - ``BUILD_COMPAT``: build extra cCurl compatible interface. + - ``BUILD_COMPAT``: build extra cCurl compatible interface. **[deprecated]** - ``BUILD_STAT``: show the statistics of the PoW information. - ``BUILD_DEBUG``: dump verbose messages internally. Build with the corresponding Sanitizer to detect software potential bugs if the value is `address`, `undefined` or `thread`. From f6cf152e52c5f302d31ba153c97f5323530837c7 Mon Sep 17 00:00:00 2001 From: marktwtn Date: Sun, 14 Jul 2019 19:30:35 +0800 Subject: [PATCH 06/15] build: Exclude RabbitMQ when BUILD_REMOTE is off When the build option BUILD_REMOTE is off, the RabbitMQ should not be compiled and included in the generated files. Makefile modification: - Extract the steps of submodule initialization and update - Combine and create the submodule related variables Close #169. --- Makefile | 14 +++++++------- mk/common.mk | 2 +- mk/remote.mk | 6 +++--- mk/submodule.mk | 24 ++++++++++++++++++++---- 4 files changed, 31 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 8d76a3c..0a42915 100644 --- a/Makefile +++ b/Makefile @@ -99,7 +99,7 @@ LIBS := $(addprefix $(OUT)/, $(LIBS)) JARS := dcurljni-$(VERSION).jar JARS := $(addprefix $(OUT)/, $(JARS)) -PREQ := config $(TESTS) $(LIBS) +PREQ := $(SUBS) config $(TESTS) $(LIBS) ifeq ("$(BUILD_JNI)","1") PREQ += $(JARS) endif @@ -162,19 +162,19 @@ endif OBJS := $(addprefix $(OUT)/, $(OBJS)) -$(OUT)/test-%.o: tests/test-%.c $(LIBTUV_PATH)/include +$(OUT)/test-%.o: tests/test-%.c $(VECHO) " CC\t$@\n" - $(Q)$(CC) -o $@ $(CFLAGS) -I $(SRC) $(LIBTUV_INCLUDE) -c -MMD -MF $@.d $< + $(Q)$(CC) -o $@ $(CFLAGS) -I $(SRC) $(SUB_INCLUDE) -c -MMD -MF $@.d $< -$(OUT)/%.o: $(SRC)/%.c $(LIBTUV_PATH)/include $(LIBRABBITMQ_PATH)/build/include +$(OUT)/%.o: $(SRC)/%.c $(SUB_OBJS) $(VECHO) " CC\t$@\n" - $(Q)$(CC) -o $@ $(CFLAGS) $(LIBTUV_INCLUDE) $(LIBRABBITMQ_INCLUDE) -c -MMD -MF $@.d $< + $(Q)$(CC) -o $@ $(CFLAGS) $(SUB_INCLUDE) -c -MMD -MF $@.d $< -$(OUT)/test-%: $(OUT)/test-%.o $(OBJS) $(LIBTUV_OBJS) $(LIBRABBITMQ_OBJS) +$(OUT)/test-%: $(OUT)/test-%.o $(OBJS) $(SUB_OBJS) $(VECHO) " LD\t$@\n" $(Q)$(CC) -o $@ $^ $(LDFLAGS) -$(OUT)/libdcurl.so: $(OBJS) $(LIBTUV_OBJS) $(LIBRABBITMQ_OBJS) +$(OUT)/libdcurl.so: $(OBJS) $(SUB_OBJS) $(VECHO) " LD\t$@\n" $(Q)$(CC) -shared -o $@ $^ $(LDFLAGS) diff --git a/mk/common.mk b/mk/common.mk index fcb3521..56251fc 100644 --- a/mk/common.mk +++ b/mk/common.mk @@ -26,7 +26,7 @@ NO_COLOR = \e[0m $(OUT)/test-%.done: $(OUT)/test-% $(Q)$(PRINTF) "*** Validating $< ***\n" $(Q)./$< && $(PRINTF) "\t$(PASS_COLOR)[ Verified ]$(NO_COLOR)\n" -check: $(addsuffix .done, $(TESTS)) +check: $(SUBS) $(addsuffix .done, $(TESTS)) config: $(OUT)/config-timestamp diff --git a/mk/remote.mk b/mk/remote.mk index 06f1a9a..4c69c90 100644 --- a/mk/remote.mk +++ b/mk/remote.mk @@ -1,8 +1,8 @@ # Build remote-worker -$(OUT)/worker-%.o: $(SRC)/%.c $(LIBTUV_PATH)/include $(LIBRABBITMQ_PATH)/build/include +$(OUT)/worker-%.o: $(SRC)/%.c $(VECHO) " CC\t$@\n" - $(Q)$(CC) -o $@ $(WORKER_CFLAGS) $(LIBTUV_INCLUDE) $(LIBRABBITMQ_INCLUDE) -c -MMD -MF $@.d $< + $(Q)$(CC) -o $@ $(WORKER_CFLAGS) $(SUB_INCLUDE) -c -MMD -MF $@.d $< -$(OUT)/remote-worker: $(OUT)/remote_worker.o $(WORKER_OBJS) $(LIBTUV_OBJS) $(LIBRABBITMQ_OBJS) +$(OUT)/remote-worker: $(OUT)/remote_worker.o $(WORKER_OBJS) $(SUB_OBJS) $(VECHO) " LD\t$@\n" $(Q)$(CC) -o $@ $^ $(LDFLAGS) diff --git a/mk/submodule.mk b/mk/submodule.mk index 25b4c40..a027d74 100644 --- a/mk/submodule.mk +++ b/mk/submodule.mk @@ -36,9 +36,11 @@ ifeq ($(UNAME_S),darwin) LDFLAGS += -L$(OPENSSL_PATH)/lib -lcrypto -lssl endif -$(LIBRABBITMQ_PATH)/build/include: +$(LIBRABBITMQ_PATH)/librabbitmq: git submodule update --init $(LIBRABBITMQ_PATH) - mkdir $(LIBRABBITMQ_PATH)/build + +$(LIBRABBITMQ_OBJS): + mkdir -p $(LIBRABBITMQ_PATH)/build ifeq ($(UNAME_S),darwin) # macOS cd $(LIBRABBITMQ_PATH)/build && \ @@ -49,7 +51,21 @@ else cmake -DCMAKE_INSTALL_PREFIX=. .. && \ cmake --build . --target install endif - -$(LIBRABBITMQ_OBJS): cd $(LIBRABBITMQ_PATH)/build && \ cmake --build . + +# Submodules +SUBS := $(LIBTUV_PATH)/include +ifeq ($(BUILD_REMOTE),1) + SUBS += $(LIBRABBITMQ_PATH)/librabbitmq +endif +# Submodule related objects +SUB_OBJS := $(LIBTUV_OBJS) +ifeq ($(BUILD_REMOTE),1) + SUB_OBJS += $(LIBRABBITMQ_OBJS) +endif +# Submodule C flags for including header files +SUB_INCLUDE := $(LIBTUV_INCLUDE) +ifeq ($(BUILD_REMOTE),1) + SUB_INCLUDE += $(LIBRABBITMQ_INCLUDE) +endif From eddf591d64cbd53e6148836a2c6e2af41df35682 Mon Sep 17 00:00:00 2001 From: marktwtn Date: Thu, 25 Jul 2019 13:33:53 +0800 Subject: [PATCH 07/15] fix: Flush the debug messages To make the redirection of the debug messages succeed. Close #175. --- src/common.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common.h b/src/common.h index f7dd479..4e18e82 100644 --- a/src/common.h +++ b/src/common.h @@ -27,6 +27,7 @@ static inline void ddprintf(const char *format, ...) va_start(ap, format); vprintf(format, ap); va_end(ap); + fflush(stdout); #endif } From 68f921ee5e0d1773347e1195fb8826098449db49 Mon Sep 17 00:00:00 2001 From: marktwtn Date: Sun, 17 Mar 2019 15:56:18 +0800 Subject: [PATCH 08/15] fix: Fix compiler warning of unused label --- src/pow_cl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pow_cl.c b/src/pow_cl.c index a73d6a0..2b3ef15 100644 --- a/src/pow_cl.c +++ b/src/pow_cl.c @@ -266,7 +266,7 @@ static bool PoWCL_Context_Initialize(ImplContext *impl_ctx) PoW_CL_Context *ctx = (PoW_CL_Context *) malloc(sizeof(PoW_CL_Context) * impl_ctx->num_max_thread); if (!ctx) - return false; + goto fail; for (int i = 0; i < impl_ctx->num_max_thread; i++) { ctx[i].clctx = &_opencl_ctx[i]; From 9aca981bf5142e1b2e4b6bd224398df2728cf4de Mon Sep 17 00:00:00 2001 From: marktwtn Date: Sun, 4 Aug 2019 11:11:27 +0800 Subject: [PATCH 09/15] refactor: Add line break --- src/remote_common.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/remote_common.c b/src/remote_common.c index 2847af9..a768ec1 100644 --- a/src/remote_common.c +++ b/src/remote_common.c @@ -226,7 +226,7 @@ bool wait_response_message(amqp_connection_state_t *conn, return false; if (frame.frame_type != AMQP_FRAME_HEADER) { - ddprintf("Unexpected header!"); + ddprintf("Unexpected header!\n"); return false; } @@ -251,23 +251,24 @@ bool wait_response_message(amqp_connection_state_t *conn, return false; if (frame.frame_type != AMQP_FRAME_BODY) { - ddprintf("Unexpected body"); + ddprintf("Unexpected body\n"); return false; } body_received += frame.payload.body_fragment.len; } if (body_received != body_target) { - ddprintf("Received body is small than body target"); + ddprintf("Received body is small than body target\n"); return false; } memcpy(frame_body, (char *) frame.payload.body_fragment.bytes, body_len); - ddprintf(MSG_PREFIX "PoW result: %.*s", + ddprintf(MSG_PREFIX "PoW result: %.*s\n", (int) frame.payload.body_fragment.len, (char *) frame.payload.body_fragment.bytes); + ddprintf("---\n"); /* everything was fine, we can quit now because we received the reply */ return true; From 453b11ae85c245bc3e4b18370653a49126872699 Mon Sep 17 00:00:00 2001 From: marktwtn Date: Tue, 23 Jul 2019 15:17:07 +0800 Subject: [PATCH 10/15] build: Add de10-nano board specific compiler flags -mcpu=cortex-a9: The CPU of de10-nano board is Cortex-A9. -mtune=cortex-a9: Improve the performance for Cortext-A9. -mfloat-abi=softfp: The NEON intrinsics are not available with the soft option. Use softfp instead of soft. -mfpu=neon: neon equals to neon-vfpv3. --- Makefile | 3 +++ mk/board.mk | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 mk/board.mk diff --git a/Makefile b/Makefile index 0a42915..011b7c7 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,9 @@ include mk/cpu-features.mk # Handle git submodule include mk/submodule.mk +# Board specific compiler flags +include mk/board.mk + # Assign the hardware to CPU if no hardware is specified PLATFORMS := $(BUILD_AVX) $(BUILD_SSE) $(BUILD_GENERIC) $(BUILD_GPU) $(BUILD_FPGA_ACCEL) ENABLE_PLATFORMS := $(findstring 1,$(PLATFORMS)) diff --git a/mk/board.mk b/mk/board.mk new file mode 100644 index 0000000..9917188 --- /dev/null +++ b/mk/board.mk @@ -0,0 +1,3 @@ +ifeq ($(BOARD),de10nano) + CFLAGS += -mcpu=cortex-a9 -mtune=cortex-a9 -mfloat-abi=hard -mfpu=neon +endif From 9ab0e510715a02d2aaa5c62a5ac02c95b3496afb Mon Sep 17 00:00:00 2001 From: marktwtn Date: Fri, 16 Aug 2019 23:43:49 +0800 Subject: [PATCH 11/15] docs: Revise remote interface document Change the file format from dos to unix. Remove useless space. Revise the description and the commands of testing the remote interface. --- docs/remote-interface.md | 143 +++++++++++++++++++++------------------ 1 file changed, 76 insertions(+), 67 deletions(-) diff --git a/docs/remote-interface.md b/docs/remote-interface.md index 26d6e22..61b89d2 100644 --- a/docs/remote-interface.md +++ b/docs/remote-interface.md @@ -1,67 +1,76 @@ -# Remote interface -## Introduction - -``` - +-----------------------------------------------+ - | remote interface | - | +----------------------------------------+ | - | +----------------------------------------+| | - | +----------------------------------------+|+ | - | | RabbitMQ-provided RPC |+ | - | +----------------------------------------+ | - | | ^ | - +------------|---------------------|------------+ - +------------|---------------------|------------+ - | | RabbitMQ broker | | - | | | | - | | +------------------+ | - | v +------------------+| | - | +------------------+ +------------------+|| | - | | incoming queue | | private queue ||| | - | | | | ||| | - | | - trytes | | - PoW result ||| | - | | - mwm | | ||+ | - | | | | |+ | - | +------------------+ +------------------+ | - | | ^ | - +------------|---------------------|------------+ - v | - +---------------------------------------------+ - +---------------------------------------------+| - +---------------------------------------------+|+ - | remote worker |+ - +---------------------------------------------+ -``` -To support asynchronous remote procedure call, remote interface in dcurl provides an interface named as `Remote_ImplContext` to implement it. dcurl currently uses RabbitMQ C client to implement asynchronous RPC in remote interface. Remote interface provides thread management to support an asynchronous RPC per thread. - -Here are detailed implementations of the RabbitMQ-provided RPC pattern as follows: -* Asynchronous RPC requests are inserted into the message queue, `incoming_queue`, in RabbitMQ broker -* Asynchronous RPCs with exclusive private queues (callback queues) with TTL = 10s property -* Correlation ID is not used -* An asynchronous RPC uses a connection to RabbitMQ broker -* Remote workers can obtain requests from `incoming_queue` by default exchange of RabbitMQ broker - -## How to test remote interface in localhost -You need to open three terminals - -Terminal 1: Run the RabbitMQ broker You can quickly use docker to run the RabbitMQ broker, rabbitmq -``` -$ sudo docker run -d rabbitmq -``` - -Terminal 2: Run remote workers -``` -$ ./build/remote-worker -``` -How to build remote worker on FPGA board -``` -$ make BUILD_REMOTE=1 BUILD_FPGA_ACCEL=1 BOARD=de10nano -``` - -Terminal 3: Run check -``` -$ make BUILD_REMOTE=1 BUILD_DEBUG=1 check -``` - -## Requirements -Remote interface requires RabbitMQ broker +# Remote interface +## Introduction + +``` + +-----------------------------------------------+ + | remote interface | + | +----------------------------------------+ | + | +----------------------------------------+| | + | +----------------------------------------+|+ | + | | RabbitMQ-provided RPC |+ | + | +----------------------------------------+ | + | | ^ | + +------------|---------------------|------------+ + +------------|---------------------|------------+ + | | RabbitMQ broker | | + | | | | + | | +------------------+ | + | v +------------------+| | + | +------------------+ +------------------+|| | + | | incoming queue | | private queue ||| | + | | | | ||| | + | | - trytes | | - PoW result ||| | + | | - mwm | | ||+ | + | | | | |+ | + | +------------------+ +------------------+ | + | | ^ | + +------------|---------------------|------------+ + v | + +---------------------------------------------+ + +---------------------------------------------+| + +---------------------------------------------+|+ + | remote worker |+ + +---------------------------------------------+ +``` +To support asynchronous remote procedure call, remote interface in dcurl provides an interface named as `Remote_ImplContext` to implement it.\ +dcurl currently uses RabbitMQ C client to implement asynchronous RPC in remote interface.\ +Remote interface provides thread management to support an asynchronous RPC per thread. + +Here are detailed implementations of the RabbitMQ-provided RPC pattern as follows: +* Asynchronous RPC requests are inserted into the message queue, `incoming_queue`, in RabbitMQ broker +* Asynchronous RPCs with exclusive private queues (callback queues) with TTL = 10s property +* Correlation ID is not used +* An asynchronous RPC uses a connection to RabbitMQ broker +* Remote workers can obtain requests from `incoming_queue` by default exchange of RabbitMQ broker + +## How to test remote interface in localhost +You need to open three terminals + +**Terminal 1:**\ +Run the RabbitMQ broker\ +You can quickly use docker to run the RabbitMQ broker, rabbitmq +``` +$ sudo docker run -d -p 5672:5672 rabbitmq +``` + +--- + +**Terminal 2:**\ +Build and run the remote worker +``` +$ cd dcurl +$ make BUILD_REMOTE=1 BUILD_DEBUG=1 +$ ./build/remote-worker +``` + +--- + +**Terminal 3:**\ +Run the tests to send requests to remote worker +``` +$ cd dcurl +$ make BUILD_REMOTE=1 BUILD_DEBUG=1 check +``` + +## Requirements +Remote interface requires RabbitMQ broker From c0c89b1658f321035f96828ba8914a15fe6fd14c Mon Sep 17 00:00:00 2001 From: marktwtn Date: Fri, 16 Aug 2019 23:56:49 +0800 Subject: [PATCH 12/15] refactor: Remove redundant characters --- src/remote_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/remote_common.c b/src/remote_common.c index a768ec1..12c1545 100644 --- a/src/remote_common.c +++ b/src/remote_common.c @@ -31,14 +31,14 @@ bool die_on_amqp_error(amqp_rpc_reply_t x, char const *context) case AMQP_CONNECTION_CLOSE_METHOD: { amqp_connection_close_t *m = (amqp_connection_close_t *) x.reply.decoded; - ddprintf("%s: server connection error %uh, message: %.*s\n", + ddprintf("%s: server connection error %u, message: %.*s\n", context, m->reply_code, (int) m->reply_text.len, (char *) m->reply_text.bytes); break; } case AMQP_CHANNEL_CLOSE_METHOD: { amqp_channel_close_t *m = (amqp_channel_close_t *) x.reply.decoded; - ddprintf("%s: server channel error %uh, message: %.*s\n", context, + ddprintf("%s: server channel error %u, message: %.*s\n", context, m->reply_code, (int) m->reply_text.len, (char *) m->reply_text.bytes); break; From 02b6d703d36b7008a9ddae107a1b6193cc6edfa0 Mon Sep 17 00:00:00 2001 From: marktwtn Date: Sun, 18 Aug 2019 01:25:45 +0800 Subject: [PATCH 13/15] refactor: Add parentheses in macros --- src/constants.h | 55 ++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/src/constants.h b/src/constants.h index 42b96be..751eb48 100644 --- a/src/constants.h +++ b/src/constants.h @@ -27,53 +27,56 @@ #define SignatureMessageFragmentTrinaryOffset 0 #define SignatureMessageFragmentTrinarySize 6561 -#define AddressTrinaryOffset \ - SignatureMessageFragmentTrinaryOffset + SignatureMessageFragmentTrinarySize +#define AddressTrinaryOffset \ + (SignatureMessageFragmentTrinaryOffset + \ + SignatureMessageFragmentTrinarySize) #define AddressTrinarySize 243 -#define ValueTrinaryOffset AddressTrinaryOffset + AddressTrinarySize +#define ValueTrinaryOffset (AddressTrinaryOffset + AddressTrinarySize) #define ValueTrinarySize 81 -#define ObsoleteTagTrinaryOffset ValueTrinaryOffset + ValueTrinarySize +#define ObsoleteTagTrinaryOffset (ValueTrinaryOffset + ValueTrinarySize) #define ObsoleteTagTrinarySize 81 -#define TimestampTrinaryOffset ObsoleteTagTrinaryOffset + ObsoleteTagTrinarySize +#define TimestampTrinaryOffset \ + (ObsoleteTagTrinaryOffset + ObsoleteTagTrinarySize) #define TimestampTrinarySize 27 -#define CurrentIndexTrinaryOffset TimestampTrinaryOffset + TimestampTrinarySize +#define CurrentIndexTrinaryOffset \ + (TimestampTrinaryOffset + TimestampTrinarySize) #define CurrentIndexTrinarySize 27 #define LastIndexTrinaryOffset \ - CurrentIndexTrinaryOffset + CurrentIndexTrinarySize + (CurrentIndexTrinaryOffset + CurrentIndexTrinarySize) #define LastIndexTrinarySize 27 -#define BundleTrinaryOffset LastIndexTrinaryOffset + LastIndexTrinarySize +#define BundleTrinaryOffset (LastIndexTrinaryOffset + LastIndexTrinarySize) #define BundleTrinarySize 243 -#define TrunkTransactionTrinaryOffset BundleTrinaryOffset + BundleTrinarySize +#define TrunkTransactionTrinaryOffset (BundleTrinaryOffset + BundleTrinarySize) #define TrunkTransactionTrinarySize 243 #define BranchTransactionTrinaryOffset \ - TrunkTransactionTrinaryOffset + TrunkTransactionTrinarySize + (TrunkTransactionTrinaryOffset + TrunkTransactionTrinarySize) #define BranchTransactionTrinarySize 243 #define TagTrinaryOffset \ - BranchTransactionTrinaryOffset + BranchTransactionTrinarySize + (BranchTransactionTrinaryOffset + BranchTransactionTrinarySize) #define TagTrinarySize 81 -#define AttachmentTimestampTrinaryOffset TagTrinaryOffset + TagTrinarySize +#define AttachmentTimestampTrinaryOffset (TagTrinaryOffset + TagTrinarySize) #define AttachmentTimestampTrinarySize 27 #define AttachmentTimestampLowerBoundTrinaryOffset \ - AttachmentTimestampTrinaryOffset + AttachmentTimestampTrinarySize + (AttachmentTimestampTrinaryOffset + AttachmentTimestampTrinarySize) #define AttachmentTimestampLowerBoundTrinarySize 27 #define AttachmentTimestampUpperBoundTrinaryOffset \ - AttachmentTimestampLowerBoundTrinaryOffset + \ - AttachmentTimestampLowerBoundTrinarySize + (AttachmentTimestampLowerBoundTrinaryOffset + \ + AttachmentTimestampLowerBoundTrinarySize) #define AttachmentTimestampUpperBoundTrinarySize 27 -#define NonceTrinaryOffset \ - AttachmentTimestampUpperBoundTrinaryOffset + \ - AttachmentTimestampUpperBoundTrinarySize +#define NonceTrinaryOffset \ + (AttachmentTimestampUpperBoundTrinaryOffset + \ + AttachmentTimestampUpperBoundTrinarySize) #define NonceTrinarySize 81 -#define transactionTrinarySize \ - SignatureMessageFragmentTrinarySize + AddressTrinarySize + \ - ValueTrinarySize + ObsoleteTagTrinarySize + TimestampTrinarySize + \ - CurrentIndexTrinarySize + LastIndexTrinarySize + BundleTrinarySize + \ - TrunkTransactionTrinarySize + BranchTransactionTrinarySize + \ - TagTrinarySize + AttachmentTimestampTrinarySize + \ - AttachmentTimestampLowerBoundTrinarySize + \ - AttachmentTimestampUpperBoundTrinarySize + NonceTrinarySize +#define transactionTrinarySize \ + (SignatureMessageFragmentTrinarySize + AddressTrinarySize + \ + ValueTrinarySize + ObsoleteTagTrinarySize + TimestampTrinarySize + \ + CurrentIndexTrinarySize + LastIndexTrinarySize + BundleTrinarySize + \ + TrunkTransactionTrinarySize + BranchTransactionTrinarySize + \ + TagTrinarySize + AttachmentTimestampTrinarySize + \ + AttachmentTimestampLowerBoundTrinarySize + \ + AttachmentTimestampUpperBoundTrinarySize + NonceTrinarySize) extern char TryteAlphabet[]; extern const int indices[]; From de005f731a814759c323d9f84486014118c3d5b5 Mon Sep 17 00:00:00 2001 From: marktwtn Date: Tue, 20 Aug 2019 02:36:21 +0800 Subject: [PATCH 14/15] docs: Add the frequently asked questions in README --- README.md | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0857fec..a444256 100644 --- a/README.md +++ b/README.md @@ -13,11 +13,9 @@ In addition, dcurl supports FPGA-accelerated PoW, described in [docs/fpga-accele dcurl can be regarded as the drop-in replacement for [ccurl](https://github.com/iotaledger/ccurl). IOTA Reference Implementation (IRI) adaptation is available to benefit from hardware-accelerated PoW. - ## Build Instructions Check [docs/build-n-test.md](docs/build-n-test.md) for details. - ## Performance After integrating dcurl into IRI, performance of [attachToTangle](https://iota.readme.io/reference#attachtotangle) is measured as following. * Each sampling is measured with 30 transaction trytes and total 200 samples are measured. @@ -25,7 +23,6 @@ After integrating dcurl into IRI, performance of [attachToTangle](https://iota.r * Settings: enable 2 pow tasks in CPU, 1 pow tasks in GPU at the same time ![](https://github.com/raw/DLTcollab/dcurl/develop/docs/benchmark.png) - ## IRI Adaptation [Modified IRI accepting external PoW Library](https://github.com/DLTcollab/iri) Supported IRI version: 1.7.0 @@ -63,6 +60,27 @@ pull requests to dcurl. it faciliates dcurl to perform hardware-accelerated PoW operations on edge devices. +## FAQ +- What is **binary encoded ternary**? + + It is a skill to transform the ternary trit value to two separate bits value.\ + Hence multiple trits can be compressed to two separate data of the same data type and fully utilize the space. + +- Can the project [Batch Binary Encoded Ternary Curl](https://github.com/luca-moser/bct_curl) be applied to dcurl? + + The answer is no.\ + They both use the same skill, **binary encoded ternary**.\ + However, their purpose are totally different. + - **bct_curl**: + + Focus on hashing the multiple data of the same length at the same time.\ + It ends when the hashing is finished. + + - **dcurl**: + + Focus on trying the different values of one transaction at the same time to find the nonce value.\ + The procedure of finding the nonce value also does the hashing.\ + However, it ends when the nonce value is found, which means one of the values is acceptable. ## Licensing `dcurl` is freely redistributable under the MIT License. From da621cf41a2bdef41549d9d0d8a18a5a4f746ba2 Mon Sep 17 00:00:00 2001 From: marktwtn Date: Wed, 21 Aug 2019 18:37:13 +0800 Subject: [PATCH 15/15] Release version 0.4.1 --- Makefile | 2 +- src/common.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 011b7c7..b9f59f1 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION = 0.4.0 +VERSION = 0.4.1 OUT ?= ./build SRC := src diff --git a/src/common.h b/src/common.h index 4e18e82..3595d16 100644 --- a/src/common.h +++ b/src/common.h @@ -16,7 +16,7 @@ #define __DCURL_MAJOR__ 0 #define __DCURL_MINOR__ 4 -#define __DCURL_PATCH__ 0 +#define __DCURL_PATCH__ 1 double diff_in_second(struct timespec t1, struct timespec t2);