Bitcoin Forum
May 29, 2024, 01:52:39 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Can you review this code and tell me if it would work?  (Read 594 times)
utclover (OP)
Sr. Member
****
Offline Offline

Activity: 378
Merit: 250


View Profile
January 01, 2015, 11:18:06 AM
 #1

right now the block reward for the coin i launched is :
but it does not work the way i expected it to.
Code:
// block reward between 500 and 20 depending on the difficulty.
int64 nSubsidy = 0;
    if(dDiff > 250) { // GPU/ASIC difficulty calc 2000000/(((x+1900)/10)^2)
        nSubsidy = (2000000.0 / (pow((dDiff+1900.0)/10.0,2.0)));
        if (nSubsidy > 100) nSubsidy = 100;
        if (nSubsidy < 20) nSubsidy = 20;
    } else { // CPU mining calc
     nSubsidy = (11111.0 / (pow((dDiff+51.0)/6.0,2.0)));
        if (nSubsidy > 500) nSubsidy = 500;
        if (nSubsidy < 200) nSubsidy = 200;
    }

if i change that part of the code to this:
would it work? like would it hard fork at block 550?
i mean can you look through the changes and the if and else statments and the "{" and "}" to see if it would work?
thank you.
Code:
int64 nSubsidy = 0;
if(nHeight >= 550) {

if(dDiff > 75) { // GPU/ASIC difficulty calc
// 2222222/(((x+2600)/9)^2)
nSubsidy = (2222222.0 / (pow((dDiff+2600.0)/9.0,2.0)));
if (nSubsidy > 25) nSubsidy = 25;
if (nSubsidy < 5) nSubsidy = 5;
} else { // CPU mining calc
nSubsidy = (11111.0 / (pow((dDiff+51.0)/6.0,2.0)));
if (nSubsidy > 500) nSubsidy = 500;
if (nSubsidy < 25) nSubsidy = 25;
}

} else {
if(dDiff > 250) { // GPU/ASIC difficulty calc 2000000/(((x+1900)/10)^2)
nSubsidy = (2000000.0 / (pow((dDiff+1900.0)/10.0,2.0)));
if (nSubsidy > 100) nSubsidy = 100;
if (nSubsidy < 20) nSubsidy = 20;
} else { // CPU mining calc
nSubsidy = (11111.0 / (pow((dDiff+51.0)/6.0,2.0)));
if (nSubsidy > 500) nSubsidy = 500;
if (nSubsidy < 200) nSubsidy = 200;
}
}
utclover (OP)
Sr. Member
****
Offline Offline

Activity: 378
Merit: 250


View Profile
January 01, 2015, 02:44:16 PM
 #2

i commited the changes https://github.com/tuxcoindev/tuxcoin/commit/5799698144a59252648cd8bd06a7beb331f4602f
we'll see if it works.
muddafudda
Legendary
*
Offline Offline

Activity: 1008
Merit: 1022



View Profile
January 01, 2015, 03:47:53 PM
 #3

all your nSubsidy should finish in coin.

e.g.

if (nSubsidy > 100) nSubsidy = 100;


if (nSubsidy > 100) nSubsidy = 100 * COIN;


The rest look broken also with the double ifs and other things.

utclover (OP)
Sr. Member
****
Offline Offline

Activity: 378
Merit: 250


View Profile
January 01, 2015, 03:58:59 PM
 #4

all your nSubsidy should finish in coin.

e.g.

if (nSubsidy > 100) nSubsidy = 100;


if (nSubsidy > 100) nSubsidy = 100 * COIN;


The rest look broken also with the double ifs and other things.


what do you mean?
it wont work?
it hard forks at block 550 and now is block 467
i think it will work. can you tell me what you mean about the ifs being broken? to me it looks they are not broken, why do you think its broken? can you give me an example?
thank you
sorry if i am asking alot of questions. this is the first time i make a coin
utclover (OP)
Sr. Member
****
Offline Offline

Activity: 378
Merit: 250


View Profile
January 02, 2015, 01:23:39 AM
 #5

It worked  Grin
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!