为广大币圈朋友提供币圈基础入门专业知识!
当前位置首页 > 区块链知识> 正文

区块链怎么实现广播功能,区块链怎么实现广播传播

发布时间:2023-12-05-21:02:00 来源:网络 区块链知识 区块

区块链怎么实现广播功能,区块链怎么实现广播传播

区块链是一种分布式数据库技术,它可以让用户在网络上安全地进行交易。它的一个重要特性是可以实现广播传播,可以让用户安全地将信息传播给网络中的其他用户。

区块链的广播功能可以通过一种叫做“共识机制”的技术来实现。这种机制允许网络中的每个节点都能够收到网络中发出的信息,从而使得信息能够安全地传播给网络中的其他用户。

共识机制可以通过多种方式来实现,但最常用的是“工作量证明”(Proof-of-Work)。工作量证明是一种技术,它要求网络中的节点在发送信息之前必须解决一个复杂的数学难题。这个难题可以防止恶意用户发送垃圾信息,并保证网络中的信息能够安全地传播给网络中的其他用户。

另外,区块链还可以通过智能合约来实现广播传播。智能合约是一种计算机程序,它可以自动执行某些特定条件下的交易。这种技术可以让用户在网络中安全地传播信息,并确保网络中的信息能够安全地传播给网络中的其他用户。

总之,区块链可以通过工作量证明和智能合约等技术来实现广播传播。这种技术可以让用户安全地将信息传播给网络中的其他用户,并确保网络中的信息能够安全地传播给网络中的其他用户。因此,区块链技术可以为用户提供安全可靠的广播传播功能,并有助于保护网络中的数据安全。


请查看相关英文文档

『一』What is the specific workflow of blockchain

Blockchain is a distributed database system participated by nodes. Its characteristic is that it cannot Changes cannot be forged. We can also understand it as an accounting system. It is an important concept of Bitcoin, a copy of the complete Bitcoin blockchain, recording every transaction in it. Through this information, we can find the value of each address at any point in history.

The blockchain is composed of a series of data blocks generated using cryptographic methods. Each block contains the hash value of the previous block, starting from the genesis block and connecting to the current block. Blocks form a block chain.

『二』How does Bitcoin broadcast to the entire network?

Two statements are for reference, both found from Babbitt:

Bitcoin Taking a mathematical race to determine when transactions arrive at a node while protecting this order, transactions are ordered in the Bitcoin system by assigning them into groups. Such groups are called blocks ( Transactions that occur at the same time will be grouped into the same block), and then linking these blocks is called a blockchain. The blockchain is used to sort transactions, and the transaction chain tracks and records changes in Bitcoin ownership. These blocks are arranged according to time and are a link. Transactions that are not within the block are considered unconfirmed or unsorted. Transactions, any node is about to put a set of unconfirmed transactions into a block and then broadcast their suggestions to other nodes in the network as to what the next block should be.
If multiple people generate blocks at the same time (this probability is basically very small), there will be multiple choices for the next block of the current block. In order to ensure the order of the block link , the Bitcoin system dictates that each valid block must include the answer to a special mathematical problem. The computer calculates the text of the entire block, plus random guessing based on cryptographic hashes, until it comes up with a value lower than a certain Numerical output, the hash function can create a short summary from any length of text. This fixed output value is very complicated. The only way to find it is to guess randomly, which is called mining.

King introduced a checkpoint mechanism when it released PPC last year to protect against attacks in the early stages of its development. This mechanism makes it resistant to 51% attacks. "Developers can control a master node and broadcast "checkpoints" to the entire network, which allows other nodes to agree on certain blocks." He said that this is actually a "(blockchain) continuity warning message." .

『三』 Blockchain core technology - P2P network

Peer-to-peer network is one of the core technologies in the blockchain. The main focus is on the The chain provides a stable network structure for broadcasting unpackaged transactions (transactions in the transaction pool) and consensus blocks. Some consensus algorithms also require some points.Peer-to-peer network support (such as PBFT), and another auxiliary function, such as Ethereum’s message network, also require peer-to-peer network support.

