NebulousLabs / Sia-GPU-Miner

A GPU Miner for Sia
MIT License
151 stars 79 forks source link

Add -H (specify hostname) option. #36

Closed visvirial closed 9 years ago

visvirial commented 9 years ago

Currently the host name of Sia daemon is pre-defined as localhost. If a miner want to run a multiple mining nodes that is connected to a single parent node that serves Sia daemon (siad), one should modify the source code to point the host name (or IP address) of siad host.

In this pull request, you can specify a host name of siad node by command line argument (-H option), which hopefully useful for miners running multiple mining nodes.

Additionally, I am suggesting that you should not prefix with : to port number. -P :9880 should be -P 9880 which is easy to verify the validity of port number (use atoi(argv[i]) instead).

DavidVorick commented 9 years ago

We prefix it with a ':' because that's how siad accepts the flag (for better or worse). I think ideally the software would correctly accept either -P 9980 or -P :9980, and would also be agnostic to the presence of quotes.

It looks like you forgot to update the switch statement. There is no -H in your code, and if you pass -P anything longer than 6 chars it'll return an error.

DavidVorick commented 9 years ago

I'm happy to merge this once it's working

visvirial commented 9 years ago

Oh, sorry. I forgot to commit some files. I updated my branch. Please review it.

DavidVorick commented 9 years ago

Except for the comment for set_host, this looks good.

There is an issue where passing in an invalid hostname causes the miner to hang/get stuck. I'm not sure if there's an easy fix for that.

visvirial commented 9 years ago

I changed the comment for get_host() in network.c.

There is an issue where passing in an invalid hostname causes the miner to hang/get stuck. I'm not sure if there's an easy fix for that.

In my environment, Sia miner reports that the host name could not be resolved as follows.

$ ./sia-gpu-miner -I 20 -H @@@
Intensity set to 20
Host name set to @@@
Initializing...

Failed to get header from @@@:9980/miner/headerforwork, curl_easy_perform() failed: Couldn't resolve host name
Are you sure that siad is running?
^C
Caught kill signal, quitting...
HTTP error 0