c++ - 比特币最近这么热,有人分析过其源码么?
伊谢尔伦
伊谢尔伦 2017-04-17 11:13:12
0
2
652

从github上clone了bitcoin的源码,看src文件里大多是cpp文件,应该是用c++写的,但是没找到main函数,如果我想在windows上编译运行,如何做呢?有人分析过源码么?

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

全部回复(2)
小葫芦

文章来自知乎:深入浅出比特币 作者:Wu Hao

  • 第负一章 反馈

    • 第一节 风险警示
    • 第二节 删节版
  • 第零章 玩具
  • 第一章 账单

    • 第一节 撕纸游戏
    • 第二节 账单链
    • 第三节 游戏规则
    • 第四节 2100万
  • 第二章 支付

    • 第一节 匿名
    • 第二节 点对点
    • 第三节 重要的细节
  • 第三章 沙发 --总结以及FAQ

    • 第一节 主观臆断
    • 第二节 客观事实
    • 第三节 结语

作者在 2013-11-22 添加了「第负一章 第二节 删节版」,并提供了一段源码:

function mine()
{
    while(true)
    {
        longestChain = getLongestValidChain()

        -- A number that changes every time, so that you don't waste time 
        -- trying to calculate a valid blockHash with the same input.
        nonce = getNewNonce()

        currentTXs = getUnconfirmedTransactionsFromNetwork()

        newBlock = getNewBlock(longestChain, currentTX, nonce)

        -- http://en.wikipedia.org/wiki/SHA-2
        -- and this is what all the "mining machines" are doing.
        blockHash = sha256(newBlock)

        if(meetReqirements(blockHash))
        {
            broadcast(newBlock)
            -- Now the height the block chain is incremented by 1
            -- (if the new block is accepted by other peers),
            -- and all the TXs in the new block are "confirmed"
        }
    }
}
////////////////////////////////////////////////////////////////
function sendBTC(amount)
{
    sourceTXs = pickConfirmedTransactionsToBeSpent(amount)
    tx = generateTX(sourceTXs, targetAddrs, amount, fee)
    signedTx = sign(tx, privateKeysOfAllInputAddress)
    broadcast(signedTx)
}
////////////////////////////////////////////////////////////////

现在虽然没有分析,不过静待作者的更新吧。

----2013-12-10 13:16 更新---

非常遗憾,作者的回信是:“没有继续写的打算”。

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!