CN110113172B - Difficulty adjustment method and related equipment - Google Patents

Difficulty adjustment method and related equipment Download PDF

Info

Publication number
CN110113172B
CN110113172B CN201910355979.7A CN201910355979A CN110113172B CN 110113172 B CN110113172 B CN 110113172B CN 201910355979 A CN201910355979 A CN 201910355979A CN 110113172 B CN110113172 B CN 110113172B
Authority
CN
China
Prior art keywords
block
difficulty
time
value
target
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
CN201910355979.7A
Other languages
Chinese (zh)
Other versions
CN110113172A (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 Launch Technology Co Ltd
Original Assignee
Shenzhen Launch 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 Launch Technology Co Ltd filed Critical Shenzhen Launch Technology Co Ltd
Priority to CN201910355979.7A priority Critical patent/CN110113172B/en
Publication of CN110113172A publication Critical patent/CN110113172A/en
Application granted granted Critical
Publication of CN110113172B publication Critical patent/CN110113172B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • 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
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/04Payment circuits
    • G06Q20/06Private payment circuits, e.g. involving electronic currency used among participants of a common payment scheme
    • G06Q20/065Private payment circuits, e.g. involving electronic currency used among participants of a common payment scheme using e-cash
    • G06Q20/0652Private payment circuits, e.g. involving electronic currency used among participants of a common payment scheme using e-cash e-cash with decreasing value according to a parameter, e.g. time
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3236Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L2209/00Additional information or applications relating to cryptographic mechanisms or cryptographic arrangements for secret or secure communication H04L9/00
    • H04L2209/56Financial cryptography, e.g. electronic payment or e-cash
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/50Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using hash chains, e.g. blockchains or hash trees

Landscapes

  • Engineering & Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Accounting & Taxation (AREA)
  • Computer Security & Cryptography (AREA)
  • Strategic Management (AREA)
  • General Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Finance (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Supply And Distribution Of Alternating Current (AREA)

Abstract

The embodiment of the application discloses a difficulty adjusting method and related equipment, which are used for adjusting block development difficulty according to real-time computing power. The method in the embodiment of the application comprises the following steps: the method comprises the steps of obtaining a first block difficulty value and a first block discharging time, obtaining a second block first target difficulty value according to the first block difficulty value and the first block discharging time, obtaining real-time computing power and system computing power, computing difference of the real-time computing power and the system computing power, outputting difficulty adjusting parameters according to the computing difference and a PID algorithm formula, and computing a second block second target difficulty value according to the second block target difficulty value and the difficulty adjusting parameters. The difficulty value is correspondingly adjusted according to the change of the calculation force so as to enable the difficulty to be matched with the real-time calculation force.

Description

Difficulty adjustment method and related equipment
Technical Field
The present application relates to the field of block chains, and in particular, to a difficulty adjustment method and related device.
Background
The Block chain is a distributed storage data structure disclosed to all Block chain link points of an access server, and comprises a plurality of blocks (blocks), and during development, the difficulty target is generally the difficulty value required by the calculation power of the whole network to generate one Block approximately every 10 minutes, and the calculation power required by the verification of the generated workload is controlled by the variable of the difficulty.
Since the computation forces at different times are different in the development process, if the difficulty variable is not changed, or the direction of the change is opposite to the direction of the change of the computation force, for example, when a certain block is developed, the computation force of the whole network is lower than that of the previous block, but the difficulty is higher than that of the previous block, which brings adverse effects, in the conventional difficulty adjustment, after 2016 blocks (two weeks) are generated in the bitcoin network, the difficulty adjustment of the mathematical difficulty is performed according to the computation time and the computation force of the previous 2016 blocks, and the threshold value of the mathematical solution is increased or decreased to reduce or increase the difficulty, so that the computation time of each block is maintained in the range of about 10 minutes. However, this is an average algorithm for a long period of time, and in a specific development process, if a large factory with a high computational power exists in the development process of the previous block, when the next block is developed, the large factory will greatly increase the development time of the next block if the large factory is withdrawn, and the difficulty and the computational power cannot be corresponded in real time, which is an obvious disadvantage existing in the current difficulty adjustment method.
Content of application
The embodiment of the application discloses a difficulty adjusting method and related equipment, which are used for adjusting block development difficulty according to real-time computing power.
A first aspect of the present application provides a difficulty adjustment method applied to a block chain device, including:
acquiring a first block difficulty value and a first block outputting time;
calculating a first target difficulty value of a second block according to the first block difficulty value and the first block outputting time;
acquiring real-time computing power and system computing power;
calculating the computing power difference of the real-time computing power and the system computing power;
outputting a difficulty adjusting parameter u (t) according to the calculating force difference and a PID algorithm formula, wherein the PID algorithm formula is as follows:
Figure GDA0003458068210000021
wherein KpTo proportional gain, KiTo integrate the gain, KdIs the differential gain, t is the current time, e (t) is the calculated force difference of the current time;
and calculating a second target difficulty value of the second block according to the first target difficulty value of the second block and the difficulty adjustment parameter.
Optionally, after calculating a second target difficulty value for the second block according to the second target difficulty value for the second block and the difficulty adjustment parameter, the method further includes:
and changing the value of the system calculation force into the value of the real-time calculation force so as to adjust the difficulty of the next time into the difficulty of the previous time.
Optionally, after calculating a second target difficulty value for the second block according to the second target difficulty value for the second block and the difficulty adjustment parameter, the method further includes:
presetting a time threshold;
judging whether the time of calculating a second target difficulty value of the second block meets the time threshold value;
if the time threshold is met, the real-time computing power and the system computing power are obtained again;
calculating the computing power difference of the real-time computing power and the system computing power;
outputting difficulty adjusting parameters according to the calculation force difference and a PID algorithm formula;
and calculating a second target difficulty value of the second block according to the first target difficulty value of the second block and the difficulty adjustment parameter.
Optionally, after calculating a second target difficulty value for the second block according to the second target difficulty value for the second block and the difficulty adjustment parameter, the method further includes:
and if the second block is calculated, the loop process of re-acquiring the real-time calculation power and the system calculation power is exited.
Optionally, the formula used for calculating the first target difficulty value of the second block by the first block difficulty value and the first block output time is as follows:
Figure GDA0003458068210000022
D0≡131072
Figure GDA0003458068210000023
Figure GDA0003458068210000031
Figure GDA0003458068210000032
d is the first block of the second blockTarget difficulty value, D0Is a constant and is widely existed in the process of mining in the ether workshop,
Figure GDA0003458068210000033
the difficulty of the basis is indicated,
Figure GDA0003458068210000034
for adjusting the difficulty of block extraction, x is the difficulty value P (D) of the parent block divided by 2048 and then rounded down, HSIs the time stamp of the second block, P (H) HUIs the time stamp of the parent block and,
Figure GDA0003458068210000035
the calculation method of (2) is also an adjustment method inherent in Taifang, -99 is an adjustment method for adjusting the range of the upper block, P (H) U is the number of the tertiary blocks, y is 1 to indicate that no tertiary block exists, and y is 2 to indicate that a tertiary block exists.
The second aspect of the present application provides a difficulty adjustment system, which is applied to a blockchain device, and includes:
an obtaining unit, configured to obtain a first block difficulty value and a first block outputting time;
a calculating unit, configured to calculate a first target difficulty value of a second block according to the first block difficulty value and the first block outputting time;
the acquisition unit is also used for acquiring real-time computing power and system computing power;
the computing unit is also used for computing the computing force difference of the real-time computing force and the system computing force;
the output unit is used for outputting the difficulty adjusting parameter u (t) according to the calculation force difference and a PID algorithm formula, wherein the PID algorithm formula is as follows:
Figure GDA0003458068210000036
wherein KpTo proportional gain, KiTo integrate the gain, KdIs the differential gain, t is the current time, e (t) is the calculated force difference of the current time;
the calculating unit is further configured to calculate a second target difficulty value of the second block according to the first target difficulty value of the second block and the difficulty adjustment parameter.
Optionally, the system further comprises:
and the changing unit is used for changing the value of the system calculation force into the value of the real-time calculation force so as to enable the difficulty adjustment of the next time to be the basis of the difficulty adjustment of the previous time.
Optionally, the system further comprises:
the device comprises a presetting unit, a processing unit and a control unit, wherein the presetting unit is used for presetting a time threshold;
the judging unit is used for judging whether the time for calculating the second target difficulty value of the second block meets the time threshold value or not;
the obtaining unit is further configured to obtain the real-time computing power and the system computing power again if the time threshold is met;
the computing unit is also used for computing the computing force difference of the real-time computing force and the system computing force;
the output unit is also used for outputting difficulty adjustment parameters according to the calculation force difference and a PID algorithm formula;
the calculating unit is further configured to calculate a second target difficulty value of the second block according to the first target difficulty value of the second block and the difficulty adjustment parameter.
Optionally, the system further comprises:
and the quitting unit is used for quitting the cyclic process of reacquiring the real-time computing power and the system computing power if the second block is computed.
A third aspect of the present application provides a blockchain apparatus, comprising:
a processor, a memory, an input-output device, and a bus;
the processor, the memory and the input and output equipment are respectively connected with the bus;
the processor is configured to perform the method according to any of the preceding embodiments.
A fourth aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, characterized in that: which when executed by a processor implements the steps of the method as described in any one of the preceding embodiments.
According to the technical scheme, the embodiment of the application has the following advantages: in this embodiment, a first block difficulty value and a first block difficulty time are obtained, a first target difficulty value of a second block is obtained according to the first block difficulty value and the first block difficulty time, a real-time computing power and a system computing power are obtained, a computing power difference between the real-time computing power and the system computing power is calculated, a difficulty adjusting parameter is output according to the computing power difference and a PID algorithm formula, and a second target difficulty value of the second block is calculated according to the target difficulty value of the second block and the difficulty adjusting parameter. The difficulty value is correspondingly adjusted according to the change of the calculation force so as to enable the difficulty to be matched with the real-time calculation force.
Drawings
Fig. 1 is a schematic diagram illustrating an embodiment of a difficulty adjustment method in an embodiment of the present application;
fig. 2 is another schematic diagram of an embodiment of a difficulty adjustment method in an embodiment of the present application;
FIG. 3 is another schematic diagram illustrating an embodiment of a difficulty adjustment method according to an embodiment of the present disclosure;
FIG. 4 is another schematic diagram illustrating an embodiment of a difficulty adjustment method according to an embodiment of the present disclosure;
FIG. 5 is a diagram illustrating an embodiment of a system for difficulty adjustment according to the present disclosure;
fig. 6 is a schematic diagram of a computer device according to an embodiment of the present application.
Detailed Description
The embodiment of the application provides a difficulty adjusting method and related equipment, which are used for adjusting block development difficulty according to real-time computing power.
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only partial embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims of the present application and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that the embodiments described herein may be practiced otherwise than as specifically illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
The present application relates to a Block Chain technology, and for ease of understanding, a Block Chain (Block Chain) in the embodiments of the present application will be briefly described below, and is a data structure of distributed storage disclosed for all Block Chain nodes of an access server, and includes several blocks (blocks). The user terminal comprising the client can be registered as a blockchain node, the blockchain node and other blockchain nodes accessed to the blockchain server form a P2P network, blockchain data can be stored in the P2P network, and any one or more blockchain nodes of the P2P network are broken down, so that the blockchain data cannot be lost, and the blockchain data has strong security and can be ensured to be permanently stored and not to be tampered. When a block persists in the blockchain data, the blockchain nodes of the access server can all add the block; the blocks are added to the blockchain data one by one in a persistence time sequence, each block except the first block in the blockchain data is linked to the previous block, so that the blockchain data forms a blockchain to the block, and the block cannot be modified after being persisted to the blockchain data.
The block difficulty is used for measuring the average operation times for digging out a block, reflects how long a certain number of blocks can be dug out under certain difficulty, and is also an important reference index for miners to dig out mines. The difficulty level of data block generation is measured by the difficulty value (difficulty), which we can also simply understand as the time it takes to dig into the data block. In the existing block difficulty adjustment scheme, when a miner starts to dig a new block, a target difficulty value is determined, which may cause the following problems: if the large ore pool in the whole system is disconnected at the moment, the whole network computing power is suddenly reduced, and the target difficulty value is larger than the current state of the whole system at the moment, so that miners cannot dig out new blocks for a long time, and the system is blocked for a long time; if a large-scale mine plant newly joins the network at this moment, because the mine plant has larger calculation power than the current system, the mine plant can dig out a new block in a shorter time to obtain the reward of a thick block, then quit the network, and join again when the difficulty of the system gradually drops to a proper level, so that the mine plant can obtain more reward of miners with less energy consumption.
For convenience of understanding, a specific flow in the embodiment of the present application is described below, and referring to fig. 1, an embodiment of the method for adjusting difficulty in the embodiment of the present application includes:
101. acquiring a first block difficulty value and a first block outputting time;
specifically, since the mining process of the block chain is irreversible and each step is recorded, in the mining process of a specific block, the difficulty value and the block-out time of the previous block are used as references, the first block refers to the previous block of the block under calculation, and since the first block is developed, the difficulty value and the block-out time of the first block are both fixed values for calculating the target difficulty value of the next block to be developed.
102. Calculating a first target difficulty value of a second block according to the first block difficulty value and the first block outputting time;
specifically, after the difficulty value and the block-out time of the first block are obtained, the second block, namely the target difficulty value of the next block of the first block, can be calculated according to the existing ether house difficulty adjustment formula, and the calculation force difference in a short time is smaller because the method for adjusting the difficulty according to the change of real-time calculation force is provided, so the difficulty bomb coefficient of the difficulty adjustment formula does not exist in the adjustment formula in the scheme, and the method comprises the following steps:
Figure GDA0003458068210000061
D0≡131072
Figure GDA0003458068210000062
Figure GDA0003458068210000063
Figure GDA0003458068210000071
wherein D is a first target difficulty value of the second block to be calculated, which is an ideal difficulty value of the second block obtained according to the difficulty value of the previous block and the block time, D0Is the minimum value which can be taken by the target difficulty value, the value is a constant and is widely existed in the ore digging process of the ether mill,
Figure GDA0003458068210000072
the difficulty of the basis is indicated,
Figure GDA0003458068210000073
for adjusting the difficulty of block extraction, x is the difficulty value P (D) of the parent block divided by 2048 and then rounded down, HSIs the time stamp of the second block, P (H) HUIs the time stamp of the parent block and,
Figure GDA0003458068210000074
the calculation method of (2) is also an adjustment method of the Taifang local, 99 is to adjust the range of the block, P (H) U represents the number of the tertiary blocks, y represents no tertiary block when y is 1, and represents the tertiary block when y is 2, wherein the tertiary block means that the tertiary block is the same as the parent block pointed by the parent block of the tertiary block.
103. Acquiring real-time computing power and system computing power;
specifically, when the target difficulty value of the current block, that is, the target difficulty value of the second block, is obtained, because the computation power is a difficulty value that may be biased, for example, a large mine is dropped, the computation power of the current whole network is greatly reduced, if the difficulty value computed on the data established in the previous block, that is, the first block is maintained, the mining time of the current block is lengthened, if a mine with high computation power is on-line when the current block is developed, the mining time of the current block is shortened, and both cases make the development of the current block unfair, so the real-time computation power and the system computation power are obtained, the computation method of the real-time computation power is mainly that after the current block is developed, the total number of hash computations completed is divided by the corresponding consumed time and the system computation power, it is the computational effort required to correspond to the target difficulty value for the second block if one wants to complete the development of one block in 10 minutes.
The calculation formula of the real-time calculation force is as follows:
ct-number of hash times/time and consumption
Wherein, CtThe force is calculated in real time.
104. Calculating the computing power difference of the real-time computing power and the system computing power;
specifically, as described in the foregoing embodiment, if a large mine site is dropped or brought on line suddenly, the difference between the real-time computing power and the system computing power is increased, and the computing formula is:
e=Ct-C
wherein, CtFor real-time computing power, C is system computing power, and e is computing force difference.
105. Outputting difficulty adjusting parameters according to the calculation force difference and a PID algorithm formula;
specifically, the current computing power and the computing power difference of the block chain system can be known through the computing power difference e, and target difficulty adjustment is carried out according to the current computing power and the computing power difference. If the large-scale mining plant is disconnected, the current calculation force is smaller than the system calculation force, the calculation force difference e is a negative value, and the obtained difficulty adjustment parameter u (t) is also a negative value. As the three gain parameters in the system are all non-negative values, the mathematical property of a PID algorithm formula is combined to know that the absolute value of u (t) is larger when the calculation capacity of a lost mine plant is larger, the purpose of quickly reducing errors can be achieved, the target difficulty is quickly reduced in a block chain system, so that miners with small calculation capacity can dig out the block, and the whole system cannot be blocked. Vice versa, if a large-scale mine plant is added into the system, the current calculation force is larger than the calculation force of the system, the calculation force difference e is a positive value, and the obtained difficulty adjustment parameter u (t) is also a positive value. Because the PID formula is not changed, the higher the calculation power of the mine factory is, the higher u (t) is obtained, and the purpose of quickly reducing errors can be achieved.
The calculation formula of the difficulty adjustment parameter u (t) is as follows:
Figure GDA0003458068210000081
kp is proportional gain, Ki is integral gain, Kd is derivative gain, t or tau is present time, e (t) is the calculated force difference at present time.
The PID control is a control method, and has the greatest advantages that complex theoretical calculation is carried out without knowing an accurate mathematical model of a controlled object, and a satisfactory control effect can be obtained by taking Kp as a proportional gain, Ki as an integral gain and Kd as a differential gain through an engineering method.
106. And calculating a second target difficulty value of the second block according to the first target difficulty value of the second block and the difficulty adjustment parameter.
Specifically, the second target difficulty value of the second block is the difficulty adjustment parameter u (t) added to the first target difficulty value D of the second block, which can be understood as the updated target difficulty value after the calculation force is changed.
In this embodiment, a first block difficulty value and a first block difficulty time are obtained, a first target difficulty value of a second block is obtained according to the first block difficulty value and the first block difficulty time, a real-time computing power and a system computing power are obtained, a computing power difference between the real-time computing power and the system computing power is calculated, a difficulty adjusting parameter is output according to the computing power difference and a PID algorithm formula, and a second target difficulty value of the second block is calculated according to the target difficulty value of the second block and the difficulty adjusting parameter. The difficulty value is correspondingly adjusted according to the change of the calculation force so as to enable the difficulty to be matched with the real-time calculation force.
Based on the embodiment described in fig. 1, the present application further introduces steps after a single difficulty adjustment process, specifically referring to fig. 2, and another embodiment of a difficulty adjustment method in the embodiment of the present application includes:
201. and changing the value of the system calculation force into the value of the real-time calculation force so as to adjust the difficulty of the next time into the difficulty of the previous time.
Specifically, since the difficulty adjustment is always present in the mining process of the ether house, i.e., the development process of the block, that is, if a difficulty adjustment process is just finished, then during the difficulty adjustment process, as in the previous embodiment, there will be a real-time calculation and a system calculation, the real-time calculation power is the latest data obtained according to the Hash calculation and the consumption time in the difficulty adjustment process, the system calculation force is the ideal calculation force for completing the current ore digging process according to the difficulty value before the difficulty adjustment, and after the difficulty adjustment is finished, the real-time computing power can replace the system computing power and become a new system computing power in the next difficulty adjustment process, therefore, the whole excavation process of the ether workshop is in a loop-by-loop mode, and the difficulty adjustment is also based.
Based on the embodiment described in fig. 2, the present application further introduces steps after a single difficulty adjustment process, specifically referring to fig. 3, and another embodiment of a difficulty adjustment method in the embodiment of the present application includes:
301. presetting a time threshold;
specifically, since the difficulty adjustment exists in the whole process of mining in the ether workshop, individual time nodes need to be set to trigger, that is, the time threshold is used to indicate that if the time from the end of the previous difficulty adjustment reaches the threshold, the next difficulty adjustment process is triggered.
302. Judging whether the time of calculating a second target difficulty value of the second block meets the time threshold value;
specifically, after the difficulty adjustment process is finished, it is determined in real time whether the time distance from the time when the previous difficulty adjustment is finished satisfies a preset time threshold, and if the time distance satisfies the preset time threshold, the next difficulty adjustment process is started.
303. If the time threshold is met, the real-time computing power and the system computing power are obtained again;
304. calculating the computing power difference of the real-time computing power and the system computing power;
305. outputting difficulty adjusting parameters according to the calculation force difference and a PID algorithm formula;
306. and calculating a second target difficulty value of the second block according to the first target difficulty value of the second block and the difficulty adjustment parameter.
The function and beneficial effect of the embodiment 303-306 are substantially the same as those of the embodiment 103-106, and are not repeated here, but it should be noted that, in the process of changing the real-time computing power to the new system computing power as described in the embodiment 201, the second target difficulty value calculated according to the computing power change is changed to the new first target difficulty value of the second block in the next difficulty adjustment process, and then the calculation process described in the above embodiment is performed.
Based on the embodiment shown in fig. 3, in the present application, please refer to fig. 4 specifically for how to quit the loop process of difficulty adjustment, another embodiment of the difficulty adjustment method in the embodiment of the present application includes:
401. and if the second block is calculated, the loop process of re-acquiring the real-time calculation power and the system calculation power is exited.
Specifically, if the second block is completed, the loop process of re-acquiring the real-time computation power and the system computation power is exited, that is, if the ore excavation of the second block is finished, that is, the hash value meeting the requirement of the current block is obtained, the process of the current difficulty adjustment is exited, so that the difficulty value at the end appears in the difficulty adjustment process of the next block as the difficulty value of the first block in embodiment 101.
The method in the embodiment of the present application is introduced above, and the embodiment of the present application is described below from the perspective of a virtual device.
Referring to fig. 5, an embodiment of a difficulty adjustment system in an embodiment of the present application includes:
an obtaining unit 501, configured to obtain a first block difficulty value and a first block outputting time;
a calculating unit 502, configured to calculate a first target difficulty value of a second block according to the first block difficulty value and the first block outputting time;
the acquiring unit 501 is further configured to acquire real-time computing power and system computing power;
the calculating unit 502 is further configured to calculate a difference between the real-time computing power and the system computing power;
the output unit 503 is configured to output the difficulty adjustment parameter according to the calculation force difference and the PID algorithm formula;
the calculating unit 502 is further configured to calculate a second target difficulty value of the second block according to the first target difficulty value of the second block and the difficulty adjustment parameter.
As a preferred embodiment, the system further comprises:
a changing unit 504, configured to change the system computation force value to the real-time computation force value, so that the difficulty adjustment at the next time is based on the difficulty adjustment at the previous time.
As a preferred embodiment, the system further comprises:
a presetting unit 505 for presetting a time threshold;
a determining unit 506, configured to determine whether a time obtained by calculating the second target difficulty value of the second block satisfies the time threshold;
the obtaining unit 501 is further configured to obtain the real-time computation power and the system computation power again if the time threshold is met;
the calculating unit 502 is further configured to calculate a difference between the real-time computing power and the system computing power;
the output unit 503 is further configured to output a difficulty adjustment parameter according to the calculation force difference and a PID algorithm formula;
the calculating unit 502 is further configured to calculate a second target difficulty value of the second block according to the first target difficulty value of the second block and the difficulty adjustment parameter.
As a preferred embodiment, the system further comprises:
an exiting unit 507, configured to exit the loop process of reacquiring the real-time computation power and the system computation power if the second block computation is completed.
In this embodiment, the obtaining unit 501 is configured to obtain a first block difficulty value and a first block play time, the calculating unit 502 is configured to calculate a first target difficulty value of a second block according to the first block difficulty value and the first block play time, the obtaining unit 501 is further configured to obtain a real-time calculation power and a system calculation power, the calculating unit 502 is further configured to calculate a difference between the real-time calculation power and the system calculation power, the outputting unit 503 is configured to output a difficulty adjustment parameter according to the difference between the calculation power and a PID algorithm formula, and the calculating unit 502 is further configured to calculate a second target difficulty value of the second block according to the first target difficulty value of the second block and the difficulty adjustment parameter. The difficulty value is correspondingly adjusted according to the change of the calculation force so as to enable the difficulty to be matched with the real-time calculation force.
Referring to fig. 6, a computer device in an embodiment of the present application is described below from the perspective of a physical device, where an embodiment of the computer device in the embodiment of the present application includes:
the computing device 600 may have a relatively large difference due to different configurations or performances, and may include one or more Central Processing Units (CPUs) 601 (e.g., one or more processors) and a memory 605, where one or more applications or data are stored in the memory 605.
The memory 605 may be volatile storage or persistent storage, among other things. The program stored in the memory 605 may include one or more modules, each of which may include a sequence of instructions operating on a server. Further, the central processor 601 may be configured to communicate with the memory 605 to execute a series of instruction operations in the memory 605 on the smart terminal 600.
The computer device 600 may also include one or more power supplies 602, one or more wired or wireless network interfaces 603, one or more input-output interfaces 604, and/or one or more operating systems, such as Windows Server, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, and the like.
It should be understood that, in the various embodiments of the present application, the sequence numbers of the above steps do not mean the execution sequence, and the execution sequence of the steps should be determined by their functions and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a separate product, may be recorded in a computer-readable recording medium. Based on such understanding, the technical solution of the present application may be substantially or partially implemented in the form of a software product recorded on a recording medium, and the software product includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to perform all or part of the steps of the method according to the embodiments of the present application. And the aforementioned recording medium includes: a U-disk, a portable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, an optical disk, or other various media capable of recording program codes.
The above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions in the embodiments of the present application.

Claims (9)

1. A difficulty adjustment method is applied to block chain equipment and comprises the following steps:
acquiring a first block difficulty value and a first block outputting time;
calculating a first target difficulty value of a second block according to the first block difficulty value and the first block outputting time;
acquiring real-time computing power and system computing power;
calculating the computing power difference of the real-time computing power and the system computing power;
outputting a difficulty adjusting parameter u (t) according to the calculating force difference and a PID algorithm formula, wherein the PID algorithm formula is as follows:
Figure FDA0003458068200000011
wherein KpTo proportional gain, KiTo integrate the gain, KdIs the differential gain, t is the current time, e (t) is the calculated force difference of the current time;
and calculating a second target difficulty value of the second block according to the first target difficulty value of the second block and the difficulty adjustment parameter.
2. The method of claim 1, wherein after calculating a second target difficulty value for a second block based on the second target difficulty value for the second block and the difficulty adjustment parameter, the method further comprises:
and changing the value of the system calculation force into the value of the real-time calculation force so as to adjust the difficulty of the next time into the difficulty of the previous time.
3. The method of claim 2, wherein after calculating a second target difficulty value for a second block based on the second target difficulty value for the second block and the difficulty adjustment parameter, the method further comprises:
presetting a time threshold;
judging whether the time of calculating a second target difficulty value of the second block meets the time threshold value;
if the time threshold is met, the real-time computing power and the system computing power are obtained again;
calculating the computing power difference of the real-time computing power and the system computing power;
outputting difficulty adjusting parameters according to the calculation force difference and a PID algorithm formula;
and calculating a second target difficulty value of the second block according to the first target difficulty value of the second block and the difficulty adjustment parameter.
4. The method of claim 3, wherein after calculating a second target difficulty value for a second block based on the second target difficulty value and the difficulty adjustment parameter, the method further comprises:
and if the second block is calculated, the loop process of re-acquiring the real-time calculation power and the system calculation power is exited.
5. The method of claim 1, wherein the first block difficulty value and the first block out time are calculated as a first target difficulty value for the second block using the following formula:
Figure FDA0003458068200000028
D0≡131072
Figure FDA0003458068200000021
Figure FDA0003458068200000022
Figure FDA0003458068200000023
d is the first target difficulty value of the second block, D0Is a constant and is widely existed in the process of mining in the ether workshop,
Figure FDA0003458068200000027
the difficulty of the basis is indicated,
Figure FDA0003458068200000025
for adjusting the difficulty of block extraction, x is the difficulty value P (D) of the parent block divided by 2048 and then rounded down, HSIs the time stamp of the second block, P (H) HUIs the time stamp of the parent block and,
Figure FDA0003458068200000026
the calculation method of (C) is also an adjustment method inherent in Taifang, -99 is an adjustment method for adjusting the range of the upper block, P (H)UThe number of tertiary blocks indicates that there is no tertiary block when y is 1, and that there is a tertiary block when y is 2.
6. A difficulty adjustment system is applied to block chain equipment and comprises:
an obtaining unit, configured to obtain a first block difficulty value and a first block outputting time;
a calculating unit, configured to calculate a first target difficulty value of a second block according to the first block difficulty value and the first block outputting time;
the acquisition unit is also used for acquiring real-time computing power and system computing power;
the computing unit is also used for computing the computing force difference of the real-time computing force and the system computing force;
the output unit is used for outputting the difficulty adjusting parameter u (t) according to the calculation force difference and a PID algorithm formula, wherein the PID algorithm formula is as follows:
Figure FDA0003458068200000024
wherein KpTo proportional gain, KiTo integrate the gain, KdIs the differential gain, t is the current time, e (t) is the calculated force difference of the current time;
the calculating unit is further configured to calculate a second target difficulty value of the second block according to the first target difficulty value of the second block and the difficulty adjustment parameter.
7. The system of claim 6, further comprising:
and the changing unit is used for changing the value of the system calculation force into the value of the real-time calculation force so as to enable the difficulty adjustment of the next time to be the basis of the difficulty adjustment of the previous time.
8. A blockchain apparatus, comprising:
a processor, a memory, an input-output device, and a bus;
the processor, the memory and the input and output equipment are respectively connected with the bus;
the processor is configured to perform the method of any one of claims 1 to 4.
9. A computer-readable storage medium having stored thereon a computer program, characterized in that: the computer program when executed by a processor implementing the steps of the method according to any one of claims 1 to 4.
CN201910355979.7A 2019-04-29 2019-04-29 Difficulty adjustment method and related equipment Active CN110113172B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910355979.7A CN110113172B (en) 2019-04-29 2019-04-29 Difficulty adjustment method and related equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910355979.7A CN110113172B (en) 2019-04-29 2019-04-29 Difficulty adjustment method and related equipment

Publications (2)

Publication Number Publication Date
CN110113172A CN110113172A (en) 2019-08-09
CN110113172B true CN110113172B (en) 2022-04-15

Family

ID=67487466

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910355979.7A Active CN110113172B (en) 2019-04-29 2019-04-29 Difficulty adjustment method and related equipment

Country Status (1)

Country Link
CN (1) CN110113172B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111539817B (en) * 2020-03-06 2023-04-07 杜晓楠 Linear difficulty calculation method for preventing timestamp hijacking among blockchains, computer-readable storage medium and blockchain network
CN113450212A (en) * 2020-03-10 2021-09-28 本无链科技(深圳)有限公司 Dynamic chain matching method and system for block chain
CN112884580B (en) * 2021-02-18 2023-09-26 中国科学院计算技术研究所 Public alliance chain consensus method and system

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107078903A (en) * 2016-12-23 2017-08-18 深圳前海达闼云端智能科技有限公司 Digging ore deposit method, device and the node device of block chain
CN108011741A (en) * 2016-10-28 2018-05-08 富士通株式会社 For simulating the method and system with the block chain of test distributed network
CN108615151A (en) * 2018-04-24 2018-10-02 深圳市元征科技股份有限公司 Data processing method, block chain server and node device
CN109242484A (en) * 2018-08-09 2019-01-18 玄章技术有限公司 A kind of common recognition motivational techniques of block chain
CN109302405A (en) * 2018-10-31 2019-02-01 北京邮电大学 Industrial data detection block chain network framework and detection method based on edge calculations
CN109658076A (en) * 2018-12-17 2019-04-19 莆田市烛火信息技术有限公司 A kind of excitation regulator control system based on the block chain network for calculating power common recognition

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160117063A1 (en) * 2014-10-23 2016-04-28 rocket-fueled, Inc. Systems and methods for managing hashtags
US10771421B2 (en) * 2017-03-31 2020-09-08 Intel Corporation Systems and methods for fair information exchange using publish-subscribe with blockchain
US10762479B2 (en) * 2017-04-05 2020-09-01 Samsung Sds Co., Ltd. Method and system for processing blockchain-based real-time transaction

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108011741A (en) * 2016-10-28 2018-05-08 富士通株式会社 For simulating the method and system with the block chain of test distributed network
CN107078903A (en) * 2016-12-23 2017-08-18 深圳前海达闼云端智能科技有限公司 Digging ore deposit method, device and the node device of block chain
CN108615151A (en) * 2018-04-24 2018-10-02 深圳市元征科技股份有限公司 Data processing method, block chain server and node device
CN109242484A (en) * 2018-08-09 2019-01-18 玄章技术有限公司 A kind of common recognition motivational techniques of block chain
CN109302405A (en) * 2018-10-31 2019-02-01 北京邮电大学 Industrial data detection block chain network framework and detection method based on edge calculations
CN109658076A (en) * 2018-12-17 2019-04-19 莆田市烛火信息技术有限公司 A kind of excitation regulator control system based on the block chain network for calculating power common recognition

Also Published As

Publication number Publication date
CN110113172A (en) 2019-08-09

Similar Documents

Publication Publication Date Title
CN110113172B (en) Difficulty adjustment method and related equipment
CN108011741B (en) Method and system for simulating and testing blockchains of distributed networks
CN109973301B (en) Method and device for controlling pitch variation of wind generating set under extreme turbulent wind condition
CN111105097B (en) Dam deformation prediction system and method based on convolutional neural network
CN108880915B (en) Electric power information network safety alarm information false alarm determination method and system
CN106684885A (en) Multi-scene analysis-based reactive power optimization method for power distribution network of wind power generation set
CN112884237A (en) Power distribution network prediction auxiliary state estimation method and system
CN107273693A (en) A kind of hydrocarbon fuel mechanism simplification method
CN109214512B (en) Deep learning parameter exchange method, device, server and storage medium
CN103455842A (en) Credibility measuring method combining Bayesian algorithm and MapReduce
CN103747003A (en) Peer-to-peer botnet core node detection method and detection device
CN113191302A (en) Method and system for monitoring grassland ecology
CN112818588A (en) Optimal power flow calculation method and device for power system and storage medium
CN116931438B (en) Method, device, equipment and medium for determining parameters of speed regulator of water turbine
CN109921462A (en) A kind of new energy digestion capability appraisal procedure and system based on LSTM
CN111736593B (en) Stage mobile robot formation control method for preventing uncertain DoS attack
CN113011886A (en) Method and device for determining account type and electronic equipment
Azzolini et al. Modeling Bitcoin Protocols with Probabilistic Logic Programming.
Xu et al. Dynamic selection of mining pool with different reward sharing strategy in blockchain networks
CN116454967A (en) New energy consumption capability assessment method and device for power grid
Li et al. Predicting the Cascading Failure Propagation Path in Complex Networks Based On Attention-LSTM Neural Networks
CN115307687A (en) Slope stability monitoring method and system, storage medium and electronic equipment
Aydın et al. Networked policy gradient play in markov potential games
CN117648585B (en) Intelligent decision model generalization method and device based on task similarity
CN113890044A (en) Method and system for determining active splitting section of power grid based on branch transient energy

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