Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flodata option for FLO Blockchain coinbase message #34

Open
wants to merge 4 commits into
base: linux
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ sign/
sign.sh

compat/curl-for-windows/
*.swp
26 changes: 24 additions & 2 deletions cpu-miner.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ char *opt_api_allow = NULL;
int opt_api_remote = 0;
int opt_api_listen = 4048; /* 0 to disable */

// FLO Blockchain
char *opt_flodata = NULL;

#ifdef HAVE_GETOPT_LONG
#include <getopt.h>
#else
Expand Down Expand Up @@ -365,6 +368,7 @@ Options:\n\
xevan Xevan (BitSend)\n\
yescrypt Yescrypt\n\
zr5 ZR5\n\
-l, --flodata=MESSAGE message for flodata field\n\
-o, --url=URL URL of mining server\n\
-O, --userpass=U:P username:password pair for mining server\n\
-u, --user=USERNAME username for mining server\n\
Expand Down Expand Up @@ -422,7 +426,7 @@ static char const short_options[] =
#ifdef HAVE_SYSLOG_H
"S"
#endif
"a:b:Bc:CDf:hm:n:p:Px:qr:R:s:t:T:o:u:O:V";
"a:b:Bc:CDf:hm:n:p:Px:qr:R:s:t:T:o:u:O:Vl:";

static struct option const options[] = {
{ "algo", 1, NULL, 'a' },
Expand All @@ -442,6 +446,7 @@ static struct option const options[] = {
{ "diff-factor", 1, NULL, 'f' },
{ "diff", 1, NULL, 'f' }, // deprecated (alias)
{ "diff-multiplier", 1, NULL, 'm' },
{ "flodata", 1, NULL, 'l' },
{ "help", 0, NULL, 'h' },
{ "nfactor", 1, NULL, 'n' },
{ "no-gbt", 0, NULL, 1011 },
Expand Down Expand Up @@ -875,7 +880,12 @@ static bool gbt_work_decode(const json_t *val, struct work *work)
}
cbvalue = (int64_t) (json_is_integer(tmp) ? json_integer_value(tmp) : json_number_value(tmp));
cbtx = (uchar*) malloc(256);
le32enc((uint32_t *)cbtx, 1); /* version */
/* version == 1 if no flodata message, 2 if flodata message set */
if (opt_flodata == NULL) {
le32enc((uint32_t *)cbtx, 1);
} else {
le32enc((uint32_t *)cbtx, 2);
}
cbtx[4] = 1; /* in-counter */
memset(cbtx+5, 0x00, 32); /* prev txout hash */
le32enc((uint32_t *)(cbtx+37), 0xffffffff); /* prev txout index */
Expand All @@ -901,6 +911,14 @@ static bool gbt_work_decode(const json_t *val, struct work *work)
cbtx_size += (int) pk_script_size;
le32enc((uint32_t *)(cbtx+cbtx_size), 0); /* lock time */
cbtx_size += 4;

if (opt_flodata != NULL) {
char floDataLen = strlen(opt_flodata); // only works if floData is less than 252 chars
cbtx[cbtx_size++] = floDataLen; // else the encoded varInt will be wrong
memcpy(cbtx+cbtx_size, opt_flodata, floDataLen);
cbtx_size += floDataLen;
}

coinbase_append = true;
}
if (coinbase_append) {
Expand Down Expand Up @@ -3271,6 +3289,10 @@ void parse_arg(int key, char *arg)
if (p) d *= 1e9;
opt_max_rate = d;
break;
case 'l': // flodata message
free(opt_flodata);
opt_flodata = strdup(arg);
break;
case 1024:
opt_randomize = true;
break;
Expand Down