CN115374216A - Construction method and device of consensus scheme, terminal equipment and computer medium - Google Patents

Construction method and device of consensus scheme, terminal equipment and computer medium Download PDF

Info

Publication number
CN115374216A
CN115374216A CN202210957995.5A CN202210957995A CN115374216A CN 115374216 A CN115374216 A CN 115374216A CN 202210957995 A CN202210957995 A CN 202210957995A CN 115374216 A CN115374216 A CN 115374216A
Authority
CN
China
Prior art keywords
node
target
initial
authoritative
consensus
Prior art date
Legal status (The legal status 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 status listed.)
Granted
Application number
CN202210957995.5A
Other languages
Chinese (zh)
Other versions
CN115374216B (en
Inventor
陈涛涛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Woxiang Technology Co ltd
Original Assignee
Shenzhen Woxiang Technology Co ltd
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 Shenzhen Woxiang Technology Co ltd filed Critical Shenzhen Woxiang Technology Co ltd
Priority to CN202210957995.5A priority Critical patent/CN115374216B/en
Publication of CN115374216A publication Critical patent/CN115374216A/en
Application granted granted Critical
Publication of CN115374216B publication Critical patent/CN115374216B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange

Abstract

The invention discloses a construction method and a device of a consensus scheme, a terminal device and a computer medium, which relate to the technical field of block chains and comprise the following steps: determining each target candidate node in the initial block chain based on the node reputation value corresponding to each node in the initial block chain and a preset reputation value threshold; randomly determining each initial authoritative node in each target candidate node, and setting the weight value of each initial authoritative node as a preset first weight value; randomly determining each initial non-authoritative node in each non-target candidate node except each target candidate node, and setting the weight value of each initial non-authoritative node as a preset second weight value; and inputting each initial authoritative node, each initial non-authoritative node and each second weight value into a preset target consensus function to construct a target consensus scheme. The invention achieves the technical effects that the target consensus scheme can realize decentralization, and the scheme is safer and can be applied to a public block chain.

Description

Construction method and device of consensus scheme, terminal equipment and computer medium
Technical Field
The present invention relates to the field of block chain technologies, and in particular, to a method and an apparatus for constructing a consensus scheme, a terminal device, and a computer-readable storage medium.
Background
With the development of the blockchain technology, in order to enable nodes in the blockchain to be in a trusted state with each other, a consensus algorithm based on different reference factors becomes an essential component in the blockchain.
The consensus algorithm adopted in the block chain at present mainly includes a POW (Proof of Work-Proof) consensus algorithm, a POS (Proof of stamp-right Proof) consensus algorithm, and a POA (Proof of-authority-Proof) consensus algorithm, wherein the POA consensus algorithm mainly determines a verification node in the block chain according to an identity value or a personal reputation corresponding to each node in the block chain, and the verification node acquires an authority to account each transaction in the block chain, so that nodes participating in verification in the block chain based on the POA consensus algorithm are always kept in a small number of nodes, and once the small number of authority nodes generate a malignant operation, the consensus scheme in the whole block chain is broken.
Disclosure of Invention
Embodiments of the present invention provide a method and an apparatus for constructing a consensus scheme, a terminal device, and a computer-readable storage medium, so that a target consensus scheme that is constructed can be decentralized, and the scheme itself is safer and can be applied to a public block chain.
The invention provides a construction method of a consensus scheme, which comprises the following steps:
determining each target candidate node in the initial block chain based on a node reputation value corresponding to each node in the initial block chain and a preset reputation value threshold;
randomly determining each initial authoritative node in each target candidate node, and setting the weight value of each initial authoritative node as a preset first weight value;
randomly determining each initial non-authoritative node in each non-target candidate node except each target candidate node, and setting the weight value of each initial non-authoritative node as a preset second weight value;
and inputting each initial authoritative node, each first weight value, each initial non-authoritative node and each second weight value into a preset target consensus function to construct a target consensus scheme.
Further, the step of determining each target candidate node in the initial block chain based on the node reputation value corresponding to each node in the initial block chain and a preset reputation value threshold includes:
acquiring a node reputation value corresponding to each initial node in an initial block chain;
comparing each node reputation value with a preset reputation value threshold value respectively to determine each target reputation value which is greater than the reputation value threshold value in each node reputation value;
and determining the initial node corresponding to each target reputation value as a target candidate node.
Further, before the step of determining each target candidate node in the initial block chain based on the node reputation value corresponding to each node in the initial block chain and a preset reputation value threshold, the method further includes:
acquiring a preset authority certificate consensus algorithm;
and constructing an initial block chain based on the authority certification consensus algorithm.
Further, the step of inputting each initial authoritative node, the first weight value, each initial non-authoritative node and the second weight value into a preset target consensus function to construct a target consensus scheme includes:
inputting each initial authoritative node, the first weight value, each initial non-authoritative node and the second weight value into a preset target consensus function, combining each initial authoritative node and the first weight value by the target consensus function, and combining each initial non-authoritative node and the second weight value to construct a target consensus scheme.
Further, the method further comprises:
constructing a target block chain based on the target consensus scheme, and detecting the target block chain to determine whether transaction data is generated in the target block chain;
if yes, calculating the transaction data through all target authoritative nodes in the target block chain together to obtain all target calculation results, wherein the target authoritative nodes are selected by all the nodes of the target block chain on the basis of the target consensus scheme and have transaction verification authority;
and determining a transaction confirmation result corresponding to each target calculation result based on the target consensus scheme.
Further, prior to the step of determining a transaction confirmation result corresponding to each of the target calculation results based on the target consensus scheme, the method further comprises:
verifying each target calculation result to determine whether each target calculation result contains a target error calculation result;
and if the target error calculation result is contained in each target calculation result, backtracking the transaction data to the moment of generating the transaction data.
Further, the method further comprises:
acquiring a preset node refreshing frequency;
and controlling the target block chain to replace each target authoritative node according to the node refreshing frequency.
In addition, to achieve the above object, the present invention further provides an apparatus for constructing a consensus scheme, the apparatus comprising:
the node screening module is used for determining each target candidate node in the initial block chain based on a node reputation value corresponding to each node in the initial block chain and a preset reputation value threshold;
the first setting module is used for randomly determining each initial authoritative node in each target candidate node and setting the weight value of each initial authoritative node as a preset first weight value;
the second setting module is used for randomly determining each initial non-authoritative node in each non-target candidate node except each target candidate node, and setting the weight value of each initial non-authoritative node as a preset second weight value;
and the consensus construction module is used for inputting each initial authoritative node, the first weight value, each initial non-authoritative node and the second weight value into a preset target consensus function so as to construct a target consensus scheme.
In addition, to achieve the above object, the present invention also provides a terminal device, including: the system comprises a memory, a processor and a construction program of the consensus scheme, wherein the construction program of the consensus scheme is stored on the memory and can run on the processor, and when executed by the processor, the steps of the construction method of the consensus scheme are realized.
Further, to achieve the above object, the present invention also provides a computer-readable storage medium having stored thereon a construction program of a consensus scheme, which when executed by a processor, implements the steps of the construction method of the consensus scheme as described above.
In the method, the device, the terminal equipment and the computer-readable storage medium for constructing the identification scheme provided by the embodiment of the invention, each target candidate node is determined in the initial block chain based on the node reputation value corresponding to each node in the initial block chain and a preset reputation value threshold; randomly determining each initial authoritative node in each target candidate node, and setting the weight value of each initial authoritative node as a preset first weight value; randomly determining each initial non-authoritative node in each non-target candidate node except each target candidate node, and setting the weight value of each initial non-authoritative node as a preset second weight value; and inputting each initial authoritative node, the first weight value, each initial non-authoritative node and the second weight value into a preset target consensus function to construct a target consensus scheme.
In this embodiment, when the terminal device operates, the terminal device first reads the storage module to obtain a reputation value threshold value pre-stored by a developer, and at the same time, the terminal device reads node reputation values corresponding to initial nodes in an initial block chain, and determines target reputation values larger than the reputation value threshold value among the node reputation values, the terminal device determines the initial nodes corresponding to the target reputation values as target candidate nodes in the initial block chain, and then the terminal device randomly determines a preset number of initial authoritative nodes in the target candidate nodes, and at the same time, the terminal device sets the respective weight values of the initial non-authoritative nodes as first weight values according to the first weight values preset by the developer, and then randomly determines a preset number of initial non-authoritative nodes in the remaining non-candidate nodes, and sets the respective weight values of the initial non-authoritative nodes as second weight values according to the second weight values preset by the developer, and finally, the terminal device obtains the initial values, the first weight values, the second authoritative nodes, and the initial non-authoritative nodes and the target node reputation value built-initial non-authoritative nodes are based on a preset weight scheme.
Therefore, the invention adopts the technical effects that each initial authoritative node and each initial non-authoritative node are determined in each initial node in the initial block chain based on the reputation value, the corresponding first weight value and second weight value are respectively set for each initial authoritative node and each initial non-authoritative node, and finally the target consensus scheme is determined based on each initial authoritative node, the first weight value, each initial non-authoritative node and the second weight value, so that the established target consensus scheme can realize decentralization, and the scheme is safer and can be applied to the public block chain.
Drawings
Fig. 1 is a schematic structural diagram of a terminal device in a hardware operating environment according to an embodiment of the present invention;
FIG. 2 is a schematic flow chart of a first embodiment of a method for constructing the consensus sequence of the present invention;
FIG. 3 is a schematic flow chart of a second embodiment of the method for constructing the consensus sequence of the present invention;
FIG. 4 is a schematic diagram illustrating node screening according to a first embodiment of the method for constructing a consensus sequence of the present invention;
fig. 5 is a schematic diagram of functional modules involved in an embodiment of the method for constructing the consensus scheme of the present invention.
The implementation, functional features and advantages of the present invention will be further described with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Referring to fig. 1, fig. 1 is a schematic structural diagram of a terminal device in a hardware operating environment according to an embodiment of the present invention.
The terminal device in the embodiment of the present invention may be a Personal Computer (PC) and a mobile terminal device configured with a windows operating system, and of course, the terminal device may also be a mobile terminal device such as a mobile phone and a tablet, or a fixed terminal device such as a PC and a server configured with other operating systems.
As shown in fig. 1, the terminal device may include: a processor 1001, such as a Central Processing Unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a WIreless interface (e.g., a WIreless-FIdelity (WI-FI) interface). The Memory 1005 may be a Random Access Memory (RAM) Memory, or may be a Non-Volatile Memory (NVM), such as a disk Memory. The memory 1005 may alternatively be a storage device separate from the processor 1001.
Those skilled in the art will appreciate that the configuration shown in fig. 1 does not constitute a limitation of the terminal device and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.
As shown in fig. 1, the memory 1005, which is a storage medium, may include therein an operating system, a data storage module, a network communication module, a user interface module, and a construction program of a consensus scheme.
In the terminal device shown in fig. 1, the network interface 1004 is mainly used for data communication with other devices; the user interface 1003 is mainly used for data interaction with a user; the processor 1001 and the memory 1005 in the terminal device of the present invention may be disposed in the terminal device, and the terminal device calls the construction program of the consensus scheme stored in the memory 1005 through the processor 1001 and executes the construction method of the consensus scheme provided by the embodiment of the present invention.
Based on the terminal device, various embodiments of the construction method of the consensus scheme are provided.
Referring to fig. 2, fig. 2 is a schematic flow chart of a first embodiment of a method for constructing a consensus scheme according to the present invention.
It is to be understood that while a logical order is shown in the flow chart, in some cases the method of constructing a consensus of the present invention may, of course, perform the steps shown or described in a different order than here.
In this embodiment, the method for constructing the consensus scheme of the present invention may include:
step S10: determining each target candidate node in the initial block chain based on a node reputation value corresponding to each node in the initial block chain and a preset reputation value threshold;
in this embodiment, when the terminal device operates, the terminal device first reads the storage module to obtain a reputation value threshold value pre-stored by a developer, and at the same time, the terminal device reads a node reputation value corresponding to each initial node in the initial block chain, and compares each node reputation value with the reputation value threshold value in sequence to determine a plurality of target candidate authoritative nodes in each initial node.
For example, the terminal device receives a data packet sent by a developer at a development terminal in advance, the data packet includes an initial block chain and a reputation value threshold, and stores the initial block chain and the reputation value threshold carried in the data packet in a storage module, then, during operation, the terminal device first reads the storage module to obtain the block chain and the reputation value threshold and determines a value corresponding to the reputation value threshold, the terminal device reads a node reputation value corresponding to each initial node in the initial block chain and inputs each node reputation value to a data comparison device built in the terminal device, and the data comparison device compares each node reputation value with the reputation value threshold to determine a plurality of candidate reputation nodes in each node.
It can be understood that, in this embodiment, the node reputation value is a comprehensive value obtained by calculating data such as transaction behavior records, transaction duration, transaction amounts, total transaction account values and the like generated by performing transactions in other block chains before the user account corresponding to the initial node according to a preset reputation parameter weight ratio, and the comprehensive value further represents the reputation of the user account.
Further, in a possible embodiment, the step S10 may specifically include:
step S101: acquiring a node reputation value corresponding to each initial node in an initial block chain;
in this embodiment, the terminal device extracts the node reputation value corresponding to each initial node in the initial block chain, and inputs the node reputation value to the data comparison module built in the terminal device.
Step S102: comparing each node reputation value with a preset reputation value threshold value respectively to determine each target reputation value which is greater than the reputation value threshold value in each node reputation value;
in this embodiment, the terminal device compares each initial node reputation value with the reputation value threshold value in sequence through the data comparison module to determine whether the node reputation value is greater than the reputation value threshold value and then determine each target node reputation value greater than the reputation value threshold value in each node reputation value.
Step S103: determining the initial node corresponding to each target reputation value as a target candidate node;
in this embodiment, the terminal device determines initial nodes corresponding to the reputation values of the target nodes, and marks the initial nodes as the target candidate nodes.
Illustratively, for example, the terminal device extracts a node reputation value corresponding to the initial node 1 in the initial block chain to be 70, and a node reputation value corresponding to the initial node 2 to be 76, so that the terminal device sequentially extracts respective node reputation values of the initial nodes in the initial block chain, inputs the extracted respective node reputation values into a data comparison module built in the terminal device, and then the data comparison module reads the values of the reputation value thresholds and compares the respective node reputation values with the reputation value thresholds in sequence, when the reputation value thresholds are preset to be 90 by the developer, the data comparison module determines respective target node reputation values with values larger than 90 in the respective node reputation values, and the terminal device further determines the initial nodes corresponding to the target node reputation values and determines respective numbers corresponding to the initial nodes, and then marks the initial nodes as the candidate nodes.
It should be noted that, in this embodiment, the reputation value threshold may be freely set based on an application scenario of an initial block chain, or may be set by a developer according to a requirement, which is not limited by the construction method of the consensus scheme of the present invention.
Further, in a possible embodiment, before the step S10, the method for constructing the consensus scheme of the present invention may further include:
step A10: acquiring a preset authority certificate consensus algorithm;
in this embodiment, the terminal device reads the storage module to obtain an authority certificate consensus algorithm pre-stored by the developer.
Step A20: constructing an initial block chain based on the authority certification consensus algorithm;
in this embodiment, the terminal device inputs the obtained authority certificate consensus algorithm to a block chain building module built in the terminal device, and the block chain building module builds the initial block chain based on the authority certificate consensus algorithm.
Illustratively, for example, the terminal device reads the storage module to obtain a POA consensus algorithm pre-stored by a developer, and inputs the POA consensus algorithm into a block chain building module built in the terminal device, and the block chain building module uses the POA consensus algorithm as a consensus mechanism of the initial block chain, and simultaneously reads core application components such as other preset programmable contracts, programmable assets, and incentive mechanisms to build the initial block chain.
It should be noted that, in this embodiment, besides the above-mentioned POA consensus algorithm, the developer may also select the rest of reference user reputations or the reference user reputation as the consensus algorithm based on the consensus.
Step S20: randomly determining each initial authoritative node in each target candidate node, and setting the weight value of each initial authoritative node as a preset first weight value;
in this embodiment, the terminal device inputs the target candidate nodes to a node screening module built in the terminal device, the node screening module randomly selects a plurality of nodes in the target candidate nodes as initial authoritative nodes, meanwhile, the terminal device reads a storage module to obtain a first weight value pre-stored by a developer, and the terminal device sets the weight value corresponding to the initial authoritative node as the first weight value.
For example, referring to fig. 4, fig. 4 is a schematic node screening diagram related to a first embodiment of a method for constructing a consensus scheme according to the present invention, where a terminal device reads a storage module in advance to obtain a number of authoritative nodes and a first weight value stored by a developer in advance, and at the same time, the terminal device inputs each obtained target candidate node to a node screening module built in the terminal device, and the node screening module randomly selects a target candidate node corresponding to the number of authoritative nodes from each target candidate node, and determines each selected target candidate node as the initial authoritative node, and then the terminal device sets each initial authoritative node according to the first weight value so that a weight value corresponding to an initial authoritative node is the first weight value.
It can be understood that, in this embodiment, when the number of the authority nodes is 4 and the first weight value is 3, it indicates that the terminal device filters 4 target candidate nodes from each target candidate node as initial authority nodes, and determines the weight value corresponding to the initial authority node as 3, so that, in a case where the number of the authority nodes is less than the number of the candidate nodes, a developer may arbitrarily set the number of the authority nodes and the first weight value, and the construction method of the consensus scheme of the present invention does not limit this.
Step S30: randomly determining each initial non-authoritative node in each non-target candidate node except each target candidate node, and setting the weight value of each initial non-authoritative node as a preset second weight value;
in this embodiment, the terminal device inputs each initial node in the initial block chain except for each target candidate node into a node screening module built in the terminal device, the node screening module randomly selects a plurality of initial nodes from each initial node as initial non-authoritative nodes, meanwhile, the terminal device reads a storage module to obtain a second weight value pre-stored by a developer, and the terminal device sets the weight value corresponding to the initial non-authoritative node as the second weight value.
For example, referring to fig. 4, for example, the terminal device reads the storage module in advance to obtain the number of non-authoritative nodes and a second weight value stored in advance by the developer, when the number of the initial non-authoritative nodes is 7 and the second weight value is 1, the terminal device inputs the remaining initial nodes except for the target candidate nodes in the initial block chain to the node screening module, the node screening module screens 7 initial nodes in each initial node as initial non-authoritative nodes, and then the terminal device sets the weight value corresponding to the initial non-authoritative node to 1 according to the second weight value.
It is understood that, in this embodiment, the terminal device may further input each initial node except each initial authoritative node in the initial block chain to the node screening module to obtain each initial non-authoritative node, and when the number of the non-authoritative nodes is smaller than the number of the initial nodes except each target candidate node, the developer may arbitrarily adjust the number of the non-authoritative nodes and the second weight value, but the second weight value should be smaller than the first weight value.
Step S40: inputting each initial authoritative node, the first weight value, each initial non-authoritative node and the second weight value into a preset target consensus function to construct a target consensus scheme;
in this embodiment, the terminal device inputs the obtained initial authoritative nodes, the first weight value, the initial non-authoritative nodes and the second weight value into a scheme building module built in the terminal device, and the scheme building module calls a target consensus function preset by a developer to build the target consensus scheme based on the initial authoritative nodes, the first weight value, the initial non-authoritative nodes and the second weight value.
Further, in a possible embodiment, the step S40 may specifically include:
step S401: inputting each initial authoritative node, the first weight value, each initial non-authoritative node and the second weight value into a preset target consensus function, combining each initial authoritative node and the first weight value by the target consensus function, and combining each initial non-authoritative node and the second weight value to construct a target consensus scheme;
illustratively, for example, the terminal device inputs the obtained initial authoritative nodes X1, X2, X3.,. XN, the initial non-authoritative nodes Y1, Y2, Y3.,. YN, the first weight value 3 and the second weight value 1 into the scenario construction module, the scenario construction module calls a target consensus function preset by a developer to combine the initial authoritative nodes X1, X2, X3.,. XN with the first weight value 3, and the target consensus function combines the non-authoritative nodes Y1, Y2, Y3.,. YN with the second weight value 1, respectively, so as to obtain a target consensus function (X3) + Σ (Y × 1) which is substituted with the first weight value, and the scenario construction module constructs an rpconsensus scenario based on the target function (X3) + Σ (Y × oa 1).
In this embodiment, the terminal device first reads the storage module to obtain the reputation value threshold value pre-stored by the developer during operation, and at the same time, the terminal equipment reads the node reputation value corresponding to each initial node in the initial block chain, compares the node reputation value with the reputation value threshold value in sequence to determine a plurality of target candidate authoritative nodes in each initial node, and then, the terminal equipment inputs the target candidate nodes into a node screening module arranged in the terminal equipment, the node screening module randomly selects a plurality of nodes in the target candidate nodes as initial authoritative nodes, and simultaneously, the terminal device reads the storage module to obtain a first weight value pre-stored by a developer, sets the weight value corresponding to the initial authoritative node as the first weight value, and then, the terminal device inputs all the other initial nodes except the target candidate nodes in the initial block chain to a node screening module arranged in the terminal device, the node screening module randomly selects a plurality of initial nodes in all the initial nodes as initial non-authoritative nodes, and simultaneously, the terminal device reads the storage module to obtain a second weight value pre-stored by the developer, sets the weight value corresponding to the initial non-authoritative node as the second weight value, and finally, the terminal device inputs the obtained initial authoritative nodes, the first weight numerical values, the initial non-authoritative nodes and the second weight numerical values into a scheme construction module arranged in the terminal device, and the scheme construction module calls a target consensus function preset by a developer to construct the target consensus scheme based on the initial authoritative nodes, the first weight numerical values, the initial non-authoritative nodes and the second weight numerical values.
Therefore, the invention adopts the technical effects that each initial authoritative node and each initial non-authoritative node are determined in each initial node in the initial block chain based on the reputation value, the corresponding first weight value and second weight value are respectively set for each initial authoritative node and each initial non-authoritative node, and finally the target consensus scheme is determined based on each initial authoritative node, the first weight value, each initial non-authoritative node and the second weight value, so that the established target consensus scheme can realize decentralization, and the scheme is safer and can be applied to the public block chain.
Further, a second embodiment of the construction method of the consensus sequence of the present invention is proposed herein, based on the above-described first embodiment of the construction method of the consensus sequence of the present invention.
Referring to fig. 3, fig. 3 is a schematic flow chart of a second embodiment of a construction method of the consensus scheme of the present invention.
Based on the first embodiment of the method for constructing the consensus sequence of the present invention shown in fig. 2, after step S40, the method for constructing the consensus sequence of the present invention may further include:
step B10: constructing a target block chain based on the target consensus scheme, and detecting the target block chain to determine whether transaction data is generated in the target block chain;
in this embodiment, the terminal device inputs the obtained target consensus scheme into a blockchain construction module arranged in the terminal device, the blockchain construction module constructs a target blockchain based on the target consensus scheme and other preset core application components such as programmable contracts, programmable assets, and an excitation mechanism, and meanwhile, the terminal device detects the target blockchain through a built-in data detection module to determine whether transaction data is generated between target nodes in the target blockchain.
Step B20: if so, calculating the transaction data through all target authoritative nodes in the target block chain together to obtain all target calculation results, wherein the target authoritative nodes are selected by all the nodes of the target block chain based on the target consensus scheme and have transaction verification authority;
in this embodiment, if the terminal device detects that transaction data is generated between target nodes in the target block chain, the terminal device obtains the transaction data, and invokes target authoritative nodes selected by the target nodes in the target block chain based on the common identification scheme to jointly calculate the transaction data and generate a corresponding calculation result.
Step B30: determining a transaction confirmation result corresponding to each target calculation result based on the target consensus scheme;
in this embodiment, the terminal device distributes the calculation result to each target authoritative node and each target non-authoritative node in the target block chain, and determines a transaction confirmation result corresponding to the calculation result based on a first weight value corresponding to the target authoritative node and a second weight value corresponding to the target non-authoritative node, which are included in the target consensus scheme.
Illustratively, for example, the terminal device inputs the obtained target RPOA consensus scheme into a block chain building module arranged in the terminal device, the block chain building module takes the RPOA consensus scheme as a consensus mechanism, and other programmable contracts, programmable assets, excitation mechanisms and other core application components are called to construct the target block chain, and simultaneously, the terminal device detects the transaction behavior of each target node in the target block chain through a built-in data detection module to determine whether each target node generates transaction data, when the terminal device detects that a digital transaction is conducted between a target node X and a target node Y within the target blockchain through the target blockchain, the terminal equipment acquires transaction data generated by the digital transaction, inputs the transaction data into each target authoritative node in the target block chain determined based on the RPOA consensus scheme, obtains a target calculation result by each target authoritative node based on the transaction data, generates a transaction confirmation result corresponding to the target calculation result, and then, the terminal device distributes the transaction confirmation result to each target authoritative node X1, X2, X3,. And XN and each target non-authoritative node Y1, Y2, Y3,. And YN in the target block chain, and simultaneously, the terminal equipment reads a first weight value 3 corresponding to a target authoritative node and a second weight value 1 corresponding to each target non-authoritative node, and determining a first transaction confirmation result corresponding to each target authoritative node and a second transaction confirmation result corresponding to each target non-authoritative node based on a target consensus function carried in the RPOA consensus scheme, and finally determining a final transaction confirmation result based on different weights by the terminal equipment.
It should be noted that, in this embodiment, if the first transaction confirmation result corresponding to each target authoritative node is inconsistent with the second transaction confirmation result corresponding to each target non-authoritative node, and the first confirmation weight value corresponding to the first transaction confirmation result is consistent with the second confirmation weight value corresponding to the second transaction confirmation result, the terminal device determines that the transaction data is invalid data.
Further, in a possible embodiment, before the step B30, the constructing of the consensus scheme of the present invention may specifically further include:
step C10: verifying each target calculation result to determine whether each target calculation result contains a target error calculation result;
in this embodiment, after detecting that each target authoritative node in the target block chain calculates to obtain a calculation result, the terminal device inputs each calculation result to the data comparison module, and the data comparison module determines whether each calculation result includes a target error calculation result.
Step C20: and if the target error calculation result is contained in each target calculation result, backtracking the transaction data to the moment of generating the transaction data.
In this embodiment, if the data comparison module in the terminal device determines that each calculation result includes the target error calculation result, the terminal device backtracks the transaction data through the built-in data recording device, and backtracks the transaction data to the time when the target block chain generates the transaction data.
For example, after detecting that each target authority node in the target block chain calculates each calculation result, the terminal device inputs each calculation result to the data comparison module, and the data comparison module compares each calculation result with other calculation results in sequence to determine whether the calculation result is consistent, so as to determine whether a target error calculation result exists in each calculation result.
Further, in a possible embodiment, the construction of the consensus scheme of the present invention may specifically further include:
step D10: acquiring a preset node refreshing frequency;
in this embodiment, the terminal device reads the storage module to obtain a node refresh frequency preset by a developer.
Step D20: controlling the target block chain to replace each target authoritative node according to the node refreshing frequency;
in this embodiment, the terminal device sets the target block chain according to the node refresh frequency, so that the target block chain re-randomly selects a new target authoritative node from the candidate nodes according to the node refresh frequency pair.
Illustratively, for example, the terminal device reads the storage module to obtain a node refresh frequency pre-stored by the developer, and determines that the node refresh frequency is 1h, and then, the terminal device sets the target block chain so as to make the target block chain randomly select a plurality of target authoritative nodes in each candidate node every 1h based on the above RPOA consensus scheme.
In this embodiment, a terminal device inputs the obtained target consensus scheme into a blockchain construction module arranged in the terminal device, the blockchain construction module constructs a target blockchain based on the target consensus scheme and other preset core application components such as programmable contracts, programmable assets, and incentive mechanisms, and meanwhile, the terminal device detects the target blockchain through a built-in data detection module to determine whether transaction data is generated between target nodes in the target blockchain, then, if the terminal device detects that transaction data is generated between target nodes in the target blockchain, the terminal device obtains the transaction data, calls each target authoritative node selected by each target node in the target blockchain based on the target consensus scheme to jointly calculate the transaction data and generate a corresponding calculation result, and finally, the terminal device distributes the calculation result to each target authoritative node and each target non-authoritative node in the target blockchain, and determines a corresponding transaction result of the target authoritative node based on a first weight value and a corresponding non-authoritative value of the target node included in the target consensus scheme, and determines a corresponding non-authoritative value of the target node.
Therefore, the target block chain is constructed based on the target consensus scheme, the calculation result corresponding to the transaction data is calculated by all the target authoritative nodes in the target block chain when the transaction data is generated in the target block chain, and the transaction confirmation result corresponding to the calculation result is determined by all the target authoritative nodes and all the target non-authoritative nodes in the target block chain, so that the purposes of enabling the transaction confirmation result to be relatively fair and reducing the centralization of the target consensus scheme are achieved.
In addition, the present invention further provides a device for constructing a consensus scheme, please refer to fig. 5, fig. 5 is a schematic diagram of functional modules related to an embodiment of a method for constructing a consensus scheme according to the present invention, as shown in fig. 5, the device for constructing a consensus scheme according to the present invention includes:
a node screening module 10, configured to determine, in an initial block chain, each target candidate node based on a node reputation value corresponding to each node in the initial block chain and a preset reputation value threshold;
a first setting module 20, configured to randomly determine each initial authoritative node in each target candidate node, and set a weight value of each initial authoritative node as a preset first weight value;
a second setting module 30, configured to randomly determine each initial non-authoritative node in each non-target candidate node except for each target candidate node, and set a weight value of each initial non-authoritative node as a preset second weight value;
a consensus constructing module 40, configured to input each initial authoritative node, the first weight value, each initial non-authoritative node, and the second weight value into a preset target consensus function to construct a target consensus scheme.
Further, the node screening module 10 includes:
the reputation extraction unit is used for acquiring node reputation values corresponding to each initial node in the initial block chain;
the reputation comparison unit is used for comparing each node reputation value with a preset reputation value threshold value respectively to determine each target reputation value which is greater than the reputation value threshold value in each node reputation value;
and the node confirmation unit is used for determining the initial node corresponding to each target reputation value as a target candidate node.
Further, the node screening module 10 further includes:
the algorithm extraction unit is used for acquiring a preset authority certificate consensus algorithm;
and the initial building unit is used for building an initial block chain based on the authority certification consensus algorithm.
Further, the consensus building block 40 comprises:
and the scheme construction unit is used for inputting each initial authoritative node, each first weight numerical value, each initial non-authoritative node and each second weight numerical value into a preset target consensus function, combining each initial authoritative node and each first weight numerical value through the target consensus function, and combining each initial non-authoritative node and each second weight numerical value to construct a target consensus scheme.
Further, the consensus building module 40 further includes:
the construction detection unit is used for constructing a target block chain based on the target consensus scheme and detecting the target block chain to determine whether transaction data are generated in the target block chain;
the transaction calculation unit is used for calculating the transaction data through all target authoritative nodes in the target block chain to obtain all target calculation results if the transaction data generated in the target block chain is determined, wherein the target authoritative nodes are the nodes with the transaction verification authority selected by all the nodes in the target block chain based on the target consensus scheme;
and the transaction confirmation unit is used for determining a transaction confirmation result corresponding to each target calculation result based on the target consensus scheme.
Further, the consensus building module 40 further includes:
the result verification unit is used for verifying each target calculation result to determine whether each target calculation result contains a target error calculation result;
and the result backtracking unit is used for backtracking the transaction data to the moment of generating the transaction data if the target error calculation result is contained in each target calculation result.
Further, the consensus building module 40 further includes:
the frequency acquisition unit is used for acquiring a preset node refreshing frequency;
and the node refreshing unit is used for controlling the target block chain to replace each target authoritative node according to the node refreshing frequency.
In addition, the present invention also provides a terminal device, where the terminal device has a construction program of a consensus scheme that can be run on a processor, and the terminal device implements the steps of the construction method of the consensus scheme according to any one of the above embodiments when executing the construction program of the consensus scheme.
The specific embodiment of the terminal device of the present invention is substantially the same as each embodiment of the method for constructing the consensus scheme, and is not described herein again.
Furthermore, the present invention also provides a computer-readable storage medium having stored thereon a construction program of a consensus scheme, which when executed by a processor, implements the steps of the construction method of the consensus scheme as described in any one of the above embodiments.
The specific embodiment of the computer-readable storage medium is substantially the same as the embodiments of the method for constructing the consensus scheme, and is not repeated herein.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising a … …" does not exclude the presence of another identical element in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (10)

1. A construction method of a consensus scheme is characterized by comprising the following steps:
determining each target candidate node in the initial block chain based on a node reputation value corresponding to each node in the initial block chain and a preset reputation value threshold;
randomly determining each initial authoritative node in each target candidate node, and setting the weight value of each initial authoritative node as a preset first weight value;
randomly determining each initial non-authoritative node in each non-target candidate node except each target candidate node, and setting the weight value of each initial non-authoritative node as a preset second weight value;
and inputting each initial authoritative node, the first weight value, each initial non-authoritative node and the second weight value into a preset target consensus function to construct a target consensus scheme.
2. The method for constructing a consensus scheme as claimed in claim 1, wherein the step of determining each target candidate node in the initial block chain based on a node reputation value corresponding to each node in the initial block chain and a preset reputation value threshold comprises:
acquiring a node reputation value corresponding to each initial node in an initial block chain;
comparing each node reputation value with a preset reputation value threshold value respectively to determine each target reputation value which is greater than the reputation value threshold value in each node reputation value;
and determining the initial node corresponding to each target reputation value as a target candidate node.
3. The method for constructing a consensus scheme as claimed in claim 2, wherein prior to the step of determining each target candidate node in the initial blockchain based on the node reputation value corresponding to each node in the initial blockchain and a preset reputation value threshold, the method further comprises:
acquiring a preset authority certification consensus algorithm;
an initial blockchain is constructed based on the authority certification consensus algorithm.
4. The method of claim 1, wherein the step of inputting each of the initial authoritative nodes, the first weight value, each of the initial non-authoritative nodes and the second weight value into a preset target consensus function to construct a target consensus scheme comprises:
inputting each initial authoritative node, the first weight value, each initial non-authoritative node and the second weight value into a preset target consensus function, combining each initial authoritative node and the first weight value by the target consensus function, and combining each initial non-authoritative node and the second weight value to construct a target consensus scheme.
5. The method of constructing a consensus scheme as claimed in claim 1, further comprising:
constructing a target block chain based on the target consensus scheme, and detecting the target block chain to determine whether transaction data are generated in the target block chain;
if yes, calculating the transaction data through all target authoritative nodes in the target block chain together to obtain all target calculation results, wherein the target authoritative nodes are selected by all the nodes of the target block chain on the basis of the target consensus scheme and have transaction verification authority;
and determining a transaction confirmation result corresponding to each target calculation result based on the target consensus scheme.
6. The method of constructing a consensus scheme as claimed in claim 5, wherein prior to the step of determining a transaction confirmation result for each of the target calculation results based on the target consensus scheme, the method further comprises:
verifying each target calculation result to determine whether each target calculation result contains a target error calculation result;
and if the target error calculation result is contained in each target calculation result, backtracking the transaction data to the moment of generating the transaction data.
7. The method of constructing a consensus scheme as claimed in claim 6, further comprising:
acquiring a preset node refreshing frequency;
and controlling the target block chain to replace each target authoritative node according to the node refreshing frequency.
8. An apparatus for constructing a consensus scheme, the apparatus comprising:
the node screening module is used for determining each target candidate node in the initial block chain based on the node reputation value corresponding to each node in the initial block chain and a preset reputation value threshold;
the first setting module is used for randomly determining each initial authoritative node in each target candidate node and setting the weight value of each initial authoritative node as a preset first weight value;
the second setting module is used for randomly determining each initial non-authoritative node in each non-target candidate node except each target candidate node and setting the weight value of each initial non-authoritative node as a preset second weight value;
and the consensus construction module is used for inputting each initial authoritative node, each first weight value, each initial non-authoritative node and each second weight value into a preset target consensus function so as to construct a target consensus scheme.
9. A terminal device, characterized in that the terminal device comprises: a memory, a processor and a consensus construction program stored on the memory and executable on the processor, the consensus construction program implementing the steps of the consensus construction method as claimed in any one of claims 1 to 7 when executed by the processor.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored thereon a construction program of a consensus scheme, which when executed by a processor, implements the steps of the construction method of the consensus scheme as claimed in any one of claims 1 to 7.
CN202210957995.5A 2022-08-10 2022-08-10 Method and device for constructing consensus scheme, terminal equipment and computer medium Active CN115374216B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210957995.5A CN115374216B (en) 2022-08-10 2022-08-10 Method and device for constructing consensus scheme, terminal equipment and computer medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210957995.5A CN115374216B (en) 2022-08-10 2022-08-10 Method and device for constructing consensus scheme, terminal equipment and computer medium

Publications (2)

Publication Number Publication Date
CN115374216A true CN115374216A (en) 2022-11-22
CN115374216B CN115374216B (en) 2024-04-02

Family

ID=84065658

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210957995.5A Active CN115374216B (en) 2022-08-10 2022-08-10 Method and device for constructing consensus scheme, terminal equipment and computer medium

Country Status (1)

Country Link
CN (1) CN115374216B (en)

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108923909A (en) * 2018-07-02 2018-11-30 上海达家迎信息科技有限公司 Block chain generation method, device, computer equipment and storage medium
CN110049029A (en) * 2019-04-04 2019-07-23 矩阵元技术(深圳)有限公司 Common recognition node determines method, apparatus, computer equipment and storage medium
CN110493198A (en) * 2019-07-26 2019-11-22 北京工业大学 A method of it is attacked based on Sybil in PBFT algorithm defence block chain is improved
CN110598060A (en) * 2019-09-18 2019-12-20 广东卓启投资有限责任公司 Block chain rapid consensus method and device, computer equipment and storage medium
CN110956542A (en) * 2019-11-07 2020-04-03 支付宝(杭州)信息技术有限公司 Block chain system and operation method, device and equipment thereof
CN111010278A (en) * 2019-11-14 2020-04-14 江苏大学 High fault tolerance layered consensus method based on DPoS
CN111241114A (en) * 2020-01-07 2020-06-05 中国科学院信息工程研究所 Intelligent service transaction block chain credit management method and system combining transaction and consensus
CN112039964A (en) * 2020-08-24 2020-12-04 大连理工大学 Node reputation consensus method based on block chain
CN113313378A (en) * 2021-05-27 2021-08-27 北京航空航天大学 Credibility model-based block chain consensus mechanism
CN113486118A (en) * 2021-07-21 2021-10-08 银清科技有限公司 Consensus node selection method and device
CN114301598A (en) * 2021-12-14 2022-04-08 中国人民解放军国防科技大学 Block chain consensus algorithm, system and storage medium based on hierarchical authority

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108923909A (en) * 2018-07-02 2018-11-30 上海达家迎信息科技有限公司 Block chain generation method, device, computer equipment and storage medium
CN110049029A (en) * 2019-04-04 2019-07-23 矩阵元技术(深圳)有限公司 Common recognition node determines method, apparatus, computer equipment and storage medium
CN110493198A (en) * 2019-07-26 2019-11-22 北京工业大学 A method of it is attacked based on Sybil in PBFT algorithm defence block chain is improved
CN110598060A (en) * 2019-09-18 2019-12-20 广东卓启投资有限责任公司 Block chain rapid consensus method and device, computer equipment and storage medium
CN110956542A (en) * 2019-11-07 2020-04-03 支付宝(杭州)信息技术有限公司 Block chain system and operation method, device and equipment thereof
CN111010278A (en) * 2019-11-14 2020-04-14 江苏大学 High fault tolerance layered consensus method based on DPoS
CN111241114A (en) * 2020-01-07 2020-06-05 中国科学院信息工程研究所 Intelligent service transaction block chain credit management method and system combining transaction and consensus
CN112039964A (en) * 2020-08-24 2020-12-04 大连理工大学 Node reputation consensus method based on block chain
CN113313378A (en) * 2021-05-27 2021-08-27 北京航空航天大学 Credibility model-based block chain consensus mechanism
CN113486118A (en) * 2021-07-21 2021-10-08 银清科技有限公司 Consensus node selection method and device
CN114301598A (en) * 2021-12-14 2022-04-08 中国人民解放军国防科技大学 Block chain consensus algorithm, system and storage medium based on hierarchical authority

Also Published As

Publication number Publication date
CN115374216B (en) 2024-04-02

Similar Documents

Publication Publication Date Title
US10063562B1 (en) Flexible access management framework based on measuring application usage behavior
CN110503207A (en) Federation's study credit management method, device, equipment and readable storage medium storing program for executing
JP2018506798A (en) System and method for user attribute information confirmation, and client and server using the same
CN109213857A (en) A kind of fraud recognition methods and device
CN110222537B (en) Verification method and device applied to block chain nodes
CN111275188B (en) Method and device for optimizing horizontal federated learning system and readable storage medium
JP7115207B2 (en) Learning program, learning method and learning device
Soriano-Sánchez et al. Smart pattern to generate small–world networks
Cooper et al. On the use of buy up as a model of customer choice in revenue management
CN113096055B (en) Training method and device for image generation model, electronic equipment and storage medium
CN108229133B (en) Service operation method and device and service permission obtaining method and device
WO2019118990A1 (en) Image generation method, image generation apparatus, image generation system and program
CN115374216A (en) Construction method and device of consensus scheme, terminal equipment and computer medium
US11023904B1 (en) Model for the competitive seeding of opinions in networks with hybrid gossip-threshold dynamics
CN113239244B (en) Multi-uncertainty preference obtaining method and device based on credibility structure and electronic equipment
CN113297310B (en) Method for selecting block chain fragmentation verifier in Internet of things
CN112862693B (en) Picture processing method and device
JP4607943B2 (en) Security level evaluation apparatus and security level evaluation program
Jones et al. Architectural scoring framework for the creation and evaluation of system-aware cyber security solutions
CN114237794A (en) Application available time duration display method, device, equipment and storage medium
CN110062023B (en) Safety education information pushing method, device and equipment
CN110224839B (en) Verification method and device applied to block chain
CN111625817A (en) Abnormal user identification method and device, electronic equipment and storage medium
CN112015768A (en) Information matching method based on Rete algorithm and related products thereof
CN113838527B (en) Method and device for generating target gene prediction model and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant