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 PDF

Info

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
Application number
TW109145847A
Other languages
Chinese (zh)
Other versions
TW202226798A (en
Inventor
呂孝恆
Original Assignee
鴻海精密工業股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 鴻海精密工業股份有限公司 filed Critical 鴻海精密工業股份有限公司
Priority to TW109145847A priority Critical patent/TWI759028B/en
Application granted granted Critical
Publication of TWI759028B publication Critical patent/TWI759028B/en
Publication of TW202226798A publication Critical patent/TW202226798A/en

Links

Images

Landscapes

  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)

Abstract

The present application provides a block packaging method and device based on blockchain transaction, and an electronic device. The block packaging method includes: each node in the blockchain receiving and storing blockchain transactions, each node calculating a hash value of each node according to the blockchain transaction, generating a voting information according to the hash value of each node, and sending the voting information to the node which being voted on; each node obtaining the number of votes for each node regarded as voted nodes according to the voting information; each node taking the node with the largest number of votes as a target node, and the target node packaging the received blockchain transactions into chunks and broadcasting the chunks to all nodes in the blockchain.

Description

基於區塊鏈交易的區塊打包方法、裝置及電子設備Block packaging method, device and electronic device based on block chain transaction

本發明涉及區塊鏈技術領域,具體涉及一種基於區塊鏈交易的區塊打包方法、裝置及電子設備。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 block packaging device 30 based on block chain transactions in an embodiment of the present invention.

在一些實施例中,所述基於區塊鏈交易的區塊打包裝置30可以包括多個由程式碼段所組成的功能模組。所述基於區塊鏈交易的區塊打包裝置30中的各個程式段的程式碼可以存儲於記憶體中,並由至少一個處理器所執行,以執行區塊打包功能。In some embodiments, the block packaging device 30 based on blockchain transactions may include a plurality of functional modules composed of program code segments. The program codes of each program segment in the block packing device 30 based on blockchain transactions can be stored in the memory and executed by at least one processor to perform the block packing function.

本實施例中,所述基於區塊鏈交易的區塊打包裝置30根據其所執行的功能,可以被劃分為多個功能模組。參閱圖2所示,所述基於區塊鏈交易的區塊打包裝置30可以包括交易接收模組301、投票模組302、計票模組303及打包模組304。本發明所稱的模組是指一種能夠被至少一個處理器所執行並且能夠完成固定功能的一系列電腦程式段,其存儲在記憶體中。所述在一些實施例中,關於各模組的功能將在後續的實施例中詳述。In this embodiment, the block packaging device 30 based on blockchain transactions can be divided into a plurality of functional modules according to the functions it performs. Referring to FIG. 2 , the block packaging device 30 based on blockchain transactions may include a transaction receiving module 301 , a voting module 302 , a vote counting module 303 and a packaging module 304 . The module referred to in the present invention refers to a series of computer program segments that can be executed by at least one processor and can perform fixed functions, and are stored in a memory. In some embodiments, the functions of each module will be described in detail in subsequent embodiments.

所述交易接收模組301用於控制區塊鏈中的每一節點接收並存儲區塊鏈交易。The transaction receiving module 301 is used to control each node in the blockchain to receive and store blockchain transactions.

本實施方式中,新產生的區塊鏈交易藉由P2P網路廣播給區塊鏈中的所有節點。所述交易接收模組301控制區塊鏈中的每一節點藉由對等網路接收所述區塊鏈交易,並將所述區塊鏈交易存儲在每一節點的本地端交易池中。例如,區塊鏈中的任一節點產生了新的區塊鏈交易後藉由對等網路後廣播給所述區塊鏈中的所有節點,所述交易接收模組301控制區塊鏈中的每一節點接收到相應節點廣播的區塊鏈交易後將所述區塊鏈交易存儲在每一節點的本地端交易池中。In this embodiment, the newly generated blockchain transaction is broadcast to all nodes in the blockchain through the P2P network. The transaction receiving module 301 controls each node in the blockchain to receive the blockchain transaction through a peer-to-peer network, and stores the blockchain transaction in the local transaction pool of each node. For example, after any node in the blockchain generates a new blockchain transaction, it broadcasts it to all nodes in the blockchain through a peer-to-peer network, and the transaction receiving module 301 controls the transaction in the blockchain. After receiving the blockchain transaction broadcasted by the corresponding node, each node of the node stores the blockchain transaction in the local transaction pool of each node.

