TW202226126A - Method and device for block operation, computer device and storage medium - Google Patents
Method and device for block operation, computer device and storage medium Download PDFInfo
- Publication number
- TW202226126A TW202226126A TW109145366A TW109145366A TW202226126A TW 202226126 A TW202226126 A TW 202226126A TW 109145366 A TW109145366 A TW 109145366A TW 109145366 A TW109145366 A TW 109145366A TW 202226126 A TW202226126 A TW 202226126A
- Authority
- TW
- Taiwan
- Prior art keywords
- target
- node
- blockchain
- block
- computing power
- Prior art date
Links
Images
Landscapes
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
Abstract
Description
本申請涉及區塊鏈技術領域,尤其涉及一種區塊運算方法、裝置、電腦裝置及儲存介質。The present application relates to the field of blockchain technology, and in particular, to a block computing method, device, computer device and storage medium.
目前,在區塊鏈的運算過程中,運算能力(算力)高的區塊鏈節點比較容易完成計算任務,從而導致了運算能力高的區塊鏈節點對計算任務的完成以及獎勵進行壟斷,降低了區塊鏈的去中心化。At present, in the process of blockchain operation, blockchain nodes with high computing power (computing power) are easier to complete computing tasks, which leads to the monopoly of blockchain nodes with high computing power on the completion of computing tasks and rewards. Decentralization of the blockchain is reduced.
因此,如何提高區塊鏈的去中心化是一個亟需解決的技術問題。Therefore, how to improve the decentralization of blockchain is a technical problem that needs to be solved urgently.
鑒於以上內容,有必要提供一種區塊運算方法、裝置、電腦裝置及儲存介質,能夠提高區塊鏈的去中心化。In view of the above, it is necessary to provide a block computing method, device, computer device and storage medium, which can improve the decentralization of the blockchain.
本申請的第一方面提供一種區塊運算方法,所述區塊運算方法包括:A first aspect of the present application provides a block operation method, the block operation method comprising:
根據每個區塊鏈節點的算力以及獎勵,對多個區塊鏈節點進行均值聚類,獲得多個集群;According to the computing power and rewards of each blockchain node, perform mean clustering on multiple blockchain nodes to obtain multiple clusters;
當目標區塊鏈節點接收到廣播區塊時,確定所述廣播區塊所攜帶的節點算力以及節點獎勵;When the target blockchain node receives the broadcast block, determine the node computing power and node reward carried by the broadcast block;
根據所述節點算力、所述節點獎勵、所述目標區塊鏈節點的目標算力、所述目標區塊鏈節點的目標獎勵以及所述目標難度權重,確定所述目標區塊鏈節點的目標難度;According to the node computing power, the node reward, the target computing power of the target blockchain node, the target reward of the target blockchain node, and the target difficulty weight, determine the target blockchain node's target difficulty;
根據所述目標難度進行區塊運算,並在所述區塊運算完成後產生一個區塊。A block operation is performed according to the target difficulty, and a block is generated after the block operation is completed.
本申請的第二方面提供一種區塊運算裝置,所述區塊運算裝置包括:A second aspect of the present application provides a block computing device, the block computing device comprising:
聚類模組,用於根據每個區塊鏈節點的算力以及獎勵,對多個區塊鏈節點進行均值聚類,獲得多個集群;The clustering module is used to perform mean clustering on multiple blockchain nodes according to the computing power and rewards of each blockchain node to obtain multiple clusters;
確定模組,用於當目標區塊鏈節點接收到廣播區塊時,確定所述廣播區塊所攜帶的節點算力以及節點獎勵;A determination module, used for determining the node computing power and node reward carried by the broadcast block when the target blockchain node receives the broadcast block;
所述確定模組,還用於根據所述節點算力、所述節點獎勵、所述目標區塊鏈節點的目標算力、所述目標區塊鏈節點的目標獎勵以及所述目標難度權重,確定所述目標區塊鏈節點的目標難度;The determination module is further configured to, according to the node computing power, the node reward, the target computing power of the target blockchain node, the target reward of the target blockchain node, and the target difficulty weight, determining the target difficulty of the target blockchain node;
運算模組,用於根據所述目標難度進行區塊運算,並在所述區塊運算完成後產生一個區塊。The operation module is used to perform block operation according to the target difficulty, and generate a block after the block operation is completed.
本申請的第三方面提供一種電腦裝置,所述電腦裝置包括:A third aspect of the present application provides a computer device, the computer device comprising:
儲存器,儲存至少一個指令;及a memory that stores at least one instruction; and
處理器,獲取所述儲存器中儲存的指令以實現所述區塊運算方法。The processor obtains the instructions stored in the memory to implement the block operation method.
本申請的第四方面提供一種電腦可讀儲存介質,所述電腦可讀儲存介質中儲存有至少一個指令,所述至少一個指令被電腦裝置中的處理器獲取以實現所述區塊運算方法。A fourth aspect of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores at least one instruction, and the at least one instruction is acquired by a processor in a computer device to implement the block operation method.
由以上技術方案,本申請中,能夠根據區塊鏈節點的算力(運算能力)以及獎勵進行計算難度調整,確保算力低的區塊鏈節點也能夠完成運算以及獲得獎勵,提高了區塊鏈的去中心化。From the above technical solutions, in this application, the calculation difficulty can be adjusted according to the computing power (computing power) and rewards of the blockchain nodes, so as to ensure that the blockchain nodes with low computing power can also complete the computation and obtain rewards, which improves the block chain. Decentralization of the chain.
下面將結合本申請實施例中的附圖,對本申請實施例中的技術方案進行清楚、完整地描述,顯然,所描述的實施例僅僅是本申請一部分實施例,而不是全部的實施例。基於本申請中的實施例,本領域普通技術人員在沒有做出創造性勞動前提下所獲得的所有其他實施例,都屬於本申請保護的範圍。The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
除非另有定義,本文所使用的所有的技術和科學術語與屬於本申請的技術領域的技術人員通常理解的含義相同。本文中在本申請的說明書中所使用的術語只是為了描述具體的實施例的目的,不是旨在於限制本申請。Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the technical field to which this application belongs. The terms used herein in the specification of the application are for the purpose of describing specific embodiments only, and are not intended to limit the application.
本申請實施例的區塊運算方法應用在電腦裝置中,也可以應用在電腦裝置和透過網路與所述電腦裝置進行連接的伺服器所構成的硬體環境中,由伺服器和電腦裝置共同執行。網路包括但不限於:廣域網路、都會區網路或局域網。The block computing method of the embodiments of the present application is applied to a computer device, and can also be applied to a hardware environment composed of a computer device and a server connected to the computer device through a network. The server and the computer device jointly implement. Networks include, but are not limited to: Wide Area Networks, Metropolitan Area Networks or Local Area Networks.
其中,伺服器可以是指能對網路中其它設備(如電腦裝置)提供服務的電腦系統。如果一個個人電腦能夠對外提供檔案傳輸通訊協定(File Transfer Protocol,簡稱FTP)服務,也可以叫伺服器。從狹義範圍上講,伺服器專指某些高性能電腦,能透過網路,對外提供服務,其相對于普通的個人電腦來說,穩定性、安全性、性能等方面都要求更高,因此在CPU、晶片組、儲存器、磁片系統、網路等硬體和普通的個人電腦有所不同。The server may refer to a computer system that can provide services to other devices (such as computer devices) in the network. If a personal computer can provide external File Transfer Protocol (File Transfer Protocol, referred to as FTP) services, it can also be called a server. In a narrow sense, a server refers to some high-performance computers that can provide services to the outside world through the network. Compared with ordinary personal computers, they have higher requirements in terms of stability, security, and performance. Therefore, The hardware such as CPU, chipset, storage, disk system, network, etc. are different from ordinary personal computers.
所述電腦裝置是一種能夠按照事先設定或儲存的指令,自動進行數值計算和/或資訊處理的設備,其硬體包括但不限於微處理器、專用積體電路(ASIC)、現場可程式設計閘陣列(FPGA)、數位訊號處理器(DSP)、嵌入式設備等。所述電腦裝置還可包括網路設備和/或使用者設備。其中,所述網路設備包括但不限於單個網路設備、多個網路設備組成的伺服器組或基於雲計算(Cloud Computing)的由大量主機或網路設備構成的雲,其中,雲計算是分散式運算的一種,由一群鬆散耦合的電腦集組成的一個超級虛擬電腦。所述使用者設備包括但不限於任何一種可與使用者透過鍵盤、滑鼠、遙控器、觸控板或聲控設備等方式進行人機交互的電子產品,例如,個人電腦、平板電腦、智慧手機、個人數位助理PDA等。The computer device is a device that can automatically perform numerical calculation and/or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, dedicated integrated circuits (ASIC), field programmable design gate array (FPGA), digital signal processor (DSP), embedded devices, etc. The computer device may also include network equipment and/or user equipment. Wherein, the network device includes but is not limited to a single network device, a server group composed of multiple network devices, or a cloud composed of a large number of hosts or network devices based on cloud computing, wherein cloud computing It is a kind of distributed computing, a super virtual computer composed of a group of loosely coupled computer sets. The user equipment includes but is not limited to any electronic product that can interact with the user through a keyboard, a mouse, a remote control, a touchpad or a voice control device, for example, a personal computer, a tablet computer, a smart phone, etc. , Personal Digital Assistant PDA, etc.
請參見圖1,圖1是本申請公開的一種區塊運算方法的較佳實施例的流程圖。其中,根據不同的需求,該流程圖中步驟的順序可以改變,某些步驟可以省略。其中,所述區塊運算方法的執行主體可以為電腦裝置。Please refer to FIG. 1. FIG. 1 is a flowchart of a preferred embodiment of a block operation method disclosed in the present application. Wherein, according to different requirements, the order of the steps in the flowchart can be changed, and some steps can be omitted. Wherein, the execution body of the block operation method may be a computer device.
步驟S11、根據每個區塊鏈節點的算力以及獎勵,對多個區塊鏈節點進行均值聚類,獲得多個集群;Step S11, according to the computing power and reward of each blockchain node, perform mean clustering on multiple blockchain nodes to obtain multiple clusters;
其中,所述算力(也稱雜湊率)是比特幣網路處理能力的度量單位。即為電腦(CPU)計算雜湊函數輸出的速度。比特幣網路必須為了安全目的而進行密集的數學和加密相關操作。 例如,當網路達到10Th/s的雜湊率時,意味著它可以每秒進行10萬億次計算。所述算力可以是區塊鏈節點的資料運算能力;所述獎勵是指區塊鏈節點完成運算任務時根據預設的獎勵機制獲得的獎勵。Among them, the computing power (also called hash rate) is a unit of measurement of the processing power of the Bitcoin network. That is, the speed at which the computer (CPU) calculates the output of the hash function. The Bitcoin network must perform intensive mathematical and cryptographic related operations for security purposes. For example, when the network reaches a hash rate of 10Th/s, it means it can perform 10 trillion calculations per second. The computing power may be the data computing ability of the blockchain node; the reward refers to the reward obtained by the blockchain node according to the preset reward mechanism when the computing task is completed.
其中,所述均值聚類可以是指k均值聚類演算法(k-means clustering algorithm),是一種反覆運算求解的聚類分析演算法,包括:預先將數據分為K組,則隨機選取K個物件作為初始的聚類中心,然後計算每個物件與各個種子聚類中心之間的距離,把每個物件分配給距離它最近的聚類中心。聚類中心以及分配給它們的物件就代表一個聚類。每分配一個樣本,聚類的聚類中心會根據聚類中現有的物件被重新計算。這個過程將不斷重複直到滿足某個終止條件。終止條件可以是沒有(或最小數目)聚類中心再發生變化。Wherein, the mean clustering may refer to a k-means clustering algorithm, which is a clustering analysis algorithm for repeated operation and solution, including: dividing the data into K groups in advance, then randomly selecting K Each object is used as the initial cluster center, and then the distance between each object and each seed cluster center is calculated, and each object is assigned to the cluster center closest to it. Cluster centers and the objects assigned to them represent a cluster. Each time a sample is assigned, the cluster center of the cluster is recalculated based on the existing objects in the cluster. This process will repeat until a certain termination condition is met. The termination condition can be that no (or the minimum number) of cluster centers change again.
其中,一個集群可以包括多個區塊鏈節點,一個區塊鏈節點只能屬於一個集群。Among them, a cluster can include multiple blockchain nodes, and a blockchain node can only belong to one cluster.
作為一種可選的實施方式,所述根據每個區塊鏈節點的算力以及獎勵,對多個區塊鏈節點進行均值聚類,獲得多個集群之前,所述區塊運算方法還包括:As an optional implementation manner, performing mean clustering on multiple blockchain nodes according to the computing power and rewards of each blockchain node, and before obtaining multiple clusters, the block computing method further includes:
獲取每個所述區塊鏈節點的算力以及獎勵;Obtain the computing power and rewards of each of the blockchain nodes;
根據每個所述區塊鏈節點的算力以及獎勵,將每個所述區塊鏈節點映射至平面直角座標系中,獲得每個所述區塊鏈節點對應的座標,其中,區塊鏈節點的算力為橫座標,區塊鏈的獎勵為縱座標。According to the computing power and rewards of each of the blockchain nodes, map each of the blockchain nodes to a plane rectangular coordinate system, and obtain the coordinates corresponding to each of the blockchain nodes, wherein the blockchain The computing power of the node is the abscissa, and the reward of the blockchain is the ordinate.
其中,所述多個區塊鏈節點與多個座標一一對應,區塊鏈節點的算力為橫座標,區塊鏈的獎勵為縱座標。比如,假設區塊鏈節點量化後的算力為10,量化後的獎勵為15,則區塊鏈節點對應的座標為(10,15)。The multiple blockchain nodes correspond to multiple coordinates one-to-one, the computing power of the blockchain nodes is the abscissa, and the reward of the blockchain is the ordinate. For example, assuming that the quantized computing power of the blockchain node is 10, and the quantized reward is 15, the coordinates corresponding to the blockchain node are (10, 15).
具體的,所述根據每個區塊鏈節點的算力以及獎勵,對多個區塊鏈節點進行均值聚類,獲得多個集群包括:Specifically, performing mean clustering on multiple blockchain nodes according to the computing power and rewards of each blockchain node, and obtaining multiple clusters includes:
根據每個區塊鏈節點的算力以及獎勵,確定每個所述區塊鏈節點對應的座標;Determine the coordinates corresponding to each of the blockchain nodes according to the computing power and rewards of each blockchain node;
從多個所述座標中確定初始中心點;determining an initial center point from a plurality of said coordinates;
根據所述初始中心點,對所述多個座標進行分組,獲得多個初始組群;According to the initial center point, the plurality of coordinates are grouped to obtain a plurality of initial groups;
重新計算所述多個初始組群的中心,獲得第一中心點;recalculating the centers of the plurality of initial groups to obtain a first center point;
若所述第一中心點與所述初始中心點一致,確定均值聚類完成,將所述多個初始組群確定為所述多個集群。If the first center point is consistent with the initial center point, it is determined that mean clustering is completed, and the multiple initial groups are determined as the multiple clusters.
在該可選的實施方式中,可以根據每個區塊鏈節點的算力以及獎勵,確定每個所述區塊鏈節點對應的座標,比如(10,10)、(10,15)、(15,10)等座標。一個區塊鏈節點對應一個座標。從多個所述座標中確定初始中心點,比如(5,5)、(10,10);根據所述初始中心點,對所述多個座標進行分組,即將每個座標分配給距離最近的初始中心點,獲得多個初始組群,每個初始族群包括最少一個座標;重新計算所述多個初始組群的中心,獲得第一中心點;若所述第一中心點與所述初始中心點一致,確定均值聚類完成,將所述多個初始組群確定為所述多個集群。In this optional embodiment, the coordinates corresponding to each of the blockchain nodes can be determined according to the computing power and rewards of each blockchain node, such as (10, 10), (10, 15), ( 15, 10) and other coordinates. A blockchain node corresponds to a coordinate. Determine an initial center point from a plurality of the coordinates, such as (5, 5), (10, 10); according to the initial center point, group the plurality of coordinates, that is, assign each coordinate to the closest distance Initial center point, obtain multiple initial groups, each initial group includes at least one coordinate; recalculate the centers of the multiple initial groups to obtain the first center point; if the first center point and the initial center If the points are consistent, it is determined that the mean clustering is completed, and the multiple initial groups are determined as the multiple clusters.
作為一種可選的實施方式,所述區塊運算方法還包括:As an optional implementation manner, the block operation method further includes:
若所述第一中心點與所述初始中心點不一致,根據所述第一中心點,對多個所述座標重新進行分組,獲得多個第一組群;If the first center point is inconsistent with the initial center point, regroup a plurality of the coordinates according to the first center point to obtain a plurality of first groups;
計算所述多個第一組群的中心,獲得第二中心點;calculating the centers of the plurality of first groups to obtain a second center point;
若所述第二中心點與所述第一中心點一致,確定均值聚類完成,將所述多個第一組群確定為所述多個集群。If the second center point is consistent with the first center point, it is determined that mean clustering is completed, and the plurality of first groups are determined as the plurality of clusters.
在該可選的實施方式中,若所述第一中心點與所述初始中心點不一致,確定均值聚類未完成,根據所述第一中心點,對多個所述座標重新進行分組,獲得多個第一組群;計算所述多個第一組群的中心,獲得第二中心點;若所述第二中心點與所述第一中心點一致,確定均值聚類完成,將所述多個第一組群確定為所述多個集群。In this optional embodiment, if the first center point is inconsistent with the initial center point, it is determined that the mean clustering is not completed, and according to the first center point, a plurality of the coordinates are re-grouped to obtain multiple first groups; calculate the centers of the multiple first groups to obtain a second center point; if the second center point is consistent with the first center point, it is determined that the mean clustering is completed, and the A plurality of first groups are determined as the plurality of clusters.
作為一種可選的實施方式,所述根據每個區塊鏈節點的算力以及獎勵,對多個區塊鏈節點進行均值聚類,獲得多個集群之前,所述區塊運算方法還包括:As an optional implementation manner, performing mean clustering on multiple blockchain nodes according to the computing power and rewards of each blockchain node, and before obtaining multiple clusters, the block computing method further includes:
從所述多個區塊鏈節點中,確定與所述平面直角座標系的原點的原點距離最小的最小節點,以及確定與所述原點的原點距離最大的最大節點;From the plurality of blockchain nodes, determine the smallest node with the smallest distance from the origin of the plane rectangular coordinate system, and determine the largest node with the largest distance from the origin of the origin;
確定所述最小節點的原點距離與所述最大節點的原點距離的距離差值;determining the distance difference between the origin distance of the smallest node and the origin distance of the largest node;
將所述距離差值確定為預設的所述第一距離。The distance difference value is determined as the preset first distance.
在該可選的實施方式中,從所述多個區塊鏈節點中,確定與所述平面直角座標系的原點的原點距離最小的最小節點,以及確定與所述原點的原點距離最大的最大節點;確定所述最小節點的原點距離與所述最大節點的原點距離的距離差值;將所述距離差值確定為預設的所述第一距離。假設所述最小節點的座標為(1,0),對應的原點距離為1,所述最大節點的座標為 (10,0)對應的原點距離為10,則所述第一距離為9。In this optional embodiment, from the plurality of blockchain nodes, the smallest node with the smallest distance from the origin of the origin of the plane rectangular coordinate system is determined, and the origin of the origin is determined the largest node with the largest distance; determine the distance difference between the origin distance of the smallest node and the origin distance of the largest node; and determine the distance difference as the preset first distance. Assuming that the coordinate of the smallest node is (1, 0), the corresponding origin distance is 1, the coordinate of the largest node is (10, 0) and the corresponding origin distance is 10, then the first distance is 9 .
步驟S12、當目標區塊鏈節點接收到廣播區塊時,確定所述廣播區塊所攜帶的節點算力以及節點獎勵。Step S12, when the target blockchain node receives the broadcast block, determine the node computing power and the node reward carried by the broadcast block.
其中,所述廣播區塊可以是某個區塊鏈節點完成計算任務後打包的區塊,打包的區塊會廣播至其它區塊鏈節點中。The broadcast block may be a block packaged by a certain blockchain node after completing the computing task, and the packaged block will be broadcast to other blockchain nodes.
其中,所述廣播區塊攜帶有打包所述廣播區塊的區塊鏈節點的算力資訊以及獎勵資訊。Wherein, the broadcast block carries the computing power information and reward information of the blockchain nodes that package the broadcast block.
作為一種可選的實施方式,所述根據每個區塊鏈節點的算力以及獎勵,對多個區塊鏈節點進行均值聚類,獲得多個集群之後以及所述當目標區塊鏈節點接收到廣播區塊時,確定所述廣播區塊所攜帶的節點算力以及節點獎勵之前,所述區塊運算方法還包括:As an optional implementation manner, according to the computing power and rewards of each blockchain node, perform mean clustering on multiple blockchain nodes, and after obtaining multiple clusters, and when the target blockchain node receives When the block is broadcast, before determining the node computing power and the node reward carried by the broadcast block, the block computing method further includes:
確定每個所述集群的中心座標;determining the coordinates of the center of each of said clusters;
確定所述中心座標與所述平面直角座標系的原點的第三距離;determining the third distance between the center coordinate and the origin of the plane rectangular coordinate system;
根據所述第三距離,為每個所述集群分配對應的難度權重。A corresponding difficulty weight is assigned to each of the clusters according to the third distance.
在該可選的實施方式中,確定每個所述集群的中心座標,然後確定所述中心座標與所述平面直角座標系的原點的第三距離,根據所述第三距離,為每個所述集群分配對應的難度權重。比如,存在3個集群,集群A的第三距離為1,集群B的第三距離為3,集群C的距離為5。則所述集群總數為3,集群A的第三距離小於集群B的第三距離,集群B的第三距離小於集群C的第三距離,則集群A對應的難度權重為1/3,則集群B對應的難度權重為2/3,則集群C對應的難度權重為3/3。In this optional implementation manner, the center coordinates of each of the clusters are determined, and then a third distance between the center coordinates and the origin of the plane rectangular coordinate system is determined, and according to the third distance, for each The clusters assign corresponding difficulty weights. For example, there are 3 clusters, the third distance of cluster A is 1, the third distance of cluster B is 3, and the distance of cluster C is 5. Then the total number of clusters is 3, the third distance of cluster A is less than the third distance of cluster B, and the third distance of cluster B is less than the third distance of cluster C, then the difficulty weight corresponding to cluster A is 1/3, then the cluster The difficulty weight corresponding to B is 2/3, and the difficulty weight corresponding to cluster C is 3/3.
步驟S13、從所述多個集群中,確定目標區塊鏈節點所屬的目標集群,並確定所述目標集群對應的目標難度權重。Step S13: From the multiple clusters, determine the target cluster to which the target blockchain node belongs, and determine the target difficulty weight corresponding to the target cluster.
其中,不同的集群具有不同的難度權重。一個集群包括至少一個區塊鏈節點,一個區塊鏈節點只屬於一個集群。Among them, different clusters have different difficulty weights. A cluster includes at least one blockchain node, and a blockchain node belongs to only one cluster.
步驟S14、根據所述節點算力、所述節點獎勵、所述目標區塊鏈節點的目標算力、所述目標區塊鏈節點的目標獎勵以及所述目標難度權重,確定所述目標區塊鏈節點的目標難度。Step S14: Determine the target block according to the node computing power, the node reward, the target computing power of the target blockchain node, the target reward of the target blockchain node, and the target difficulty weight The target difficulty of the chain node.
其中,所述難度Difficulty,可以用來控制區塊的平均產生時間,Difficulty 值越高時,區塊鏈節點越不容易完成運算。相反地,當 Difficulty 值越低時,區塊鏈節點越容易完成運算。Among them, the difficulty Difficulty can be used to control the average generation time of blocks. The higher the Difficulty value is, the more difficult it is for the blockchain nodes to complete the operation. Conversely, when the Difficulty value is lower, it is easier for the blockchain node to complete the operation.
具體的,所述根據所述節點算力、所述節點獎勵、所述目標區塊鏈節點的目標算力、所述目標區塊鏈節點的目標獎勵以及所述目標難度權重,確定所述目標區塊鏈節點的目標難度包括:Specifically, the target is determined according to the node computing power, the node reward, the target computing power of the target blockchain node, the target reward of the target blockchain node, and the target difficulty weight The target difficulty for blockchain nodes includes:
確定與所述節點算力以及所述節點獎勵均對應的節點座標;Determine the node coordinates corresponding to the node computing power and the node reward;
確定與所述目標區塊鏈節點的目標獎勵以及所述目標區塊鏈節點的目標獎勵均對應的目標座標;Determine the target coordinates corresponding to the target reward of the target blockchain node and the target reward of the target blockchain node;
計算所述節點座標與所述目標座標之間的第二距離;calculating a second distance between the node coordinates and the target coordinates;
獲取預設的第一距離,其中,所述第一距離為所述多個區塊鏈節點中的最大的距離;obtaining a preset first distance, where the first distance is the largest distance among the plurality of blockchain nodes;
根據所述第一距離、所述第二距離以及所述目標集群對應的難度權重,確定所述目標難度。The target difficulty is determined according to the first distance, the second distance, and the difficulty weight corresponding to the target cluster.
在該可選的實施方式中,可以確定與所述節點算力以及所述節點獎勵均對應的節點座標;確定與所述目標區塊鏈節點的目標獎勵以及所述目標區塊鏈節點的目標獎勵均對應的目標座標;計算所述節點座標與所述目標座標之間的第二距離;獲取預設的第一距離,其中,所述第一距離為所述多個區塊鏈節點中的最大的距離;根據所述第一距離、所述第二距離以及所述目標集群對應的難度權重,確定所述目標難度。比如:假設節點算力為 28,節點獎勵為 14,則節點座標為(28,14)。目標區塊鏈節點A及目標區塊鏈節點B接收到廣播的區塊,並驗證其為有效區塊。假設第一距離為 30。目標區塊鏈節點 A與節點座標之間的第二距離為 15,所屬的目標集群對應的難度權重為1。目標區塊鏈節點B與節點座標的距離為 15,所述的目標集群對應的難度權重為1/3,集群總數為3。目標區塊鏈節點 A 計算的目標難度為 (1 - 15 / 30) * (1 / 1) * 2256 = 0.5 * 2256。目標區塊鏈節點 B 計算的目標難度為礦工節點 B 計算之 Difficulty 為 (1 - 15 / 30) * (1 / 3) * 2256 = 0.16 * 2256。In this optional embodiment, the node coordinates corresponding to the node computing power and the node reward can be determined; the target reward of the target blockchain node and the target of the target blockchain node can be determined. The target coordinates corresponding to the rewards; calculate the second distance between the node coordinates and the target coordinates; obtain a preset first distance, where the first distance is the The maximum distance; the difficulty of the target is determined according to the first distance, the second distance and the difficulty weight corresponding to the target cluster. For example: Suppose the node computing power is 28 and the node reward is 14, then the node coordinate is (28, 14). Target blockchain node A and target blockchain node B receive the broadcast block and verify that it is a valid block. Suppose the first distance is 30. The second distance between the target blockchain node A and the node coordinates is 15, and the difficulty weight corresponding to the target cluster to which it belongs is 1. The distance between the target blockchain node B and the node coordinates is 15, the difficulty weight corresponding to the target cluster is 1/3, and the total number of clusters is 3. The target difficulty calculated by the target blockchain node A is (1 - 15 / 30) * (1 / 1) * 2256 = 0.5 * 2256. The target difficulty calculated by the target blockchain node B is (1 - 15 / 30) * (1 / 3) * 2256 = 0.16 * 2256.
步驟S15、根據所述目標難度進行區塊運算,並在所述區塊運算完成後產生一個區塊。Step S15, perform block operation according to the target difficulty, and generate a block after the block operation is completed.
本申請實施例中,所有的區塊鏈節點都會同時處理一個運算任務,所述區塊運算可以是指所述運算任務,當一個區塊鏈節點完成運算任務時,會產生一個區塊,可以將該區塊添加至區塊鏈中,並進行打包(可以將該區塊鏈節點的算力以及獎勵資訊打包進區塊中),然後將打包好的區塊廣播至其他的區塊鏈節點中,其他區塊鏈節點接收到廣播的區塊後,開始進行下一個運算任務。In the embodiment of the present application, all blockchain nodes will simultaneously process an operation task, and the block operation may refer to the operation task. When a blockchain node completes the operation task, a block will be generated, which can be Add the block to the blockchain and package it (the computing power and reward information of the blockchain node can be packaged into the block), and then broadcast the packaged block to other blockchain nodes , other blockchain nodes begin to perform the next computing task after receiving the broadcasted block.
在圖1所描述的方法流程中,能夠根據區塊鏈節點的算力(運算能力)以及獎勵進行計算難度調整,確保算力低的區塊鏈節點也能夠完成運算以及獲得獎勵,提高了區塊鏈的去中心化。In the method process described in Figure 1, the calculation difficulty can be adjusted according to the computing power (computing power) and rewards of the blockchain nodes, so as to ensure that the blockchain nodes with low computing power can also complete the computation and obtain rewards, which improves the area of Decentralization of the blockchain.
請參見圖2,圖2是本申請公開的一種區塊運算裝置的較佳實施例的功能模組圖。Please refer to FIG. 2 , which is a functional module diagram of a preferred embodiment of a block computing device disclosed in the present application.
在一些實施例中,所述區塊運算裝置運行於電腦裝置中。所述區塊運算裝置可以包括多個由程式碼段所組成的功能模組。所述區塊運算裝置中的各個程式段的程式碼可以儲存於儲存器中,並由至少一個處理器所執行,以執行圖1所描述的區塊運算方法中的部分或全部步驟。In some embodiments, the block computing device runs on a computer device. The block computing device may include a plurality of functional modules composed of program code segments. The code of each program segment in the block operation device may be stored in a memory and executed by at least one processor to perform some or all of the steps in the block operation method described in FIG. 1 .
本實施例中,所述區塊運算裝置根據其所執行的功能,可以被劃分為多個功能模組。所述功能模組可以包括:聚類模組201、確定模組202、及運算模組203。本申請所稱的模組是指一種能夠被至少一個處理器所執行並且能夠完成固定功能的一系列電腦程式段,其儲存在儲存器中。In this embodiment, the block computing device can be divided into a plurality of functional modules according to the functions performed by the block computing device. The functional modules may include: a
聚類模組201,用於根據每個區塊鏈節點的算力以及獎勵,對多個區塊鏈節點進行均值聚類,獲得多個集群。The
其中,所述算力(也稱雜湊率)是比特幣網路處理能力的度量單位。即為電腦(CPU)計算雜湊函數輸出的速度。比特幣網路必須為了安全目的而進行密集的數學和加密相關操作。 例如,當網路達到10Th/s的雜湊率時,意味著它可以每秒進行10萬億次計算。所述算力可以是區塊鏈節點的資料運算能力;所述獎勵是指區塊鏈節點完成運算任務時根據預設的獎勵機制獲得的獎勵。Among them, the computing power (also called hash rate) is a unit of measurement of the processing power of the Bitcoin network. That is, the speed at which the computer (CPU) calculates the output of the hash function. The Bitcoin network must perform intensive mathematical and cryptographic related operations for security purposes. For example, when the network reaches a hash rate of 10Th/s, it means it can perform 10 trillion calculations per second. The computing power may be the data computing ability of the blockchain node; the reward refers to the reward obtained by the blockchain node according to the preset reward mechanism when the computing task is completed.
其中,所述均值聚類可以是指k均值聚類演算法(k-means clustering algorithm),是一種反覆運算求解的聚類分析演算法,包括:預先將資料分為K組,則隨機選取K個物件作為初始的聚類中心,然後計算每個物件與各個種子聚類中心之間的距離,把每個物件分配給距離它最近的聚類中心。聚類中心以及分配給它們的物件就代表一個聚類。每分配一個樣本,聚類的聚類中心會根據聚類中現有的物件被重新計算。這個過程將不斷重複直到滿足某個終止條件。終止條件可以是沒有(或最小數目)聚類中心再發生變化。Wherein, the mean clustering may refer to a k-means clustering algorithm, which is a clustering analysis algorithm for repeated operation and solution, including: dividing the data into K groups in advance, then randomly selecting K Each object is used as the initial cluster center, and then the distance between each object and each seed cluster center is calculated, and each object is assigned to the cluster center closest to it. Cluster centers and the objects assigned to them represent a cluster. Each time a sample is assigned, the cluster center of the cluster is recalculated based on the existing objects in the cluster. This process will repeat until a certain termination condition is met. The termination condition can be that no (or the minimum number) of cluster centers change again.
其中,一個集群可以包括多個區塊鏈節點,一個區塊鏈節點只能屬於一個集群。Among them, a cluster can include multiple blockchain nodes, and a blockchain node can only belong to one cluster.
確定模組202,用於當目標區塊鏈節點接收到廣播區塊時,確定所述廣播區塊所攜帶的節點算力以及節點獎勵。The
其中,所述廣播區塊可以是某個區塊鏈節點完成計算任務後打包的區塊,打包的區塊會廣播至其它區塊鏈節點中。The broadcast block may be a block packaged by a certain blockchain node after completing the computing task, and the packaged block will be broadcast to other blockchain nodes.
其中,所述廣播區塊攜帶有打包所述廣播區塊的區塊鏈節點的算力資訊以及獎勵資訊。Wherein, the broadcast block carries the computing power information and reward information of the blockchain nodes that package the broadcast block.
所述確定模組202,還用於從所述多個集群中,確定目標區塊鏈節點所屬的目標集群,並確定所述目標集群對應的目標難度權重。The determining
其中,不同的集群具有不同的難度權重。一個集群包括至少一個區塊鏈節點,一個區塊鏈節點只屬於一個集群。Among them, different clusters have different difficulty weights. A cluster includes at least one blockchain node, and a blockchain node belongs to only one cluster.
所述確定模組202,還用於根據所述節點算力、所述節點獎勵、所述目標區塊鏈節點的目標算力、所述目標區塊鏈節點的目標獎勵以及所述目標難度權重,確定所述目標區塊鏈節點的目標難度。The determining
其中,所述難度Difficulty,可以用來控制區塊的平均產生時間,Difficulty 值越高時,區塊鏈節點越不容易完成運算。相反地,當 Difficulty 值越低時,區塊鏈節點越容易完成運算。Among them, the difficulty Difficulty can be used to control the average generation time of blocks. The higher the Difficulty value is, the more difficult it is for the blockchain nodes to complete the operation. Conversely, when the Difficulty value is lower, it is easier for the blockchain node to complete the operation.
運算模組203,用於根據所述目標難度進行區塊運算,並在所述區塊運算完成後產生一個區塊。The
本申請實施例中,所有的區塊鏈節點都會同時處理一個運算任務,所述區塊運算可以是指所述運算任務,當一個區塊鏈節點完成運算任務時,會產生一個區塊,可以將該區塊添加至區塊鏈中,並進行打包(可以將該區塊鏈節點的算力以及獎勵資訊打包進區塊中),然後將打包好的區塊廣播至其他的區塊鏈節點中,其他區塊鏈節點接收到廣播的區塊後,開始進行下一個運算任務。In the embodiment of the present application, all blockchain nodes will simultaneously process an operation task, and the block operation may refer to the operation task. When a blockchain node completes the operation task, a block will be generated, which can be Add the block to the blockchain and package it (the computing power and reward information of the blockchain node can be packaged into the block), and then broadcast the packaged block to other blockchain nodes , other blockchain nodes begin to perform the next computing task after receiving the broadcasted block.
作為一種可選的實施方式,所述區塊運算裝置還可以包括:As an optional implementation manner, the block computing device may further include:
獲取模組,用於所述聚類模組201根據每個區塊鏈節點的算力以及獎勵,對多個區塊鏈節點進行均值聚類,獲得多個集群之前,獲取每個所述區塊鏈節點的算力以及獎勵;The acquisition module is used for the
映射模組,用於根據每個所述區塊鏈節點的算力以及獎勵,將每個所述區塊鏈節點映射至平面直角座標系中,獲得每個所述區塊鏈節點對應的座標,其中,區塊鏈節點的算力為橫座標,區塊鏈的獎勵為縱座標。The mapping module is used to map each of the blockchain nodes to a plane rectangular coordinate system according to the computing power and rewards of each of the blockchain nodes, and obtain the coordinates corresponding to each of the blockchain nodes , where the computing power of the blockchain node is the abscissa, and the reward of the blockchain is the ordinate.
其中,所述多個區塊鏈節點與多個座標一一對應,區塊鏈節點的算力為橫座標,區塊鏈的獎勵為縱座標。比如,假設區塊鏈節點量化後的算力為10,量化後的獎勵為15,則區塊鏈節點對應的座標為(10,15)。The multiple blockchain nodes correspond to multiple coordinates one-to-one, the computing power of the blockchain nodes is the abscissa, and the reward of the blockchain is the ordinate. For example, assuming that the quantized computing power of the blockchain node is 10, and the quantized reward is 15, the coordinates corresponding to the blockchain node are (10, 15).
作為一種可選的實施方式,所述確定模組202根據所述節點算力、所述節點獎勵、所述目標區塊鏈節點的目標算力、所述目標區塊鏈節點的目標獎勵以及所述目標難度權重,確定所述目標區塊鏈節點的目標難度的方式具體為:As an optional implementation manner, the
確定與所述節點算力以及所述節點獎勵均對應的節點座標;Determine the node coordinates corresponding to the node computing power and the node reward;
確定與所述目標區塊鏈節點的目標獎勵以及所述目標區塊鏈節點的目標獎勵均對應的目標座標;Determine the target coordinates corresponding to the target reward of the target blockchain node and the target reward of the target blockchain node;
計算所述節點座標與所述目標座標之間的第二距離;calculating a second distance between the node coordinates and the target coordinates;
獲取預設的第一距離,其中,所述第一距離為所述多個區塊鏈節點中的最大的距離;obtaining a preset first distance, where the first distance is the largest distance among the plurality of blockchain nodes;
根據所述第一距離、所述第二距離以及所述目標集群對應的難度權重,確定所述目標難度。The target difficulty is determined according to the first distance, the second distance, and the difficulty weight corresponding to the target cluster.
在該可選的實施方式中,可以確定與所述節點算力以及所述節點獎勵均對應的節點座標;確定與所述目標區塊鏈節點的目標獎勵以及所述目標區塊鏈節點的目標獎勵均對應的目標座標;計算所述節點座標與所述目標座標之間的第二距離;獲取預設的第一距離,其中,所述第一距離為所述多個區塊鏈節點中的最大的距離;根據所述第一距離、所述第二距離以及所述目標集群對應的難度權重,確定所述目標難度。比如:假設節點算力為 28,節點獎勵為 14,則節點座標為(28,14)。目標區塊鏈節點A及目標區塊鏈節點B接收到廣播的區塊,並驗證其為有效區塊。假設第一距離為 30。目標區塊鏈節點 A與節點座標之間的第二距離為 15,所屬的目標集群對應的難度權重為1。目標區塊鏈節點B與節點座標的距離為 15,所述的目標集群對應的難度權重為1/3,集群總數為3。目標區塊鏈節點 A 計算的目標難度為 (1 - 15 / 30) * (1 / 1) * 2256 = 0.5 * 2256。目標區塊鏈節點 B 計算的目標難度為礦工節點 B 計算之 Difficulty 為 (1 - 15 / 30) * (1 / 3) * 2256 = 0.16 * 2256。In this optional embodiment, the node coordinates corresponding to the node computing power and the node reward can be determined; the target reward of the target blockchain node and the target of the target blockchain node can be determined. The target coordinates corresponding to the rewards; calculate the second distance between the node coordinates and the target coordinates; obtain a preset first distance, where the first distance is the The maximum distance; the difficulty of the target is determined according to the first distance, the second distance and the difficulty weight corresponding to the target cluster. For example: Suppose the node computing power is 28 and the node reward is 14, then the node coordinate is (28, 14). Target blockchain node A and target blockchain node B receive the broadcast block and verify that it is a valid block. Suppose the first distance is 30. The second distance between the target blockchain node A and the node coordinates is 15, and the difficulty weight corresponding to the target cluster to which it belongs is 1. The distance between the target blockchain node B and the node coordinates is 15, the difficulty weight corresponding to the target cluster is 1/3, and the total number of clusters is 3. The target difficulty calculated by the target blockchain node A is (1 - 15 / 30) * (1 / 1) * 2256 = 0.5 * 2256. The target difficulty calculated by the target blockchain node B is (1 - 15 / 30) * (1 / 3) * 2256 = 0.16 * 2256.
作為一種可選的實施方式,所述確定模組201,還用於所述聚類模組201根據每個區塊鏈節點的算力以及獎勵,對多個區塊鏈節點進行均值聚類,獲得多個集群之前,從所述多個區塊鏈節點中,確定與所述平面直角座標系的原點的原點距離最小的最小節點,以及確定與所述原點的原點距離最大的最大節點;As an optional implementation manner, the determining
所述區塊運算裝置還可以包括:The block computing device may further include:
第一計算模組,用於確定所述最小節點的原點距離與所述最大節點的原點距離的距離差值;a first calculation module for determining the distance difference between the origin distance of the smallest node and the origin distance of the largest node;
所述確定模組202,還用於將所述距離差值確定為預設的所述第一距離。The determining
在該可選的實施方式中,從所述多個區塊鏈節點中,確定與所述平面直角座標系的原點的原點距離最小的最小節點,以及確定與所述原點的原點距離最大的最大節點;確定所述最小節點的原點距離與所述最大節點的原點距離的距離差值;將所述距離差值確定為預設的所述第一距離。假設所述最小節點的座標為(1,0),對應的原點距離為1,所述最大節點的座標為 (10,0)對應的原點距離為10,則所述第一距離為9。In this optional embodiment, from the plurality of blockchain nodes, the smallest node with the smallest distance from the origin of the origin of the plane rectangular coordinate system is determined, and the origin of the origin is determined the largest node with the largest distance; determine the distance difference between the origin distance of the smallest node and the origin distance of the largest node; and determine the distance difference as the preset first distance. Assuming that the coordinate of the smallest node is (1, 0), the corresponding origin distance is 1, the coordinate of the largest node is (10, 0) and the corresponding origin distance is 10, then the first distance is 9 .
作為一種可選的實施方式,所述聚類模組201根據每個區塊鏈節點的算力以及獎勵,對多個區塊鏈節點進行均值聚類,獲得多個集群的方式具體為:As an optional implementation manner, the
根據每個區塊鏈節點的算力以及獎勵,確定每個所述區塊鏈節點對應的座標;Determine the coordinates corresponding to each of the blockchain nodes according to the computing power and rewards of each blockchain node;
從多個所述座標中確定初始中心點;determining an initial center point from a plurality of said coordinates;
根據所述初始中心點,對所述多個座標進行分組,獲得多個初始組群;According to the initial center point, the plurality of coordinates are grouped to obtain a plurality of initial groups;
重新計算所述多個初始組群的中心,獲得第一中心點;recalculating the centers of the plurality of initial groups to obtain a first center point;
若所述第一中心點與所述初始中心點一致,確定均值聚類完成,將所述多個初始組群確定為所述多個集群。If the first center point is consistent with the initial center point, it is determined that mean clustering is completed, and the multiple initial groups are determined as the multiple clusters.
在該可選的實施方式中,可以根據每個區塊鏈節點的算力以及獎勵,確定每個所述區塊鏈節點對應的座標,比如(10,10)、(10,15)、(15,10)等座標。一個區塊鏈節點對應一個座標。從多個所述座標中確定初始中心點,比如(5,5)、(10,10);根據所述初始中心點,對所述多個座標進行分組,即將每個座標分配給距離最近的初始中心點,獲得多個初始組群,每個初始族群包括最少一個座標;重新計算所述多個初始組群的中心,獲得第一中心點;若所述第一中心點與所述初始中心點一致,確定均值聚類完成,將所述多個初始組群確定為所述多個集群。In this optional embodiment, the coordinates corresponding to each of the blockchain nodes can be determined according to the computing power and rewards of each blockchain node, such as (10, 10), (10, 15), ( 15, 10) and other coordinates. A blockchain node corresponds to a coordinate. Determine an initial center point from a plurality of the coordinates, such as (5, 5), (10, 10); according to the initial center point, group the plurality of coordinates, that is, assign each coordinate to the closest distance Initial center point, obtain multiple initial groups, each initial group includes at least one coordinate; recalculate the centers of the multiple initial groups to obtain the first center point; if the first center point and the initial center If the points are consistent, it is determined that the mean clustering is completed, and the multiple initial groups are determined as the multiple clusters.
作為一種可選的實施方式,所述區塊運算裝置還可以包括:As an optional implementation manner, the block computing device may further include:
分組模組,用於若所述第一中心點與所述初始中心點不一致,根據所述第一中心點,對多個所述座標重新進行分組,獲得多個第一組群;a grouping module, configured to regroup a plurality of the coordinates according to the first center point to obtain a plurality of first groups if the first center point is inconsistent with the initial center point;
第二計算模組,用於計算所述多個第一組群的中心,獲得第二中心點;a second calculation module, configured to calculate the centers of the plurality of first groups to obtain a second center point;
所述確定模組202,還用於若所述第二中心點與所述第一中心點一致,確定均值聚類完成,將所述多個第一組群確定為所述多個集群。The determining
在該可選的實施方式中,若所述第一中心點與所述初始中心點不一致,確定均值聚類未完成,根據所述第一中心點,對多個所述座標重新進行分組,獲得多個第一組群;計算所述多個第一組群的中心,獲得第二中心點;若所述第二中心點與所述第一中心點一致,確定均值聚類完成,將所述多個第一組群確定為所述多個集群。In this optional embodiment, if the first center point is inconsistent with the initial center point, it is determined that the mean clustering is not completed, and according to the first center point, a plurality of the coordinates are re-grouped to obtain multiple first groups; calculate the centers of the multiple first groups to obtain a second center point; if the second center point is consistent with the first center point, it is determined that the mean clustering is completed, and the A plurality of first groups are determined as the plurality of clusters.
作為一種可選的實施方式,所述區塊運算方法還包括:As an optional implementation manner, the block operation method further includes:
所述確定模組202,還用於所述聚類模組201根據每個區塊鏈節點的算力以及獎勵,對多個區塊鏈節點進行均值聚類,獲得多個集群之後以及所述確定模組202當目標區塊鏈節點接收到廣播區塊時,確定所述廣播區塊所攜帶的節點算力以及節點獎勵之前,確定每個所述集群的中心座標;The
所述確定模組202,還用於確定所述中心座標與所述平面直角座標系的原點的第三距離;The determining
所述區塊運算裝置還可以包括:The block computing device may further include:
分配模組,用於根據所述第三距離,為每個所述集群分配對應的難度權重。an assignment module, configured to assign a corresponding difficulty weight to each of the clusters according to the third distance.
在該可選的實施方式中,確定每個所述集群的中心座標,然後確定所述中心座標與所述平面直角座標系的原點的第三距離,根據所述第三距離,為每個所述集群分配對應的難度權重。比如,存在3個集群,集群A的第三距離為1,集群B的第三距離為3,集群C的距離為5。則所述集群總數為3,集群A的第三距離小於集群B的第三距離,集群B的第三距離小於集群C的第三距離,則集群A對應的難度權重為1/3,則集群B對應的難度權重為2/3,則集群C對應的難度權重為3/3。In this optional implementation manner, the center coordinates of each of the clusters are determined, and then a third distance between the center coordinates and the origin of the plane rectangular coordinate system is determined, and according to the third distance, for each The clusters assign corresponding difficulty weights. For example, there are 3 clusters, the third distance of cluster A is 1, the third distance of cluster B is 3, and the distance of cluster C is 5. Then the total number of clusters is 3, the third distance of cluster A is less than the third distance of cluster B, and the third distance of cluster B is less than the third distance of cluster C, then the difficulty weight corresponding to cluster A is 1/3, then the cluster The difficulty weight corresponding to B is 2/3, and the difficulty weight corresponding to cluster C is 3/3.
在圖2所描述的區塊運算裝置中,能夠根據區塊鏈節點的算力(運算能力)以及獎勵進行計算難度調整,確保算力低的區塊鏈節點也能夠完成運算以及獲得獎勵,提高了區塊鏈的去中心化。In the block computing device described in Figure 2, the calculation difficulty can be adjusted according to the computing power (computing power) and rewards of the blockchain nodes, so as to ensure that the blockchain nodes with low computing power can also complete the computing and obtain rewards, and improve the decentralization of the blockchain.
如圖3所示,圖3是本申請實現區塊運算方法的較佳實施例的電腦裝置的結構示意圖。所述電腦裝置3包括儲存器31、至少一個處理器32、儲存在所述儲存器31中並可在所述至少一個處理器32上運行的電腦程式33及至少一條通訊匯流排34。As shown in FIG. 3 , FIG. 3 is a schematic structural diagram of a computer device implementing a preferred embodiment of the block operation method of the present application. The
本領域技術人員可以理解,圖3所示的示意圖僅僅是所述電腦裝置3的示例,並不構成對所述電腦裝置3的限定,可以包括比圖示更多或更少的部件,或者組合某些部件,或者不同的部件,例如所述電腦裝置3還可以包括輸入輸出設備、網路接入設備等。Those skilled in the art can understand that the schematic diagram shown in FIG. 3 is only an example of the
所述電腦裝置3還包括但不限於任何一種可與使用者透過鍵盤、滑鼠、遙控器、觸控板或聲控設備等方式進行人機交互的電子產品,例如,個人電腦、平板電腦、智慧手機、個人數位助理(Personal Digital Assistant,PDA)、遊戲機、互動式網路電視(Internet Protocol Television,IPTV)、智慧式穿戴式設備等。所述電腦裝置3所處的網路包括但不限於網際網路、廣域網路、都會區網路、局域網、虛擬私人網路(Virtual Private Network,VPN)等。The
所述至少一個處理器32可以是中央處理單元(Central Processing Unit,CPU),還可以是其他通用處理器、數位訊號處理器(Digital Signal Processor,DSP)、專用積體電路(Application Specific Integrated Circuit,ASIC)、現場可程式設計閘陣列(Field-Programmable Gate Array,FPGA)或者其他可程式設計邏輯器件、電晶體邏輯器件、分立硬體元件等。該處理器32可以是微處理器或者該處理器32也可以是任何常規的處理器等,所述處理器32是所述電腦裝置3的控制中心,利用各種介面和線路連接整個電腦裝置3的各個部分。The at least one
所述儲存器31可用於儲存所述電腦程式33和/或模組/單元,所述處理器32透過運行或執行儲存在所述儲存器31內的電腦程式和/或模組/單元,以及調用儲存在儲存器31內的資料,實現所述電腦裝置3的各種功能。所述儲存器31可主要包括儲存程式區和儲存資料區,其中,儲存程式區可儲存作業系統、至少一個功能所需的應用程式(比如聲音播放功能、圖像播放功能等)等;儲存資料區可儲存根據電腦裝置3的使用所創建的資料等。此外,儲存器31可以包括非易失性儲存器,例如硬碟、儲存器、插接式硬碟,智慧儲存卡(Smart Media Card,SMC),安全數位(Secure Digital,SD)卡,快閃儲存器卡(Flash Card)、至少一個磁碟儲存器件、快閃儲存器件等。The
結合圖1,所述電腦裝置3中的所述儲存器31儲存多個指令以實現一種區塊運算方法,所述處理器32可執行所述多個指令從而實現:1, the
根據每個區塊鏈節點的算力以及獎勵,對多個區塊鏈節點進行均值聚類,獲得多個集群;According to the computing power and rewards of each blockchain node, perform mean clustering on multiple blockchain nodes to obtain multiple clusters;
當目標區塊鏈節點接收到廣播區塊時,確定所述廣播區塊所攜帶的節點算力以及節點獎勵;When the target blockchain node receives the broadcast block, determine the node computing power and node reward carried by the broadcast block;
根據所述節點算力、所述節點獎勵、所述目標區塊鏈節點的目標算力、所述目標區塊鏈節點的目標獎勵以及所述目標難度權重,確定所述目標區塊鏈節點的目標難度;According to the node computing power, the node reward, the target computing power of the target blockchain node, the target reward of the target blockchain node, and the target difficulty weight, determine the target blockchain node's target difficulty;
根據所述目標難度進行區塊運算,並在所述區塊運算完成後產生一個區塊。A block operation is performed according to the target difficulty, and a block is generated after the block operation is completed.
作為一種可選的實施方式,所述根據每個區塊鏈節點的算力以及獎勵,對多個區塊鏈節點進行均值聚類,獲得多個集群之前,所述區塊運算方法還包括:As an optional implementation manner, performing mean clustering on multiple blockchain nodes according to the computing power and rewards of each blockchain node, and before obtaining multiple clusters, the block computing method further includes:
獲取每個所述區塊鏈節點的算力以及獎勵;Obtain the computing power and rewards of each of the blockchain nodes;
根據每個所述區塊鏈節點的算力以及獎勵,將每個所述區塊鏈節點映射至平面直角座標系中,獲得每個所述區塊鏈節點對應的座標,其中,區塊鏈節點的算力為橫座標,區塊鏈的獎勵為縱座標。According to the computing power and rewards of each of the blockchain nodes, map each of the blockchain nodes to a plane rectangular coordinate system, and obtain the coordinates corresponding to each of the blockchain nodes, wherein the blockchain The computing power of the node is the abscissa, and the reward of the blockchain is the ordinate.
作為一種可選的實施方式,所述根據所述節點算力、所述節點獎勵、所述目標區塊鏈節點的目標算力、所述目標區塊鏈節點的目標獎勵以及所述目標難度權重,確定所述目標區塊鏈節點的目標難度包括:As an optional implementation manner, according to the node computing power, the node reward, the target computing power of the target blockchain node, the target reward of the target blockchain node, and the target difficulty weight , and determining the target difficulty of the target blockchain node includes:
確定與所述節點算力以及所述節點獎勵均對應的節點座標;Determine the node coordinates corresponding to the node computing power and the node reward;
確定與所述目標區塊鏈節點的目標獎勵以及所述目標區塊鏈節點的目標獎勵均對應的目標座標;Determine the target coordinates corresponding to the target reward of the target blockchain node and the target reward of the target blockchain node;
計算所述節點座標與所述目標座標之間的第二距離;calculating a second distance between the node coordinates and the target coordinates;
獲取預設的第一距離,其中,所述第一距離為所述多個區塊鏈節點中的最大的距離;obtaining a preset first distance, where the first distance is the largest distance among the plurality of blockchain nodes;
根據所述第一距離、所述第二距離以及所述目標集群對應的難度權重,確定所述目標難度。The target difficulty is determined according to the first distance, the second distance, and the difficulty weight corresponding to the target cluster.
作為一種可選的實施方式,所述根據每個區塊鏈節點的算力以及獎勵,對多個區塊鏈節點進行均值聚類,獲得多個集群之前,所述處理器32可執行所述多個指令從而實現:As an optional implementation manner, performing mean clustering on multiple blockchain nodes according to the computing power and rewards of each blockchain node, and before obtaining multiple clusters, the
從所述多個區塊鏈節點中,確定與所述平面直角座標系的原點的原點距離最小的最小節點,以及確定與所述原點的原點距離最大的最大節點;From the plurality of blockchain nodes, determine the smallest node with the smallest distance from the origin of the plane rectangular coordinate system, and determine the largest node with the largest distance from the origin of the origin;
確定所述最小節點的原點距離與所述最大節點的原點距離的距離差值;determining the distance difference between the origin distance of the smallest node and the origin distance of the largest node;
將所述距離差值確定為預設的所述第一距離。The distance difference value is determined as the preset first distance.
作為一種可選的實施方式,所述根據每個區塊鏈節點的算力以及獎勵,對多個區塊鏈節點進行均值聚類,獲得多個集群之後以及所述當目標區塊鏈節點接收到廣播區塊時,確定所述廣播區塊所攜帶的節點算力以及節點獎勵之前,所述處理器32可執行所述多個指令從而實現:As an optional implementation manner, according to the computing power and rewards of each blockchain node, perform mean clustering on multiple blockchain nodes, and after obtaining multiple clusters, and when the target blockchain node receives When a block is broadcast, before determining the node computing power and node reward carried by the broadcast block, the
確定每個所述集群的中心座標;determining the coordinates of the center of each of said clusters;
確定所述中心座標與所述平面直角座標系的原點的第三距離;determining the third distance between the center coordinate and the origin of the plane rectangular coordinate system;
根據所述第三距離,為每個所述集群分配對應的難度權重。A corresponding difficulty weight is assigned to each of the clusters according to the third distance.
作為一種可選的實施方式,所述根據每個區塊鏈節點的算力以及獎勵,對多個區塊鏈節點進行均值聚類,獲得多個集群包括:As an optional implementation manner, performing mean clustering on multiple blockchain nodes according to the computing power and rewards of each blockchain node, and obtaining multiple clusters includes:
根據每個區塊鏈節點的算力以及獎勵,確定每個所述區塊鏈節點對應的座標;Determine the coordinates corresponding to each of the blockchain nodes according to the computing power and rewards of each blockchain node;
從多個所述座標中確定初始中心點;determining an initial center point from a plurality of said coordinates;
根據所述初始中心點,對所述多個座標進行分組,獲得多個初始組群;According to the initial center point, the plurality of coordinates are grouped to obtain a plurality of initial groups;
重新計算所述多個初始組群的中心,獲得第一中心點;recalculating the centers of the plurality of initial groups to obtain a first center point;
若所述第一中心點與所述初始中心點一致,確定均值聚類完成,將所述多個初始組群確定為所述多個集群。If the first center point is consistent with the initial center point, it is determined that mean clustering is completed, and the multiple initial groups are determined as the multiple clusters.
作為一種可選的實施方式,所述處理器32可執行所述多個指令從而實現:As an optional implementation manner, the
若所述第一中心點與所述初始中心點不一致,根據所述第一中心點,對多個所述座標重新進行分組,獲得多個第一組群;If the first center point is inconsistent with the initial center point, regroup a plurality of the coordinates according to the first center point to obtain a plurality of first groups;
計算所述多個第一組群的中心,獲得第二中心點;calculating the centers of the plurality of first groups to obtain a second center point;
若所述第二中心點與所述第一中心點一致,確定均值聚類完成,將所述多個第一組群確定為所述多個集群。If the second center point is consistent with the first center point, it is determined that mean clustering is completed, and the plurality of first groups are determined as the plurality of clusters.
具體地,所述處理器32對上述指令的具體實現方法可參考圖1對應實施例中相關步驟的描述,在此不贅述。Specifically, for the specific implementation method of the above-mentioned instruction by the
在圖3所描述的電腦裝置3中,能夠根據區塊鏈節點的算力(運算能力)以及獎勵進行計算難度調整,確保算力低的區塊鏈節點也能夠完成運算以及獲得獎勵,提高了區塊鏈的去中心化。In the
所述電腦裝置3集成的模組/單元如果以軟體功能單元的形式實現並作為獨立的產品銷售或使用時,可以儲存在一個電腦可讀取儲存介質中。基於這樣的理解,本申請實現上述實施例方法中的全部或部分流程,也可以透過電腦程式來指令相關的硬體來完成,所述的電腦程式可儲存於一電腦可讀儲存介質中,該電腦程式在被處理器執行時,可實現上述各個方法實施例的步驟。其中,所述電腦程式代碼可以為原始程式碼形式、物件代碼形式、可執行檔或某些中間形式等。所述電腦可讀介質可以包括:能夠攜帶所述電腦程式代碼的任何實體或裝置、記錄介質、隨身碟、移動硬碟、磁碟、光碟、電腦儲存器、唯讀儲存器(ROM,Read-Only Memory)。If the modules/units integrated in the
在本申請所提供的幾個實施例中,應該理解到,所揭露的系統,裝置和方法,可以透過其它的方式實現。例如,以上所描述的裝置實施例僅僅是示意性的,例如,所述模組的劃分,僅僅為一種邏輯功能劃分,實際實現時可以有另外的劃分方式。In the several embodiments provided in this application, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. For example, the device embodiments described above 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.
所述作為分離部件說明的模組可以是或者也可以不是物理上分開的,作為模組顯示的部件可以是或者也可以不是物理單元,即可以位於一個地方,或者也可以分佈到多個網路單元上。可以根據實際的需要選擇其中的部分或者全部模組來實現本實施例方案的目的。The modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical units, that is, they can be located in one place or distributed to multiple networks. on the unit. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
另外,在本申請各個實施例中的各功能模組可以集成在一個處理單元中,也可以是各個單元單獨物理存在,也可以兩個或兩個以上單元集成在一個單元中。上述集成的單元既可以採用硬體的形式實現,也可以採用硬體加軟體功能模組的形式實現。In addition, each functional module in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit. The above-mentioned integrated units 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 application is not limited to the details of the above-described exemplary embodiments, but that the present application may be implemented in other specific forms without departing from the spirit or essential characteristics of the present application. Accordingly, the embodiments are to be regarded in all respects as illustrative and not restrictive, and the scope of this application is defined by the appended claims rather than the foregoing description, and is therefore intended to fall within the scope of the claims. All changes within the meaning and scope of the equivalents of , are included in this application. Any associated icon indicia in a claim should not be considered to limit the claim to which it relates. Furthermore, it is clear that the word "comprising" does not exclude other units or steps and the singular does not exclude the plural. A plurality of units or devices stated in this application may also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to denote names and do not denote any particular order.
最後應說明的是,以上實施例僅用以說明本申請的技術方案而非限制,儘管參照較佳實施例對本申請進行了詳細說明,本領域的普通技術人員應當理解,可以對本申請的技術方案進行修改或等同替換,而不脫離本申請技術方案的精神和範圍。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application and not to limit them. Although the present application has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the present application can be Modifications or equivalent substitutions can be made without departing from the spirit and scope of the technical solutions of the present application.
2:區塊運算裝置 201:聚類模組 202:確定模組 203:運算模組 3:電腦裝置 31:儲存器 32:處理器 33:電腦程式 34:通訊匯流排 2: block computing device 201: Clustering Module 202: Determine the module 203: Operation Module 3: Computer device 31: Storage 32: Processor 33: Computer Programs 34: Communication bus
圖1是本申請公開的一種區塊運算方法的較佳實施例的流程圖。 圖2是本申請公開的一種區塊運算裝置的較佳實施例的功能模組圖。 圖3是本申請實現區塊運算方法的較佳實施例的電腦裝置的結構示意圖。 FIG. 1 is a flowchart of a preferred embodiment of a block operation method disclosed in the present application. FIG. 2 is a functional module diagram of a preferred embodiment of a block computing device disclosed in the present application. FIG. 3 is a schematic structural diagram of a computer device according to a preferred embodiment of the block operation method of the present application.
無。none.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
TW109145366A TWI764456B (en) | 2020-12-21 | 2020-12-21 | Method and device for block operation, computer device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
TW109145366A TWI764456B (en) | 2020-12-21 | 2020-12-21 | Method and device for block operation, computer device and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
TWI764456B TWI764456B (en) | 2022-05-11 |
TW202226126A true TW202226126A (en) | 2022-07-01 |
Family
ID=82594100
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
TW109145366A TWI764456B (en) | 2020-12-21 | 2020-12-21 | Method and device for block operation, computer device and storage medium |
Country Status (1)
Country | Link |
---|---|
TW (1) | TWI764456B (en) |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8542763B2 (en) * | 2004-04-02 | 2013-09-24 | Rearden, Llc | Systems and methods to coordinate transmissions in distributed wireless systems via user clustering |
TWI677213B (en) * | 2017-11-23 | 2019-11-11 | 財團法人資訊工業策進會 | Monitor apparatus, method, and computer program product thereof |
CN110287268A (en) * | 2019-06-30 | 2019-09-27 | 智慧谷(厦门)物联科技有限公司 | A kind of digital asset processing method and system based on block chain |
CN111324453B (en) * | 2020-01-23 | 2023-01-03 | 天津大学 | Method for block chain platform resource scheduling |
-
2020
- 2020-12-21 TW TW109145366A patent/TWI764456B/en active
Also Published As
Publication number | Publication date |
---|---|
TWI764456B (en) | 2022-05-11 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP7308003B2 (en) | Decentralized distributed deep learning | |
JP6381170B2 (en) | Efficient determination of joint paths via radix estimation | |
TWI731543B (en) | Computer data processing method and device | |
US9940102B2 (en) | Partial stochastic rounding that includes sticky and guard bits | |
US20190087723A1 (en) | Variable isa vector-based compaction in distributed training of neural networks | |
WO2020233709A1 (en) | Model compression method, and device | |
CN111897818A (en) | Data storage method and device, electronic equipment and storage medium | |
CN113449861A (en) | Speculative training using partial gradient update | |
US11023825B2 (en) | Platform as a service cloud server and machine learning data processing method thereof | |
CN109697083B (en) | Fixed-point acceleration method and device for data, electronic equipment and storage medium | |
CN109412865B (en) | Virtual network resource allocation method, system and electronic equipment | |
TWI764456B (en) | Method and device for block operation, computer device and storage medium | |
WO2021253346A1 (en) | Data transmission computation method and apparatus, and storage medium | |
CN112015552A (en) | Hash ring load balancing method and device, electronic equipment and storage medium | |
CN114726851B (en) | Block operation method, device, electronic equipment and storage medium | |
CN115865607A (en) | Distributed training computing node management method and related device | |
TWI769661B (en) | Method and device for detecting image abnormities, computer device and storage medium | |
CN104657087A (en) | Virtual disk mapping method, device and system | |
CN114666327B (en) | Block packing method and device based on block chain transaction and electronic equipment | |
TW202315360A (en) | Microservice allocation method, electronic equipment, and storage medium | |
CN110199255B (en) | Combining execution units to compute a single wide scalar result | |
US11811862B1 (en) | System and method for management of workload distribution | |
US10740213B1 (en) | Counter overflow management for asynchronous data mover facility | |
US10630957B2 (en) | Scalable distributed computation framework for data-intensive computer vision workloads | |
CN115511936A (en) | Virtual model adjusting method and device, storage medium and electronic device |