본문 바로가기

0/blockchain

Bitcoin and Cryptocurrencies Week 4 (Mining) (1)

반응형

Step 0 :

  • Download the entire Bitcoin blockchain. This only has to be done once.
    • This allows us to know the history so we can validate future transactions.
    • Note: This step is optional if you mine in a mining pool or are doing lightweight mining.

Step 1:

  • Verify transactions
    • You store newly received, unprocessed transactions in a "mempool," where all pending transactions live before making their way into a block.
    • You then choose the transactions with the highest fee per byte or size ratio to verify.
    • You verify the validity of each transaction by running the unlocking script.
    • If that script runs successfully, then the transaction is included within our block.

Step 2:

  • Create the block with the given transactions and nessasary metadata, such as time, version, and target.
    • Construct the block data from our list of valid transactions.
    • Construct the Merkle Root by hashing the hashes of each pair of transactions
    • Construct the Previous Block Hash by hashing the previous block's header

 

Step 3:

  • Find the proof-of-work that solves the partial preimage hash puzzle.
    • A valid nonce makes the hash of the block header less than some algorithmically generated value known as the "target."
    • By finding the nonce, we have translated the energy burned in computation into voting power, as designed by the Proof-of-Work consensus protocol.
    • Note: There are two different nonces, the header nonce and the coinbase nonce. In the event that no permutation of the header nonce solves the hash puzzle, alter the coinbase nonce. This changes the Merkle root, yielding an entirely different hash puzzle.

Step 4:

  • Broadcast your block if you have not yet seen any competitor blocks.
    • After finding the valid proof-of-work, broadcast the block as soon as possible.
    • Other miners will validate the block for themselves before accepting it into their chain and propagating it further through the network.

Step 5:

  • If your block makes it into the longest chain, you profit!
    • You receive both the block reward and the transaction fees,
    • All the transactions within that block are added to the transaction history.
    • Note: When two valid blocks are submitted to the network at roughly the same time, resulting in a fork, honest miners choose to mine on whichever block they see first. You will not receive block reward if the other fork grows longer.

 

이 글은 edX의 Bitcoin and Cryptocurrencies 강의 자료를 참고하여 정리한 글입니다.

반응형