所述投票模組302用於控制每一節點根據所述區塊鏈交易計算出每一節點的雜湊值,並根據每一節點的雜湊值生成一打包投票資訊,並將所述打包投票資訊發送給被投票的節點,其中,所述打包投票資訊中包括投票的節點的數位簽章及被投票的節點的唯一識別碼。The voting module 302 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 voted node, wherein the packaged voting information includes the digital signature of the voted 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.

本實施方式中,所述投票模組302控制計算每一節點接收到的交易組合中的每一交易的雜湊值,並將所述交易組合中的每一交易的雜湊值進行異或運算得到相應的節點的雜湊值;將每一節點的雜湊值分別與所述區塊鏈中的所有節點的唯一標識碼進行異或運算得到每一節點與所述區塊鏈中的每一節點的異或距離值;分別確定出每一節點與所述區塊鏈的各個節點之間的異或距離值的最小值;在所述區塊鏈中將距離每一節點的異或距離值為最小值所對應的節點作為每一節點的打包投票資訊中被投票的節點;及每一節點分別將打包投票資訊發送給相應的被投票的節點。In this embodiment, the voting module 302 controls and calculates the hash value of each transaction in the transaction combination received by each node, and performs XOR operation on the hash value of each transaction in the transaction combination to obtain the corresponding The hash value of the node; the hash value of each node is XORed with the unique identification codes of all nodes in the blockchain to obtain the XOR of each node and each node in the blockchain Distance value; determine the minimum value of the XOR distance value between each node and each node of the blockchain respectively; in the blockchain, set the XOR distance value from each node to the minimum value The corresponding node is used as the voted node in the packaged voting information of each node; and each node respectively sends the packaged voting information to the corresponding voted node.

例如,所述區塊鏈由節點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 voting module 302 calculates the hash value of transaction A as 0x0FFF, calculates the hash value of transaction B as 0xF0FF, and calculates the hash value of transaction C as 0xFF0F. When the blockchain transaction received by node X includes transaction A, transaction B and transaction C, the voting module 302 controls node X to perform XOR operation on the hash values ​​of transaction A, transaction B and transaction C, that is, 0x0FFF⊕ ​0xF0FF⊕0xFF0F is calculated to obtain the hash value of node X as 0x000F. When the blockchain transaction received by node Y includes transaction A, transaction B and transaction C, the voting module 302 controls node Y to perform XOR operation on the hash values ​​of transaction A, transaction B and transaction C, that is, 0x0FFF⊕ ​0xF0FF⊕0xFF0F is calculated to obtain the hash value of node Y as 0x000F. When the blockchain transaction received by node Z includes transaction A and transaction B, the voting module 302 controls node Z to perform XOR operation on the hash values ​​of transaction A and transaction B, that is, 0x0FFF⊕​0xF0FF is calculated to obtain the node The hash value of Y is 0xFF00. When the blockchain transaction received by node U includes transaction B and transaction C, the voting module 302 controls node U to perform XOR operation on the hash values ​​of transaction B and transaction C, that is, ​0xF0FF⊕0xFF0F is calculated to obtain the node The hash value of U is 0x0FF0. The voting module 302 controls node X to perform 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 between node X and node X is 61455, The XOR distance value between node X and node Y 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 between node X and node U is the smallest, the voting module 302 controls node X to use node U as the node to be voted in the packaged voting information of node X, and controls node X to send the packaged voting information to node U. The voting module 302 controls and controls the remaining nodes Y, node Z, and node U in the blockchain to determine the process of determining the voted node in their respective packaged voting information and the process of node X determining the voted node in the packaged voting information node. The process is the same 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.

所述計票模組303用於控制每一節點根據接收的打包投票資訊記錄作為被投票的節點的數量得到每一節點的投票數。The vote counting module 303 is used to control each node to obtain the number of votes of each node according to the received packaged voting information records as the number of voted nodes.

