Algorithm for Ninja style mining pool block share assignment
-
Could anyone elaborate on how the current block share allocations are determined?
E.G. if the top miner has a 4 min DL he gets 75% of the block and the next miner gets 3%. Then the top miner is 15 minutes and 22% and the 18 minute miner gets 16%. Obviosly an inverse function but I was interested if someone could provide the exact formula.
Thanks,
-
@rds It's based on the deadline, but I don't know the exact formula. I'd have to dig through the source code to figure it out.
-
Is the source code for the pools open/vailable for anyone to see?
-
@rds I can make it available to you, or anyone that wants to look at it.
-
@haitch , I would like to see it to see if I can understand how the shares are implemented. I only used languages from the old days and just recently looked into python. Is it written in a language that I would be able to decipher the math algorithm? Thanks,
-
@rds The pool code is written in C#, but is fairly readable.
-
@haitch , great how do I access it?
-
@haitch I second this, my I get a link to the pools code as well. C# shouldn't be much of a problem.
-
@AngryChicken @rds https://db.burst-team.us/ninja.zip - It's a 24 MB Download. If you have questions about the code, I'll try and answer, but it's not my code.
-
@haitch No worries, Thanks I appreciate it.
-
@haitch thank you
-
OK, i'm lost. Extracted the files, but can't see where/what files are the C# source code?? Any help appreciated.
-
Are the cpp files the src code? Do I need a special program to read these files? Thanks, sorry for the noobie questions.
-
@rds Yes they are the c++ files, you need Visual Studio or some other IDE, you can find them on the internet with a simple search. I think this is what your asking at least?
(C++ can be a very hard to comprehend language as it's a very low level language)

-
@AngryChicken , ok thanks,
-
@AngryChicken to just read the files, Notepad or Textpad or any other text editor will work. Compiling the code, yeah, that's a whole different challenge.
-
@haitch Yea, you could edit in notepad but then the text assist wouldn't be their to help generating/recommending code. But yea Compiling without an IDE (Which pre installs all the redistributes required to run and compile the code would be a huge pain). I just always recommend using a Full IDE when editing rather than bear bones editors as they provide more than a click to compile.
-
Just to view the files notepad++ is excellent, it will structure and colour the C++ Code to make it more readable.
https://notepad-plus-plus.org/
Rich
-
Thanks, @AngryChicken , @haitch and all those who helped in this thread.
For those interested, I was actually able to see the shares calculation by looking at the javascript of the share-curve.html file in the build subdirectory. I really don't know this language but it was pretty easy to see what was going on.
It appears that all miner deadlines are summed. Each miner's share is the total of all deadlines submitted/the individual miner's deadline. Then the % share is calculated by the miner's share/total shares.
I checked this against actual data from random blocks on both burst.ninja and pool.burstcoin.biz. Although not exactly as I determined from this source code, there is a very high correlation. It appears that the actual pools are skewing the rewards curve slightly in favor of the top, best deadlines for each block. Anyway, my curiosity is satisfied, and I thought it best to post this for anyone else to see.
-
@rds I do recall there was a skew added to the deadlines so that the top deadlines - but the discussion about that was a couple of years ago and I don't recall the details.
-
It's at objects/Block.cpp line 110, the method called Block::recalculate_shares() and here's some simplified pseudo-code to explain it:
sum_scaled_shares = 0 for each account's best deadline (let's call this "deadline") { // because it's possible, but rare, to have a 0 deadline // and we don't want a divide by zero error later deadline += 1 // deadline raised to the power of 1.2 (1.2 is set in pool's config file) scaled_share = pow(deadline, 1.2) // SOME_BIG_INT is actually 0x7fffffffffffffff in the code scaled_share = SOME_BIG_INT / scaled_share sum_scaled_shares += scaled_share }So after this loop, each account's slice of the pie will be their "scaled_share" out of "sum_scaled_shares".
As a dummy run, say you have 3 miners (a, b and c) with 3 deadlines ("0", "123" aka 2 minutes 3 seconds and "8125" aka 2 hours 15 minutes 25 seconds):a's "scaled_share" would be:
0 +1 = 1 ^1.2 = 1 0x7ffffffffffffffff/ = 0x7fffffffffffffffb's scaled_share would be:
123 +1 = 124 ^1.2 = 325.16666 0x7fffffffffffffff/ = 0x0064c5df25dc5f6cc's scaled_share would be:
8125 +1 = 8126 ^1.2 = 49187.2091402907 0x7fffffffffffffff/ = 0x0000aa8b645dc96bsum_scaled_shares = 0x7fffffffffffffff + 0x0064c5df25dc5f6c + 0x0000aa8b645dc96b = 0x8065706a8a3a28d6
so as percentages:
a: 0x7fffffffffffffff / 0x8065706a8a3a28d6 = 99.6914%
b: 0x0064c5df25dc5f6c / 0x8065706a8a3a28d6 = 0.3066%
c: 0x0000aa8b645dc96b / 0x8065706a8a3a28d6 = 0.0020%99.6914% + 0.3066% + 0.0020% = 100%

