c++ - 如何改变山寨币的重定向难度

标签 c++ bitcoin

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

这是我对 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/

相关文章:

bitcoin - 区 block 链是去中心化数据库吗?

正则表达式匹配比特币地址?

c++ - 由另一个 CRTP 子类访问数据/方法

c++ - 函数声明有什么问题?

c++ - C++的依赖注入(inject)框架

c++ - 无法初始化 ifstream "Error reading characters of string"

java - 从 jar 文件写入 $HOME

C++ 检查类对象是否包含某个元素

c++ - 了解 C++ 中的以下数据类型

javascript - 重新启动 bitcoind 守护进程,以防 Node.js 代码崩溃