我正在帮助一个山寨币社区,需要改变它的重新定位难度。到目前为止,我已经为新钱包编写了一些代码。
这是我对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)
此代码是否正确或是否还有其他事情要做?
谢谢,我感谢您的帮助。
答案 0 :(得分:-1)
你的代码看起来不错。我想知道同样的事情,所以我改变了它,但我得到了这个错误
GetNextWorkRequired RETARGET
nTargetTimespan = 60 nActualTimespan = 79
Before: 1d0d7333 0000000d73330000000000000000000000000000000000000000000000000000
After: 1d11b58b 00000011b58baeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
ERROR: AcceptBlock() : incorrect proof of work
ERROR: ProcessBlock() : AcceptBlock FAILED
我不知道如果我发布新钱包它是否可行