Bitcoin Forum
November 13, 2024, 01:20:04 PM *
News: Check out the artwork 1Dq created to commemorate this forum's 15th anniversary
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Retargeting algorithm  (Read 1957 times)
Jimmy2011 (OP)
Hero Member
*****
Offline Offline

Activity: 589
Merit: 500



View Profile
August 28, 2011, 02:58:38 AM
Last edit: August 28, 2011, 05:56:53 AM by Jimmy2011
 #1

Retargeting algorithm before seems that difficulty was constantly changing. Why should be that? Why not adjust it in time, that means, for example, adjust it with an adjustment factor t_0/t and also an adjustment coefficient zeta is multiplied, zeta = 0.8 for some case and zeta = 1.1 for the other case as an example. Furthermore, zeta can also be adjusted automatically according to some rules.

One more problem is how to get more and more miners and mining power to involve?
NothinG
Hero Member
*****
Offline Offline

Activity: 560
Merit: 500



View Profile
August 28, 2011, 03:07:02 AM
 #2

1) Spend Money (for mining rigs, electricity)
2) Mine BTC
3) Huh
4) Profit!

Jimmy2011 (OP)
Hero Member
*****
Offline Offline

Activity: 589
Merit: 500



View Profile
August 28, 2011, 03:31:03 AM
 #3

1) Spend Money (for mining rigs, electricity)
2) Mine BTC
3) Huh
4) Profit!

Sorry, my question is how to transfer the existing power to the new fork by an algorithm so as to let the fork reach a modest scale.
smoothie
Legendary
*
Offline Offline

Activity: 2492
Merit: 1474


LEALANA Bitcoin Grim Reaper


View Profile
August 28, 2011, 05:42:56 AM
 #4

1) Spend Money (for mining rigs, electricity)
2) Mine BTC
3) Huh
4) Profit!

Sorry, my question is how to transfer the existing power to the new fork by an algorithm so as to let the fork reach a modest scale.


He answered u correctly. You pay the miners for their rigs and the electricity bills and they mine on the network of your choosing...etc..

███████████████████████████████████████

            ,╓p@@███████@╗╖,           
        ,p████████████████████N,       
      d█████████████████████████b     
    d██████████████████████████████æ   
  ,████²█████████████████████████████, 
 ,█████  ╙████████████████████╨  █████y
 ██████    `████████████████`    ██████
║██████       Ñ███████████`      ███████
███████         ╩██████Ñ         ███████
███████    ▐▄     ²██╩     a▌    ███████
╢██████    ▐▓█▄          ▄█▓▌    ███████
 ██████    ▐▓▓▓▓▌,     ▄█▓▓▓▌    ██████─
           ▐▓▓▓▓▓▓█,,▄▓▓▓▓▓▓▌          
           ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌          
    ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓─  
     ²▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓╩    
        ▀▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀       
           ²▀▀▓▓▓▓▓▓▓▓▓▓▓▓▀▀`          
                   ²²²                 
███████████████████████████████████████

. ★☆ WWW.LEALANA.COM        My PGP fingerprint is A764D833.                  History of Monero development Visualization ★☆ .
LEALANA BITCOIN GRIM REAPER SILVER COINS.
 
Jimmy2011 (OP)
Hero Member
*****
Offline Offline

Activity: 589
Merit: 500



View Profile
August 28, 2011, 05:57:49 AM
 #5

Retargeting algorithm before seems that difficulty was constantly changing. Why should be that? Why not adjust it in time, that means, for example, adjust it with an adjustment factor t_0/t and also an adjustment coefficient zeta is multiplied, zeta = 0.8 for some case and zeta = 1.1 for the other case as an example. Furthermore, zeta can also be adjusted automatically according to some rules.

One more problem is how to get more and more miners and mining power to involve?


It may be not a problem.
Jimmy2011 (OP)
Hero Member
*****
Offline Offline

Activity: 589
Merit: 500



View Profile
August 29, 2011, 12:40:44 AM
 #6

A similar coin can be defined:
1) every 15/4 minutes generate a block
2) each block rewards 32 coins
3) retarget every 64 blocks or 128 blocks
4) the rewards for each block changed to a half every 262144 blocks
5) the limited amount is 16777216 coins
6) zeta in the retargeting algorithm can be simply defined or calculate it in site with theoretical expected probability and an attractive parameter

P.S. could someone get a code to do some analysis on SC?
a) actual consuming time for each block
b) average time of a block in a window of 240 blocks at the same difficulty
c) actual distribution for the block generation time
d) some curves for the quantities change with time

I am not familiar with coding, if someone is interesting, take it and do it, and if you get something please post here. Thanks!

Jimmy2011 (OP)
Hero Member
*****
Offline Offline

Activity: 589
Merit: 500



View Profile
September 05, 2011, 01:51:40 AM
Last edit: September 05, 2011, 03:55:04 AM by Jimmy2011
 #7

I post one example of such algorithms as the following code segment. Just an example, it's not usable directly, some necessary validity changes and modifications, optimization should be added for the actual application.

Anyone can use it as long as you find it useful.

------------------------------------------------------------------

// Go back by what we want to be 14 days worth of blocks
    const CBlockIndex* pindexFirst = pindexLast;
    for (int i = 0; pindexFirst && i < nInterval-1; i++)
        pindexFirst = pindexFirst->pprev;
    assert(pindexFirst);

    // Limit adjustment step
    int64 nActualTimespan = pindexLast->GetBlockTime() - pindexFirst->GetBlockTime();
    printf("  nActualTimespan = %"PRI64d"  before bounds\n", nActualTimespan);

    int64 nThisTimespan = nActualTimespan;

   if (nActualTimespan < nTargetTimespan/4)
        nActualTimespan = nTargetTimespan/4;
    if (nActualTimespan > nTargetTimespan*4)
        nActualTimespan = nTargetTimespan*4;

    
    const CBlockIndex* pindexPreviousFirst = pindexFirst;
    for (int i = 0; pindexPreviousFirst && i < nInterval-1; i++)
        pindexPreviousFirst = pindexPreviousFirst->pprev;
    assert(pindexPreviousFirst);                                                        

    int64 nPreviousTimespan = pindexFirst->GetBlockTime() - pindexPreviousFirst->GetBlockTime();


// Retarget
    CBigNum bnNew;
    bnNew.SetCompact(pindexLast->nBits);
    bnNew *= nActualTimespan;

    if ( ( nPreviousTimespan > nThisTimespan ) && ( nPreviousTimespan < nTargetTimespan ) )
    {
                
         bnNew *= 2;
         bnNew /= ( nTargetTimespan + nActualTimespan );
    
     }
     else if ( ( nPreviousTimespan < nThisTimespan ) && ( nPreviousTimespan > nTargetTimespan ) )
     {
          bnNew *=  nActualTimespan;
          bnNew /= ( nTargetTimespan * nTargetTimespan );
      }
      else
      {
          
               bnNew /= nTargetTimespan;
       }

      
      if (bnNew > bnProofOfWorkLimit)
        bnNew = bnProofOfWorkLimit;

    /// debug print
    printf("GetNextWorkRequired RETARGET\n");
    printf("nTargetTimespan = %"PRI64d"    nActualTimespan = %"PRI64d"\n", nTargetTimespan, nActualTimespan);
    printf("Before: %08x  %s\n", pindexLast->nBits, CBigNum().SetCompact(pindexLast->nBits).getuint256().ToString().c_str());
    printf("After:  %08x  %s\n", bnNew.GetCompact(), bnNew.getuint256().ToString().c_str());

    return bnNew.GetCompact();

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!