Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support CheckPoints #350

Closed
wants to merge 18 commits into from
Closed

Support CheckPoints #350

wants to merge 18 commits into from

Conversation

AlexiaChen
Copy link
Contributor

More detailed description in #343

@AlexiaChen AlexiaChen added the enhancement New feature or request label Dec 25, 2019
@AlexiaChen AlexiaChen self-assigned this Dec 25, 2019
@cchanm
Copy link
Contributor

cchanm commented Dec 30, 2019

CBlockChain类中
const int nCheckpointConfirmations{ 2016 };
CBlock checkPointBlock;
CCheckPoint nextCheckPoint;
这几个参数未被使用。

std::map<int, CCheckPoint> mapCheckPoints;
std::vector<CCheckPoint> vecCheckPoints;

这两个参数看看有没有必要合并成一个,感觉有点重了,是不是要高度值排序的功能,map好像也可以排序,可以使用map的反向迭代器,只是建议,看看有没有可以优化的。

FindPreviousCheckPointBlock这个函数在testnet情况下,会true返回,但block没有数据,CNetChannel里又使用了block里的nTimeStamp,值为0,if (checkPointBlock.nTimeStamp > block.nTimeStamp)不会产生错误,但代码上不够清晰,建议在CNetChannel里针对mainnet才处理这个检查点。

没有发现其它问题

@AlexiaChen
Copy link
Contributor Author

@cch809094 可以删掉,现在确实没用。之前以为是要用的。稍等。

@AlexiaChen
Copy link
Contributor Author

AlexiaChen commented Dec 30, 2019

CBlockChain类中
const int nCheckpointConfirmations{ 2016 };
CBlock checkPointBlock;
CCheckPoint nextCheckPoint;
这几个参数未被使用

std::map<int, CCheckPoint> mapCheckPoints;
std::vector<CCheckPoint> vecCheckPoints;

这两个参数看看有没有必要合并成一个,感觉有点重了,是不是要高度值排序的功能,map好像也可以排序吧

map是查找,vector是高效率遍历,典型的空间换时间。遍历map性能是不如vector的。因为BTC是这么做的。我也只是参考它来实现。BTC的代码报告在这里: #343 , 你也可以看看。

@AlexiaChen
Copy link
Contributor Author

AlexiaChen commented Dec 31, 2019

CBlockChain类中
const int nCheckpointConfirmations{ 2016 };
CBlock checkPointBlock;
CCheckPoint nextCheckPoint;
这几个参数未被使用。

std::map<int, CCheckPoint> mapCheckPoints;
std::vector<CCheckPoint> vecCheckPoints;

这两个参数看看有没有必要合并成一个,感觉有点重了,是不是要高度值排序的功能,map好像也可以排序,可以使用map的反向迭代器,只是建议,看看有没有可以优化的。

FindPreviousCheckPointBlock这个函数在testnet情况下,会true返回,但block没有数据,CNetChannel里又使用了block里的nTimeStamp,值为0,if (checkPointBlock.nTimeStamp > block.nTimeStamp)不会产生错误,但代码上不够清晰,建议在CNetChannel里针对mainnet才处理这个检查点。

没有发现其它问题

好的

@AlexiaChen
Copy link
Contributor Author

暂时关闭,需要更新下检查点。

@AlexiaChen AlexiaChen closed this Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants