From a336d9a70c95dee1114fa5dd9738ef2f3d3dfbb3 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Sat, 9 Jan 2016 21:13:44 +0000 Subject: [PATCH] Move varintEncode earlier in file --- blkmaker.c | 58 +++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/blkmaker.c b/blkmaker.c index 7bc1421..8e01c6c 100644 --- a/blkmaker.c +++ b/blkmaker.c @@ -47,6 +47,35 @@ bool _blkmk_dblsha256(void *hash, const void *data, size_t datasz) { #define dblsha256 _blkmk_dblsha256 +static +char varintEncode(unsigned char *out, uint64_t n) { + if (n < 0xfd) + { + out[0] = n; + return 1; + } + char L; + if (n <= 0xffff) + { + out[0] = '\xfd'; + L = 3; + } + else + if (n <= 0xffffffff) + { + out[0] = '\xfe'; + L = 5; + } + else + { + out[0] = '\xff'; + L = 9; + } + for (unsigned char i = 1; i < L; ++i) + out[i] = (n >> ((i - 1) * 8)) % 256; + return L; +} + uint64_t blkmk_init_generation3(blktemplate_t * const tmpl, const void * const script, const size_t scriptsz, bool * const inout_newcb) { if (tmpl->cbtxn && !(*inout_newcb && (tmpl->mutations & BMM_GENERATE))) { @@ -451,35 +480,6 @@ unsigned long blkmk_work_left(const blktemplate_t *tmpl) { return BLKMK_UNLIMITED_WORK_COUNT; } -static -char varintEncode(unsigned char *out, uint64_t n) { - if (n < 0xfd) - { - out[0] = n; - return 1; - } - char L; - if (n <= 0xffff) - { - out[0] = '\xfd'; - L = 3; - } - else - if (n <= 0xffffffff) - { - out[0] = '\xfe'; - L = 5; - } - else - { - out[0] = '\xff'; - L = 9; - } - for (unsigned char i = 1; i < L; ++i) - out[i] = (n >> ((i - 1) * 8)) % 256; - return L; -} - char *blkmk_assemble_submission_(blktemplate_t * const tmpl, const unsigned char * const data, const unsigned int dataid, blknonce_t nonce, const bool foreign) { unsigned char blk[80 + 8 + 1000000];