-
Notifications
You must be signed in to change notification settings - Fork 130
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
Initialization logic is rewritten #476
Conversation
jonano614
commented
Dec 6, 2018
- xdag_init function is splitted to logical parts
- some global varibales are moved to global.h file
- variables g_is_miner, g_is_pool, g_xdag_pool and g_light_mode are replaces with one variable g_xdag_type
- dnet_crypt.c file is formatted, some reduntunt lines are remove
- reading dnet key is moved to separate function
- preparations for adding single wallet file "xdag.wallet"
- windows-compilation and formatting for PR: Config file for pools #461
client/block.c
Outdated
@@ -839,7 +839,7 @@ void *add_block_callback(void *block, void *data) | |||
|
|||
pthread_mutex_unlock(&block_mutex); | |||
|
|||
if(res >= 0) { | |||
if(res >= 0 && g_xdag_type == XDAG_POOL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocks synchronization logic is initialized only for pools now, so xdag_sync_pop_block can be called only for pools
# Conflicts: # client/commands.c # client/init.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good, hope there aren't issue ;)
it think monothematic commits/PR are better to make it easier to review (catch issues) and to keep commits/PR history methodical
@@ -1194,15 +1194,6 @@ static void *work_thread(void *arg) | |||
} else if (time(NULL) - last_time_nmain_unequal > MAX_TIME_NMAIN_STALLED) { | |||
g_block_production_on = 1; | |||
} | |||
|
|||
if (g_block_production_on) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need remove these logs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this code block for pool at all. Maybe I just move xdag_mess("Starting refer blocks creation...");
to another place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
client/commands.c
Outdated
@@ -331,7 +332,7 @@ int xdag_command(char *cmd, FILE *out) | |||
|
|||
XDAG_COMMAND *command = find_xdag_command(cmd); | |||
|
|||
if(!command || (command->avaibility == 1 && !g_is_miner) || (command->avaibility == 2 && g_is_miner)) { | |||
if(!command || (command->avaibility == 1 && g_xdag_type == XDAG_POOL) || (command->avaibility == 2 && g_xdag_type == XDAG_WALLET)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just use two functions
isPool() {
return g_xdag_type == XDAG_POOL;
}
isWallet() {
return g_xdag_type == XDAG_WALLET;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I will add it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
client/global.c
Outdated
struct xdag_ext_stats g_xdag_extstats; | ||
int g_disable_mining = 0; | ||
enum xdag_type g_xdag_type = 0; | ||
char *g_coinname, *g_progname; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Emmm, there is one extra character on windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I didn't understand what is wrong here.
@@ -38,6 +38,7 @@ int terminal(void) | |||
|
|||
if(!xdag_network_init()) { | |||
printf("Can't initialize sockets"); | |||
return -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!!
} | ||
} | ||
return str; | ||
if(str != NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trim can be moved to utils, or we can introduce a file strutils.c to hold all related functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, currently there is just formatting. I had to do something wih that file because there was compilation error. I fixed a problem and decided to do formatting too.
@@ -66,4 +66,7 @@ extern int g_disable_mining; | |||
//Test network and main network have different types of the block headers, so blocks from different networks are incompatible | |||
extern enum xdag_field_type g_block_header_type; | |||
|
|||
inline int is_pool() { return g_xdag_type == XDAG_POOL; } | |||
inline int is_wallet() { return g_xdag_type == XDAG_WALLET; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think you are missing void :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes.