TWI759028B - Block packaging method, block packaging device based on blockchain transaction, and electronic device - Google Patents
Block packaging method, block packaging device based on blockchain transaction, and electronic device Download PDFInfo
- Publication number
- TWI759028B TWI759028B TW109145847A TW109145847A TWI759028B TW I759028 B TWI759028 B TW I759028B TW 109145847 A TW109145847 A TW 109145847A TW 109145847 A TW109145847 A TW 109145847A TW I759028 B TWI759028 B TW I759028B
- Authority
- TW
- Taiwan
- Prior art keywords
- node
- blockchain
- transaction
- voted
- voting information
- Prior art date
Links
Images
Landscapes
- Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)
Abstract
Description
本發明涉及區塊鏈技術領域,具體涉及一種基於區塊鏈交易的區塊打包方法、裝置及電子設備。The invention relates to the technical field of blockchain, in particular to a block packaging method, device and electronic device based on blockchain transactions.
在去中心化的區塊鏈網路中,各節點之間依循一套共識演算法,用以定義誰具有區塊的打包權。具有打包權的節點將打包完成的區塊透過廣播的方式傳遞給所有節點。其他節點接收到廣播的區塊後,首先驗證該區塊的有效性,然後再將有效的區塊寫入區塊鏈中。現有的工作量證明(Proof of Work, PoW)共識演算法使得區塊鏈網路中的所有節點必須耗費大量的計算資源來猜測雜湊值才能確定哪個節點取得區塊的打包權。In a decentralized blockchain network, each node follows a consensus algorithm to define who has the right to package a block. The node with the packaging right transmits the packaged block to all nodes by broadcasting. After receiving the broadcast block, other nodes first verify the validity of the block, and then write the valid block into the blockchain. The existing Proof of Work (PoW) consensus algorithm makes all nodes in the blockchain network have to spend a lot of computing resources to guess the hash value to determine which node obtains the right to pack the block.
鑒於以上內容,有必要提出一種基於區塊鏈交易的區塊打包方法、裝置及電子設備,以避免在確定區塊的打包權時使用工作量證明共識演算法耗費大量的計算資源的問題。In view of the above, it is necessary to propose a block packaging method, device and electronic device based on blockchain transactions, so as to avoid the problem of consuming a lot of computing resources by using the proof-of-work consensus algorithm when determining the packaging rights of blocks.
本申請的第一方面提供一種基於區塊鏈交易的區塊打包方法,所述方法包括:A first aspect of the present application provides a block packaging method based on blockchain transactions, the method comprising:
區塊鏈中的每一節點接收並存儲區塊鏈交易;Each node in the blockchain receives and stores blockchain transactions;
每一節點根據所述區塊鏈交易計算出每一節點的雜湊值,並根據每一節點的雜湊值生成一打包投票資訊,並將所述打包投票資訊發送給被投票的節點,其中,所述打包投票資訊中包括投票的節點的數位簽章及被投票的節點的唯一識別碼;Each node calculates the hash value of each node according to the blockchain transaction, generates a packaged voting information according to the hash value of each node, and sends the packaged voting information to the voted node, wherein the The packaged voting information includes the digital signature of the voting node and the unique identification code of the voted node;
每一節點根據接收的打包投票資訊記錄作為被投票的節點的數量得到每一節點的投票數;Each node obtains the number of votes for each node according to the received packaged voting information record as the number of voted nodes;
每一節點根據所述投票數將所述投票數最多的節點作為目標節點;及Each node selects the node with the most votes as a target node according to the votes; and
所述目標節點將接收的區塊鏈交易打包成區塊,並廣播給所述區塊鏈中的所有節點。The target node packages the received blockchain transactions into blocks and broadcasts them to all nodes in the blockchain.
優選地,所述區塊鏈中的每一節點接收並存儲區塊鏈交易包括:Preferably, each node in the blockchain receives and stores blockchain transactions comprising:
區塊鏈中的每一節點藉由對等網路接收所述區塊鏈交易,並將所述區塊鏈交易存儲在每一節點的本地端交易池中。Each node in the blockchain receives the blockchain transaction through a peer-to-peer network and stores the blockchain transaction in each node's local transaction pool.
優選地,所述區塊鏈交易為包括多個交易的交易組合。Preferably, the blockchain transaction is a transaction combination including multiple transactions.
優選地,所述每一節點根據所述區塊鏈交易計算出每一節點的雜湊值,並根據每一節點的雜湊值生成一打包投票資訊,並將所述打包投票資訊發送給被投票的節點包括:Preferably, each node calculates the hash value of each node according to the blockchain transaction, generates a packaged voting information according to the hash value of each node, and sends the packaged voting information to the voted Nodes include:
計算每一節點接收到的交易組合中的每一交易的雜湊值,並將所述交易組合中的每一交易的雜湊值進行異或運算得到相應的節點的雜湊值;Calculate the hash value of each transaction in the transaction combination received by each node, and perform XOR operation on the hash value of each transaction in the transaction combination to obtain the hash value of the corresponding node;
將每一節點的雜湊值分別與所述區塊鏈中的所有節點的唯一標識碼進行異或運算得到每一節點與所述區塊鏈中的每一節點的異或距離值;XORing the hash value of each node with the unique identification codes of all nodes in the blockchain to obtain the XOR distance value between each node and each node in the blockchain;
分別確定出每一節點與所述區塊鏈的各個節點之間的異或距離值的最小值;Determine the minimum value of the XOR distance value between each node and each node of the blockchain respectively;
在所述區塊鏈中將距離每一節點的異或距離值為最小值所對應的節點作為每一節點的打包投票資訊中被投票的節點;及In the blockchain, the node corresponding to the minimum value of the XOR distance from each node is used as the node to be voted in the packaged voting information of each node; and
每一節點分別將打包投票資訊發送給相應的被投票的節點。Each node sends the packaged voting information to the corresponding voted nodes.
優選地,所述區塊鏈中的每一節點根據所述區塊鏈交易計算出每一節點的雜湊值,並根據每一節點的雜湊值生成一打包投票資訊,並將所述打包投票資訊發送給被投票的節點包括:Preferably, each node in the blockchain calculates the hash value of each node according to the blockchain transaction, generates a packaged voting information according to the hash value of each node, and sends the packaged voting information Sent to voted nodes include:
所述區塊鏈中的每一節點在預設時間段內根據所述區塊鏈交易計算出每一節點的雜湊值,並根據每一節點的雜湊值生成一打包投票資訊,並將所述打包投票資訊發送給被投票的節點。Each node in the blockchain calculates the hash value of each node according to the blockchain transaction within a preset time period, and generates a packaged voting information according to the hash value of each node, and sends the Package the voting information and send it to the voted nodes.
優選地,所述每一節點根據接收的打包投票資訊記錄作為被投票的節點的數量得到每一節點的投票數包括:Preferably, each node obtains the number of votes for each node according to the received packaged voting information records as the number of voted nodes, including:
每一節點根據作為被投票節點的投票數、作為被投票節點的唯一識別碼及驗證資訊生成投票資訊;及Each node generates voting information according to the number of votes as the voted node, the unique identification code and verification information of the voted node; and
每一節點將投票資訊廣播給所述區塊鏈中所有的節點。Each node broadcasts voting information to all nodes in the blockchain.
優選地,所述區塊鏈中的每一節點接收相同或不同的區塊鏈交易。Preferably, each node in the blockchain receives the same or a different blockchain transaction.
本申請的第二方面提供一種基於區塊鏈交易的區塊打包裝置,所述裝置包括:A second aspect of the present application provides a block packaging device based on blockchain transactions, the device comprising:
交易接收模組,用於控制區塊鏈中的每一節點接收並存儲區塊鏈交易;The transaction receiving module is used to control each node in the blockchain to receive and store blockchain transactions;
投票模組,用於控制每一節點根據所述區塊鏈交易計算出每一節點的雜湊值,並根據每一節點的雜湊值生成一打包投票資訊,並將所述打包投票資訊發送給被投票的節點,其中,所述打包投票資訊中包括投票的節點的數位簽章及被投票的節點的唯一識別碼;The voting module is used to control each node to calculate the hash value of each node according to the blockchain transaction, generate a packaged voting information according to the hash value of each node, and send the packaged voting information to the recipient A voting node, wherein the packaged voting information includes the digital signature of the voting node and the unique identification code of the voted node;
計票模組,用於:控制每一節點根據接收的打包投票資訊記錄作為被投票的節點的數量得到每一節點的投票數;及控制每一節點根據所述投票數將所述投票數最多的節點作為目標節點;及A vote counting module, used for: controlling each node to obtain the number of votes of each node according to the received packaged voting information records as the number of nodes to be voted; and controlling each node to maximize the number of votes according to the number of votes node as the target node; and
打包模組,用於控制所述目標節點將接收的區塊鏈交易打包成區塊,並廣播給所述區塊鏈中的所有節點。The packaging module is used to control the target node to package the received blockchain transaction into blocks and broadcast to all nodes in the blockchain.
優選地,所述區塊鏈交易為包括多個交易的交易組合,所述投票模組還用於:Preferably, the blockchain transaction is a transaction combination including multiple transactions, and the voting module is further used for:
計算每一節點接收到的交易組合中的每一交易的雜湊值,並將所述交易組合中的每一交易的雜湊值進行異或運算得到相應的節點的雜湊值;Calculate the hash value of each transaction in the transaction combination received by each node, and perform XOR operation on the hash value of each transaction in the transaction combination to obtain the hash value of the corresponding node;
將每一節點的雜湊值分別與所述區塊鏈中的所有節點的唯一標識碼進行異或運算得到每一節點與所述區塊鏈中的每一節點的異或距離值;XORing the hash value of each node with the unique identification codes of all nodes in the blockchain to obtain the XOR distance value between each node and each node in the blockchain;
分別確定出每一節點與所述區塊鏈的各個節點之間的異或距離值的最小值;Determine the minimum value of the XOR distance value between each node and each node of the blockchain respectively;
在所述區塊鏈中將距離每一節點的異或距離值為最小值所對應的節點作為每一節點的打包投票資訊中被投票的節點;及In the blockchain, the node corresponding to the minimum value of the XOR distance from each node is used as the node to be voted in the packaged voting information of each node; and
每一節點分別將打包投票資訊發送給相應的被投票的節點。Each node sends the packaged voting information to the corresponding voted nodes.
本申請的第三方面提供一種電子設備,所述電子設備包括處理器及記憶體,所述處理器用於執行所述記憶體中存儲的電腦程式時實現所述基於區塊鏈交易的區塊打包方法。A third aspect of the present application provides an electronic device, the electronic device includes a processor and a memory, the processor is configured to implement the block packaging based on the blockchain transaction when executing a computer program stored in the memory method.
本申請中每一節點根據所述投票數將所述投票數最多的節點作為目標節點,及所述目標節點將接收的區塊鏈交易打包成區塊,並廣播給所述區塊鏈中的所有節點,從而避免在確定區塊的打包權時使用工作量證明共識演算法耗費大量的計算資源的問題。In this application, each node uses the node with the largest number of votes as the target node according to the number of votes, and the target node packages the received blockchain transactions into blocks and broadcasts them to the blockchain. All nodes, so as to avoid the problem of consuming a lot of computing resources using the proof-of-work consensus algorithm when determining the packaging rights of the block.
為了能夠更清楚地理解本發明的上述目的、特徵和優點,下面結合附圖和具體實施例對本發明進行詳細描述。需要說明的是,在不衝突的情況下,本申請的實施例及實施例中的特徵可以相互組合。In order to more clearly understand the above objects, features and advantages of the present invention, the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments may be combined with each other in the case of no conflict.
在下面的描述中闡述了很多具體細節以便於充分理解本發明,所描述的實施例僅僅是本發明一部分實施例,而不是全部的實施例。基於本發明中的實施例,本領域普通技術人員在沒有做出創造性勞動前提下所獲得的所有其他實施例,都屬於本發明保護的範圍。In the following description, many specific details are set forth in order to facilitate a full understanding of the present invention, and the described embodiments are only some, but not all, embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
除非另有定義,本文所使用的所有的技術和科學術語與屬於本發明的技術領域的技術人員通常理解的含義相同。本文中在本發明的說明書中所使用的術語只是為了描述具體的實施例的目的,不是旨在於限制本發明。Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terms used herein in the description of the present invention are for the purpose of describing specific embodiments only, and are not intended to limit the present invention.
優選地,本發明基於區塊鏈交易的區塊打包方法應用在一個或者多個電子設備中。所述電子設備是一種能夠按照事先設定或存儲的指令,自動進行數值計算和/或資訊處理的設備,其硬體包括但不限於微處理器、專用積體電路(Application Specific Integrated Circuit,ASIC)、可程式設計閘陣列(Field-Programmable Gate Array,FPGA)、數位訊號處理器(Digital Signal Processor,DSP)、嵌入式設備等。Preferably, the block packaging method based on block chain transactions of the present invention is applied in one or more electronic devices. The electronic device is a device that can automatically perform numerical calculations and/or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (ASICs) , Programmable Gate Array (Field-Programmable Gate Array, FPGA), Digital Signal Processor (Digital Signal Processor, DSP), embedded devices, etc.
所述電子設備可以是桌上型電腦、筆記型電腦、平板電腦及雲端伺服器等計算設備。所述設備可以與使用者藉由鍵盤、滑鼠、遙控器、觸控板或聲控設備等方式進行人機交互。The electronic device may be a computing device such as a desktop computer, a notebook computer, a tablet computer, and a cloud server. The device can interact with the user by means of a keyboard, a mouse, a remote control, a touch pad or a voice control device.
實施例1Example 1
圖1是本發明一實施方式中基於區塊鏈交易的區塊打包方法的流程圖。根據不同的需求,所述流程圖中步驟的順序可以改變,某些步驟可以省略。FIG. 1 is a flowchart of a block packaging method based on block chain transactions in an embodiment of the present invention. According to different requirements, the order of the steps in the flowchart can be changed, and some steps can be omitted.
參閱圖1所示,所述基於區塊鏈交易的區塊打包方法具體包括以下步驟。Referring to FIG. 1 , the block packaging method based on blockchain transactions specifically includes the following steps.
步驟S11,區塊鏈中的每一節點接收並存儲區塊鏈交易。Step S11, each node in the blockchain receives and stores the blockchain transaction.
本實施方式中,新產生的區塊鏈交易藉由對等(Peer to Peer, P2P)網路廣播給區塊鏈中的所有節點。區塊鏈中的每一節點藉由對等網路接收所述區塊鏈交易,並將所述區塊鏈交易存儲在每一節點的本地端交易池中。例如,區塊鏈中的任一節點產生了新的區塊鏈交易後藉由對等網路後廣播給所述區塊鏈中的所有節點,區塊鏈中的每一節點接收到相應節點廣播的區塊鏈交易後將所述區塊鏈交易存儲在每一節點的本地端交易池中。In this embodiment, the newly generated blockchain transaction is broadcast to all nodes in the blockchain through a peer-to-peer (P2P) network. Each node in the blockchain receives the blockchain transaction through a peer-to-peer network and stores the blockchain transaction in each node's local transaction pool. For example, any node in the blockchain generates a new blockchain transaction and broadcasts it to all nodes in the blockchain through the peer-to-peer network, and each node in the blockchain receives the corresponding node After the broadcasted blockchain transaction, the blockchain transaction is stored in the local transaction pool of each node.
步驟S12,每一節點根據所述區塊鏈交易計算出每一節點的雜湊值,並根據每一節點的雜湊值生成一打包投票資訊,並將所述打包投票資訊發送給被投票的節點,其中,所述打包投票資訊中包括投票的節點的數位簽章及被投票的節點的唯一識別碼。Step S12, each node calculates the hash value of each node according to the blockchain transaction, and generates a packaged voting information according to the hash value of each node, and sends the packaged voting information to the voted node, Wherein, the packaged voting information includes the digital signature of the voting node and the unique identification code of the voted node.
本實施方式中,所述區塊鏈交易為包括多個交易的交易組合。本實施方式中,由於P2P網路傳輸延時的影響,所述區塊鏈中的每一節點接收到的區塊鏈交易可能相同,也可能不同,也即,所述區塊鏈中的每一節點接收到的交易組合中的交易可能相同,也可能不同。本實施方式中,當所述區塊鏈的兩個節點接收到相同的區塊鏈交易時,所述兩個節點計算出的雜湊值相同;當所述區塊鏈的兩個節點接收到不同的區塊鏈交易時,所述兩個節點計算出的雜湊值也不相同。In this embodiment, the blockchain transaction is a transaction combination including multiple transactions. In this embodiment, due to the influence of the transmission delay of the P2P network, the blockchain transactions received by each node in the blockchain may be the same or different, that is, each node in the blockchain may receive the same or different blockchain transactions. Transactions in a combination of transactions received by a node may or may not be the same. In this embodiment, when two nodes of the blockchain receive the same blockchain transaction, the hash values calculated by the two nodes are the same; when the two nodes of the blockchain receive different The hash value calculated by the two nodes is also different when the blockchain transaction is performed.
本實施方式中,所述每一節點根據所述區塊鏈交易計算出每一節點的雜湊值,並根據每一節點的雜湊值生成一打包投票資訊,並將所述打包投票資訊發送給被投票的節點包括:計算每一節點接收到的交易組合中的每一交易的雜湊值,並將所述交易組合中的每一交易的雜湊值進行異或運算得到相應的節點的雜湊值;將每一節點的雜湊值分別與所述區塊鏈中的所有節點的唯一標識碼進行異或運算得到每一節點與所述區塊鏈中的每一節點的異或距離值;分別確定出每一節點與所述區塊鏈的各個節點之間的異或距離值的最小值;在所述區塊鏈中將距離每一節點的異或距離值為最小值所對應的節點作為每一節點的打包投票資訊中被投票的節點;及每一節點分別將打包投票資訊發送給相應的被投票的節點。In this embodiment, each node calculates the hash value of each node according to the blockchain transaction, generates a packaged voting information according to the hash value of each node, and sends the packaged voting information to the recipient. The voting nodes include: calculating the hash value of each transaction in the transaction combination received by each node, and performing XOR operation on the hash value of each transaction in the transaction combination to obtain the hash value of the corresponding node; The hash value of each node is XORed with the unique identification codes of all nodes in the blockchain to obtain the XOR distance value between each node and each node in the blockchain; The minimum value of the XOR distance value between a node and each node of the blockchain; in the blockchain, the node corresponding to the minimum XOR distance value from each node is taken as each node The voted nodes in the packaged voting information of ; and each node sends the packaged voting information to the corresponding voted nodes.
例如,所述區塊鏈由節點X、節點Y、節點Z、節點U四個節點組成。節點X的唯一識別碼為0xF000,節點Y的識別碼為0x0F00,節點Z的識別碼為0x00F0,節點U的識別碼為0x000F。其中,F表示十六進位中的數字F。所述區塊鏈交易包括交易A、交易B及交易C中的一個或多個。計算出交易A的雜湊值為0x0FFF,計算出交易B的雜湊值為0xF0FF,計算出交易C的雜湊值為0xFF0F。當節點X接收到的區塊鏈交易包括交易A、交易B及交易C時,節點X將交易A、交易B及交易C的雜湊值進行異或運算,即將0x0FFF⊕0xF0FF⊕0xFF0F進行運算得到節點X的雜湊值為0x000F。當節點Y接收到的區塊鏈交易包括交易A、交易B及交易C時,節點Y將交易A、交易B及交易C的雜湊值進行異或運算,即將0x0FFF⊕0xF0FF⊕0xFF0F進行運算得到節點Y的雜湊值為0x000F。當節點Z接收到的區塊鏈交易包括交易A及交易B時,節點Z將交易A及交易B的雜湊值進行異或運算,即將0x0FFF⊕0xF0FF進行運算得到節點Y的雜湊值為0xFF00。當節點U接收到的區塊鏈交易包括交易B及交易C時,節點U將交易B及交易C的雜湊值進行異或運算,即將0xF0FF⊕0xFF0F進行運算得到節點U的雜湊值為0x0FF0。節點X將節點X的雜湊值分別與節點X、節點Y、節點Z、節點U的唯一標識碼進行異或運算得到節點X與節點X的異或距離值為61455,得到節點X與節點Y的異或距離值為3855,得到節點X與節點Z的異或距離值為255,及得到節點X與節點U的異或距離值為0。由於節點X與節點U之間的異或距離值最小,所以節點X將節點U作為節點X的打包投票資訊中被投票的節點,及節點X將打包投票資訊發送給節點U。區塊鏈中剩餘的節點Y、節點Z、節點U確定出各自打包投票資訊中被投票的節點的過程與節點X確定出打包投票資訊節點中被投票的節點的過程相同,這裡不再詳述。For example, the blockchain consists of four nodes: node X, node Y, node Z, and node U. The unique identification code of node X is 0xF000, the identification code of node Y is 0x0F00, the identification code of node Z is 0x00F0, and the identification code of node U is 0x000F. where F represents the number F in hexadecimal. The blockchain transaction includes one or more of transaction A, transaction B, and transaction C. The hash value of transaction A is calculated to be 0x0FFF, the hash value of transaction B is calculated to be 0xF0FF, and the hash value of transaction C is calculated to be 0xFF0F. When the blockchain transaction received by node X includes transaction A, transaction B and transaction C, node X performs XOR operation on the hash values of transaction A, transaction B and transaction C, that is, 0x0FFF⊕0xF0FF⊕0xFF0F is obtained by operation The hash value of node X is 0x000F. When the blockchain transaction received by node Y includes transaction A, transaction B and transaction C, node Y performs XOR operation on the hash values of transaction A, transaction B and transaction C, that is, 0x0FFF⊕0xF0FF⊕0xFF0F is obtained by operation The hash value of node Y is 0x000F. When the blockchain transaction received by node Z includes transaction A and transaction B, node Z performs an XOR operation on the hash values of transaction A and transaction B, that is, 0x0FFF⊕0xF0FF is calculated to obtain the hash value of node Y as 0xFF00. When the blockchain transaction received by node U includes transaction B and transaction C, node U performs XOR operation on the hash value of transaction B and transaction C, that is, 0xF0FF⊕0xFF0F is calculated to obtain the hash value of node U. 0x0FF0. Node X performs XOR operation on the hash value of node X with the unique identification codes of node X, node Y, node Z, and node U, respectively, to obtain the XOR distance value of node X and node X, which is 61455, and obtains the difference between node X and node Y. The XOR distance value is 3855, the XOR distance value between node X and node Z is 255, and the XOR distance value between node X and node U is 0. Since the XOR distance value between node X and node U is the smallest, node X takes node U as the node to be voted in the packaged voting information of node X, and node X sends the packaged voting information to node U. The process for the remaining nodes Y, Z, and U in the blockchain to determine the voted node in their respective packaged voting information is the same as the process for node X to determine the voted node in the packaged voting information node, and will not be described in detail here. .
在一實施方式中,所述區塊鏈中的每一節點根據所述區塊鏈交易計算出每一節點的雜湊值,並根據每一節點的雜湊值生成一打包投票資訊,並將所述打包投票資訊發送給被投票的節點包括:所述區塊鏈中的每一節點在預設時間段內根據所述區塊鏈交易計算出每一節點的雜湊值,並根據每一節點的雜湊值生成一打包投票資訊,並將所述打包投票資訊發送給被投票的節點。本實施方式中,所述預設時間段為10秒。In one embodiment, each node in the blockchain calculates a hash value of each node according to the blockchain transaction, generates a packaged voting information according to the hash value of each node, and sends the Packing the voting information and sending it to the voted node includes: each node in the blockchain calculates the hash value of each node according to the blockchain transaction within a preset time period, and calculates the hash value of each node according to the hash value of each node within a preset time period. value to generate a packaged voting information and send the packaged voting information to the voted nodes. In this embodiment, the preset time period is 10 seconds.
步驟S13,每一節點根據接收的打包投票資訊記錄作為被投票的節點的數量得到每一節點的投票數。Step S13, each node obtains the number of votes for each node according to the received packaged voting information record as the number of voted nodes.
本實施方式中,所述每一節點根據接收的打包投票資訊記錄作為被投票的節點的數量得到每一節點的投票數包括:每一節點根據作為被投票節點的投票數、作為被投票節點的唯一識別碼及驗證資訊生成投票資訊;及每一節點將投票資訊廣播給所述區塊鏈中所有的節點。In this embodiment, each node obtains the number of votes of each node according to the number of voted nodes recorded according to the received packaged voting information, including: each node according to the number of votes as the voted node, as the voted node The unique identification code and verification information generate voting information; and each node broadcasts the voting information to all nodes in the blockchain.
步驟S14,每一節點根據所述投票數將所述投票數最多的節點作為目標節點。Step S14, each node selects the node with the largest number of votes as the target node according to the number of votes.
步驟S15,所述目標節點將接收的區塊鏈交易打包成區塊,並廣播給所述區塊鏈中的所有節點。Step S15, the target node packages the received blockchain transaction into blocks, and broadcasts it to all nodes in the blockchain.
本實施方式中,所述目標節點所述目標節點將接收的區塊鏈交易打包成區塊,並藉由P2P網路廣播給所述區塊鏈中的所有節點。In this embodiment, the target node packages the received blockchain transactions into blocks, and broadcasts them to all nodes in the blockchain through a P2P network.
本發明中每一節點根據所述投票數將所述投票數最多的節點作為目標節點,及所述目標節點將接收的區塊鏈交易打包成區塊,並廣播給所述區塊鏈中的所有節點,從而避免在確定區塊的打包權時使用工作量證明共識演算法耗費大量的計算資源的問題。In the present invention, each node uses the node with the largest number of votes as the target node according to the number of votes, and the target node packages the received blockchain transactions into blocks and broadcasts them to the blockchain. All nodes, so as to avoid the problem of consuming a lot of computing resources using the proof-of-work consensus algorithm when determining the packaging rights of the block.
實施例2Example 2
圖2為本發明一實施方式中基於區塊鏈交易的區塊打包裝置30的結構圖。FIG. 2 is a structural diagram of a
在一些實施例中,所述基於區塊鏈交易的區塊打包裝置30可以包括多個由程式碼段所組成的功能模組。所述基於區塊鏈交易的區塊打包裝置30中的各個程式段的程式碼可以存儲於記憶體中,並由至少一個處理器所執行,以執行區塊打包功能。In some embodiments, the
本實施例中,所述基於區塊鏈交易的區塊打包裝置30根據其所執行的功能,可以被劃分為多個功能模組。參閱圖2所示,所述基於區塊鏈交易的區塊打包裝置30可以包括交易接收模組301、投票模組302、計票模組303及打包模組304。本發明所稱的模組是指一種能夠被至少一個處理器所執行並且能夠完成固定功能的一系列電腦程式段,其存儲在記憶體中。所述在一些實施例中,關於各模組的功能將在後續的實施例中詳述。In this embodiment, the
所述交易接收模組301用於控制區塊鏈中的每一節點接收並存儲區塊鏈交易。The
本實施方式中,新產生的區塊鏈交易藉由P2P網路廣播給區塊鏈中的所有節點。所述交易接收模組301控制區塊鏈中的每一節點藉由對等網路接收所述區塊鏈交易,並將所述區塊鏈交易存儲在每一節點的本地端交易池中。例如,區塊鏈中的任一節點產生了新的區塊鏈交易後藉由對等網路後廣播給所述區塊鏈中的所有節點,所述交易接收模組301控制區塊鏈中的每一節點接收到相應節點廣播的區塊鏈交易後將所述區塊鏈交易存儲在每一節點的本地端交易池中。In this embodiment, the newly generated blockchain transaction is broadcast to all nodes in the blockchain through the P2P network. The
所述投票模組302用於控制每一節點根據所述區塊鏈交易計算出每一節點的雜湊值,並根據每一節點的雜湊值生成一打包投票資訊,並將所述打包投票資訊發送給被投票的節點,其中,所述打包投票資訊中包括投票的節點的數位簽章及被投票的節點的唯一識別碼。The
本實施方式中,所述區塊鏈交易為包括多個交易的交易組合。本實施方式中,由於P2P網路傳輸延時的影響,所述區塊鏈中的每一節點接收到的區塊鏈交易可能相同,也可能不同,也即,所述區塊鏈中的每一節點接收到的交易組合中的交易可能相同,也可能不同。本實施方式中,當所述區塊鏈的兩個節點接收到相同的區塊鏈交易時,所述兩個節點計算出的雜湊值相同;當所述區塊鏈的兩個節點接收到不同的區塊鏈交易時,所述兩個節點計算出的雜湊值也不相同。In this embodiment, the blockchain transaction is a transaction combination including multiple transactions. In this embodiment, due to the influence of the transmission delay of the P2P network, the blockchain transactions received by each node in the blockchain may be the same or different, that is, each node in the blockchain may receive the same or different blockchain transactions. Transactions in a combination of transactions received by a node may or may not be the same. In this embodiment, when two nodes of the blockchain receive the same blockchain transaction, the hash values calculated by the two nodes are the same; when the two nodes of the blockchain receive different The hash value calculated by the two nodes is also different when the blockchain transaction is performed.
本實施方式中,所述投票模組302控制計算每一節點接收到的交易組合中的每一交易的雜湊值,並將所述交易組合中的每一交易的雜湊值進行異或運算得到相應的節點的雜湊值;將每一節點的雜湊值分別與所述區塊鏈中的所有節點的唯一標識碼進行異或運算得到每一節點與所述區塊鏈中的每一節點的異或距離值;分別確定出每一節點與所述區塊鏈的各個節點之間的異或距離值的最小值;在所述區塊鏈中將距離每一節點的異或距離值為最小值所對應的節點作為每一節點的打包投票資訊中被投票的節點;及每一節點分別將打包投票資訊發送給相應的被投票的節點。In this embodiment, the
例如,所述區塊鏈由節點X、節點Y、節點Z、節點U四個節點組成。節點X的唯一識別碼為0xF000,節點Y的識別碼為0x0F00,節點Z的識別碼為0x00F0,節點U的識別碼為0x000F。其中,F表示十六進位中的數字F。所述區塊鏈交易包括交易A、交易B及交易C中的一個或多個。所述投票模組302計算出交易A的雜湊值為0x0FFF,計算出交易B的雜湊值為0xF0FF,計算出交易C的雜湊值為0xFF0F。當節點X接收到的區塊鏈交易包括交易A、交易B及交易C時,所述投票模組302控制節點X將交易A、交易B及交易C的雜湊值進行異或運算,即將0x0FFF⊕0xF0FF⊕0xFF0F進行運算得到節點X的雜湊值為0x000F。當節點Y接收到的區塊鏈交易包括交易A、交易B及交易C時,所述投票模組302控制節點Y將交易A、交易B及交易C的雜湊值進行異或運算,即將0x0FFF⊕0xF0FF⊕0xFF0F進行運算得到節點Y的雜湊值為0x000F。當節點Z接收到的區塊鏈交易包括交易A及交易B時,所述投票模組302控制節點Z將交易A及交易B的雜湊值進行異或運算,即將0x0FFF⊕0xF0FF進行運算得到節點Y的雜湊值為0xFF00。當節點U接收到的區塊鏈交易包括交易B及交易C時,所述投票模組302控制節點U將交易B及交易C的雜湊值進行異或運算,即將0xF0FF⊕0xFF0F進行運算得到節點U的雜湊值為0x0FF0。所述投票模組302控制節點X將節點X的雜湊值分別與節點X、節點Y、節點Z、節點U的唯一標識碼進行異或運算得到節點X與節點X的異或距離值為61455,得到節點X與節點Y的異或距離值為3855,得到節點X與節點Z的異或距離值為255,得到節點X與節點U的異或距離值為0。由於節點X與節點U之間的異或距離值最小,所述投票模組302控制節點X將節點U作為節點X的打包投票資訊中被投票的節點,及控制節點X將打包投票資訊發送給節點U。所述投票模組302控制控制區塊鏈中剩餘的節點Y、節點Z、節點U確定出各自打包投票資訊中被投票的節點的過程與節點X確定出打包投票資訊節點中被投票的節點的過程相同,這裡不再詳述。For example, the blockchain consists of four nodes: node X, node Y, node Z, and node U. The unique identification code of node X is 0xF000, the identification code of node Y is 0x0F00, the identification code of node Z is 0x00F0, and the identification code of node U is 0x000F. where F represents the number F in hexadecimal. The blockchain transaction includes one or more of transaction A, transaction B, and transaction C. The
在一實施方式中,所述區塊鏈中的每一節點根據所述區塊鏈交易計算出每一節點的雜湊值,並根據每一節點的雜湊值生成一打包投票資訊,並將所述打包投票資訊發送給被投票的節點包括:所述區塊鏈中的每一節點在預設時間段內根據所述區塊鏈交易計算出每一節點的雜湊值,並根據每一節點的雜湊值生成一打包投票資訊,並將所述打包投票資訊發送給被投票的節點。本實施方式中,所述預設時間段為10秒。In one embodiment, each node in the blockchain calculates a hash value of each node according to the blockchain transaction, generates a packaged voting information according to the hash value of each node, and sends the Packing the voting information and sending it to the voted node includes: each node in the blockchain calculates the hash value of each node according to the blockchain transaction within a preset time period, and calculates the hash value of each node according to the hash value of each node within a preset time period. value to generate a packaged voting information and send the packaged voting information to the voted nodes. In this embodiment, the preset time period is 10 seconds.
所述計票模組303用於控制每一節點根據接收的打包投票資訊記錄作為被投票的節點的數量得到每一節點的投票數。The
本實施方式中,所述計票模組303控制每一節點根據作為被投票節點的投票數、作為被投票節點的唯一識別碼及驗證資訊生成投票資訊;及每一節點將投票資訊廣播給所述區塊鏈中所有的節點。In this embodiment, the
所述計票模組303控制每一節點根據所述投票數將所述投票數最多的節點作為目標節點。The
所述打包模組304控制所述目標節點將接收的區塊鏈交易打包成區塊,並廣播給所述區塊鏈中的所有節點。The
本實施方式中,所述打包模組304控制所述目標節點所述目標節點將接收的區塊鏈交易打包成區塊,並藉由P2P網路廣播給所述區塊鏈中的所有節點。In this embodiment, the
本發明中每一節點根據所述投票數將所述投票數最多的節點作為目標節點,及所述目標節點將接收的區塊鏈交易打包成區塊,並廣播給所述區塊鏈中的所有節點,從而避免在確定區塊的打包權時使用工作量證明共識演算法耗費大量的計算資源的問題。In the present invention, each node uses the node with the largest number of votes as the target node according to the number of votes, and the target node packages the received blockchain transactions into blocks and broadcasts them to the blockchain. All nodes, so as to avoid the problem of consuming a lot of computing resources using the proof-of-work consensus algorithm when determining the packaging rights of the block.
實施例3Example 3
圖3為本發明一實施方式中電子設備6的示意圖。FIG. 3 is a schematic diagram of an
所述電子設備6包括記憶體61、處理器62以及存儲在所述記憶體61中並可在所述處理器62上運行的電腦程式63。所述處理器62執行所述電腦程式63時實現上述基於區塊鏈交易的區塊打包方法實施例中的步驟,例如圖1所示的步驟S11~S15。或者,所述處理器62執行所述電腦程式63時實現上述基於區塊鏈交易的區塊打包裝置實施例中各模組/單元的功能,例如圖2中的模組301~304。The
示例性的,所述電腦程式63可以被分割成一個或多個模組/單元,所述一個或者多個模組/單元被存儲在所述記憶體61中,並由所述處理器62執行,以完成本發明。所述一個或多個模組/單元可以是能夠完成特定功能的一系列電腦程式指令段,所述指令段用於描述所述電腦程式63在所述電子設備6中的執行過程。例如,所述電腦程式63可以被分割成圖2中的交易接收模組301、投票模組302、計票模組303及打包模組304,各模組具體功能參見實施例2。Exemplarily, the
本領域技術人員可以理解,所述示意圖僅僅是電子設備6的示例,並不構成對電子設備6的限定,可以包括比圖示更多或更少的部件,或者組合某些部件,或者不同的部件,例如所述電子設備6還可以包括輸入輸出設備、網路接入設備、匯流排等。Those skilled in the art can understand that the schematic diagram is only an example of the
所稱處理器62可以是中央處理模組(Central Processing Unit,CPU),還可以是其他通用處理器、數位訊號處理器 (Digital Signal Processor,DSP)、專用積體電路 (Application Specific Integrated Circuit,ASIC)、現場可程式設計閘陣列 (Field-Programmable Gate Array,FPGA) 或者其他可程式設計邏輯器件、分立門或者電晶體邏輯器件、分立硬體元件等。通用處理器可以是微處理器或者所述處理器62也可以是任何常規的處理器等,所述處理器62是所述電子設備6的控制中心,利用各種介面和線路連接整個電子設備6的各個部分。The
所述記憶體61可用於存儲所述電腦程式63和/或模組/單元,所述處理器62藉由運行或執行存儲在所述記憶體61內的電腦程式和/或模組/單元,以及調用存儲在記憶體61內的資料,實現所述電子設備6的各種功能。所述記憶體61可主要包括存儲程式區和存儲資料區,其中,存儲程式區可存儲作業系統、至少一個功能所需的應用程式(比如聲音播放功能、圖像播放功能等)等;存儲資料區可存儲根據電子設備6的使用所創建的資料(比如音訊資料、電話本等)等。此外,記憶體61可以包括高速隨機存取記憶體,還可以包括非易失性記憶體,例如硬碟、記憶體、插接式硬碟,智慧存儲卡(Smart Media Card, SMC),安全數位(Secure Digital, SD)卡,快閃記憶體卡(Flash Card)、至少一個磁碟記憶體件、快閃記憶體器件、或其他易失性固態記憶體件。The
所述電子設備6集成的模組/單元如果以軟體功能模組的形式實現並作為獨立的產品銷售或使用時,可以存儲在一個電腦可讀取存儲介質中。基於這樣的理解,本發明實現上述實施例方法中的全部或部分流程,也可以藉由電腦程式來指令相關的硬體來完成,所述的電腦程式可存儲於一電腦可讀存儲介質中,所述電腦程式在被處理器執行時,可實現上述各個方法實施例的步驟。其中,所述電腦程式包括電腦程式代碼,所述電腦程式代碼可以為原始程式碼形式、物件代碼形式、可執行檔或某些中間形式等。所述電腦可讀介質可以包括:能夠攜帶所述電腦程式代碼的任何實體或裝置、記錄介質、隨身碟、移動硬碟、磁碟、光碟、電腦記憶體、唯讀記憶體(ROM,Read-Only Memory)、隨機存取記憶體(RAM,Random Access Memory)、電載波信號、電信信號以及軟體分發介質等。需要說明的是,所述電腦可讀介質包含的內容可以根據司法管轄區內立法和專利實踐的要求進行適當的增減,例如在某些司法管轄區,根據立法和專利實踐,電腦可讀介質不包括電載波信號和電信信號。If the modules/units integrated in the
在本發明所提供的幾個實施例中,應該理解到,所揭露的電子設備和方法,可以藉由其它的方式實現。例如,以上所描述的電子設備實施例僅僅是示意性的,例如,所述模組的劃分,僅僅為一種邏輯功能劃分,實際實現時可以有另外的劃分方式。In the several embodiments provided by the present invention, it should be understood that the disclosed electronic devices and methods may be implemented in other manners. For example, the above-described electronic device embodiments are only illustrative. For example, the division of the modules is only a logical function division, and other division methods may be used in actual implementation.
另外,在本發明各個實施例中的各功能模組可以集成在相同處理模組中,也可以是各個模組單獨物理存在,也可以兩個或兩個以上模組集成在相同模組中。上述集成的模組既可以採用硬體的形式實現,也可以採用硬體加軟體功能模組的形式實現。In addition, each functional module in each embodiment of the present invention may be integrated in the same processing module, or each module may exist physically alone, or two or more modules may be integrated in the same module. The above-mentioned integrated modules can be implemented in the form of hardware, or can be implemented in the form of hardware plus software function modules.
對於本領域技術人員而言,顯然本發明不限於上述示範性實施例的細節,而且在不背離本發明的精神或基本特徵的情況下,能夠以其他的具體形式實現本發明。因此,無論從哪一點來看,均應將實施例看作是示範性的,而且是非限制性的,本發明的範圍由所附請求項而不是上述說明限定,因此旨在將落在申請專利範圍的等同要件的含義和範圍內的所有變化涵括在本發明內。不應將申請專利範圍中的任何附圖標記視為限制所涉及的申請專利範圍。此外,顯然“包括”一詞不排除其他模組或步驟,單數不排除複數。電子設備申請專利範圍中陳述的多個模組或電子設備也可以由同一個模組或電子設備藉由軟體或者硬體來實現。第一,第二等詞語用來表示名稱,而並不表示任何特定的順序。It will be apparent to those skilled in the art that the present invention is not limited to the details of the above-described exemplary embodiments, but that the present invention may be embodied in other specific forms without departing from the spirit or essential characteristics of the invention. Therefore, the embodiments are to be regarded in all respects as exemplary and not restrictive, and the scope of the present invention is defined by the appended claims rather than the foregoing description, and is therefore intended to fall within the scope of the patent application. All changes within the meaning and scope of equivalents to the scope are encompassed within the invention. Any reference signs in the patentable scope should not be construed as limiting the claimed scope. Furthermore, it is clear that the word "comprising" does not exclude other modules or steps, and the singular does not exclude the plural. Multiple modules or electronic devices stated in the scope of the electronic device patent application can also be implemented by the same module or electronic device through software or hardware. The terms first, second, etc. are used to denote names and do not denote any particular order.
綜上所述,本發明符合發明專利要件,爰依法提出專利申請。惟,以上所述僅為本發明之較佳實施方式,舉凡熟悉本案技藝之人士,在援依本案創作精神所作之等效修飾或變化,皆應包含於以下之申請專利範圍內。To sum up, the present invention complies with the requirements of an invention patent, and a patent application can be filed in accordance with the law. However, the above descriptions are only the preferred embodiments of the present invention, and for those who are familiar with the techniques of this case, equivalent modifications or changes made in accordance with the creative spirit of this case shall be included in the scope of the following patent application.
30:基於區塊鏈交易的區塊打包裝置30: Block packaging device based on blockchain transactions
301:交易接收模組301: Transaction receiving module
302:投票模組302: Voting Module
303:計票模組303: Voting module
304:打包模組304: Packaging Modules
6:電子設備6: Electronic equipment
61:記憶體61: Memory
62:處理器62: Processor
63:電腦程式63: Computer Programs
S11~S15:步驟S11~S15: Steps
圖1為本發明一實施方式中基於區塊鏈交易的區塊打包方法的流程圖。FIG. 1 is a flowchart of a block packaging method based on block chain transactions in an embodiment of the present invention.
圖2為本發明一實施方式中基於區塊鏈交易的區塊打包裝置的結構圖。FIG. 2 is a structural diagram of a block packaging device based on block chain transactions in an embodiment of the present invention.
圖3為本發明一實施方式中電子設備的示意圖。FIG. 3 is a schematic diagram of an electronic device in an embodiment of the present invention.
S11~S15:步驟 S11~S15: Steps
Claims (9)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
TW109145847A TWI759028B (en) | 2020-12-23 | 2020-12-23 | Block packaging method, block packaging device based on blockchain transaction, and electronic device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
TW109145847A TWI759028B (en) | 2020-12-23 | 2020-12-23 | Block packaging method, block packaging device based on blockchain transaction, and electronic device |
Publications (2)
Publication Number | Publication Date |
---|---|
TWI759028B true TWI759028B (en) | 2022-03-21 |
TW202226798A TW202226798A (en) | 2022-07-01 |
Family
ID=81710793
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
TW109145847A TWI759028B (en) | 2020-12-23 | 2020-12-23 | Block packaging method, block packaging device based on blockchain transaction, and electronic device |
Country Status (1)
Country | Link |
---|---|
TW (1) | TWI759028B (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
TWM568414U (en) * | 2018-07-03 | 2018-10-11 | 萬福資訊股份有限公司 | Blockchain counting system based on digital currency |
CN110708171A (en) * | 2019-12-13 | 2020-01-17 | 腾讯科技(深圳)有限公司 | Block chain consensus voting method, device, equipment and storage medium |
TW202034186A (en) * | 2019-03-14 | 2020-09-16 | 香港商阿里巴巴集團服務有限公司 | Methods and devices for acquiring and recording tracking information on blockchain |
TW202034247A (en) * | 2019-03-04 | 2020-09-16 | 香港商阿里巴巴集團服務有限公司 | Methods and devices for providing transaction data to blockchain system for processing |
-
2020
- 2020-12-23 TW TW109145847A patent/TWI759028B/en active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
TWM568414U (en) * | 2018-07-03 | 2018-10-11 | 萬福資訊股份有限公司 | Blockchain counting system based on digital currency |
TW202034247A (en) * | 2019-03-04 | 2020-09-16 | 香港商阿里巴巴集團服務有限公司 | Methods and devices for providing transaction data to blockchain system for processing |
TW202034186A (en) * | 2019-03-14 | 2020-09-16 | 香港商阿里巴巴集團服務有限公司 | Methods and devices for acquiring and recording tracking information on blockchain |
CN110708171A (en) * | 2019-12-13 | 2020-01-17 | 腾讯科技(深圳)有限公司 | Block chain consensus voting method, device, equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
TW202226798A (en) | 2022-07-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10657526B2 (en) | System and method to dynamically setup a private sub-blockchain based on agility of transaction processing | |
US10360191B2 (en) | Establishing overlay trust consensus for blockchain trust validation system | |
WO2020088110A1 (en) | Blockchain-based node management method and device | |
US20180331835A1 (en) | Trusted agent blockchain oracle | |
EP3825945A1 (en) | Method and device for performing credit evaluation on work publisher based on block chain | |
WO2019097322A1 (en) | Optimization of high volume transaction performance on a blockchain | |
US11057220B2 (en) | Signature verification for a blockchain ledger | |
CN108848148B (en) | Transaction information confirmation method and device based on block chain | |
CN110020854B (en) | Data evidence storage method and system based on multiple block chain networks | |
WO2020199708A1 (en) | Monitoring method, apparatus, and device for time service certificate generation request | |
CN114039733B (en) | Certificate storage service transfer method, device and equipment for alliance chains | |
US11290256B2 (en) | Blockchain-based advertisement monitoring method and apparatus, and electronic device | |
CN110060153B (en) | Data evidence storage method and system based on multiple block chain networks | |
CN110020945B (en) | Data reading method and system based on multiple block chain networks | |
WO2020233149A1 (en) | Method, apparatus and device for timing authentication in blockchain account book | |
US10790968B2 (en) | Ledger verification method and apparatus, and device | |
CN112967119A (en) | Bidding method, device and medium based on block chain | |
CN111292190A (en) | Transaction generation method, block creation method, related device and equipment | |
CN110659905A (en) | Transaction verification method, device, terminal equipment and storage medium | |
CN112134883A (en) | Method and device for quickly authenticating trust relationship between nodes based on trusted computing and related products | |
CN110992031A (en) | Data processing method and device | |
TWI759028B (en) | Block packaging method, block packaging device based on blockchain transaction, and electronic device | |
CN111899104B (en) | Service execution method and device | |
US20220198449A1 (en) | Block packaging method based on blockchain transaction and electronic device using the same | |
WO2020107223A1 (en) | Multi-chain information management method and apparatus, storage medium, and blockchain identity parser |