Fork for Duino-Coin Arduino library based on the Arduino sketches on the official repository. Main official repository: https://github.com/revoxhere/duino-coin This repository has been created in order to test, fix and modify the library before making it official, I believe revox wants this to be official but if we want to include it on the main repository it will change the directory tree. This library supports most Arduino boards, here is the list of architectures it supports:
- AVR based boards
- Teensy based boards
- SAMD based boards
- SAMD21 based boards
- STM32 boards
- AVRMega based boards
- Raspberry Pi Pico
Any board or architecture not mentioned on the list will not be supported and will not compile, it should show an error message on the Arduino IDE. Also, at the moment there are three examples implemented; the Serial_miner, ESP32_example and the ESP8266_example. I'm planning to include a generic Ethernet miner example and also a generic WiFi miner example and maybe another I2C miner example but I believe this will take me some time, maybe a couple of weeks, if anyone want to do it please feel free to do that. Just let me know before making a pull request.
I've tried to maintain the main code logic of the sketches and mix everything in one library, of course I've had to make some trade off decisions but they're not critical or important and they don't change the SHA1 calculation. Right now there are a lot of commentaries missing that I will try to put on the next few days but please feel free to include them if you think it is needed. The library contains a lot of preprocessor directives to switch between architectures and to separate the Serial miners (I believe I2C, SPI and most Stream classes derivatives are supported too but I haven't tested that) from the network miners (WiFi, Ethernet). To separate the two different ways of communication I had to handle the Serial functions as generic Stream objects, with this I can also use the same functions with the WiFi and Ethernet client classes as they're derivatives from the Stream class. Another thing I want to point out is that I didn't want to give the class complete control of the Stream objects, this is just a personal opinion but I think the user should be free to call the Stream object whenever he wants, not exclusively on DUCO operations. This can be changed in the future if someone shows me a nicer and cleaner way to implement it.
Here is a quick explanation of each function member:
This is the constructor of the object, it has some predefined arguments in case the user doesn't need to include them, for instance the Serial miners don't need any the ducouser and the rigname.
Just to get the unique ID of the microcontroller. This doesn't return the ID, it is just stored inside the object. Also this function needs to be called on the setup section of the sketch, it is actually called inside the constructor but for some reason a lot of architectures don't like that and they want to be called on the actual sketch. Maybe someone can fix that, I'm not sure if it's possible.
I have included this function that is defined on the ESP8266 sketch because I like how it handles the blinks of the led, we can give the function how many times we want the led to blink. This function is called inside other functions of the class but for
This function just returns the last result calculated from a job. uintDiff is a data type that can be uint8_t for AVR 8-bit devices and uint16_t for the rest of architectures.
This function just returns the current difficulty obtained.
Returns the latest lastblockhash.
Returns the latest newblockhash.
Returns the last String object read by the class on any of its member functions.
Returns the difficulty tier associated with the current architecture.
Returns the library version.
Implements the SHA1 loop calculation. In order to make fair calculations of hashrate I have moved the initialization of the SHA1 algorithm to the member function recv_job.
Receive the data necessary to calculate a job (lastblockhash, newblockhash and difficulty) and also implement the initialization of the SHA1 algorithm.
Handle the job calculation and send the result through the Stream object.
Returns the hashrate of the last job calculated.
Returns the number of the shares or jobs calculated.
Returns the string that the server sends as feedback after the device sends the result.
Returns the server version sent by the server.
Returns the address or URL of the Duino-Coin server.
It increments the index of the ports array so the object can use another port on the next connection.
Returns the current port in use.
It tries to connect to the server and waits for the response containing the version of the server.
It makes a request for a new job but doesn't wait for the response in this function.
It waits for the feedback from the server. This needs to be called after the result of a job is sent to the server.