【问题标题】:How To Change Retarget Difficulty For An Altcoin如何更改山寨币的重定向难度
【发布时间】:2023-03-14 12:42:01
【问题描述】:

我正在帮助一个需要改变其重定向难度的山寨币社区。到目前为止,我已经为新钱包编写了一些代码。

这是我对 main.cpp 文件所做的

我想将重新定位难度从 960 块(1 天)更改为 40 块(1 小时)一个硬币。我希望更改发生的块是 28000。

来自:

static const int64 nTargetTimespan = 1 * 24 * 60 * 60; // UFO: 1 days
static const int64 nTargetSpacing = 90; // UFO: 1.5 minute blocks
static const int64 nInterval = nTargetTimespan / nTargetSpacing;
static const int64 nReTargetHistoryFact = 4; // look at 4 times the retarget interval into block history

到:

static int64 nTargetTimespan = 1 * 24 * 60 * 60; // 1 day
static int64 nTargetSpacing = 90; // 1.5 minute blocks
static int64 nInterval = nTargetTimespan / nTargetSpacing;
static int64 nReTargetHistoryFact = 4; // look at 4 times the retarget interval into block history

然后在 GetNextWorkRequired 函数中:

来自:

// Genesis block
if (pindexLast == NULL)
    return nProofOfWorkLimit;

// Only change once per interval
if ((pindexLast->nHeight+1) % nInterval != 0)

到:

// Genesis block
if (pindexLast == NULL)
    return nProofOfWorkLimit;

// From block 28000 reassess the difficulty every 40 blocks
// Reduce Retarget factor to 2
if(pindexLast->nHeight >= 28000)
{
    nTargetTimespan = 60 * 60; // 1 hours
    nTargetSpacing = 1.5 * 60; // 1.5 minutes
    nInterval = nTargetTimespan / nTargetSpacing;
    nReTargetHistoryFact = 2;
}
else
{
    nTargetTimespan = 1 * 24 * 60 * 60; // 1 day
    nTargetSpacing = 1.5 * 60; // 1.5 minutes
    nInterval = nTargetTimespan / nTargetSpacing;
    nReTargetHistoryFact = 4;
}

// Only change once per interval
if ((pindexLast->nHeight+1) % nInterval != 0)

这段代码是正确的还是需要做其他事情?

感谢任何帮助。

【问题讨论】:

  • 嗨..有任何解决方案来实现它..??

标签: c++ bitcoin


【解决方案1】:

您的代码看起来不错。我也想知道,所以我像你一样改变了它,但我得到了这个错误

  GetNextWorkRequired RETARGET
nTargetTimespan = 60    nActualTimespan = 79
Before: 1d0d7333  0000000d73330000000000000000000000000000000000000000000000000000
After:  1d11b58b  00000011b58baeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
ERROR: AcceptBlock() : incorrect proof of work
ERROR: ProcessBlock() : AcceptBlock FAILED

我不知道如果我发布新钱包是否可以工作

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-02-20
    • 1970-01-01
    • 1970-01-01
    • 2013-11-12
    • 1970-01-01
    • 1970-01-01
    • 2022-01-24
    • 2020-12-08
    相关资源
    最近更新 更多