CN115374216B - Method and device for constructing consensus scheme, terminal equipment and computer medium - Google Patents

Method and device for constructing consensus scheme, terminal equipment and computer medium Download PDF

Info

Publication number
CN115374216B
CN115374216B CN202210957995.5A CN202210957995A CN115374216B CN 115374216 B CN115374216 B CN 115374216B CN 202210957995 A CN202210957995 A CN 202210957995A CN 115374216 B CN115374216 B CN 115374216B
Authority
CN
China
Prior art keywords
target
node
initial
weight value
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.)
Active
Application number
CN202210957995.5A
Other languages
Chinese (zh)
Other versions
CN115374216A (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

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

Landscapes

  • Engineering & Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Finance (AREA)
  • Accounting & Taxation (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Strategic Management (AREA)
  • Technology Law (AREA)
  • General Business, Economics & Management (AREA)
  • Medical Treatment And Welfare Office Work (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention discloses a method, a device, terminal equipment and a computer medium for constructing a consensus scheme, 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 authority node in each target candidate node, and setting the weight value of each initial authority 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. The invention achieves the technical effects that the target consensus scheme can realize the decentralization, and the scheme is safer and can be applied to the public block chain.

Description

Method and device for constructing consensus scheme, terminal equipment and computer medium
Technical Field
The present invention relates to the field of blockchain technologies, and in particular, to a method and apparatus for constructing a consensus scheme, a terminal device, and a computer readable storage medium.
Background
With the development of blockchain technology, in order to enable nodes in a blockchain to be in a state of trust with each other, a consensus algorithm based on different reference factors is also an essential component in the blockchain.
The current consensus algorithm adopted in the blockchain mainly comprises a POW (Proof of Work-Proof) consensus algorithm, a POS (Proof of authority-Proof) consensus algorithm and a POA (Proof of authority-Proof) consensus algorithm, wherein the POA consensus algorithm mainly determines verification nodes in the blockchain through identity values or personal credits corresponding to each node in the blockchain, and the verification nodes acquire rights for accounting each transaction in the blockchain, so that nodes which participate in verification in the blockchain based on the POA consensus algorithm are always reserved in a few authoritative node hands, and once the few authoritative nodes generate malignant operation, the consensus scheme in the whole blockchain is broken.
Disclosure of Invention
The embodiment of the invention aims to realize the decentralization of the constructed target consensus scheme by providing a construction method, a device, terminal equipment and a computer readable storage medium of the consensus scheme, and the scheme 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 the node reputation value corresponding to each node in the initial block chain and a preset reputation value threshold;
randomly determining each initial authority node in each target candidate node, and setting the weight value of each initial authority 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 authority node, the first weight value, each initial non-authority node and the 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 blockchain based on the node reputation value corresponding to each node in the initial blockchain and a preset reputation value threshold value comprises the following steps:
acquiring node reputation values corresponding to all initial nodes in the initial block chain;
comparing the node reputation values with preset reputation value thresholds respectively to determine target reputation values which are larger than the reputation value thresholds in the node reputation values;
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 blockchain based on the node reputation value and the preset reputation value threshold corresponding to each node in the initial blockchain, the method further comprises:
acquiring a preset authority proof consensus algorithm;
and constructing an initial blockchain based on the authority proof consensus algorithm.
Further, the step of inputting each of the initial authoritative node, the first weight value, each of the initial non-authoritative node and the second weight value to 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 with the first weight value by the target consensus function, and combining each initial non-authoritative node with the second weight value to construct a target consensus scheme.
Further, the method further comprises:
constructing a target blockchain based on the target consensus scheme, and detecting the target blockchain to determine whether transaction data is generated in the target blockchain;
if yes, calculating the transaction data through all target authority nodes in the target block chain to obtain all target calculation results, wherein the target authority nodes are nodes with transaction verification authorities selected by all nodes of the target block chain based on the target consensus scheme;
and determining a transaction confirmation result corresponding to each target calculation result based on the target consensus scheme.
Further, before the step of determining a transaction confirmation result corresponding to each target calculation result based on the target consensus scheme, the method further includes:
Verifying each target calculation result to determine whether each target calculation result contains a target error calculation result or not;
and if the target calculation results contain the target error calculation results, 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 authority node according to the node refreshing frequency.
In addition, to achieve the above object, the present invention further provides a device for constructing a consensus scheme, the device 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 authority node in each target candidate node and setting the weight value of each initial authority 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 stored on the memory and capable of running on the processor, wherein the construction program of the consensus scheme realizes the steps of the construction method of the consensus scheme when being executed by the processor.
In addition, in order 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.
The embodiment of the invention provides a method, a device, terminal equipment and a computer readable storage medium for constructing an identification scheme, wherein each target candidate node is determined in an 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 authority node in each target candidate node, and setting the weight value of each initial authority 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 authority node, the first weight value, each initial non-authority node and the second weight value into a preset target consensus function to construct a target consensus scheme.
In this embodiment, when running, the terminal device first reads the storage module to obtain the reputation value threshold value stored in advance by the developer, meanwhile, the terminal device reads the node reputation value corresponding to each initial node in the initial block chain, determines each target reputation value greater than the reputation value threshold value in each node reputation value, the terminal device determines each initial node corresponding to each target reputation value as a target candidate node in the initial block chain, then the terminal device randomly determines a preset number of initial authority nodes in each target candidate node, meanwhile, the terminal device sets each weight value of each initial authority node as a first weight value according to the first weight value preset by the developer, then the terminal device randomly determines a preset number of initial non-authority nodes in other non-candidate nodes, sets each weight value of each initial non-authority node as a second weight value according to the second weight value preset by the developer, finally, the terminal device constructs a scheme by calling each initial authority node, the first weight value, each initial authority node, each initial non-authority node and each initial authority node to the second weight value, and the target non-authority node, and the terminal device constructs a target weighting scheme based on the preset weight scheme.
In this way, the invention adopts the mode of determining each initial authoritative node and each initial non-authoritative node in each initial node in the initial block chain based on the reputation value, respectively setting corresponding first weight value and second weight value for each initial authoritative node and each initial non-authoritative node, and finally determining the target consensus scheme based on each initial authoritative node, the first weight value, each initial non-authoritative node and the second weight value, thereby achieving the technical effects that the built 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 of a hardware running environment according to an embodiment of the present invention;
FIG. 2 is a flow chart of a first embodiment of a method for constructing a consensus scheme of the present invention;
FIG. 3 is a flow chart of a second embodiment of a method for constructing a consensus scheme of the present invention;
FIG. 4 is a schematic diagram of node screening according to a first embodiment of a method for constructing a consensus scheme of the present invention;
fig. 5 is a schematic diagram of functional modules involved in an embodiment of a method for constructing a consensus scheme of the present invention.
The achievement of the objects, functional features and advantages of the present invention will be further described with reference to the accompanying drawings, in conjunction with the embodiments.
Detailed Description
It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
Referring to fig. 1, fig. 1 is a schematic diagram of a terminal device structure of a hardware running environment according to an embodiment of the present invention.
The terminal device in the embodiment of the invention can 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 which are provided with other operating systems, and the PC (Personal Computer) and the personal computer which are provided with windows operating systems.
As shown in fig. 1, the terminal device may include: a processor 1001, such as a central processing unit (Central Processing Unit, CPU), a communication bus 1002, a user interface 1003, a network interface 1004, a memory 1005. Wherein the communication bus 1002 is used to enable connected communication between these components. The user interface 1003 may include a Display, an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may further 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 high-speed random access Memory (Random Access Memory, RAM) Memory or a stable nonvolatile Memory (NVM), such as a disk Memory. The memory 1005 may also optionally be a storage device separate from the processor 1001 described above.
It will be appreciated by those skilled in the art that the structure shown in fig. 1 does not constitute a limitation of the terminal device, and may include more or less components than illustrated, or may combine certain components, or may be arranged in different components.
As shown in fig. 1, the memory 1005, which is a storage medium, may include an operating system, a data storage module, a network communication module, a user interface module, and a program for constructing 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 provided 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 above terminal device, various embodiments of the construction method of the consensus scheme of the present invention are provided.
Referring to fig. 2, fig. 2 is a flowchart illustrating a first embodiment of a method for constructing a consensus scheme according to the present invention.
It will be appreciated that although a logical order is depicted in the flowchart, in some cases the method of construction of the consensus scheme of the present invention may of course also be performed in an order different from that depicted or described herein.
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 the node reputation value corresponding to each node in the initial block chain and a preset reputation value threshold;
in this embodiment, when running, the terminal device first reads the storage module to obtain a reputation value threshold stored in advance by the developer, and at the same time, the terminal device reads node reputation values corresponding to each initial node in the initial blockchain, and sequentially compares each node reputation value with the reputation value threshold, so as to determine a plurality of target candidate authoritative nodes in each initial node.
For example, the terminal device receives a data packet including an initial blockchain and a reputation value threshold sent by a developer in the development terminal in advance and stores the initial blockchain and the reputation value threshold carried in the data packet in a storage module, then, in the operation process, the terminal device firstly reads the storage module to obtain the blockchain and the reputation value threshold and determine the value corresponding to the reputation value threshold, and the terminal device reads the node reputation value corresponding to each initial node in the initial blockchain 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 authoritative nodes in each node.
It may be understood that in this embodiment, the node reputation value is a comprehensive value obtained by calculating, according to a preset reputation parameter weight ratio, data such as each transaction behavior record, transaction duration, each transaction amount, total value of a transaction account and the like generated by performing transactions in each other block chain before performing the transactions on the user account corresponding to the initial node, where the comprehensive value further represents the reputation of the user account, and according to different transaction scenarios, a developer may also change the reputation parameter weight ratio and other reputation reference data.
Further, in a possible embodiment, the step S10 may specifically include:
step S101: acquiring node reputation values corresponding to all initial nodes in the initial block chain;
in this embodiment, the terminal device extracts the node reputation values corresponding to the initial nodes in the initial blockchain, and inputs the node reputation values to the data comparison module built in the terminal device.
Step S102: comparing the node reputation values with preset reputation value thresholds respectively to determine target reputation values which are larger than the reputation value thresholds in the node reputation values;
In this embodiment, the terminal device sequentially compares the reputation value of each initial node with the reputation value threshold through the data comparison module to determine whether the reputation value of the node is greater than the reputation value threshold, and further determines, in each node reputation value, a reputation value of each target node greater than the reputation value threshold.
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 each initial node as the target candidate node.
For example, the terminal device extracts a node reputation value corresponding to the initial node 1 in the initial blockchain to be 70, and a node reputation value corresponding to the initial node 2 to be 76.
It should be noted that, in this embodiment, the reputation value threshold may be set freely based on the application scenario of the initial blockchain, or set by the developer according to the requirement, which is not limited by the method of constructing 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 specifically further include:
step A10: acquiring a preset authority proof consensus algorithm;
in this embodiment, the terminal device reads the storage module to acquire the authority-proof consensus algorithm stored in advance by the developer.
Step A20: constructing an initial blockchain based on the authority proof consensus algorithm;
in this embodiment, the terminal device inputs the obtained authority-proof consensus algorithm to a blockchain construction module built in the terminal device, and the blockchain construction module constructs the initial blockchain based on the authority-proof consensus algorithm.
For example, the terminal device reads the storage module to obtain the POA consensus algorithm stored in advance by the developer, and inputs the POA consensus algorithm to the built-in blockchain building module of the terminal device, the blockchain building module uses the POA consensus algorithm as the consensus mechanism of the initial blockchain, and the blockchain building module reads the core application components such as the preset other programmable contracts, programmable assets, and incentive mechanisms to build the initial blockchain.
In this embodiment, besides the POA consensus algorithm, the developer may select the rest of the consensus algorithm with reference to the user reputation or the reference user reputation as the consensus base.
Step S20: randomly determining each initial authority node in each target candidate node, and setting the weight value of each initial authority 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 authority nodes, and meanwhile, the terminal device reads the storage module to obtain a first weight value stored in advance by a developer, and the terminal device sets the weight value corresponding to the initial authority 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 of the present invention, a terminal device reads a storage module in advance to obtain the number of authoritative nodes and a first weight value stored in advance by a developer, and meanwhile, the terminal device inputs each obtained target candidate node to a node screening module built in the terminal device, the node screening module randomly selects a target candidate node corresponding to the number of authoritative nodes from each target candidate node, 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 to make the weight value corresponding to the initial authoritative node be the first weight value.
It may be understood that in this embodiment, when the number of the authoritative nodes is 4 and the first weight value is 3, it indicates that the terminal device screens 4 target candidate nodes from all target candidate nodes as initial authoritative nodes, and determines the weight value corresponding to the initial authoritative nodes as 3, so that, when the number of the authoritative nodes is smaller than the number of the candidate nodes, a developer may set the number of the authoritative nodes and the first weight value at will, and the construction method of the consensus scheme of the present invention is not limited thereto.
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 all the initial nodes except for the target candidate nodes in the initial blockchain to a node screening module built in the terminal device, the node screening module randomly selects a plurality of initial nodes from all the initial nodes as initial non-authoritative nodes, and meanwhile, the terminal device reads the storage module to obtain a second weight value stored in advance 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, the terminal device reads the storage module in advance to obtain the number of non-authoritative nodes and the 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 rest initial nodes except for each target candidate node in the initial blockchain to the node screening module, the node screening module screens 7 initial nodes from the initial nodes as initial non-authoritative nodes, and then the terminal device sets the weight value corresponding to the initial non-authoritative nodes to be 1 according to the second weight value.
It may be understood that in this embodiment, the terminal device may further input, to the node screening module, each of the remaining initial nodes except for each of the initial authoritative nodes in the initial blockchain to obtain each of the initial non-authoritative nodes, and when the number of the non-authoritative nodes is smaller than the number of the remaining initial nodes except for each of the target candidate nodes, the developer may optionally adjust the number of the non-authoritative nodes and the second weight value, where the second weight value is 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 authority nodes, the first weight value, the initial non-authority nodes and the second weight value to a scheme construction module built in the terminal device, and the scheme construction module invokes a target consensus function preset by a developer to construct the target consensus scheme based on the initial authority nodes, the first weight value, the initial non-authority 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 with the first weight value by the target consensus function, and combining each initial non-authoritative node with the second weight value to construct a target consensus scheme;
For example, the terminal device inputs the obtained initial authority nodes X1, X2, X3, XN, the initial non-authority nodes Y1, Y2, Y3, YN, the first weight value 3, and the second weight value 1 to the scheme building module, the scheme building module invokes a target consensus function preset by the developer to combine the initial authority nodes X1, X2, X3, XN and the first weight value 3, respectively, while the target consensus function combines the non-authority nodes Y1, Y2, Y3, respectively, YN and the second weight value 1 to obtain a target consensus function Σ (x×3) +Σ (y×1) after each value is taken in, and the scheme building module builds an RPOA consensus scheme as the target consensus scheme based on the target function Σ (x×3) +Σ (y×1).
In this embodiment, when running, a terminal device first reads a 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 an initial block chain, and sequentially compares each node reputation value with the reputation value threshold value to determine a plurality of target candidate authoritative nodes in each initial node, then the terminal device inputs each target candidate node into a node screening module built in the terminal device, the node screening module randomly selects a plurality of nodes in each target candidate node as initial authoritative nodes, and at the same time, the terminal device reads the storage module to obtain a first weight value pre-stored by the developer, the terminal device sets a weight value corresponding to the initial authoritative node as the first weight value, then the terminal device inputs all initial nodes except for each target candidate node in the initial block chain into the node screening module built in the terminal device, the node screening module randomly selects a plurality of initial nodes in each initial authoritative nodes as initial non-nodes, and at the same time, the terminal device reads a first weight value corresponding to the initial weight value pre-stored by the developer, and the terminal device sets a second weight value corresponding to the first weight value, and the terminal device calls a second weight value corresponding to the first weight value, and the terminal device sets a second weight value corresponding to the initial value, and the first weight value is built up a second weight value corresponding to the initial value, each of the initial non-authoritative nodes and the second weight value construct the target consensus scheme.
In this way, the invention adopts the mode of determining each initial authoritative node and each initial non-authoritative node in each initial node in the initial block chain based on the reputation value, respectively setting corresponding first weight value and second weight value for each initial authoritative node and each initial non-authoritative node, and finally determining the target consensus scheme based on each initial authoritative node, the first weight value, each initial non-authoritative node and the second weight value, thereby achieving the technical effects that the built target consensus scheme can realize decentralization, and the scheme is safer and can be applied to the public block chain.
Further, based on the first embodiment of the construction method of the consensus scheme of the present invention described above, a second embodiment of the construction method of the consensus scheme of the present invention is presented herein.
Referring to fig. 3, fig. 3 is a flowchart illustrating a second embodiment of a method for constructing a consensus scheme according to the present invention.
Based on the first embodiment of the construction method of the consensus scheme of the present invention shown in fig. 2, after the step S40, the construction method of the consensus scheme of the present invention may further include:
step B10: constructing a target blockchain based on the target consensus scheme, and detecting the target blockchain to determine whether transaction data is generated in the target blockchain;
In this embodiment, the terminal device inputs the obtained target consensus scheme to a blockchain construction module set in the terminal device, and 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 incentive 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 each target node in the target blockchain.
Step B20: if yes, calculating the transaction data through all target authority nodes in the target block chain to obtain all target calculation results, wherein the target authority nodes are nodes with transaction verification authorities selected by all nodes of the target block chain based on the target consensus scheme;
in this embodiment, if the terminal device detects that transaction data is generated between the target nodes in the target blockchain, the terminal device acquires the transaction data, invokes each target authority node selected by each target node in the target blockchain based on the identification scheme to calculate the transaction data together, and generates 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 blockchain, 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 included in the target consensus scheme.
For example, the terminal device inputs the obtained target RPOA consensus scheme to a blockchain construction module arranged in the terminal device, the blockchain construction module uses the RPOA consensus scheme as a consensus mechanism, and invokes other core application components such as programmable contracts, programmable assets, and incentive mechanisms to construct the target blockchain, meanwhile, the terminal device detects the transaction behaviors of each target node in the target blockchain through a built-in data detection module to determine whether each target node generates transaction data, when the terminal device detects that digital transaction is performed between a target node X and a target node Y in the target blockchain through the target blockchain, the terminal device obtains the transaction data generated by the digital transaction, inputting the transaction data to each target authority node in the target blockchain determined based on the RPOA consensus scheme, obtaining a target calculation result by each target authority node based on the transaction data, generating a transaction confirmation result corresponding to the target calculation result, then distributing the transaction confirmation result to each target authority node X1, X2, X3,..2, XN and each target non-authority node Y1, Y2, Y3, & gt, YN in the target blockchain by the terminal equipment, simultaneously, reading a first weight value 3 corresponding to the target authority node, a second weight value 1 corresponding to each target non-authority node by the terminal equipment, determining a first transaction confirmation result corresponding to each target authority node and a second transaction confirmation result corresponding to each target non-authority node based on a target consensus function carried in the RPOA consensus scheme, and finally, the terminal device determines a final transaction confirmation result based on the different weights.
It should be noted that, in this embodiment, if the first transaction confirmation result corresponding to each target authority node is inconsistent with the second transaction confirmation result corresponding to each target non-authority 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 construction 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 or not;
in this embodiment, after detecting that each target authority node in the target blockchain calculates to obtain a calculation result, the terminal device inputs each calculation result to a 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 calculation results contain the target error calculation results, 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 the calculation results include 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 blockchain generates the transaction data.
For example, after detecting that each target authority node in the target blockchain calculates to obtain each calculation result, the terminal device inputs each calculation result to a data comparison module, and the data comparison module sequentially compares each calculation result with other calculation results to determine whether the calculation results are consistent, so as to determine whether a target error calculation result exists in each calculation result, and when detecting that the target error calculation result exists in each calculation result, the terminal device reads a built-in data recording device to determine transaction data corresponding to the transaction behavior and backtracks the transaction data to the moment when the target blockchain generates the transaction data.
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 the node refresh frequency preset by the developer.
Step D20: the target block chain is controlled to replace each target authority node according to the node refreshing frequency;
in this embodiment, the terminal device sets the target blockchain according to the node refresh frequency, so that the target blockchain randomly selects a new target authority node from the candidate nodes again according to the node refresh frequency pair.
For example, the terminal device reads the storage module to obtain the node refresh frequency stored in advance by the developer, determines that the node refresh frequency is 1h, and then sets the target blockchain to randomly select a plurality of target authoritative nodes in each candidate node based on the RPOA consensus scheme every 1 h.
In this embodiment, the terminal device inputs the obtained target consensus scheme to a blockchain construction module set 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 excitation mechanisms, and meanwhile, the terminal device detects the target blockchain through a built-in data detection module to determine whether transaction data are generated between target nodes in the target blockchain, and then, if the terminal device detects that transaction data are generated between target nodes in the target blockchain, the terminal device obtains the transaction data, invokes the target authority nodes selected by the target nodes in the target blockchain based on the identification scheme to jointly calculate the transaction data and generate corresponding calculation results, and finally, distributes the calculation results to the target authority nodes and the target non-authority nodes in the target blockchain, and determines a transaction confirmation result based on a first weight value corresponding to the target authority node and a second calculation result corresponding to the target non-authority node included in the target consensus scheme.
In this way, the invention adopts the mode of constructing the target block chain based on the target consensus scheme, and when transaction data is generated in the target block chain, all target authority nodes in the target block chain jointly calculate the calculation result corresponding to the transaction data, and all target authority nodes and all target non-authority nodes in the target block chain jointly determine the transaction confirmation result corresponding to the calculation result, thereby achieving the purposes of ensuring relatively fair and fair transaction confirmation result and reducing the centralization of the target consensus scheme.
In addition, the present invention further provides a device for constructing a consensus scheme, referring to fig. 5, fig. 5 is a schematic diagram of functional modules related to an embodiment of a method for constructing a consensus scheme of the present invention, and as shown in fig. 5, the device for constructing a consensus scheme of the present invention includes:
the node screening module 10 is configured to determine each target candidate node in the initial blockchain based on a node reputation value corresponding to each node in the initial blockchain and a preset reputation value threshold;
the first setting module 20 is configured to randomly determine each initial authority node in each target candidate node, and set a weight value of each initial authority node to be a preset first weight value;
A second setting module 30, configured to randomly determine each initial non-authoritative node among the non-target candidate nodes other than each target candidate node, and set a weight value of each initial non-authoritative node to a preset second weight value;
the consensus construction module 40 is configured to input each of the initial authoritative node, the first weight value, each of the initial non-authoritative node, and the second weight value to 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 obtaining the node reputation value corresponding to each initial node in the initial block chain;
the reputation comparison unit is used for comparing the reputation value of each node with a preset reputation value threshold value respectively to determine each target reputation value which is larger than the reputation value threshold value in the reputation value of each node;
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 proof consensus algorithm;
And the initial construction unit is used for constructing an initial blockchain based on the authority proof consensus algorithm.
Further, the consensus construction module 40 includes:
the scheme construction unit is used for inputting the initial authority nodes, the first weight values, the initial non-authority nodes and the second weight values into a preset target consensus function, combining the initial authority nodes with the first weight values by the target consensus function, and combining the initial non-authority nodes with the second weight values to construct a target consensus scheme.
Further, the consensus construction module 40 further includes:
a building detection unit for building a target blockchain based on the target consensus scheme and detecting the target blockchain to determine whether transaction data is generated in the target blockchain;
the transaction calculation unit is used for calculating the transaction data through all target authority nodes in the target blockchain to obtain all target calculation results if the transaction data are generated in the target blockchain, wherein the target authority nodes are nodes with transaction verification authority selected by all nodes of the target blockchain 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 construction module 40 further includes:
a result verification unit configured to verify each of the target calculation results to determine whether each of the target calculation results includes 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 calculation results contain the target error calculation results.
Further, the consensus construction 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 authority node according to the node refreshing frequency.
The invention also provides a terminal device, which is provided with a construction program of the consensus scheme capable of running on a processor, and the terminal device realizes the steps of the construction method of the consensus scheme according to any one of the embodiments when executing the construction program of the consensus scheme.
The specific embodiment of the terminal device of the present invention is basically the same as each embodiment of the method for constructing the above-mentioned consensus scheme, and will not be described herein.
Furthermore, the present invention provides a computer-readable storage medium, on which a construction program of a consensus scheme is stored, which when executed by a processor implements the steps of the construction method of the consensus scheme as described in any of the above embodiments.
The specific embodiments of the computer readable storage medium are basically the same as the embodiments of the method for constructing the above-mentioned consensus scheme, and are not described 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 one … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The foregoing embodiment numbers of the present invention are merely for the purpose of description, and do not represent the advantages or disadvantages of the embodiments.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium (e.g. ROM/RAM, magnetic disk, optical disk) as described above, comprising instructions for causing a terminal device (which may be a mobile phone, a computer, a server, or a network device, etc.) to perform the method according to the embodiments of the present invention.
The foregoing description is only of the preferred embodiments of the present invention, and is not intended to limit the scope of the invention, but rather is intended to cover any equivalents of the structures or equivalent processes disclosed herein or in the alternative, which may be employed directly or indirectly in other related arts.

Claims (8)

1. The construction method of the consensus scheme is characterized by comprising the following steps 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;
randomly determining each initial authority node in each target candidate node, and setting the weight value of each initial authority 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, wherein the second weight value is smaller than the first weight value;
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;
the step of inputting each of the initial authoritative node, the first weight value, each of the 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 with the first weight value by the target consensus function, and combining each initial non-authoritative node with the second weight value to construct a target consensus scheme;
Constructing a target blockchain based on the target consensus scheme, and detecting the target blockchain to determine whether transaction data is generated in the target blockchain;
if yes, calculating the transaction data through all target authority nodes in the target block chain to obtain all target calculation results, wherein the target authority nodes are nodes with transaction verification authorities selected by all nodes of the target block chain based on the target consensus scheme;
determining a transaction confirmation result corresponding to each target calculation result based on the target consensus scheme;
the step of determining a transaction confirmation result corresponding to each target calculation result based on the target consensus scheme comprises the following steps:
determining a first transaction confirmation result corresponding to each target authority node based on the target consensus function and each first weight value in the target consensus scheme, and determining a second transaction confirmation result corresponding to each target non-authority node based on the target consensus function and each second weight value;
and if the first transaction confirmation results are inconsistent with the second transaction confirmation results and the first confirmation weight value corresponding to each first transaction confirmation result is consistent with the second confirmation weight value corresponding to each second transaction confirmation result, determining that the transaction confirmation result is invalid data.
2. The method of claim 1, wherein the step of determining each target candidate node in the initial blockchain based on the node reputation value and the preset reputation value threshold value corresponding to each node in the initial blockchain comprises:
acquiring node reputation values corresponding to all initial nodes in the initial block chain;
comparing the node reputation values with preset reputation value thresholds respectively to determine target reputation values which are larger than the reputation value thresholds in the node reputation values;
and determining the initial node corresponding to each target reputation value as a target candidate node.
3. The method of claim 2, wherein prior to the step of determining each target candidate node within the initial blockchain based on the respective node reputation value for each node within the initial blockchain and a preset reputation value threshold, the method further comprises:
acquiring a preset authority proof consensus algorithm;
and constructing an initial blockchain based on the authority proof consensus algorithm.
4. The method of claim 1, wherein 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 or not;
and if the target calculation results contain the target error calculation results, backtracking the transaction data to the moment of generating the transaction data.
5. The method of constructing a consensus scheme as claimed in claim 4, wherein the method further comprises:
acquiring a preset node refreshing frequency;
and controlling the target block chain to replace each target authority node according to the node refreshing frequency.
6. 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 authority node in each target candidate node and setting the weight value of each initial authority 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, wherein the second weight value is smaller than the first weight value;
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 to construct a target consensus scheme;
the consensus construction module is further configured to input each of the initial authoritative node, the first weight value, each of the initial non-authoritative node, and the second weight value to a preset target consensus function, combine each of the initial authoritative node and the first weight value by the target consensus function, and combine each of the initial non-authoritative node and the second weight value to construct a target consensus scheme;
the consensus construction module is further used for constructing a target blockchain based on the target consensus scheme and detecting the target blockchain to determine whether transaction data are generated in the target blockchain;
if yes, calculating the transaction data through all target authority nodes in the target block chain to obtain all target calculation results, wherein the target authority nodes are nodes with transaction verification authorities selected by all nodes of the target block chain based on the target consensus scheme;
Determining a transaction confirmation result corresponding to each target calculation result based on the target consensus scheme;
the determining the transaction confirmation result corresponding to each target calculation result based on the target consensus scheme comprises the following steps:
determining a first transaction confirmation result corresponding to each target authority node based on the target consensus function and each first weight value in the target consensus scheme, and determining a second transaction confirmation result corresponding to each target non-authority node based on the target consensus function and each second weight value;
and if the first transaction confirmation results are inconsistent with the second transaction confirmation results and the first confirmation weight value corresponding to each first transaction confirmation result is consistent with the second confirmation weight value corresponding to each second transaction confirmation result, determining that the transaction confirmation result is invalid data.
7. A terminal device, characterized in that the terminal device comprises: memory, a processor and a construction program for a consensus scheme stored on the memory and executable on the processor, the construction program for a consensus scheme when executed by the processor implementing the steps of the construction method for a consensus scheme according to any of claims 1 to 5.
8. 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 according to any of the claims 1 to 5.
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 CN115374216A (en) 2022-11-22
CN115374216B true 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
CN115374216A (en) 2022-11-22

Similar Documents

Publication Publication Date Title
US10063562B1 (en) Flexible access management framework based on measuring application usage behavior
WO2021036014A1 (en) Federated learning credit management method, apparatus and device, and readable storage medium
WO2017054504A1 (en) Identity authentication method and device, and storage medium
CN108683666A (en) A kind of web page identification method and device
CN112801670B (en) Risk assessment method and device for payment operation
CN109213857A (en) A kind of fraud recognition methods and device
CN111836063A (en) Live broadcast content monitoring method and device
CN110120928A (en) A kind of identity authentication method, device, server and computer-readable medium
CN107888553A (en) A kind of verification method, server and system
EP4364009A1 (en) Preventing unauthorized access to personal data during authentication processes
CN115374216B (en) Method and device for constructing consensus scheme, terminal equipment and computer medium
CN108229133B (en) Service operation method and device and service permission obtaining method and device
CN111275188B (en) Method and device for optimizing horizontal federated learning system and readable storage medium
Cooper et al. On the use of buy up as a model of customer choice in revenue management
TWI778411B (en) Learning model application system, learning model application method and program product
US11023904B1 (en) Model for the competitive seeding of opinions in networks with hybrid gossip-threshold dynamics
CN110278241A (en) A kind of registration request processing method and processing device
CN110062023B (en) Safety education information pushing method, device and equipment
CN113239244B (en) Multi-uncertainty preference obtaining method and device based on credibility structure and electronic equipment
CN112862693B (en) Picture processing method and device
CN114237794A (en) Application available time duration display method, device, equipment and storage medium
CN114530073A (en) Training method and device based on virtual reality
CN113987328A (en) Topic recommendation method, equipment, server and storage medium
KR101580159B1 (en) Method of setting survey population, server performing the same and storage media storing the same
CN115567214A (en) Intelligent contract execution method and device, terminal equipment and computer 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