github.com/lbryio/lbcd@v0.22.119/blockchain/README.md (about) 1 blockchain 2 ========== 3 4 [![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) 5 6 ### Bitcoin Chain Processing Overview 7 8 Before a block is allowed into the block chain, it must go through an intensive 9 series of validation rules. The following list serves as a general outline of 10 those rules to provide some intuition into what is going on under the hood, but 11 is by no means exhaustive: 12 13 - Reject duplicate blocks 14 - Perform a series of sanity checks on the block and its transactions such as 15 verifying proof of work, timestamps, number and character of transactions, 16 transaction amounts, script complexity, and merkle root calculations 17 - Compare the block against predetermined checkpoints for expected timestamps 18 and difficulty based on elapsed time since the checkpoint 19 - Save the most recent orphan blocks for a limited time in case their parent 20 blocks become available 21 - Stop processing if the block is an orphan as the rest of the processing 22 depends on the block's position within the block chain 23 - Perform a series of more thorough checks that depend on the block's position 24 within the block chain such as verifying block difficulties adhere to 25 difficulty retarget rules, timestamps are after the median of the last 26 several blocks, all transactions are finalized, checkpoint blocks match, and 27 block versions are in line with the previous blocks 28 - Determine how the block fits into the chain and perform different actions 29 accordingly in order to ensure any side chains which have higher difficulty 30 than the main chain become the new main chain 31 - When a block is being connected to the main chain (either through 32 reorganization of a side chain to the main chain or just extending the 33 main chain), perform further checks on the block's transactions such as 34 verifying transaction duplicates, script complexity for the combination of 35 connected scripts, coinbase maturity, double spends, and connected 36 transaction values 37 - Run the transaction scripts to verify the spender is allowed to spend the 38 coins 39 - Insert the block into the block database