P2P networks are divided into two categories: structured and unstructured networks. The structured network uses a similar DHT algorithm to build the network structure; the unstructured network is a flat network, and each node has the addresses of some neighbor nodes.

The main responsibilities of a peer-to-peer network are maintaining the network structure and sending information. The network structure should focus on the two aspects of adding new nodes and network updates, while sending information includes broadcast and unicast aspects

How to establish and maintain an entire point-to-point network? How to join and exit nodes?
There are two core parameters for establishing a network structure. One is the number of nodes connected to each node, and the second is the maximum number of forwardings.

The new node knows nothing about the entire network. It either obtains some nodes in the network to connect to through a central service, or connects to "seed" nodes in the network.

Network update processing occurs when new nodes join or nodes exit, or even when some nodes have poor network and cannot be connected, they come back alive after a while, etc. These routing table changes are generally broadcast through the node's existing connections. It should be noted that due to the particularity of point-to-point networks, the routing table of each node is different (also called partial view)

Broadcasts generally use flooding protocols, that is, received and forwarded, so that When messages spread in the network, some restrictions are generally applied. For example, a maximum number of forwardings must be set for a message to avoid excessive load on the network.

Unicast requires the support of a structured network structure, usually DHT, which is similar to the DNS resolution method. It searches for the target node address hop by hop, then transmits it, and updates the local routing table.

To quickly retrieve information, there are two data structures that can be used. One is tree type, such as AVL tree, red-black tree, B-tree, etc.; the other is hash table.
Hash tables are more efficient than trees, but require more memory.
Information is represented in the form of key-value pairs, that is, a key corresponds to a value. What we are looking for is the key, and the value is the attached information.
The problem that the hash table needs to solve is how to evenly allocate a storage location to each key.
There are two key points here: 1. Allocate a storage location for the key. This allocation algorithm is fixed. Ensure that the same algorithm is used during storage and search, otherwise it will not be found after it is stored; 2. It should be distributed evenly. There should not be more data stored in some places and less data in some places.

Structures such as hashtable and map in general languages ​​are implemented using this technology. The hash function can directly use the modulo function, key%n, in this way, n represents the number of places, and the key is an integer. If the key is of other types, a hash needs to be performed first to convert the key into an integer. This method can solve the above two requirements, but when n is not large enough (less than the data to be stored), conflicts will occur. There must be two keys to be stored in one place. At this time, one needs to be placed in this place. The linked list will be assigned to the same location, different keys, and placed in order. When there are too many keys in one location, the search speed of the linked list is too slow, and it needs to be converted into a tree type structure (red-black tree or AVL tree).

As mentioned above, hash tables are very efficient, but occupy content. This limitation can be solved by using multiple machines. In a distributed environment, the above locations can be understood as computers (later called nodes), that is, how to map a key to a node. Each node has a node ID, which is the mapping of key->node id. This mapping The algorithm must also be fixed.
This algorithm also has a very important requirement, namely scaleability. When new nodes join and exit, the number of keys that need to be migrated should be as small as possible.

This mapping algorithm has two typical structures, one is ring-shaped and the other is tree-shaped; the ring-shaped one is called consistent hashing algorithm, and the tree-shaped one is called kademlia algorithm.

The point selection algorithm is a mapping algorithm that solves key->node id. To put it figuratively, it means selecting the node in its life for a key.

Assuming we use 32 hashes, the total amount of key data that can be accommodated is 2**32, which is called hash space. The node ID is mapped to an integer, and the key is also mapped to an integer. The difference between the key hash and the node hash value is called the distance (if it is a negative number, the modulus must be taken, not the absolute value). For example, the hash of a key is 100 (represented by an integer), and the hash of a node is 105, then The distance between these two is 105-100=5. Of course, other distance representations can also be used, such as subtraction in reverse, but the algorithm must be fixed. We map (place) the key to the node closest to it. If the distance is taken modulo, it seems that the node and key are placed on a ring, and the key belongs to the node closest to it from a clockwise angle.