本實施方式中,所述計票模組303控制每一節點根據作為被投票節點的投票數、作為被投票節點的唯一識別碼及驗證資訊生成投票資訊;及每一節點將投票資訊廣播給所述區塊鏈中所有的節點。In this embodiment, the vote counting module 303 controls each node to generate 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 the voting information to the All nodes in the blockchain.

所述計票模組303控制每一節點根據所述投票數將所述投票數最多的節點作為目標節點。The vote counting module 303 controls each node to use the node with the most votes as the target node according to the votes.

所述打包模組304控制所述目標節點將接收的區塊鏈交易打包成區塊,並廣播給所述區塊鏈中的所有節點。The packaging module 304 controls the target node to package the received blockchain transaction into blocks and broadcast to all nodes in the blockchain.

本實施方式中,所述打包模組304控制所述目標節點所述目標節點將接收的區塊鏈交易打包成區塊,並藉由P2P網路廣播給所述區塊鏈中的所有節點。In this embodiment, the packaging module 304 controls the target node to package the received blockchain transaction into blocks, and broadcasts it to all nodes in the blockchain through the 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.

實施例3Example 3

圖3為本發明一實施方式中電子設備6的示意圖。FIG. 3 is a schematic diagram of an electronic device 6 in an embodiment of the present invention.

所述電子設備6包括記憶體61、處理器62以及存儲在所述記憶體61中並可在所述處理器62上運行的電腦程式63。所述處理器62執行所述電腦程式63時實現上述基於區塊鏈交易的區塊打包方法實施例中的步驟,例如圖1所示的步驟S11~S15。或者,所述處理器62執行所述電腦程式63時實現上述基於區塊鏈交易的區塊打包裝置實施例中各模組/單元的功能,例如圖2中的模組301~304。The electronic device 6 includes a memory 61 , a processor 62 and a computer program 63 stored in the memory 61 and executable on the processor 62 . When the processor 62 executes the computer program 63, the steps in the above embodiments of the block packaging method based on blockchain transactions are implemented, for example, steps S11 to S15 shown in FIG. 1 . Alternatively, when the processor 62 executes the computer program 63, the functions of each module/unit in the above-mentioned embodiment of the block packaging device based on blockchain transactions are implemented, such as modules 301 to 304 in FIG. 2 .

示例性的,所述電腦程式63可以被分割成一個或多個模組/單元,所述一個或者多個模組/單元被存儲在所述記憶體61中,並由所述處理器62執行,以完成本發明。所述一個或多個模組/單元可以是能夠完成特定功能的一系列電腦程式指令段,所述指令段用於描述所述電腦程式63在所述電子設備6中的執行過程。例如,所述電腦程式63可以被分割成圖2中的交易接收模組301、投票模組302、計票模組303及打包模組304,各模組具體功能參見實施例2。Exemplarily, the computer program 63 can be divided into one or more modules/units, and the one or more modules/units are stored in the memory 61 and executed by the processor 62 , to complete the present invention. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, and the instruction segments are used to describe the execution process of the computer program 63 in the electronic device 6 . For example, the computer program 63 can be divided into a transaction receiving module 301, a voting module 302, a vote counting module 303, and a packaging module 304 in FIG.

本領域技術人員可以理解,所述示意圖僅僅是電子設備6的示例,並不構成對電子設備6的限定,可以包括比圖示更多或更少的部件,或者組合某些部件,或者不同的部件,例如所述電子設備6還可以包括輸入輸出設備、網路接入設備、匯流排等。Those skilled in the art can understand that the schematic diagram is only an example of the electronic device 6, and does not constitute a limitation to the electronic device 6, and may include more or less components than the one shown, or combine some components, or different Components such as the electronic device 6 may also include input and output devices, network access devices, bus bars, and the like.

所稱處理器62可以是中央處理模組(Central Processing Unit,CPU),還可以是其他通用處理器、數位訊號處理器 (Digital Signal Processor,DSP)、專用積體電路 (Application Specific Integrated Circuit,ASIC)、現場可程式設計閘陣列 (Field-Programmable Gate Array,FPGA) 或者其他可程式設計邏輯器件、分立門或者電晶體邏輯器件、分立硬體元件等。通用處理器可以是微處理器或者所述處理器62也可以是任何常規的處理器等,所述處理器62是所述電子設備6的控制中心,利用各種介面和線路連接整個電子設備6的各個部分。The processor 62 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs) ), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor 62 can also be any conventional processor, etc. The processor 62 is the control center of the electronic device 6, and uses various interfaces and lines to connect the entire electronic device 6. various parts.

