Block chain transaction broadcasting method and device and related product
By calculating transmission path indicators and connection history evaluation indicators in the blockchain network, and determining the optimal transaction broadcast destination node, the problem of high transaction broadcast delay in the blockchain network is solved, the transaction broadcast efficiency is improved, and the decentralized characteristics are maintained.
Patent Information
- Application Number
- CN202311173231.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-12
- Publication Date
- 2025-03-14
AI Technical Summary
The transaction broadcast delay in the blockchain network is high, resulting in low transaction broadcast efficiency, and the method of relying on centralized nodes is inconsistent with the decentralization characteristics of blockchain.
The transmission path index is calculated by using the IP address of the first node and the IP address of the candidate transaction broadcast destination node in the blockchain network, and combining the connection history evaluation indicators of the candidate node, the optimal transaction broadcast destination node is determined, thereby conducting transaction broadcasting.
Without relying on centralized nodes, this method improves transaction broadcasting efficiency in the blockchain network, reduces broadcast delay, and conforms to the decentralized characteristics of blockchain.
Smart Images

Figure CN119628979A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of blockchain technology, and in particular to a blockchain transaction broadcasting method, device and related products. Background Art
[0002] At present, with the rapid development of blockchain technology, blockchain technology has penetrated into various industries. In the blockchain network, transactions between blocks are broadcast to all nodes in the entire network based on the transaction broadcast algorithm, and the speed and reliability of the broadcast will directly affect the delay of transaction chain and the reliability of the network.
[0003] Currently, transaction broadcasts in blockchain networks are usually carried out point-to-point based on the connection history and network configuration of each node. The global information in the blockchain network is not taken into account, and there is a problem of high broadcast latency, which leads to low efficiency of blockchain network transaction broadcasts. If transactions are broadcasted with the help of a few centralized nodes, although the communication speed can be improved to a certain extent, this method of relying on centralized nodes is inconsistent with the decentralized characteristics of blockchain.
[0004] Therefore, how to improve the efficiency of transaction broadcasting in blockchain networks without relying on a few centralized nodes has become a technical problem that needs to be solved urgently in the current field. Summary of the invention
[0005] The embodiments of the present application provide a blockchain transaction broadcasting method, device and related products, which aim to improve the transaction broadcasting efficiency in the blockchain network without relying on a few centralized nodes.
[0006] In a first aspect, the present application provides a blockchain transaction broadcasting method, which is applied to a first node and includes:
[0007] Based on the IP address of the first node in the blockchain network and the IP addresses of each candidate transaction broadcast destination node of the first node, obtaining a transmission path indicator between the first node and each candidate transaction broadcast destination node;
[0008] Based on the node connection history of each candidate transaction broadcast destination node itself as a transaction broadcast destination node, a connection history evaluation index of each candidate transaction broadcast destination node is calculated;
[0009] Obtaining a comprehensive index based on the transmission path index and the connection history evaluation index of the same candidate transaction broadcast destination node;
[0010] Determining the transaction broadcast destination node of the first node according to the comprehensive indicators of each candidate transaction broadcast destination node;
[0011] The first node broadcasts the transaction to the transaction broadcast destination node.
[0012] A second aspect of the present application provides a blockchain transaction broadcasting device, which is deployed on a first node and includes:
[0013] A first indicator acquisition module, used to obtain a transmission path indicator between the first node and each candidate transaction broadcast destination node based on the IP address of the first node in the blockchain network and the IP address of each candidate transaction broadcast destination node of the first node;
[0014] A second indicator acquisition module is used to calculate the connection history evaluation index of each candidate transaction broadcast destination node based on the node connection history of each candidate transaction broadcast destination node itself as a transaction broadcast destination node;
[0015] A third indicator acquisition module, used to obtain a comprehensive indicator based on the transmission path indicator and the connection history evaluation indicator of the same candidate transaction broadcast destination node;
[0016] A determination module, configured to determine the transaction broadcast destination node of the first node according to comprehensive indicators of each candidate transaction broadcast destination node;
[0017] The transaction broadcast module is used to broadcast the transaction from the first node to the transaction broadcast destination node.
[0018] A third aspect of the present application provides a blockchain transaction broadcasting device, the device comprising a processor and a memory:
[0019] The memory is used to store a computer program and transmit the computer program to the processor;
[0020] The processor is used to execute the steps of the blockchain transaction broadcasting method provided in the first aspect according to the instructions in the computer program.
[0021] The fourth aspect of the present application provides a computer-readable storage medium, which is used to store a computer program. When the computer program is executed by a blockchain transaction broadcasting device, it implements the steps of the blockchain transaction broadcasting method provided in the first aspect.
[0022] The fifth aspect of the present application provides a computer program product, including a computer program, which, when executed by a blockchain transaction broadcasting device, implements the steps of the blockchain transaction broadcasting method provided in the first aspect.
[0023] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:
[0024] The embodiment of the present application provides a blockchain transaction broadcasting method, which is applied to a first node. In the method, based on the IP address of the first node in the blockchain network and the IP addresses of each candidate transaction broadcast destination node of the first node, the transmission path index between the first node and each candidate transaction broadcast destination node can be obtained. Based on the node connection history of each candidate transaction broadcast destination node itself as a transaction broadcast destination node, the connection history evaluation index of each candidate transaction broadcast destination node can be obtained by calculation. A comprehensive index is obtained based on the transmission path index and the connection history evaluation index of the same candidate transaction broadcast destination node. According to the comprehensive index of each candidate transaction broadcast destination node, the transaction broadcast destination node of the first node is determined. The first node broadcasts the transaction to the determined transaction broadcast destination node. It can be seen that in this scheme, there is no need to rely on a central node. The transaction broadcast destination node of the first node can be determined through the node connection history and the virtual distance between the nodes, that is, the IP address. Compared with the method of selecting peer nodes only through the node's own connection history, the transaction broadcast destination node determined from each candidate transaction broadcast destination node by combining the transmission path indicator and the connection history indicator has a better selection effect. Therefore, the transaction is broadcasted through the first node and the transaction broadcast destination node with a better selection effect, which reduces the broadcast delay and thus improves the transaction broadcast efficiency in the blockchain network. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1A A scenario architecture diagram of a blockchain transaction broadcasting method provided in an embodiment of the present application;
[0026] Figure 1B A schematic diagram of the structure of a distributed system provided in an embodiment of the present application;
[0027] Figure 1C A schematic diagram of a block structure provided in an embodiment of the present application;
[0028] Figure 2 A flowchart of a blockchain transaction broadcasting method provided in an embodiment of the present application;
[0029] Figure 3 A schematic diagram of the structure of a blockchain node storage architecture provided in an embodiment of the present application;
[0030] Figure 4 A code diagram for defining a storage structure in a smart contract provided in an embodiment of the present application;
[0031] Figure 5 A code diagram for registering node information in a smart contract provided in an embodiment of the present application;
[0032] Figure 6A code diagram for updating node connection information in a smart contract provided in an embodiment of the present application;
[0033] Figure 7 A schematic diagram of a transaction broadcast destination node selection process provided in an embodiment of the present application;
[0034] Figure 8 A schematic diagram of a structure for calculating a transmission path indicator provided in an embodiment of the present application;
[0035] Fig. 9 A schematic diagram of another structure for calculating transmission path indicators provided in an embodiment of the present application;
[0036] Fig.10 A schematic diagram of the structure of a blockchain transaction broadcasting device provided in an embodiment of the present application;
[0037] Fig.11 A schematic diagram of the structure of the server in the embodiment of the present application;
[0038] Fig.12 A schematic diagram of the structure of a terminal device in an embodiment of the present application. DETAILED DESCRIPTION
[0039] At present, the blockchain transactions, both on-chain and off-chain, need to be broadcast in the peer-to-peer blockchain node network. The speed and reliability of the broadcast will directly affect the latency of the transaction on-chain and the reliability of the network. At present, when all nodes in the blockchain network broadcast transactions, they usually perform traditional peer-to-peer broadcasts based on the node's own connection history and network configuration. For example, after connecting once, they will find the corresponding node to establish a connection and broadcast the next time. They do not consider the global information in the blockchain network to select a more optimized connection algorithm, that is, the shortest path algorithm that broadcasts the blockchain blocks and transactions to all network nodes. There is a problem of high broadcast latency, resulting in low efficiency in blockchain network transaction broadcasts.
[0040] If we rely on a small number of centralized nodes, for example, the Blockchain High-Speed Communication Network (BTN) is the "digital highway" of the blockchain network, supporting Ant Chain and other blockchains to establish large-scale applications. BTN improves the connectivity, stability and real-time performance of blockchain nodes through intelligent routing algorithms, efficient transmission protocols, transmission optimization, virtual network dedicated lines and other technologies, and realizes high-speed and secure interconnection of global blockchain networks. It is a public network infrastructure that supports the large-scale and ecological development of blockchain. Although this method of relying on a small number of centralized nodes for transaction broadcasting can improve communication speed to a certain extent, this method of relying on centralized nodes is inconsistent with the decentralized characteristics of blockchain.
[0041] Therefore, how to improve the efficiency of transaction broadcasting in blockchain networks without relying on a few centralized nodes has become a technical problem that needs to be solved urgently in the current field.
[0042] In view of the above problems, a blockchain transaction broadcasting method, device and related products are provided in the present application, the purpose of which is to improve the transaction broadcasting efficiency in the blockchain network without the help of centralized nodes. In the technical solution provided in the present application, based on the transmission path index between the first node and each candidate transaction broadcast destination node, and the connection history evaluation index of each candidate transaction broadcast destination node, the comprehensive index of the same candidate transaction broadcast destination node can be obtained. The transaction broadcast destination node of the first node can be determined based on the comprehensive index of each candidate transaction broadcast destination node. Compared with the method of selecting peer nodes only through the node's own connection history, the transaction broadcast destination node determined from each candidate transaction broadcast destination node by combining the transmission path index and the connection history index has a better selection effect, thereby broadcasting transactions through the first node and the transaction broadcast destination node with a better selection effect, reducing broadcast delays, thereby improving the transaction broadcasting efficiency in the blockchain network.
[0043] First, several terms that may be involved in the embodiments of the present application are explained below.
[0044] Blockchain: A data structure consisting of several blocks connected by hash values. Each block consists of transactions generated within a period of time, packaged by computer nodes that have obtained the right to record accounts, and independently verified by each computer node.
[0045] Smart Contract: A smart contract is a computer program that can automatically execute the terms of a contract, with features such as event-driven, value transfer, and automatic execution. Smart contracts are programs stored on the blockchain that run when predetermined conditions are met. They are often used to automatically execute agreements so that all participants can determine the results immediately, without the involvement of any middlemen or wasting time. They can also automatically complete the workflow and trigger the next action when the conditions are met.
[0046] Blockchain node: In the embodiment of the present application, it refers to a full node, that is, a complete node that maintains the blockchain. A full node is a node that has all transaction data of the entire network, can independently complete the packaging and verification of transactions, and process the client's read and write requests for the status of the smart contract.
[0047] Connection history: refers to the connection and data transmission history between blockchain nodes. For example, if node A and node B have successfully connected, each party will have a record of successfully connecting to the other party.
[0048] Distance: refers to the distance between the IP addresses of blockchain nodes in the network, not the physical distance.
[0049] Transaction broadcast: refers to the point-to-point broadcast of blocks and transactions in the blockchain among various nodes. The time required to broadcast to all nodes in the entire network is usually an important indicator for evaluating the performance of a transaction broadcast algorithm.
[0050] The execution subject of the blockchain transaction broadcast method provided in the embodiment of the present application can be a terminal device. For example, the terminal device is used as the first node, the first node is the node of the transaction broadcast to be executed, and the first node broadcasts the transaction to the determined transaction broadcast destination node. As an example, the terminal device can specifically include but is not limited to mobile phones, desktop computers, tablet computers, notebook computers, PDAs, intelligent voice interaction devices, smart home appliances, vehicle terminals, aircraft, etc. The execution subject of the blockchain transaction broadcast method provided in the embodiment of the present application can also be a server, that is, the server can also be used as the first node to obtain transmission path indicators, connection history evaluation indicators, and comprehensive indicators, and determine the transaction broadcast destination node according to the comprehensive indicators of each candidate transaction broadcast destination node, and the first node broadcasts the transaction to the determined transaction broadcast destination node. The blockchain transaction broadcast method provided in the embodiment of the present application can also be executed collaboratively by the terminal device and the server. For example, each terminal device is used as a candidate transaction broadcast destination node, and the server is used as the first node. The server uses the method provided in the embodiment of the present application to determine the transaction broadcast destination node of the first node, and then the first node broadcasts the transaction to the determined transaction broadcast destination node, so the embodiment of the present application does not limit the implementation subject of the technical solution of the present application.
[0051] Figure 1A The following is an exemplary scenario architecture diagram of a blockchain transaction broadcasting method, which includes a server and various terminal devices. Figure 1A The server shown can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. In addition, the server can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms.
[0052] The blockchain transaction broadcasting method involved in the embodiment of the present application can be applied to a distributed system formed by connecting a client and multiple nodes (any form of computing device in the access network, such as a server and a user terminal) through network communication.
[0053] Take the distributed system as the blockchain system as an example, see Figure 1B , Figure 1BThis is an optional structural diagram of the distributed system 100 provided by the embodiment of the present invention applied to the blockchain system, which is formed by multiple nodes (any form of computing devices in the access network, such as servers, user terminals) and clients, and a point-to-point network is formed between the nodes. In a distributed system, any machine such as a server or a terminal can join and become a node, and the node includes a hardware layer, an intermediate layer, an operating system layer, and an application layer.
[0054] See also Figure 1B The functions of each node in the blockchain system shown include:
[0055] 1) Routing: a basic function of a node, used to support communication between nodes.
[0056] In addition to the routing function, the node can also have the following functions:
[0057] 2) Applications are deployed in the blockchain to implement specific businesses based on actual business needs, record data related to the implementation of functions to form record data, carry digital signatures in the record data to indicate the source of the task data, and send the record data to other nodes in the blockchain system for other nodes to add the record data to a temporary block when they successfully verify the source and integrity of the record data.
[0058] For example, the services implemented by the application include:
[0059] 2.1) Wallet, used to provide the function of conducting electronic currency transactions, including initiating transactions (i.e., sending the transaction record of the current transaction to other nodes in the blockchain system. After the other nodes successfully verify the transaction, as a response to acknowledge the validity of the transaction, the transaction record data is stored in the temporary block of the blockchain; of course, the wallet also supports querying the remaining electronic currency in the electronic currency address;
[0060] 2.2) Shared ledger, which is used to provide functions such as storage, query and modification of account data. The record data of the operation on the account data is sent to other nodes in the blockchain system. After other nodes verify the validity, as a response to acknowledging the validity of the account data, the record data is stored in a temporary block, and a confirmation can also be sent to the node that initiated the operation.
[0061] 2.3) Smart contracts are computerized protocols that can execute the terms of a contract. They are implemented by deploying code on a shared ledger that is executed when certain conditions are met. The code is used to complete automated transactions based on actual business needs, such as querying the logistics status of the goods purchased by the buyer and transferring the buyer's electronic currency to the merchant's address after the buyer signs for the goods. Of course, smart contracts are not limited to executing contracts for transactions, but can also execute contracts for processing received information.
[0062] 3) Blockchain, including a series of blocks that are connected to each other in the order of their generation. Once a new block is added to the blockchain, it will not be removed. The block records the record data submitted by the nodes in the blockchain system.
[0063] See also Figure 1C , Figure 1C This is an optional schematic diagram of the block structure provided by an embodiment of the present invention. Each block includes the hash value of the transaction record stored in this block (the hash value of this block) and the hash value of the previous block. Each block is connected by the hash value to form a blockchain. In addition, the block can also include information such as the timestamp when the block was generated. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains relevant information for verifying the validity of its information (anti-counterfeiting) and generating the next block.
[0064] Figure 2 A flowchart of a blockchain transaction broadcasting method provided in an embodiment of the present application. Figure 2 In the blockchain transaction broadcasting method shown, the method is applied to the first node and includes:
[0065] S201: Based on the IP address of the first node in the blockchain network and the IP addresses of the candidate transaction broadcast destination nodes of the first node, a transmission path indicator between the first node and each candidate transaction broadcast destination node is obtained.
[0066] In related technologies, a small number of centralized nodes are used to build blockchain communication networks. Although this improves the communication speed to a certain extent, this construction method is different from the decentralized characteristics of blockchain and is not suitable for the decentralized network requirements of blockchain.
[0067] The transaction broadcast of the blockchain network involves the architecture of node connections, as well as the selection and update algorithm of nodes for connected peer nodes. Therefore, before introducing the selection and update algorithm of nodes for connected peer nodes, we first introduce the architecture of node connections in the blockchain network. Figure 3 , Figure 3 A schematic diagram of the structure of a blockchain node storage architecture provided in an embodiment of the present application.
[0068] A node is part of a blockchain network. Transactions or blocks can be broadcasted through connected nodes. Nodes do not need to be connected to every node in the network. A node is connected to several other nodes, which are then connected to several other nodes. By connecting in this way, transactions or blocks can be broadcasted to all nodes in the network.
[0069] The blockchain network is mainly composed of peer nodes. Peer nodes are the basic elements in the blockchain network and are mainly used to host ledgers and smart contracts. The ledger is used to record all transactions generated by smart contracts. Each peer node can save a copy of the ledger and a copy of the smart contract.
[0070] Figure 3 The blockchain network in includes blockchain nodes A, B and C, as well as system broadcast smart contracts. Blockchain nodes A, B and C refer to the nodes that actually run the blockchain accounting program and broadcast blocks and transactions with external nodes. Peer-to-peer identifiers A, B and C are identifiers that represent node identities in the peer-to-peer node network. Specifically, they can be represented by enode: / / acdefgh, etc. Their physical meaning refers to the public key or hash value of the public key of the peer node in the network. In addition, this identifier is only used for peer-to-peer broadcasts in peer-to-peer networks, and is not used for signatures of blockchain transactions. Peer-to-peer networks refer to any two network nodes that can share files and pass messages, greatly improving network efficiency. Accounting programs refer to blockchain client programs that actually maintain blockchain world state data and package and verify blockchain transactions. System broadcast smart contracts refer to smart contracts that actually store node identifiers, distances, i.e., IP addresses, and connection history.
[0071] Blockchain node A, blockchain node B and blockchain node C are all peer nodes, and peer nodes are connected to each other. The peer-to-peer identification, IP address and connection history of each peer node can be saved in the system broadcast smart contract, and can be synchronized to other nodes through the copy of the system broadcast smart contract. Blockchain node A includes peer-to-peer identification A and accounting program A. As an example, the peer-to-peer identification A of blockchain node A can be represented by enode:a. Blockchain node B includes peer-to-peer identification B and accounting program B. As an example, the peer-to-peer identification B of blockchain node B can be represented by enode:b. Blockchain node C includes peer-to-peer identification C and accounting program C. As an example, the peer-to-peer identification C of blockchain node C can be represented by enode:c. Since smart contracts are decentralized programs running on blockchains, this storage architecture is also decentralized. Based on this architecture, the optimal choice is found between peer nodes without the help of centralized nodes, maintaining the premise of decentralization of the blockchain network.
[0072] Based on the storage structure provided above, the first node can store the node connection history between the first node and other nodes and the IP address of the first node in the system broadcast smart contract, so that the system broadcast smart contract can synchronize the received node connection history and IP address to the smart contract copy.
[0073] Since each peer node can save a copy of the smart contract, and the IP address and node connection history of each peer node are stored in the smart contract, and then synchronized to the smart contract copy by the smart contract, the first node can obtain the IP address of the first node, the IP addresses of each candidate transaction broadcast destination node of the first node, and the node connection history of each candidate transaction broadcast destination node itself as a transaction broadcast destination node from the smart contract copy of the first node.
[0074] As an example, in the decentralized node information storage structure based on smart contracts mentioned above, the code defining the storage structure in the smart contract can refer to Figure 4 , Figure 4 A code diagram for defining a storage structure in a smart contract provided in an embodiment of the present application. In order to store the connection history, node identification, IP address and other node information of the blockchain node on the chain, three data structures need to be defined in the ChainTransmission smart contract first, which may include: The connection history Connect is a data structure of the connection history of two peer nodes, including the number of successes successCnt, the number of exceptions errorCnt, and the last update time lastUpdated, wherein the abnormal conditions in the connection history may include illegal blocks, illegal transactions, disconnected connections, etc. This application does not specifically limit the abnormal conditions in the connection history.
[0075] The peer node Peer is a data structure of a certain node information, which may specifically include: the address account owner that can modify the node information, the IP address of the node, and the peer node identifier and transmission history enode2connect connected to it, where enode2connect is a connection history mapping, which is mainly used to map the node identifier and connection history of the peer node connected to the declaration node. Taking blockchain node A as an example, the data structure in the peer node peer includes the address account owner of blockchain node A, the IP address of blockchain node A, the node identifier b and connection history of blockchain node B connected to blockchain node A, and the node identifier c and connection history of blockchain node C connected to blockchain node A. The connection history between blockchain node B and blockchain node A includes the number of successful connections between blockchain node B and blockchain node A successCnt, the number of abnormalities errorCnt, and the last update time lastUpdated. The connection history between blockchain node C and blockchain node A includes the number of successful connections between blockchain node C and blockchain node A successCnt, the number of abnormalities errorCnt, and the last update time lastUpdated.
[0076] The peer node mapping enode2peer is a mapping from enodeid to peer structure, where enodeid is the node identifier. As an example, enode2peer represents the mapping relationship between the node identifier a of blockchain node A to the address account owner of blockchain node A, the IP address of blockchain node A, the node identifier and connection history of blockchain node B connected to blockchain node A, and the node identifier and connection history of blockchain node C connected to blockchain node A. Therefore, according to the three data structures defined above, the mapping relationship between node identifiers and connection histories between peer nodes is established, which provides a basic guarantee for the subsequent selection of the optimal transaction broadcast destination node.
[0077] The decentralized node information storage structure based on smart contracts also includes registered node information. The code for registering node information in smart contracts can be found in Figure 5 . Figure 5 A code diagram for registering node information in a smart contract provided in an embodiment of the present application. When entering the network, the node needs to sign the node's IP address and node identifier, i.e., enodeid, with its own private key, and call the registration function register() to initialize basic information in the mapping of enode2peer, i.e., initialize the IP address corresponding to the enodeid in enode2peer and the owner address account corresponding to the enodeid.
[0078] The decentralized node information storage structure based on smart contracts also includes updating node connection information. The code for updating node connection information in smart contracts can refer to Figure 6 , Figure 6 A code diagram for updating node connection information in a smart contract provided in an embodiment of the present application. After two nodes, the broadcast node enodeFrom and the receiving node enodeTo, have been connected and interacted for a period of time, enodeFrom (or enodeTo) will report the connection history to the smart contract, that is, the number of successful connections successCnt and the number of abnormalities errorCnt. At this time, the smart contract will also record the last updated time lastUpdated. Before updating the connection information, it is first necessary to determine whether the connection information update comes from the owner address account of the enodeFrom (or enodeTo) node. The security and accuracy of the connection history data update are guaranteed through permission control. Since the registration node information and the update node connection information in the smart contract are both public, the transparency and security of the node information can be ensured through the smart contract. Among them, the broadcast node enodeFrom is the first node, and the receiving node enodeTo is the first node's candidate transaction broadcast destination node.
[0079] In addition, when registering node information and updating node connection information, it is based on the willingness of the node information rather than the mandatory execution of the protocol. However, when selecting the optimal transaction broadcast destination node later, the selection of the optimal transaction broadcast destination node is mainly based on the node information. The more information the node contributes, the better the quality of the transaction broadcast destination node connected to it, and the higher the efficiency of the transaction broadcast, which is used to incentivize nodes to contribute node information such as connection history.
[0080] It should be noted that Figure 4 , Figure 5 and Figure 6 The smart contract code in the system broadcast smart contract is mainly used to complete the decentralized storage of blockchain node identification, IP address and connection history, realizing decentralization in the node connection architecture and meeting the decentralization requirements of the blockchain network.
[0081] In the related art, blockchain node connection and broadcasting usually select peer nodes based on the node's own connection history. For example, the peer nodes in the blockchain network include blockchain node A, blockchain node B and blockchain node C. Currently, blockchain node A is only connected to blockchain node B, that is, the connection history of blockchain node A only includes the number of successful connections, the number of exceptions and the last update time between blockchain node A and blockchain node B. Then, when blockchain node A broadcasts a transaction, it will directly select blockchain node B for transaction broadcasting based on its own connection history, and will not consider the possibility of blockchain node A broadcasting a transaction to blockchain node C. The node connection information is incomplete and there is a lack of connection algorithms with global information, which leads to low efficiency of transaction broadcasting.
[0082] After the smart contract provided in the embodiment of the present application is completed on the blockchain node, the optimal transaction broadcast destination node can be selected based on the transmission path and connection history, thereby improving the transaction broadcast efficiency.
[0083] The first node is the resource node for the transaction broadcast to be executed, that is, the first node has completed the transaction verification and needs to broadcast the transaction to other nodes, and then other nodes broadcast the transaction to several other nodes, thereby realizing the broadcast of the transaction to all nodes in the network.
[0084] See also Figure 7 , Figure 7 A schematic diagram of a transaction broadcast destination node selection process provided by an embodiment of the present application. Figure 7 The node identification, connection history and IP address of each node in a are stored in the system broadcast smart contract, that is, each node has completed the on-chain storage. Figure 7 The darkest point in a represents the first node. Figure 7 The white dots in a represent the remaining nodes that have completed on-chain storage. Figure 7 The darkest point in b represents the first node. Figure 7 The gray dots in b represent the candidate transaction broadcast destination nodes. Of course, the candidate transaction broadcast destination nodes can be nodes in the entire network except the first node. The gray dots in the figure are only used as an example. Figure 7 The first node in b and each candidate transaction broadcast destination node perform calculations on each indicator result, thereby determining the transaction broadcast destination node of the first node, and the first node broadcasts the transaction to the transaction broadcast destination node, that is, Figure 7 Connect the transaction broadcast destination node in c.
[0085] On the Internet, it is impossible to obtain the physical distance between nodes, so the virtual distance between nodes can be calculated through IP addresses.
[0086] In a possible implementation, the transmission path index between the first node and each candidate transaction broadcast destination node can be calculated based on the IP address of the first node and the IP addresses of each candidate transaction broadcast destination node of the first node, wherein the transmission path index refers to the virtual distance between the IP address of the first node and the IP address of each candidate transaction broadcast destination node. Since the system broadcast smart contract stores the IP address, node identifier, and connection history of each node, the first node can send a request to the system broadcast smart contract to obtain the IP address of the first node and the IP address of each candidate transaction broadcast destination node.
[0087] Specifically, calculating the transmission path index may include: first performing binary conversion on the IP address of the first node to obtain a first binary code, and performing binary conversion on the IP address of the target node in each candidate transaction broadcast destination node to obtain a second binary code. Then, an XOR operation is performed on the first binary code and the second binary code to obtain an XOR operation result. Then, the XOR operation result is processed by removing the first and last 0s to obtain a processed value, and then the processed value is converted from binary to decimal to obtain a converted value. Among them, the converted value is positively correlated with the virtual distance between the first node and the second node as the target node, indicating that the larger the virtual distance between the first node and the target node, the larger the converted value. Finally, a power operation is performed based on the converted value to obtain the transmission path index between the first node and the target node, so that the transmission path index is negatively correlated with the converted value.
[0088] As an example, the IP address of the first node and the IP address of the target node can be obtained according to the IP field of the peer node structure in the peer node mapping enode2peer recorded in the smart contract. The first node is represented by A, and the target node is represented by B. The IP address of A is 1.1.1.1, and the IP address of B is 5.5.1.1. The two IP addresses can be converted into binary format, that is, 00000001000000010000000100000001 and 0000010100000101000001010000000100000001, and then the IP addresses converted into binary format are XORed, and the XOR result is 000001000000010000000000000000000. Then, the character removal function Trim() can be used to remove the first and last 0s of the XOR result to obtain the processed value 100000001. The processed value is converted from binary to decimal to obtain a converted value of 257. Finally, a power operation is performed based on the converted data to obtain a transmission path indicator between the first node and the target node.
[0089] In one possible implementation, see Figure 8 , Figure 8 A structural diagram of calculating a transmission path index provided in an embodiment of the present application, wherein the operation based on the converted value refers to taking x as the base and the converted value as the exponent of x to perform a power operation, thereby obtaining a first operation result. Wherein, x can be a value greater than 1, for example, x is 2, and the converted value is taken as the exponent of 2 to perform a power operation, thereby obtaining a first operation result. Then, the opposite of the first operation result is taken as the transmission path index between the first node and the target node, so that the transmission path index and the converted value show a negative correlation, indicating that the larger the converted value, the smaller the transmission path index.
[0090] Correspondingly, the calculation formula of the transmission path index can be expressed by Formula 1:
[0091] Dist(A,B)=-x^Trim(A.IP⊕B.IP) (Formula 1)
[0092] Among them, Dist(A,B) represents the transmission path indicator between the first node and the target node, that is, the virtual distance between the first node and the target node, A.IP represents the IP address of the first node, B.IP represents the IP address of the target node, and ⊕ represents the XOR operation.
[0093] In another possible implementation, see Fig. 9 , Fig. 9Another structural diagram of calculating the transmission path index provided in the embodiment of the present application, the operation based on the converted value means taking y as the base, taking the converted value as the exponent of y, and performing a power operation to obtain a second operation result. Wherein, y can be a value greater than 0 and less than 1, for example, y is 1 / 2, taking the converted value as the exponent of 0.5, and performing a power operation to obtain a second operation result. Then, the second operation result is used as the transmission path index between the first node and the target node, so that the transmission path index and the converted data are negatively correlated, and the larger the converted value, the smaller the transmission path index.
[0094] Correspondingly, the calculation formula of the transmission path index can also be expressed by Formula 2:
[0095] Dist(A,B)=y^Trim(A.IP⊕B.IP) (Formula 2)
[0096] Among them, Dist(A,B) represents the transmission path indicator between the first node and the target node, that is, the virtual distance between the first node and the target node, A.IP represents the IP address of the first node, B.IP represents the IP address of the target node, and ⊕ represents the XOR operation.
[0097] S202: Based on the node connection history of each candidate transaction broadcast destination node itself as a transaction broadcast destination node, a connection history evaluation index of each candidate transaction broadcast destination node is calculated.
[0098] In a possible implementation, by retrieving the connection history mapping enode2connect recorded by the smart contract, the target node itself in each candidate transaction broadcast destination node, once used as the node connection history of the transaction broadcast destination node, that is, the target node itself as the node connection history of enodeTo, the connection history evaluation index of the target node can be obtained. For example, the target node in each candidate transaction broadcast destination node is node B, and the connection history evaluation index of the target node can be obtained by retrieving the node connection history of node B itself as enodeTo (other nodes as the connection history of node B updated by enodeFrom) in enode2connect recorded by the smart contract. As an example, node A is connected to node B, node C is connected to node B, node D is connected to node B, nodes A, C, and D are all broadcast nodes enodeFrom, node B is the receiving node enodeTo, and the connection history of node B as the receiving node includes the number of successful connections between node B and node A, the number of abnormalities, and the last update time, the number of successful connections between node B and node C, and the number of successful connections between node B and node D, the number of abnormalities, and the last update time.
[0099] Specifically, calculating the connection history evaluation index of the target node includes: extracting the number of successful connections and abnormal connections when other nodes perform transaction broadcasts to the target node from the node connection history of the target node and other nodes. As an example, the other node represents the node as the broadcasting node enodeFrom, the other node is node A, the receiving node enodeTo is the target node, and the target node is node B. From the connection history of node A and node B, the number of successful connections and abnormal connections when node A performs transaction broadcasts to node B are extracted.
[0100] Then, the ratio of the number of successful connections to the number of abnormal connections is obtained, and the ratio is added to the first array corresponding to the target node, wherein the first array includes multiple ratios obtained based on the node connection history of the target node and multiple different other nodes, and one ratio corresponds to one other node that performs a transaction broadcast to the target node.
[0101] As an example, the multiple different other nodes include node C and node D, and the multiple different other nodes correspond to the same target node. According to the above method for obtaining the ratio of the number of successful connections to the number of abnormal connections, the ratio c of the number of successful connections to the number of abnormal connections when node C performs transaction broadcasting to node B, and the ratio d of the number of successful connections to the number of abnormal connections when node D performs transaction broadcasting to node B can be obtained. The first array includes the above two ratios c and d, and one ratio corresponds to one other node that performs transaction broadcasting to the target node. Then the ratio a of the number of successful connections to the number of abnormal connections when node A performs transaction broadcasting to node B can be added to the first array.
[0102] In addition, before obtaining the ratio of the number of successful connections to the number of abnormal connections, you can also obtain the last update time of the number of successful connections and the number of abnormal connections when other nodes perform transaction broadcasts to the target node. If the last update time is within the preset time period, for example, the last update time is within 5 minutes, then the ratio of the number of successful connections to the number of abnormal connections is obtained. If the last update time exceeds 5 minutes, the ratio of the number of successful connections to the number of abnormal connections is not obtained. The working status of the target node is ensured by verifying the last update time.
[0103] Correspondingly, the first array can be expressed by Formula 3:
[0104]
[0105] B_Array represents the first array, i.e., the connection history evaluation array of the target node. The first array contains the connection history evaluations of all other nodes on the target node. enode2peer[k].enode2connect[b].successCnt represents the number of successful connections when other nodes K (enode is identified as k) perform transaction broadcasts to the target node B (enode is identified as b). enode2peer[k].enode2connect[b].errorCnt represents the number of abnormal connections when other nodes K (enode is identified as k) perform transaction broadcasts to the target node B (enode is identified as b). k∈all includes all other nodes corresponding to the target node.
[0106] Then, based on the multiple ratios in the first array, a representative value for the first array can be obtained as a connection history evaluation index of the target node. As an example, the representative value for the first array can be the average or median of the first array. First, the data in the first array can be sorted to obtain a sorted array. Sorting the first array can be expressed by Formula 4:
[0107] B_Sort=Sort(B_Array) (Formula 4)
[0108] Among them, Sort() is a custom sorting function, and B_Sort represents the sorted array.
[0109] Finally, the average or median of the sorted array can be used as the connection history evaluation index of the target node. The connection history evaluation index of the target node can be expressed by Formula 5:
[0110] History(B)=Middle(B_Sort) (Formula 5)
[0111] History(B) represents the connection history evaluation index of the target node. The Middle() function is the middle value function, which can be used to calculate the average or median of the sorted array. Finally, the average or median of the sorted array is used as the connection history evaluation index of the target node.
[0112] S203: Obtain a comprehensive index based on the transmission path index and the connection history evaluation index of the same candidate transaction broadcast destination node.
[0113] In a possible implementation, after obtaining the transmission path index and the connection history evaluation index, the transmission path index and the connection history evaluation index of the target node may be weighted and summed to obtain a comprehensive index of the target node. First, the index weight configuration value corresponding to the first node may be obtained, the index weight configuration value including a first weight and a second weight, the first weight is configured for the transmission path index, and the second weight is configured for the connection history evaluation index. The index weight configuration value corresponding to the first node may be set by the owner of the first node, for example, the first weight may be m, and the second weight may be 1-m.
[0114] Then, obtaining the comprehensive index based on the transmission path index and the connection history evaluation index of the same candidate transaction broadcast destination node may include: obtaining a first product of the first weight and the transmission path index of the target node, and obtaining a second product of the second weight and the connection history evaluation index of the target node, and then summing the first product and the second product to obtain the comprehensive index of the transaction broadcast destination node of the target node as the first node. The target node refers to one of the candidate transaction broadcast destination nodes.
[0115] Correspondingly, the comprehensive index of the target node can be expressed by Formula 6:
[0116] Eval(A,B)=m*Dist(A,B)+(1-m)*History(B) (Formula 6)
[0117] Eval(A,B) represents the comprehensive index of the target node, m is the first weight, 1-m is the second weight, Dist(A,B) represents the transmission path index between the first node and the target node, and History(B) represents the connection history evaluation index of the target node.
[0118] S204: Determine the transaction broadcast destination node of the first node according to the comprehensive indicators of each candidate transaction broadcast destination node.
[0119] According to the transmission path index and the connection history evaluation index, the comprehensive index of each candidate transaction broadcast destination node can be determined. Based on the node information of the entire network nodes, the comprehensive index of the entire network nodes can be traversed to determine the optimal node for the first node, thereby improving the transaction broadcast efficiency.
[0120] In a possible implementation, after obtaining the comprehensive index of each candidate transaction broadcast destination node, the comprehensive index of each candidate transaction broadcast destination node is sorted, and the top K candidate transaction broadcast destination nodes with larger comprehensive indexes are selected according to the sorting result as the transaction broadcast destination nodes of the first node. Wherein, K is a positive integer, K is less than the total number of candidate transaction broadcast destination nodes of the first node, and the value of K can be set by the owner of the first node. This application does not specifically limit the value of K. For example, the total number of candidate transaction broadcast destination nodes of the first node is 6, and K is 3. According to the sorting result, the top 3 candidate transaction broadcast destination nodes with larger comprehensive indexes are selected as the transaction broadcast destination nodes of the first node.
[0121] In another possible implementation, the top M% of candidate transaction broadcast destination nodes with larger comprehensive indexes are further selected according to the sorting results as the transaction broadcast destination nodes of the first node. Wherein, M is a positive number less than 100. For example, the top 30% of candidate transaction broadcast destination nodes with larger comprehensive indexes can also be selected according to the sorting results as the transaction broadcast destination nodes of the first node. The value of M can be set by the owner of the first node, and the present application does not specifically limit the value of M.
[0122] S205: The first node broadcasts the transaction to the transaction broadcast destination node.
[0123] Based on the above steps, the transaction broadcast destination node of the first node can be determined. The transaction broadcast destination node determined by the method provided in the embodiment of the present application is determined based on the node information of the entire network, and has a better selection effect. The first node then broadcasts the transaction to the determined transaction broadcast destination node, thereby improving the transaction broadcast efficiency.
[0124] In addition, after running for a period of time, the connection history of all network nodes will change. Therefore, based on the change of the node connection history at the first moment, the node connection history evaluation index can be updated, and then the node comprehensive index can be updated, so that the first node can determine the transaction broadcast destination node according to the updated comprehensive index at the second moment, where the second moment is later than the first moment. By continuously updating in a cycle to obtain the optimal node situation, higher broadcast efficiency is provided in the continuous updating of the network.
[0125] A blockchain transaction broadcasting method provided in the above embodiment is applied to the first node. In the method, based on the IP address of the first node in the blockchain network and the IP addresses of each candidate transaction broadcast destination node of the first node, the transmission path index between the first node and each candidate transaction broadcast destination node can be obtained. Based on the node connection history of each candidate transaction broadcast destination node itself as a transaction broadcast destination node, the connection history evaluation index of each candidate transaction broadcast destination node can be obtained. A comprehensive index is obtained based on the transmission path index and the connection history evaluation index of the same candidate transaction broadcast destination node. The transaction broadcast destination node of the first node is determined according to the comprehensive index of each candidate transaction broadcast destination node. The first node broadcasts the transaction to the determined transaction broadcast destination node.
[0126] It can be seen that in this scheme, there is no need to rely on a central node. The transaction broadcast destination node of the first node can be determined through the node connection history and the virtual distance between the nodes, that is, the IP address. Compared with the method of selecting peer nodes only through the node's own connection history, the transaction broadcast destination node determined from each candidate transaction broadcast destination node by combining the transmission path indicator and the connection history indicator has a better selection effect. Therefore, the transaction is broadcasted through the first node and the transaction broadcast destination node with a better selection effect, which reduces the broadcast delay and thus improves the transaction broadcast efficiency in the blockchain network.
[0127] Based on the blockchain transaction broadcasting method provided in the above embodiment, this application also provides a blockchain transaction broadcasting device. Fig.10 Provide explanation. Fig.10 This is a schematic diagram of the structure of the blockchain transaction broadcasting device provided in the embodiment of the present application. Fig.10 The blockchain transaction broadcasting device shown is deployed on the first node, and the device includes:
[0128] A first indicator acquisition module 1001, configured to obtain a transmission path indicator between the first node and each candidate transaction broadcast destination node based on the IP address of the first node in the blockchain network and the IP address of each candidate transaction broadcast destination node of the first node;
[0129] The second indicator acquisition module 1002 is used to calculate the connection history evaluation index of each candidate transaction broadcast destination node based on the node connection history of each candidate transaction broadcast destination node itself as a transaction broadcast destination node;
[0130] A third indicator acquisition module 1003, configured to obtain a comprehensive indicator based on the transmission path indicator and the connection history evaluation indicator of the same candidate transaction broadcast destination node;
[0131] A determination module 1004, configured to determine the transaction broadcast destination node of the first node according to comprehensive indicators of each candidate transaction broadcast destination node;
[0132] The transaction broadcast module 1005 is used to broadcast the transaction from the first node to the transaction broadcast destination node.
[0133] Optionally, for each target node in the candidate transaction broadcast destination node, the first indicator acquisition module 1001 correspondingly includes:
[0134] A first conversion unit, configured to perform binary conversion on the IP address of the first node to obtain a first binary code, and perform binary conversion on the IP address of the target node to obtain a second binary code;
[0135] an XOR operation unit, configured to perform an XOR operation on the first binary code and the second binary code to obtain an XOR operation result;
[0136] A processing unit, used for truncating the leading and trailing 0s of the XOR operation result to obtain a processed value;
[0137] A second conversion unit, used to convert the processed value from binary to decimal to obtain a converted value;
[0138] A calculation unit is used to perform a power operation according to the converted value to obtain a transmission path indicator between the first node and the target node.
[0139] Optionally, the computing unit includes:
[0140] A first power operation unit, used to use x as a base and the converted value as an exponent of x to perform a power operation to obtain a first operation result; wherein x is a value greater than 1;
[0141] The first determining unit is configured to use the opposite number of the first operation result as a transmission path indicator between the first node and the target node.
[0142] Optionally, the computing unit includes:
[0143] The second power operation unit is used to use y as the base and the converted value as the exponent of y to perform power operation to obtain a second operation result, and the second operation result is used as the transmission path indicator between the first node and the target node; wherein y is a value greater than 0 and less than 1.
[0144] Optionally, for each target node in the candidate transaction broadcast destination node, the corresponding second indicator acquisition module 1002 includes:
[0145] An extraction unit, configured to extract, from the node connection history between the target node and other nodes, the number of successful connections and the number of abnormal connections of the other nodes performing transaction broadcasting to the target node;
[0146] A first acquisition unit, used to acquire a ratio of the number of successful connections to the number of abnormal connections;
[0147] An adding unit is used to add the ratio to a first array corresponding to the target node, wherein the first array includes multiple ratios obtained based on the node connection history between the target node and multiple different other nodes; one of the ratios corresponds to another node that performs transaction broadcasting to the target node; and a second determining unit is used to obtain a representative value for the first array based on the multiple ratios in the first array as a connection history evaluation indicator for the target node.
[0148] Optionally, the first acquiring unit includes:
[0149] A second acquisition unit is used to acquire the most recent update time of the number of successful connections and the number of abnormal connections;
[0150] The judgment unit is used to obtain the ratio of the number of successful connections to the number of abnormal connections if the most recent update time of the number of successful connections and the number of abnormal connections is within a preset time period.
[0151] Optionally, the device further includes: for each target node in each candidate transaction broadcast destination node, a corresponding third indicator acquisition module 1003 includes:
[0152] The fourth acquisition unit is used to perform weighted summation on the transmission path index and the connection history evaluation index of the target node to obtain a comprehensive index of the target node as a transaction broadcast destination node of the first node.
[0153] Optionally, the determining module 1004 includes:
[0154] A second sorting unit, used to sort the comprehensive indicators of each candidate transaction broadcast destination node;
[0155] A first screening unit is used to screen out the first K candidate transaction broadcast destination nodes with larger comprehensive indicators as the transaction broadcast destination nodes of the first node according to the sorting result; the K is a positive integer, and the K is less than the total number of candidate transaction broadcast destination nodes of the first node; or
[0156] The second screening unit is used to screen out the top M% of candidate transaction broadcast destination nodes with larger comprehensive indicators as the transaction broadcast destination nodes of the first node according to the sorting result; the M is a positive number less than 100.
[0157] Optionally, the device further comprises: broadcasting the smart contract to the system and sending:
[0158] a synchronization unit for the node connection history of the first node with other nodes, and the IP address of the first node, so that the system broadcast smart contract synchronizes the node connection history and IP address received from the first node to the smart contract copy;
[0159] The fifth acquisition unit is used to acquire the IP address of the first node, the IP addresses of each candidate transaction broadcast destination node of the first node, and the node connection history of each candidate transaction broadcast destination node itself as a transaction broadcast destination node from the smart contract copy of the first node.
[0160] Optionally, after determining the transaction broadcast destination node of the first node, the device further includes:
[0161] An updating unit is used to update the connection history evaluation index of the node based on the change of the node connection history at the first moment, and further update the comprehensive index of the node, so as to be used for determining the transaction broadcast destination node at the second moment; the second moment is later than the first moment.
[0162] An embodiment of the present application provides a blockchain transaction broadcasting device, which may be a server. Fig.11 : This is a schematic diagram of a server structure provided in an embodiment of the present application. The server 900 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 922 (for example, one or more processors) and a memory 932, and one or more storage media 930 (for example, one or more mass storage devices) storing application programs 942 or data 944. Among them, the memory 932 and the storage medium 930 can be short-term storage or permanent storage. The program stored in the storage medium 930 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Furthermore, the central processing unit 922 can be configured to communicate with the storage medium 930 and execute a series of instruction operations in the storage medium 930 on the server 900.
[0163] The server 900 may also include one or more power supplies 926 , one or more wired or wireless network interfaces 950 , one or more input and output interfaces 958 , and / or one or more operating systems 941 .
[0164] The CPU 922 is used to execute the following steps:
[0165] Based on the IP address of the first node in the blockchain network and the IP addresses of the candidate transaction broadcast destination nodes of the first node, a transmission path indicator between the first node and each candidate transaction broadcast destination node is obtained;
[0166] Based on the node connection history of each candidate transaction broadcast destination node itself as a transaction broadcast destination node, a connection history evaluation index of each candidate transaction broadcast destination node is calculated;
[0167] A comprehensive index is obtained based on the transmission path index and connection history evaluation index of the same candidate transaction broadcast destination node;
[0168] Determine the transaction broadcast destination node of the first node according to the comprehensive indicators of each candidate transaction broadcast destination node;
[0169] The first node broadcasts the transaction to the transaction broadcast destination node.
[0170] The present application embodiment also provides another blockchain transaction broadcasting device, which can be a terminal device. Fig.12 For the sake of convenience, only the parts related to the embodiments of the present application are shown. For specific technical details not disclosed, please refer to the method part of the embodiments of the present application. Take the terminal device as a mobile phone as an example:
[0171] Fig.12 The block diagram shows a partial structure of a mobile phone provided by an embodiment of the present application. Fig.12 The mobile phone includes: a radio frequency (RF) circuit 1010, a memory 1020, an input unit 1030, a display unit 1040, a sensor 1050, an audio circuit 1060, a wireless fidelity (WiFi) module 1070, a processor 1080, and a power supply 1090. Those skilled in the art can understand that Fig.12 The mobile phone structure shown in the figure does not constitute a limitation on the mobile phone, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0172] Combine the following Fig.12 A detailed introduction to the various components of the mobile phone:
[0173] The RF circuit 1010 can be used for receiving and sending signals during information transmission or calls. In particular, after receiving the downlink information of the base station, it is sent to the processor 1080 for processing; in addition, the designed uplink data is sent to the base station. Generally, the RF circuit 1010 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (full name: LowNoiseAmplifier, English abbreviation: LNA), a duplexer, etc. In addition, the RF circuit 1010 can also communicate with the network and other devices through wireless communication. The above-mentioned wireless communications may use any communication standard or protocol, including but not limited to Global System of Mobile communications (Global System of Mobile communication, English abbreviation: GSM), General Packet Radio Service (General Packet Radio Service, GPRS), Code Division Multiple Access (Code Division Multiple Access, English abbreviation: CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (Long Term Evolution, English abbreviation: LTE), e-mail, Short Messaging Service (SMS), etc.
[0174] The memory 1020 can be used to store software programs and modules. The processor 1080 executes various functional applications and data processing of the mobile phone by running the software programs and modules stored in the memory 1020. The memory 1020 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 1020 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0175] The input unit 1030 can be used to receive input digital or character information, and to generate key signal input related to the user settings and function control of the mobile phone. Specifically, the input unit 1030 may include a touch panel 1031 and other input devices 1032. The touch panel 1031, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on the touch panel 1031 or near the touch panel 1031 using any suitable object or accessory such as a finger, stylus, etc.), and drive the corresponding connection device according to a pre-set program. Optionally, the touch panel 1031 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into contact coordinates, and then sends it to the processor 1080, and can receive and execute commands sent by the processor 1080. In addition, the touch panel 1031 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch panel 1031, the input unit 1030 may further include other input devices 1032. Specifically, the other input devices 1032 may include but are not limited to one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, and the like.
[0176] The display unit 1040 can be used to display information input by the user or information provided to the user and various menus of the mobile phone. The display unit 1040 may include a display panel 1041. Optionally, the display panel 1041 may be configured in the form of a liquid crystal display (full name in English: Liquid Crystal Display, English abbreviation: LCD), an organic light-emitting diode (full name in English: Organic Light-Emitting Diode, English abbreviation: OLED), etc. Further, the touch panel 1031 may cover the display panel 1041. When the touch panel 1031 detects a touch operation on or near it, it is transmitted to the processor 1080 to determine the type of touch event. Subsequently, the processor 1080 provides a corresponding visual output on the display panel 1041 according to the type of touch event. Although in Fig.12 In the embodiment, the touch panel 1031 and the display panel 1041 are used as two independent components to realize the input and output functions of the mobile phone, but in some embodiments, the touch panel 1031 and the display panel 1041 can be integrated to realize the input and output functions of the mobile phone.
[0177] The mobile phone may also include at least one sensor 1050, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 1041 according to the brightness of the ambient light, and the proximity sensor may turn off the display panel 1041 and / or the backlight when the mobile phone is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in all directions (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used for applications that identify the posture of the mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; as for other sensors that can be configured in the mobile phone, such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc., they will not be repeated here.
[0178] The audio circuit 1060, the speaker 1061, and the microphone 1062 can provide an audio interface between the user and the mobile phone. The audio circuit 1060 can transmit the received audio data to the speaker 1061 after converting the received audio data into an electrical signal, which is converted into a sound signal for output; on the other hand, the microphone 1062 converts the collected sound signal into an electrical signal, which is received by the audio circuit 1060 and converted into audio data, and then the audio data is output to the processor 1080 for processing, and then sent to another mobile phone through the RF circuit 1010, or the audio data is output to the memory 1020 for further processing.
[0179] WiFi is a short-range wireless transmission technology. The mobile phone can help users send and receive emails, browse web pages and access streaming media through the WiFi module 1070. It provides users with wireless broadband Internet access. Fig.12 A WiFi module 1070 is shown, but it is understandable that it is not an essential component of the mobile phone and can be omitted as needed without changing the essence of the invention.
[0180] The processor 1080 is the control center of the mobile phone. It uses various interfaces and lines to connect various parts of the entire mobile phone. By running or executing software programs and / or modules stored in the memory 1020, and calling data stored in the memory 1020, it executes various functions of the mobile phone and processes data, thereby collecting overall data and information of the mobile phone. Optionally, the processor 1080 may include one or more processing units; preferably, the processor 1080 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 1080.
[0181] The mobile phone also includes a power supply 1090 (such as a battery) for supplying power to various components. Preferably, the power supply can be logically connected to the processor 1080 through a power management system, so that the power management system can manage functions such as charging, discharging, and power consumption.
[0182] Although not shown, the mobile phone may also include a camera, a Bluetooth module, etc., which will not be described in detail here.
[0183] In the embodiment of the present application, the processor 1080 included in the mobile phone also has the following functions:
[0184] Based on the IP address of the first node in the blockchain network and the IP addresses of the candidate transaction broadcast destination nodes of the first node, a transmission path indicator between the first node and each candidate transaction broadcast destination node is obtained;
[0185] Based on the node connection history of each candidate transaction broadcast destination node itself as a transaction broadcast destination node, a connection history evaluation index of each candidate transaction broadcast destination node is calculated;
[0186] A comprehensive index is obtained based on the transmission path index and connection history evaluation index of the same candidate transaction broadcast destination node;
[0187] Determine the transaction broadcast destination node of the first node according to the comprehensive indicators of each candidate transaction broadcast destination node;
[0188] The first node broadcasts the transaction to the transaction broadcast destination node.
[0189] An embodiment of the present application also provides a computer-readable storage medium for storing a computer program. When the computer program is run on a blockchain transaction broadcasting device, the blockchain transaction broadcasting device executes any one of the implementation methods of a blockchain transaction broadcasting method described in the aforementioned embodiments.
[0190] An embodiment of the present application also provides a computer program product including a computer program, which, when running on a blockchain transaction broadcasting device, enables the blockchain transaction broadcasting device to execute any one of the implementation methods of a blockchain transaction broadcasting method described in the aforementioned embodiments.
[0191] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems and devices described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0192] In the several embodiments provided in the present application, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are only schematic. For example, the division of the system is only a logical function division. There may be other division methods in actual implementation, such as multiple systems can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0193] The systems described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0194] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0195] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (full name in English: Read-Only Memory, English abbreviation: ROM), random access memory (full name in English: Random Access Memory, English abbreviation: RAM), disk or optical disk and other media that can store computer programs.
[0196] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A blockchain transaction broadcasting method, characterized in that: The method is applied to a first node, and the method comprises: Based on the IP address of the first node in the blockchain network and the IP addresses of each candidate transaction broadcast destination node of the first node, obtaining a transmission path indicator between the first node and each candidate transaction broadcast destination node; Based on the node connection history of each candidate transaction broadcast destination node itself as a transaction broadcast destination node, a connection history evaluation index of each candidate transaction broadcast destination node is calculated; Obtaining a comprehensive index based on the transmission path index and the connection history evaluation index of the same candidate transaction broadcast destination node; Determining the transaction broadcast destination node of the first node according to the comprehensive indicators of each candidate transaction broadcast destination node; The first node broadcasts the transaction to the transaction broadcast destination node.
2. The blockchain transaction broadcasting method according to claim 1, characterized in that: For a target node in each candidate transaction broadcast destination node, based on the IP address of the first node in the blockchain network and the IP address of the target node, a transmission path indicator between the first node and the target node is obtained, including: Performing binary conversion on the IP address of the first node to obtain a first binary code, and performing binary conversion on the IP address of the target node to obtain a second binary code; Performing an XOR operation on the first binary code and the second binary code to obtain an XOR operation result; The first and last 0s of the XOR operation result are truncated to obtain a processed value; Convert the processed value from binary to decimal to obtain a converted value; A power operation is performed according to the converted value to obtain a transmission path indicator between the first node and the target node.
3. The blockchain transaction broadcasting method according to claim 2, characterized in that: The performing a power operation according to the converted value to obtain a transmission path indicator between the first node and the target node includes: Taking x as the base and the converted value as the exponent of x, performing a power operation to obtain a first operation result; wherein x is a value greater than 1; The inverse of the first operation result is used as a transmission path indicator between the first node and the target node.
4. The blockchain transaction broadcasting method according to claim 2, characterized in that: The performing a power operation according to the converted value to obtain a transmission path indicator between the first node and the target node includes: Taking y as the base and the converted value as the exponent of y, a power operation is performed to obtain a second operation result, and the second operation result is used as a transmission path indicator between the first node and the target node; wherein y is a value greater than 0 and less than 1.
5. The blockchain transaction broadcasting method according to claim 1, characterized in that: For a target node in each candidate transaction broadcast destination node, based on the node connection history of the target node itself as a transaction broadcast destination node, a connection history evaluation index of the target node is calculated, including: Extracting the number of successful connections and abnormal connections of the other nodes to the target node from the node connection history between the target node and other nodes; Obtaining a ratio of the number of successful connections to the number of abnormal connections; adding the ratio to a first array corresponding to the target node, wherein the first array includes multiple ratios obtained based on node connection history between the target node and multiple different other nodes; one of the ratios corresponds to another node that performs transaction broadcasting to the target node; Based on multiple ratios in the first array, a representative value for the first array is obtained as a connection history evaluation index of the target node.
6. The blockchain transaction broadcasting method according to claim 5, characterized in that: The obtaining the ratio of the number of successful connections to the number of abnormal connections includes: Obtain the most recent update time of the number of successful connections and the number of abnormal connections; If the most recent update time of the number of successful connections and the number of abnormal connections is within a preset time period, then the ratio of the number of successful connections to the number of abnormal connections is obtained.
7. The blockchain transaction broadcasting method according to claim 1, characterized in that: For a target node in each candidate transaction broadcast destination node, a comprehensive index is obtained based on the transmission path index and the connection history evaluation index of the target node, including: The transmission path index and the connection history evaluation index of the target node are weighted and summed to obtain a comprehensive index of the target node as a transaction broadcast destination node of the first node.
8. The blockchain transaction broadcasting method according to claim 1, characterized in that: The step of determining the transaction broadcast destination node of the first node according to the comprehensive index of each candidate transaction broadcast destination node comprises: Sort the comprehensive indicators of each candidate transaction broadcast destination node; According to the sorting result, the first K candidate transaction broadcast destination nodes with larger comprehensive indicators are selected as the transaction broadcast destination nodes of the first node; the K is a positive integer, and the K is less than the total number of candidate transaction broadcast destination nodes of the first node; or According to the sorting result, the top M% of candidate transaction broadcast destination nodes with larger comprehensive indicators are selected as the transaction broadcast destination nodes of the first node; the M is a positive number less than 100.
9. The blockchain transaction broadcasting method according to any one of claims 1 to 8, characterized in that: Also includes: Broadcast the smart contract to the system and send: The node connection history of the first node with other nodes, and the IP address of the first node, so that the system broadcast smart contract synchronizes the node connection history and IP address received from the first node to the smart contract copy; The IP address of the first node, the IP addresses of each candidate transaction broadcast destination node of the first node, and the node connection history of each candidate transaction broadcast destination node itself as a transaction broadcast destination node are obtained from the smart contract copy of the first node.
10. The blockchain transaction broadcasting method according to any one of claims 1 to 8, characterized in that: After determining the transaction broadcast destination node of the first node, the method further includes: Based on the change of the node connection history at the first moment, the node connection history evaluation index is updated, and the node comprehensive index is further updated to facilitate the determination of the transaction broadcast destination node at the second moment; the second moment is later than the first moment.
11. A blockchain transaction broadcasting device, characterized in that: The device is deployed at a first node, and includes: A first indicator acquisition module, used to obtain a transmission path indicator between the first node and each candidate transaction broadcast destination node based on the IP address of the first node in the blockchain network and the IP address of each candidate transaction broadcast destination node of the first node; A second indicator acquisition module is used to calculate the connection history evaluation index of each candidate transaction broadcast destination node based on the node connection history of each candidate transaction broadcast destination node itself as a transaction broadcast destination node; A third indicator acquisition module, used to obtain a comprehensive indicator based on the transmission path indicator and the connection history evaluation indicator of the same candidate transaction broadcast destination node; A determination module, configured to determine the transaction broadcast destination node of the first node according to comprehensive indicators of each candidate transaction broadcast destination node; The transaction broadcast module is used to broadcast the transaction from the first node to the transaction broadcast destination node.
12. A blockchain transaction broadcasting device, characterized in that: The device comprises a processor and a memory: The memory is used to store a computer program and transmit the computer program to the processor; The processor is used to execute the steps of the blockchain transaction broadcasting method described in any one of claims 1 to 10 according to the instructions in the computer program.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store a computer program, and when the computer program is executed by a blockchain transaction broadcasting device, the steps of the blockchain transaction broadcasting method described in any one of claims 1 to 10 are implemented.
14. A computer program product, characterized in that It includes a computer program which, when executed by a blockchain transaction broadcasting device, implements the steps of the blockchain transaction broadcasting method described in any one of claims 1 to 10.