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

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

伊谢尔伦
伊谢尔伦

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

reply all(2)
小葫芦

The article comes from Zhihu: A simple explanation of Bitcoin Author: Wu Hao

  • Chapter Negative Feedback

    • Section 1 Risk Warning
    • Section 2 Abridged Version
  • Chapter 0 Toys
  • Chapter 1 Bill

    • Section 1 Tear-up Paper Game
    • Section 2 Bill Chain
    • Section 3 Game Rules
    • Fourth Quarter 21 million
  • Chapter 2 Payment

    • Section 1 Anonymous
    • Second node peer-to-peer
    • Section 3 Important Details
  • Chapter 3 Sofa --Summary and FAQ

    • Section 1 Subjective Assumptions
    • Section 2 Objective Facts
    • Section 3 Conclusion

The author added "Chapter Negative Chapter 2, Abridged Version" on 2013-11-22 and provided a source code:

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 of 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)
}
////////////////////////////////////////////////////// ///////////////

Although there is no analysis now, please wait for the author's update.

----Updated at 2013-12-10 13:16---

It is a pity that the author's reply was: "I have no intention to continue writing."

小葫芦

The MAIN function is in bitcoinGUI.cpp or bitcoind.cpp. Check DOC/BUILD-WIN.MD for compilation methods

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template