Logic burn Brain: a simple implementation of Python blockchain

Source: Internet
Author: User

Blockchain technology is widely watched because of the popularity of Bitcoin, where we use Python code to talk about blockchain technology:

Simple description of the principle of blockchain implementation

Blockchain technology as a digital bookkeeping technology, its core is to save the transaction data block, in an encrypted manner, in chronological order chain records. The blockchain itself is a public database in which the newly-created business data is stored in a container called a chunk and added to the chain of existing chunks. A bit like a snake, the more chunks eaten, the longer the snake's body; in the case of Bitcoin, the data is a set of transfer transactions. In the case of a shared bike, the data can be a loan-to-car transaction.

Easy implementation code for blockchain

In the above code, the blockchain core storage data structure is a list, through the New_block () generated by the new block, is constantly added to the end of the blockchain, each chunk of the hash value contains all the data information of the chunk, in the process of calculating the hash value to refer to the previous chunk of the hash value, Therefore, tamper-proof is achieved. The maximum value of a blockchain database is this highly tamper-proof, trusted computing. This has been successfully demonstrated in our simple blockchain implementation. In a commercial-grade blockchain application, the process of creating a new block is called a smart contract, and the blockchain is constantly growing through smart contracts.

The following is the result of the code running, at different times, the results are different.

Run results

To learn more about it technology, go to the 51Testing Software testing network-the spiritual homeland of Chinese Software Testers (http://www.51testing.com).

Logic burn Brain: a simple implementation of Python blockchain

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.