Adding Classic Etherium Functionality
Alright, so in the last blog I managed to get GoLang installed on an Oracle VM Virtual box with a uBuntu OS. Specifically to get my open-ethereum-pool working. I forgot to credit this Medium article, so thank you Patrick!
- Pull Request — Adding ethereum classic
One of the most requested features is classic ehtereum mining but the people using the pool don’t know how to add the needed configuration values to allow this capability. I began by creating a boolean flag in the configuration with a const value to hold the wei calculation value depending on block chain height.
- Finding Reward formula
The calculation is based off of the block height which determines the era through a calculation and depending on whether it is a base reward or an uncle reward — finding the algorithm/value within a certain time frame of the initial — allows a smaller reward. Thus a formula for base reward and uncle reward was required.Found reward calculation through medium article here. This helped me understand how to go about making the calculations for the Classic ethereum rewards.
- Creating the reward function
Used boolean flag in config to check whether classic ehtereum was being mined and if it was, the corresponding uncle/base reward was calculated. It felt a little cheesy, but looking at the code, this is what they all did. I didn’t quite understand the point of a hard coded value that needed to be updated depending on the era, but it made sense a little later.
When I made an attempt to calculate the wei currency , the value was too large for a Big Integer — I wanted to find a way to avoid hard coding the era value but after an hour or two trying to write the calculation, working with the existing functions, I realized it wasn’t possible because of the values being used in GoLang didn’t allow the number to convert from a big float to a big integer properly without losing it’s values in larger eras. Thus unless the other functions are changed to use big floats or strings, I won’t be able to implement this work around using a const value that needs to be change every new era (it doesn’t change frequently, harder as time goes by).
When I started working with the tests, I basically just copied the other reward/uncle reward function. Thanks to classic ehtereum giving basically the same rewards all the time, it was pretty easy to confirm these worked. I wanted to be extra sure so I went through here to check the rewards. Basically if you found the ethereum block, you’re rewarded about 4 ethereum, if you’re an uncle, 0.125 ethereum. Woohoo, thus completes the pull request, now I just got to see if they’ll merge it. Otherwise, maybe the people who needed help can just throw this in themselves to get started.