我正在帮助一个需要改变其重定向难度的山寨币社区。到目前为止,我已经为新钱包编写了一些代码。
这是我对 main.cpp 文件所做的
我想将重新定位难度从 960 个区 block (1 天)更改为 40 个区 block (1 小时)的硬币。我希望发生更改的 block 是 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)
这段代码是正确的还是需要做其他事情?
谢谢,感谢任何帮助。
最佳答案
你的代码看起来不错。我也在想同样的问题,所以我像你一样改变了它,但是我得到了这个错误
GetNextWorkRequired RETARGET
nTargetTimespan = 60 nActualTimespan = 79
Before: 1d0d7333 0000000d73330000000000000000000000000000000000000000000000000000
After: 1d11b58b 00000011b58baeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
ERROR: AcceptBlock() : incorrect proof of work
ERROR: ProcessBlock() : AcceptBlock FAILED
我不知道如果我发布新钱包是否可以使用
关于c++ - 如何改变山寨币的重定向难度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21568400/