Blockchain Python IOT
blockchain technology does not rely on additional third-party management institutions or hardware facilities, and there is no central control. In addition to the self-contained blockchain itself, each node realizes information self verification, transmission and management through distributed accounting and storage. Decentralization is the most prominent and essential feature of blockchain< Second, openness:
the foundation of blockchain technology is open source. In addition to the private information of all parties to the transaction is encrypted, the data of blockchain is open to all. Anyone can query blockchain data and develop related applications through the open interface, so the information of the whole system is highly transparent< Third, independence:
based on consensus specifications and Protocols (similar to various mathematical algorithms such as hash algorithm used by bitcoin), the whole blockchain system does not rely on other third parties, and all nodes can automatically and safely verify and exchange data in the system without any human intervention< Fourth, security:
as long as 51% of all data nodes cannot be controlled, the network data cannot be arbitrarily controlled and modified, which makes the blockchain itself relatively safe and avoids subjective and artificial data changes
5. Anonymity:
unless there are legal requirements, technically speaking, the identity information of each block node does not need to be disclosed or verified, and information transmission can be carried out anonymously
Digital China is the first major development strategy explicitly put forward in the report of the 19th National Congress of the Communist Party of China. The application of digital technology represented by cloud computing, big data and mobile Internet is no longer limited to the economic field, but widely penetrated into all aspects of public services, social development and people's life, which requires macro coordination, overall control and integrated development
with the deepening of a new round of scientific and technological revolution and instrial change, the tide of digital economy in the world is unstoppable. The development of digital economy has become a global consensus, known as the key to the fourth instrial revolution
adhering to the connotation of the University of nice's world inclusive humanistic spirit, always embracing change, standing up to the tide, conforming to the development trend of the digital economy era, and integrating the essence of Chinese and Western cultural thinking, the University of nice's doctor of blockchain and digital economy management (DDE) came into being
based on this, we can enable the managers of digital economy instry to have global vision and global integration thinking, integrate knowledge, operate digital economy intelligently, promote the sustainable development of the instry, and contribute to the community of human destiny. Therefore, DDE project will cooperate with colleagues in the field of digital economy
if you have MBA related questions, you are welcome to contact me personally 180; 65381; 7447; 65381;` ) Bixin~~~~
e to the use of Distributed Accounting and storage, there is no centralized hardware or management organization, the rights and obligations of any node are equal, and the data blocks in the system are jointly maintained by the nodes with maintenance function in the whole system
openness
the system is open, in addition to the private information of all parties to the transaction is encrypted, the data of the blockchain is open to all, and anyone can query the blockchain data and develop related applications through the open interface, so the information of the whole system is highly transparent
autonomy
blockchain adopts consensus based specifications and Protocols (such as a set of open and transparent algorithms) to enable all nodes in the whole system to exchange data freely and safely in a de trusted environment, so that the trust in "people" is changed into the trust in machines, and any human intervention does not work
information cannot be tampered with
once the information is verified and added to the blockchain, it will be stored permanently. Unless more than 51% of the nodes in the system can be controlled at the same time, the modification of the database on a single node is invalid, so the data stability and reliability of the blockchain are extremely high<
anonymity
since the exchange between nodes follows a fixed algorithm, their data interaction does not need to be trusted (the program rules in the blockchain will judge whether the activity is effective by themselves), so the counterparties do not need to trust themselves by disclosing their identities, which is very helpful for credit accumulation
features:
blockchain is an immutable and orderly chain record composed of block records. The main features are as follows:
1: decentralization
e to the use of Distributed Accounting and storage, there is no centralized hardware or management organization, the rights and obligations of any node are equal, and the data blocks in the system are jointly maintained by the nodes with maintenance function in the whole system. Thanks to the decentralization of blockchain, bitcoin also has the characteristics of decentralization
2: openness
the system is open, in addition to the private information of the parties to the transaction is encrypted, the data of the blockchain is open to all, and anyone can query the blockchain data and develop related applications through the open interface, so the information of the whole system is highly transparent
3: autonomy
blockchain adopts consensus based specifications and Protocols (such as a set of open and transparent algorithms) to enable all nodes in the whole system to exchange data freely and safely in a de trusted environment, so that the trust in "people" is changed into the trust in machines, and any human intervention does not work
4: information cannot be tampered with
once the information is verified and added to the blockchain, it will be stored permanently. Unless more than 51% of the nodes in the system can be controlled at the same time, the modification of the database on a single node is invalid, so the data stability and reliability of the blockchain are extremely high
5: anonymity
since the exchange between nodes follows a fixed algorithm, their data interaction does not need to be trusted (the program rules in the blockchain will judge whether the activity is effective by themselves), so the counterparties do not need to make the other party trust themselves by disclosing their identities, which is very helpful for credit accumulation
compared with the traditional distributed database, there are two main differences:
1: the traditional distributed database supports adding, deleting, checking and modifying, while the blockchain only supports searching and inserting, and blocks cannot be deleted or modified
2: the traditional distributed database is generally a master-slave structure: master and slaves structure. In order to ensure high availability, it is realized by standby master, while the blockchain is a decentralized database. There is no master-slave structure
blockchain and bitcoin:
when it comes to blockchain, most people talk about bitcoin. However, blockchain is not equal to bitcoin. It is now the era of blockchain 3.0, and bitcoin is only the proct of blockchain 1.0
the evolution mode of blockchain is:
& ᦇ 9642; Blockchain 1.0 digital currency; Blockchain 2.0 digital assets and smart contracts; Blockchain 3.0 - Implementation of distributed applications in various instries
classification of blockchain:
public blockchains
public blockchain means that any indivial or group in the world can send transactions, and transactions can be effectively confirmed by the blockchain, and anyone can participate in its consensus process. Public blockchain is the earliest and the most widely used blockchain. The virtual digital currencies of bitcoin series are all based on public blockchain. There is only one blockchain corresponding to this currency in the world
consortium blockchains
instry blockchains: multiple preselected nodes are designated as bookkeepers within a certain group, and the generation of each block is jointly determined by all preselected nodes (preselected nodes participate in the consensus process). Other access nodes can participate in transactions, but not the bookkeeping process (essentially, trusteeship bookkeeping), It just becomes distributed accounting, the number of preselected nodes, and how to determine the bookkeeper of each block to become the main risk point of the blockchain). Anyone else can conct limited query through the open API of the blockchain
private blockchain: it only uses the general ledger technology of blockchain for bookkeeping. It can be a company or an indivial, enjoying the write permission of the blockchain. This blockchain is not very different from other distributed storage schemes Dec2015) conservative giants (traditional finance) want to experiment with private blockchain, while the application of public chain, such as bitcoin, has been instrialized, and the application procts of private chain are still groping.
Can be
blockchain to achieve a simple description of the principle of
blockchain technology as a digital accounting technology, its core is to save the transaction data block, in the form of encryption, according to the order of time chain record. Blockchain itself is a public database. The system stores the new business data in a container called block, and adds the block to the chain composed of existing blocks. It's a bit like a snake. The more you eat, the longer the snake's body; In the application scenario of bitcoin, the data is a set of transfer transaction records. In the application scenario of bike sharing, these data can be the transaction records of car borrowing and returning
The simple implementation code ofblockchain
in the above code, the data structure stored in the core of blockchain is list, which can be accessed through
new_ New blocks generated by block () are constantly added to the end of the blockchain. The hash value of each block contains all the data information of the block. In the process of calculating the hash
value, the hash
value of the previous block needs to be referenced, so tamper proof is realized. The biggest value of blockchain database is this highly tamper proof trusted computing. This has been successfully demonstrated in our simple blockchain implementation. In commercial level blockchain applications, the process of creating new blocks is called smart contract, and blockchain is growing through smart contract
the following is the running result of the code, which is different at different times
running results
< img / >
and Python is an object-oriented interpretive computer programming language
it's better to learn together without conflict. I think it's Python because it's a language that can do a lot of things.
1 import hashlib as hasher
2 import datetime as date
3
4 # Define what a Snakecoin block is
5 class Block:
6 def __init__(self, index, timestamp, data, previous_hash):
7 self.index = index
8 self.timestamp = timestamp
9 self.data = data
10 self.previous_hash = previous_hash
11 self.hash = self.hash_block()
12
13 def hash_block(self):
14 sha = hasher.sha256()
15 sha.update(str(self.index) + str(self.timestamp) + str(self.data) + str(self.previous_hash))
16 return sha.hexdigest()
17
18 # Generate genesis block
19 def create_genesis_block():
20 # Manually construct a block with
21 # index zero and arbitrary previous hash
22 return Block(0, date.datetime.now(), "Genesis Block", "0")
23
24 # Generate all later blocks in the blockchain
25 def next_block(last_block):
26 this_index = last_block.index + 1
27 this_timestamp = date.datetime.now()
28 this_data = "Hey! I'm block " + str(this_index)
29 this_hash = last_block.hash
30 return Block(this_index, this_timestamp, this_data, this_hash)
31
32 # Create the blockchain and add the genesis block
33 blockchain = [create_genesis_block()]
34 previous_block = blockchain[0]
35
36 # How many blocks should we add to the chain
37 # after the genesis block
38 num_of_blocks_to_add = 20
39
40 # Add blocks to the chain
41 for i in range(0, num_of_blocks_to_add):
42 block_to_add = next_block(previous_block)
43 blockchain.append(block_to_add)
44 previous_block = block_to_add
45 # Tell everyone about it!
46 print "Block #{} has been added to the blockchain!".format(block_to_add.index)
47 print "Hash: {}\n".format(block_to_add.hash)
******************************************************************************
* @file stm32_eth.c
* @author MCD Application Team
* @version V1.1.0
* @date 11/20/2009
* @brief This file provides all the ETH firmware functions.
******************************************************************************
* @
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
* <h2><center>© COPYRIGHT 2009 STMicroelectronics</center></h2>
*/