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

Initialization logic is rewritten #476

Merged
merged 8 commits into from
Dec 13, 2018
Merged

Conversation

jonano614
Copy link
Contributor

  • 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

@ghost ghost assigned jonano614 Dec 6, 2018
@ghost ghost added the in progress label Dec 6, 2018
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) {
Copy link
Contributor Author

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

@jonano614 jonano614 changed the title WIP: Initialization logic is rewritten Initialization logic is rewritten Dec 7, 2018
Copy link
Contributor

@sgaragagghu sgaragagghu left a 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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -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)) {
Copy link
Contributor

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;
}

Copy link
Contributor Author

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.

Copy link
Contributor Author

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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;
Copy link
Contributor

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) {
Copy link
Contributor

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.

Copy link
Contributor Author

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; }
Copy link
Contributor

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 :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes.

@jonano614 jonano614 merged commit 24793fa into XDagger:develop Dec 13, 2018
@ghost ghost removed the in progress label Dec 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants