Skip to content
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
17 changes: 12 additions & 5 deletions src/datum_protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -1326,15 +1326,22 @@ int datum_protocol_pow(void *arg) {

char * const username = (char *)&msg[i];
if (((!datum_config.datum_pool_pass_full_users) && (!datum_config.datum_pool_pass_workers)) || pow->username[0] == '\0') {
i+=snprintf(username, 385, "%s", datum_config.mining_pool_address);
j = snprintf(username, DATUM_PROTOCOL_MAX_USERNAME_LEN + 1, "%s", datum_config.mining_pool_address);
} else if (datum_config.datum_pool_pass_full_users && pow->username[0] != '.') {
// TODO: Make sure the usernames are addresses, and if not use one of the configured addresses
i+=snprintf(username, 385, "%s", pow->username);
} else if (datum_config.datum_pool_pass_full_users || datum_config.datum_pool_pass_workers) {
j = snprintf(username, DATUM_PROTOCOL_MAX_USERNAME_LEN + 1, "%s", pow->username);
} else {
// append the miner's username to the configured address as .workername
i+=snprintf(username, 385, "%s%s%s", datum_config.mining_pool_address, (pow->username[0] == '.') ? "" : ".", pow->username);
j = snprintf(username, DATUM_PROTOCOL_MAX_USERNAME_LEN + 1, "%s%s%s", datum_config.mining_pool_address, (pow->username[0] == '.') ? "" : ".", pow->username);
}
if (j < 0) {
DLOG_ERROR("Unexpected error copying username to POW!");
Comment thread
luke-jr marked this conversation as resolved.
Comment thread
luke-jr marked this conversation as resolved.
// Still submit it without a username in case it's a block
username[0] = '\0';
j = 0;
}
Comment thread
luke-jr marked this conversation as resolved.
i++; // already 0 from snprintf
if (j > DATUM_PROTOCOL_MAX_USERNAME_LEN) j = DATUM_PROTOCOL_MAX_USERNAME_LEN;
i += j + 1; // including final null byte

// reserve 4 bytes for future use
memset(&msg[i], 0, 4); i+=4;
Expand Down
1 change: 1 addition & 0 deletions src/datum_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@

#define DATUM_PROTOCOL_MAX_CMD_DATA_SIZE 4194304 // 2^22 - protocol limit!
#define DATUM_PROTOCOL_BUFFER_SIZE (DATUM_PROTOCOL_MAX_CMD_DATA_SIZE*3)
#define DATUM_PROTOCOL_MAX_USERNAME_LEN 384

#define MAX_DATUM_CLIENT_EVENTS 32
Comment thread
luke-jr marked this conversation as resolved.

Expand Down
Loading