Skip to content

N Factor

Alistair Buxton edited this page May 10, 2013 · 3 revisions

Yacoin adjusts the N factor of the hash using a formula which is based on block time.

Dates

N Factor change dates.
N Factor N UTC Time Unix Time
4 16 2013-05-08 06:33:20 1367991200
5 32 2013-05-14 08:11:28 1368515488
6 64 2013-05-17 09:00:32 1368777632
7 128 2013-05-20 09:49:36 1369039776
8 256 2013-05-29 12:16:48 1369826208
9 512 2013-06-01 13:05:52 1370088352
10 1024 2013-06-25 19:38:24 1372185504
11 2048 2013-07-07 22:54:40 1373234080
12 4096 2013-08-13 08:43:28 1376379808
13 8192 2013-09-30 21:48:32 1380574112
14 16384 2013-11-18 09:53:36 1384768416
15 32768 2014-05-31 15:13:52 1401545632
16 65536 2014-09-05 17:24:00 1409934240
17 131072 2015-06-23 23:54:24 1435100064
18 262144 2016-07-16 08:34:56 1468654496
19 524288 2017-08-08 17:15:28 1502208928
20 1048576 2020-10-16 19:17:04 1602872224
21 2097152 2021-11-09 02:57:36 1636426656
22 4194304 2030-05-13 01:21:52 1904862112
23 8388608 2038-11-13 21:46:08 2173297568
24 16777216 2047-05-17 20:10:24 2441733024
25 33554432 2072-11-22 11:23:12 3247039392
26 67108864 2081-05-26 09:47:28 3515474848
27 134217728 2149-06-14 13:01:36 5662958496
28 268435456 2183-06-24 02:38:40 6736700320
29 536870912 2285-07-21 19:29:52 9957925792
30 1073741824 2421-08-28 01:58:08 14252893088

Algorithm

// yacoin: increasing Nfactor gradually
const unsigned char minNfactor = 4;
const unsigned char maxNfactor = 30;
int64 nChainStartTime = 1367991200;

unsigned char GetNfactor(int64 nTimestamp) {
    int l = 0;

    if (nTimestamp <= nChainStartTime)
        return 4;

    int64 s = nTimestamp - nChainStartTime;
    while ((s >> 1) > 3) {
      l += 1;
      s >>= 1;
    }

    s &= 3;

    int n = (l * 170 + s * 25 - 2320) / 100;

    if (n < 0) n = 0;

    if (n > 255)
        printf("GetNfactor(%d) - something wrong(n == %d)\n", nTimestamp, n);

    unsigned char N = (unsigned char)n;

    return min(max(N, minNfactor), maxNfactor);
}
Clone this wiki locally