所述記憶體61可用於存儲所述電腦程式63和/或模組/單元,所述處理器62藉由運行或執行存儲在所述記憶體61內的電腦程式和/或模組/單元,以及調用存儲在記憶體61內的資料,實現所述電子設備6的各種功能。所述記憶體61可主要包括存儲程式區和存儲資料區,其中,存儲程式區可存儲作業系統、至少一個功能所需的應用程式(比如聲音播放功能、圖像播放功能等)等;存儲資料區可存儲根據電子設備6的使用所創建的資料(比如音訊資料、電話本等)等。此外,記憶體61可以包括高速隨機存取記憶體,還可以包括非易失性記憶體,例如硬碟、記憶體、插接式硬碟,智慧存儲卡(Smart Media Card, SMC),安全數位(Secure Digital, SD)卡,快閃記憶體卡(Flash Card)、至少一個磁碟記憶體件、快閃記憶體器件、或其他易失性固態記憶體件。The memory 61 can be used to store the computer programs 63 and/or modules/units, and the processor 62 runs or executes the computer programs and/or modules/units stored in the memory 61, And call the data stored in the memory 61 to realize various functions of the electronic device 6 . The memory 61 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; storage data The area may store data created according to the use of the electronic device 6 (such as audio data, phone book, etc.) and the like. In addition, the memory 61 may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, memory, plug-in hard disk, Smart Media Card (SMC), Secure Digital (Secure Digital, SD) card, flash memory card (Flash Card), at least one disk memory device, flash memory device, or other volatile solid state memory device.

所述電子設備6集成的模組/單元如果以軟體功能模組的形式實現並作為獨立的產品銷售或使用時,可以存儲在一個電腦可讀取存儲介質中。基於這樣的理解,本發明實現上述實施例方法中的全部或部分流程,也可以藉由電腦程式來指令相關的硬體來完成,所述的電腦程式可存儲於一電腦可讀存儲介質中,所述電腦程式在被處理器執行時,可實現上述各個方法實施例的步驟。其中,所述電腦程式包括電腦程式代碼,所述電腦程式代碼可以為原始程式碼形式、物件代碼形式、可執行檔或某些中間形式等。所述電腦可讀介質可以包括:能夠攜帶所述電腦程式代碼的任何實體或裝置、記錄介質、隨身碟、移動硬碟、磁碟、光碟、電腦記憶體、唯讀記憶體(ROM,Read-Only Memory)、隨機存取記憶體(RAM,Random Access Memory)、電載波信號、電信信號以及軟體分發介質等。需要說明的是,所述電腦可讀介質包含的內容可以根據司法管轄區內立法和專利實踐的要求進行適當的增減,例如在某些司法管轄區,根據立法和專利實踐,電腦可讀介質不包括電載波信號和電信信號。If the modules/units integrated in the electronic device 6 are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the present invention realizes all or part of the processes in the methods of the above embodiments, and can also be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, When the computer program is executed by the processor, the steps of the above method embodiments can be implemented. Wherein, the computer program includes computer program code, and the computer program code may be in the form of original code, object code, executable file, or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a flash drive, a removable hard disk, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM, Read-Only Memory); Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction, for example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium Electric carrier signals and telecommunication signals are not included.

在本發明所提供的幾個實施例中,應該理解到,所揭露的電子設備和方法,可以藉由其它的方式實現。例如,以上所描述的電子設備實施例僅僅是示意性的,例如,所述模組的劃分,僅僅為一種邏輯功能劃分,實際實現時可以有另外的劃分方式。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)