The distance of the kademlia algorithm is represented by the numerical value after the XOR calculation of the key hash and the node hash (integer). From left to right, the more "same prefixes" there are, the greater the distance. Closer, the position is different the further to the left, the further away.
The embodiment of the tree structure is to regard the nodes and keys as the nodes of the tree. The number of bits supported by this algorithm is 160 bits, that is, 20 8 bytes. The height of the tree is 160, and each edge represents one bit.
The point selection algorithm is the same as consistent hashing. From all nodes, select a node with the smallest distance from the key.Click as the destination of this key.

Since it is in a distributed environment, in order to ensure high availability, we assume that there is no central routing table. Without this routing table that can see the whole picture, it brings some challenges, such as how to discover nodes, Find node?
In P2P networks, a common method is for each node to maintain a partial routing table, which only contains routing information for some nodes. In the flooding algorithm, these nodes are random; in the DHT algorithm, the routing table is structured, and the nodes maintained are also selective. So how to reasonably select nodes that need to maintain routing information?

A simple approach is for each node to store information about nodes larger than it, so that a ring can be formed. However, there is a big problem and a small problem in doing so. The big problem is that each node knows too little information (only the hash and address of the next node). When a key is given, it does not know if there is any node in the network that is shorter than the distance to the key. So it first determines whether the key belongs to itself and the next node. If so, then the key belongs to the next node. If not, it calls the same method on the next node. The complexity is N (number of nodes). An optimization method is that the other nodes maintained by each node i are: i+2 1, i+2 2,...i+2**31. By observing this data, it is found that from near to far, the node is more Becoming more and more sparse. This can reduce the complexity to lgN

Each node saves the information of other nodes, including, from left to right, nodes that are different from this node in each bit, and selects at most k (algorithm hyperparameters). For example, on node 00110 (for demonstration purposes, select 5 digits), the node routing information to be saved is:
1****: xxx,....,xxx(k)
01: xxx,....,xxx(k items)
000: xxx,....,xxx(k items)
0010: xxx,....,xxx(k items)
00111: xxx,....,xxx(k)
The above line is called k-bucket. From a visual point of view, the closer you are to yourself, the denser the nodes are, and the further away you are, the sparser the nodes are. This route search and node search algorithm also has lgN complexity.

『四』Blockchain Principle

Blockchain is a technology, but it is not a single technology, but the result of the integration of multiple technologies, including cryptography Science, mathematics, economics, network science, etc. You can think of it as a distributed shared accounting technology, or as a database, but this database is jointly maintained by all nodes on the chain, and each node has a ledger, because all nodes Account book oneConsistently, different nodes can trust each other and have no doubts about the data, so everyone says that the blockchain technically achieves trust. For detailed professional technology, you can consult some professional technology companies. For example: Jinbo Technology, which focuses on developing blockchain-related products, has a professional R&D team and complete after-sales service. You can call for consultation.

『五』What is blockchain

Blockchain is a new application model of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. Blockchain is an important concept of Bitcoin.

It is essentially a decentralized database. As the underlying technology of Bitcoin, it is a series of data blocks generated using cryptographic methods. Each data block contains a batch of The information of Bitcoin network transactions is used to verify the validity of its information (anti-counterfeiting) and generate the next block.

(5) How does the blockchain realize broadcast extended reading

Characteristics of the blockchain:

1. Deposit certificate< /p>

The "non-tamperable" feature of blockchain provides a solution to the problem of "certificate storage" in economic and social development. As long as the authenticity of the on-chain information and data can be ensured, the blockchain can solve the problem of "storage" and "certification" of information.

For example, in the field of copyright, blockchain can be used to store electronic evidence, which can ensure that it is not tampered with, and can link original platforms, copyright bureaus, judicial agencies and other parties through distributed ledgers, which can greatly Improve the efficiency of handling infringements.

2. Sharing

The "distributed" characteristics of the blockchain can break through the "data barriers" between departments and achieve information and data sharing. Different from centralized data storage, the information on the blockchain will be distributed to each node through point-to-point broadcasting, and all information can be "truthfully recorded" through "whole network witness".

博客主人唯心底涂
男,单身,无聊上班族,闲着没事喜欢研究股票,无时无刻分享股票入门基础知识,资深技术宅。
  • 35028 文章总数
  • 3637265访问次数
  • 3077建站天数