Block chain

From Bitcoin Wiki
Jump to: navigation, search

Block chain is a public database of every Bitcoin transactions that has ever occured in Bitcoin network. By utilizing this base every user is able to find out what amount of Bitcoin has ever belonged to some particular address at a certain time period. The block chain is supported by decentralized efforts of many miners. With this information, one can find out how much value belonged to each address at any point in history.

The block chain is the main innovation of Bitcoin.

Principles of building

Every mined block contains hash of the previous one. That way a chain of blocks is created which origins back from the so-called genesis block (the very first block in the Bitcoin system) up until the most recent block found by network. Editing data in a block that's been a part of chain for a long time isn't practical because you'd have to edit the data in all following blocks. Thanks to these properties the double-spending attack (repeated spending of already spent money) is almost impossible to perform in Bitcoin network.

Honest miners are always building their block upon the last mined, referencing to it. The "length" of the chain is calculated based on total complexity of the chain and not on the amount of blocks in it. A continuation of chain is only considered valid if it has information about all previous chain links and the chain itself starts with genesis block.

Forks in block chain

Every block in the chain has only one path back to genesis block. However the chain can split several ways from genesis block thus forming a "fork". Forks consisting of just one block are fairly common. They appear when several nods find a block with time difference of a couple of seconds. When this happens other nods start building the block chain further upon the block which they received first. The moment any of the two blocks gets its continuation its chain is considered main in the block chain because it becomes longer.

Blocks that aren't a part of the main block chain aren't used. There's also a lower reward issued for their discovery. These blocks are called "orphan blocks". Because a block can link back to just one previous block combining 2 different chains is impossible.

Blocks in shorter chains (or invalid chains) are not used for anything. When the bitcoin client switches to another, longer chain, all valid transactions of the blocks inside the shorter chain are re-added to the pool of queued transactions and will be included in another block. The reward for the blocks on the shorter chain will not be present in the longest chain, so they will be practically lost, which is why a network-enforced 100-block maturation time for generations exists.

These blocks on the shorter chains are often called "orphan" blocks. This is because the generation transactions do not have a parent block in the longest chain, so these generation transactions show up as orphan in the listtransactions RPC call. Several pools have misinterpreted these messages and started calling their blocks "orphans". In reality, these blocks have a parent block, and might even have children.

Because a block can only reference one previous block, it is impossible for two forked chains to merge.

It's possible to use the block chain algorithm for non-financial purposes: see Alternative chain.

The block chain is broadcast to all nodes on the networking using a flood protocol.

See also