一種基於區塊鏈交易的區塊打包方法,其改良在於,所述方法包括:區塊鏈中的每一節點接收並存儲區塊鏈交易;每一節點根據所述區塊鏈交易計算出每一節點的雜湊值,並根據每一節點的雜湊值生成一打包投票資訊,並將所述打包投票資訊發送給被投票的節點,其中,所述打包投票資訊中包括投票的節點的數位簽章及被投票的節點的唯一識別碼;每一節點根據接收的打包投票資訊記錄作為被投票的節點的數量得到每一節點的投票數,包括:每一節點根據作為被投票節點的投票數、作為被投票節點的唯一識別碼及驗證資訊生成投票資訊;每一節點將投票資訊廣播給所述區塊鏈中所有的節點;每一節點根據所述投票數將所述投票數最多的節點作為目標節點;及所述目標節點將接收的區塊鏈交易打包成區塊,並廣播給所述區塊鏈中的所有節點。 A block packaging method based on block chain transactions, the improvement is that the method includes: each node in the block chain receives and stores the block chain transactions; hash value of a node, and generate a packaged voting information according to the hash value of each node, and send 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 node to be voted; each node records the number of voted nodes according to the received packaged voting information to obtain the number of votes for each node, including: each node according to the number of votes as the voted node, as The unique identification code and verification information of the voted node generate voting information; each node broadcasts the voting information to all nodes in the blockchain; each node selects the node with the most votes as the target node according to the number of votes ; and the target node packages the received blockchain transaction into blocks and broadcasts it to all nodes in the blockchain. 如請求項1所述的基於區塊鏈交易的區塊打包方法,其中,所述區塊鏈中的每一節點接收並存儲區塊鏈交易包括:區塊鏈中的每一節點藉由對等網路接收所述區塊鏈交易,並將所述區塊鏈交易存儲在每一節點的本地端交易池中。 The block packaging method based on block chain transactions according to claim 1, wherein each node in the block chain receives and stores the block chain transactions comprising: each node in the block chain The other network receives the blockchain transaction and stores the blockchain transaction in the local transaction pool of each node. 如請求項1所述的基於區塊鏈交易的區塊打包方法,其中,所述區塊鏈交易為包括多個交易的交易組合。 The block packaging method based on a blockchain transaction according to claim 1, wherein the blockchain transaction is a transaction combination including multiple transactions. 如請求項3所述的基於區塊鏈交易的區塊打包方法,其中,所述每一節點根據所述區塊鏈交易計算出每一節點的雜湊值,並根據每一節點的雜湊值生成一打包投票資訊,並將所述打包投票資訊發送給被投票的節點包括: 計算每一節點接收到的交易組合中的每一交易的雜湊值,並將所述交易組合中的每一交易的雜湊值進行異或運算得到相應的節點的雜湊值;將每一節點的雜湊值分別與所述區塊鏈中的所有節點的唯一標識碼進行異或運算得到每一節點與所述區塊鏈中的每一節點的異或距離值;分別確定出每一節點與所述區塊鏈的各個節點之間的異或距離值的最小值;在所述區塊鏈中將距離每一節點的異或距離值為最小值所對應的節點作為每一節點的打包投票資訊中被投票的節點;及每一節點分別將打包投票資訊發送給相應的被投票的節點。 The block packaging method based on blockchain transactions according to claim 3, wherein each node calculates a hash value of each node according to the blockchain transaction, and generates a hash value according to the hash value of each node Packing voting information and sending the voting information to the voted node includes: 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; The value 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 each node of the blockchain; in the blockchain, the node corresponding to the minimum XOR distance value from each node is taken as the packaged voting information of each node. The voted nodes; and each node sends the packaged voting information to the corresponding voted nodes. 如請求項3所述的基於區塊鏈交易的區塊打包方法,其中,所述區塊鏈中的每一節點根據所述區塊鏈交易計算出每一節點的雜湊值,並根據每一節點的雜湊值生成一打包投票資訊,並將所述打包投票資訊發送給被投票的節點包括:所述區塊鏈中的每一節點在預設時間段內根據所述區塊鏈交易計算出每一節點的雜湊值,並根據每一節點的雜湊值生成一打包投票資訊,並將所述打包投票資訊發送給被投票的節點。 The block packaging method based on block chain transactions according to claim 3, wherein each node in the block chain calculates the hash value of each node according to the block chain transaction, and according to each The hash value of the node generates a packaged voting information, and sending the packaged voting information to the node to be voted includes: each node in the blockchain calculates according to the blockchain transaction within a preset time period. hash value of each node, and generate a packaged voting information according to the hash value of each node, and send the packaged voting information to the voted node. 如請求項1所述的基於區塊鏈交易的區塊打包方法,其中,所述區塊鏈中的每一節點接收相同或不同的區塊鏈交易。 The block packaging method based on block chain transactions according to claim 1, wherein each node in the block chain receives the same or different block chain transactions. 一種基於區塊鏈交易的區塊打包裝置,其改良在於,所述裝置包括:交易接收模組,用於控制區塊鏈中的每一節點接收並存儲區塊鏈交易;投票模組,用於控制每一節點根據所述區塊鏈交易計算出每一節點的雜湊值,並根據每一節點的雜湊值生成一打包投票資訊,並將所述打包投票資訊發送給被投票的節點,其中,所述打包投票資訊中包括投票的節點的數位簽章及被投票的節點的唯一識別碼;計票模組,用於: 控制每一節點根據接收的打包投票資訊記錄作為被投票的節點的數量得到每一節點的投票數,包括:每一節點根據作為被投票節點的投票數、作為被投票節點的唯一識別碼及驗證資訊生成投票資訊;每一節點將投票資訊廣播給所述區塊鏈中所有的節點;及控制每一節點根據所述投票數將所述投票數最多的節點作為目標節點;及打包模組,用於控制所述目標節點將接收的區塊鏈交易打包成區塊,並廣播給所述區塊鏈中的所有節點。 A block packaging device based on blockchain transactions, the improvement is that the device includes: a transaction receiving module for controlling each node in the blockchain to receive and store blockchain transactions; a voting module for using Controlling each node to calculate the hash value of each node according to the blockchain transaction, and generating a packaged voting information according to the hash value of each node, and sending 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; the vote counting module is used for: Control each node to obtain 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 is based on the number of votes as the voted node, the unique identification code and verification of the voted node information to generate voting information; each node broadcasts the voting information to all nodes in the blockchain; and controls each node to use the node with the largest number of votes as the target node according to the number of votes; and a packaging module, using It is used to control the target node to package the received blockchain transaction into blocks and broadcast it to all nodes in the blockchain. 如請求項7所述的基於區塊鏈交易的區塊打包裝置,其中,所述區塊鏈交易為包括多個交易的交易組合,所述投票模組還用於:計算每一節點接收到的交易組合中的每一交易的雜湊值,並將所述交易組合中的每一交易的雜湊值進行異或運算得到相應的節點的雜湊值;將每一節點的雜湊值分別與所述區塊鏈中的所有節點的唯一標識碼進行異或運算得到每一節點與所述區塊鏈中的每一節點的異或距離值;分別確定出每一節點與所述區塊鏈的各個節點之間的異或距離值的最小值;在所述區塊鏈中將距離每一節點的異或距離值為最小值所對應的節點作為每一節點的打包投票資訊中被投票的節點;及每一節點分別將打包投票資訊發送給相應的被投票的節點。 The block packaging device based on block chain transactions according to claim 7, wherein the block chain transaction is a transaction combination including multiple transactions, and the voting module is further configured to: the hash value of each transaction in the transaction combination, and perform XOR operation on the hash value of each transaction in the transaction combination to obtain the hash value of the corresponding node; Perform XOR operation on 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 each node and each node in the blockchain respectively The minimum value of the XOR distance value between each node; the node corresponding to the minimum value of the XOR distance value from each node in the blockchain is regarded as the node voted in the packaged voting information of each node; and Each node sends the packaged voting information to the corresponding voted nodes. 一種電子設備,其改良在於,所述電子設備包括處理器及記憶體,所述處理器用於執行所述記憶體中存儲的電腦程式時實現如請求項1至6中任一項所述基於區塊鏈交易的區塊打包方法。An electronic device, which is improved in that the electronic device includes a processor and a memory, and the processor is configured to implement the region-based system according to any one of claims 1 to 6 when executing a computer program stored in the memory. Block packaging method for blockchain transactions.
TW109145847A 2020-12-23 2020-12-23 Block packaging method, block packaging device based on blockchain transaction, and electronic device TWI759028B (en)

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)

* Cited by examiner, † Cited by third party
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

Patent Citations (4)

* Cited by examiner, † Cited by third party
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