CN114036237A - Block generation method and device, storage medium and electronic equipment - Google Patents
Block generation method and device, storage medium and electronic equipment Download PDFInfo
- Publication number
- CN114036237A CN114036237A CN202111397226.6A CN202111397226A CN114036237A CN 114036237 A CN114036237 A CN 114036237A CN 202111397226 A CN202111397226 A CN 202111397226A CN 114036237 A CN114036237 A CN 114036237A
- Authority
- CN
- China
- Prior art keywords
- block
- state
- state type
- adjustment gain
- allocation rule
- 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.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
- G06F16/278—Data partitioning, e.g. horizontal or vertical partitioning
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
Landscapes
- Engineering & Computer Science (AREA)
- Databases & Information Systems (AREA)
- Theoretical Computer Science (AREA)
- Computing Systems (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
The present disclosure relates to a block generation method, apparatus, storage medium, and electronic device, the method comprising: acquiring block generation configuration information, wherein the block generation configuration information is determined based on state parameters of a block chain network; determining the storage capacity of the block according to the block generation configuration information; and packing the data to be stored in the block chain into blocks based on the block storage capacity. Since the block generation configuration information is determined based on the state parameter of the blockchain network, the above technical solution can achieve the effect of adjusting the block size according to the state of the blockchain network. For example, in the case that the block generation frequency of the blockchain network is high, the capacity of a single block can be increased, so that the block generation frequency is reduced, the input/output frequency of the node is reduced, and the performance of the blockchain network is optimized.
Description
Technical Field
The present disclosure relates to the field of block chain technologies, and in particular, to a block generation method and apparatus, a storage medium, and an electronic device.
Background
Blockchain technology is a technology that can collectively maintain a reliable database through decentralized and distrust. In the block chain network, even nodes which are not trusted with each other can conveniently verify data, and a certain consensus mechanism is relied on to achieve consistency. Therefore, the blockchain technology can obviously reduce trust cost among multiple nodes, and has wide application scenes and application values in cross-border payment, credential business and financial fields.
When building a blockchain network, relevant blockchain network parameters, such as block size, may be preset. However, such an approach may also affect the performance of the blockchain network.
Disclosure of Invention
An object of the present disclosure is to provide a block generation method, apparatus, storage medium and electronic device to solve the above related technical problems.
In order to achieve the above object, according to a first aspect of embodiments of the present disclosure, there is provided a tile generation method including:
acquiring block generation configuration information, wherein the block generation configuration information is determined based on state parameters of a block chain network;
determining the storage capacity of the block according to the block generation configuration information;
and packing the data to be stored in the block chain into blocks based on the block storage capacity.
Optionally, the obtaining the block generation configuration information includes:
acquiring state parameters of a block chain network to obtain first state parameters, wherein the first state parameters comprise one or more of transaction concurrency number, throughput, transaction success rate and response duration;
determining a first state type of the block chain network according to the first state parameter;
determining a target block capacity allocation rule based on the first state type and the incidence relation among the state type of the block chain network, the block capacity allocation rule and the adjustment gain parameter;
wherein the block generation allocation information includes the target block capacity allocation rule.
Optionally, the determining a target block capacity allocation rule based on the first state type and an association relationship among the state type of the block chain network, the block capacity allocation rule, and the adjustment gain parameter includes:
determining a plurality of candidate block capacity allocation rules corresponding to the first state type and an adjustment gain parameter corresponding to each candidate capacity allocation rule based on the first state type and the association relation;
and taking the candidate block capacity allocation rule with the maximum adjustment gain parameter as the target block capacity allocation rule.
Optionally, after the data to be stored in the block chain is packed into blocks, the method further includes:
acquiring the state parameter of the block chain network again to obtain a second state parameter;
determining a second state type of the block chain network according to the second state parameter;
calculating a target adjustment gain value according to the first state type, the second state type and the incidence relation;
and updating the adjustment gain parameters corresponding to the first state type in the association relation and the target block capacity allocation rule according to the target adjustment gain value.
Optionally, the calculating a target adjustment gain value through the first state type, the second state type, and the association relationship includes:
inquiring the incidence relation to obtain an initial adjustment gain parameter corresponding to the first state type, the first state type and an adjustment gain parameter corresponding to the target block capacity allocation rule;
calculating the target adjustment gain value r' by:
r′=Q(s,a)+α(r+γmaxQ(s′,a′)-Q(s,a))
wherein Q (s, a) is the initial adjustment gain parameter, α is a learning rate, γ is a discount rate, maxQ (s ', a ') is the adjustment gain parameter corresponding to the first state type and the target block capacity allocation rule, r is an excitation value for switching the block chain network from the first state type to the second state type, s is a description value of the first state type, and s ' is a description value of the second state type.
Optionally, the method further comprises:
based on the historical block generation configuration information acquired last time, taking a block capacity configuration rule in the historical block generation configuration information as an initial block capacity configuration rule corresponding to the first state type;
inquiring the association relation according to the initial block capacity allocation rule and the first state type to obtain initial adjustment gain parameters corresponding to the initial block capacity allocation rule and the first state type;
randomly determining a block capacity allocation rule as the target block capacity allocation rule under the condition that no historical block generation allocation information exists or the initial adjustment gain parameter is smaller than a preset threshold value;
before determining the target block capacity allocation rule based on the first state type and the association relationship among the state type of the block chain network, the block capacity allocation rule, and the adjustment gain parameter, the method further includes:
and determining that the initial adjustment gain parameter is larger than the preset threshold value.
Optionally, the method further comprises:
performing linear mapping on the state parameters of the block chain network to obtain a mapping result;
calculating a state description value of the block chain network according to the mapping result;
dividing the state description value into a plurality of range intervals, wherein each range interval corresponds to one state type of the block chain network;
the determining a first state type of the blockchain network according to the first state parameter includes:
calculating a target state description value according to the first state parameter;
and determining a first state type of the block chain network according to the range interval of the target state description value.
According to a second aspect of the embodiments of the present disclosure, there is provided a tile generating apparatus, including:
a first obtaining module, configured to obtain block generation configuration information, where the block generation configuration information is determined based on a state parameter of a block chain network;
the storage capacity determining module is used for determining the storage capacity of the block according to the block generation configuration information;
and the block packing module is used for packing the data to be stored in the block chain into blocks based on the block storage capacity.
Optionally, the first obtaining module includes:
the first obtaining submodule is used for obtaining state parameters of the block chain network to obtain first state parameters, and the first state parameters comprise one or more of transaction concurrency number, throughput, transaction success rate and response duration;
a first determining submodule, configured to determine a first state type of the blockchain network according to the first state parameter;
a second determining submodule, configured to determine a target block capacity allocation rule based on the first state type and an association relationship between the state type of the block chain network, the block capacity allocation rule, and the adjustment gain parameter;
wherein the block generation allocation information includes the target block capacity allocation rule.
Optionally, the second determining sub-module includes:
a first determining subunit, configured to determine, based on the first state type and the association relationship, a plurality of candidate block capacity allocation rules corresponding to the first state type and an adjustment gain parameter corresponding to each of the candidate block capacity allocation rules;
the first execution subunit is configured to use the candidate block size allocation rule with the largest adjustment gain parameter as the target block size allocation rule.
Optionally, the apparatus further comprises:
the second obtaining module is used for obtaining the state parameters of the block chain network again after the block packing module packs the data to be stored in the block chain into the block, so as to obtain second state parameters;
a first determining module, configured to determine a second state type of the blockchain network according to the second state parameter;
a first calculation module, configured to calculate a target adjustment gain value according to the first state type, the second state type, and the association relationship;
and the first updating module is used for updating the adjustment gain parameters corresponding to the first state type in the association relation and the target block capacity allocation rule according to the target adjustment gain value.
Optionally, the first computing module includes:
the query submodule is used for querying the association relationship to obtain an initial adjustment gain parameter corresponding to the first state type, the first state type and an adjustment gain parameter corresponding to the target block capacity allocation rule;
a first calculation sub-module for calculating the target adjustment gain value r' by:
r′=Q(s,a)+α(r+γmaxQ(s′,a′)-Q(s,a))
wherein Q (s, a) is the initial adjustment gain parameter, α is a learning rate, γ is a discount rate, maxQ (s ', a ') is the adjustment gain parameter corresponding to the first state type and the target block capacity allocation rule, r is an excitation value for switching the block chain network from the first state type to the second state type, s is a description value of the first state type, and s ' is a description value of the second state type.
Optionally, the method further comprises:
a first execution module, configured to generate configuration information based on a history block obtained last time, and use a block capacity configuration rule in the history block generation configuration information as an initial block capacity configuration rule corresponding to the first status type;
a query module, configured to query the association relationship according to the initial block capacity allocation rule and the first state type, so as to obtain an initial adjustment gain parameter corresponding to the initial block capacity allocation rule and the first state type;
a second determining module, configured to randomly determine a block capacity allocation rule as the target block capacity allocation rule when there is no history block generation allocation information or the initial adjustment gain parameter is smaller than a preset threshold;
the device further comprises:
a third determining module, configured to determine that the initial adjustment gain parameter is greater than the preset threshold before the second determining sub-module determines a target block capacity allocation rule based on the first state type and an association relationship between a state type of a block chain network, a block capacity allocation rule, and an adjustment gain parameter.
Optionally, the method further comprises:
the mapping module is used for carrying out linear mapping on the state parameters of the block chain network to obtain a mapping result;
the second calculation module is used for calculating the state description value of the block chain network according to the mapping result;
a second execution module, configured to divide the state description value into a plurality of range intervals, where each range interval corresponds to a state type of the blockchain network;
the first determination submodule includes:
the second calculation submodule is used for calculating a target state description value according to the first state parameter;
and the third determining submodule is used for determining the first state type of the block chain network according to the range interval in which the target state description value is positioned.
According to a third aspect of embodiments of the present disclosure, there is provided a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the method of any one of the above first aspects.
According to a fourth aspect of the embodiments of the present disclosure, there is provided an electronic apparatus including:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to implement the steps of the method of any of the first aspects above.
In the above technical solution, a node in the blockchain network may obtain block generation configuration information determined based on a state parameter of the blockchain network, and determine a block storage capacity according to the block generation configuration information. In this way, the node may pack the data to be uplinked according to the determined block storage capacity, thereby generating a new block. Since the block generation configuration information is determined based on the state parameter of the blockchain network, the above technical solution can achieve the effect of adjusting the block size according to the state of the blockchain network. For example, in the case that the block generation frequency of the blockchain network is high, the capacity of a single block can be increased, so that the block generation frequency is reduced, the input/output frequency of the node is reduced, and the performance of the blockchain network is optimized.
Additional features and advantages of the disclosure will be set forth in the detailed description which follows.
Drawings
The accompanying drawings, which are included to provide a further understanding of the disclosure and are incorporated in and constitute a part of this specification, illustrate embodiments of the disclosure and together with the description serve to explain the disclosure without limiting the disclosure. In the drawings:
fig. 1 is a flowchart illustrating a block generation method according to an exemplary embodiment of the disclosure.
Fig. 2 is a flowchart illustrating a block generation method according to an exemplary embodiment of the disclosure.
Fig. 3 is a flow chart illustrating the determination of status types for a blockchain network according to an exemplary embodiment of the present disclosure.
Fig. 4 is a flowchart illustrating a block generation method according to an exemplary embodiment of the disclosure.
Fig. 5 is a block diagram of a block generation apparatus according to an exemplary embodiment of the disclosure.
FIG. 6 is a block diagram of an electronic device shown in an exemplary embodiment of the present disclosure.
Detailed Description
The following detailed description of specific embodiments of the present disclosure is provided in connection with the accompanying drawings. It should be understood that the detailed description and specific examples, while indicating the present disclosure, are given by way of illustration and explanation only, not limitation.
Before introducing the block generation method, apparatus, storage medium, and electronic device provided by the present disclosure, an application scenario of the present disclosure is first introduced. The block capacity, which is a parameter index of the blockchain network, is usually preset by the developer based on experience.
The block capacity has a large impact on the performance of the blockchain network. For example, in the case of a small block capacity, a phenomenon of a fast block generation speed may occur, which may cause the related nodes of the blockchain network to frequently perform input/output operations, thereby reducing the performance of the nodes. When the block size is large, the block generation speed may be slow, which also results in a slow processing speed of related transactions. In addition, when the block capacity is large, the amount of data submitted in a single time in the accounting process is also large, so that the probability of accounting failure is increased.
To this end, the present disclosure provides a block generation method. Fig. 1 is a flowchart of a block generation method illustrated in the present disclosure, and referring to fig. 1, the method includes:
in step 11, tile generation configuration information is obtained.
Wherein the block generation configuration information is determined based on a state parameter of a block chain network. Taking the example that the method is applied to a sorting node in a federation chain, the sorting node may, for example, obtain a state parameter (such as a response duration, a concurrency number, and the like) of a block chain network, and determine the block generation configuration information according to the obtained state parameter. In some implementation scenarios, the tile generation configuration information may also be determined by other devices based on state parameters of the blockchain network. In this case, step 11 may refer to the sorting node acquiring the tile generation configuration information generated by other devices.
The block generation configuration information may include an adjustment policy of the block capacity, such as "increase the block capacity by a first target value", "decrease the block capacity by a second target value", and so on. Here, increasing the block capacity by the first target value may refer to increasing the number of transactions that can be accommodated by a single block by the first target value, and decreasing the block capacity by the second target value may refer to decreasing the number of transactions that can be accommodated by a single block by the second target value.
Thus, in step 12, the block storage capacity is determined according to the block generation configuration information.
For example, in the case that the current block storage capacity is a and the block generation configuration information includes "increase the block capacity by 10", the sorting node may determine that the new block storage capacity is a + 10. Of course, in some implementation scenarios, the block generation configuration information may also include block storage capacity information. In this case, the sorting node or other device executing the method may directly apply the chunk storage capacity in the chunk generation configuration information.
In step 13, data to be stored into the block chain is packed into blocks based on the block storage capacity.
By adopting the technical scheme, the nodes in the block chain network can acquire the block generation configuration information determined based on the state parameters of the block chain network, and determine the block storage capacity according to the block generation configuration information. In this way, the node may pack the data to be uplinked according to the determined block storage capacity, thereby generating a new block. Since the block generation configuration information is determined based on the state parameter of the blockchain network, the above technical solution can achieve the effect of adjusting the block size according to the state of the blockchain network. For example, in the case that the block generation frequency of the blockchain network is high, the capacity of a single block can be increased, so that the block generation frequency is reduced, the input/output frequency of the node is reduced, and the performance of the blockchain network is optimized.
Fig. 2 is a flowchart of a block generation method shown in this disclosure, and as shown in fig. 2, the method obtains block generation configuration information (step 11) based on fig. 1, and includes:
in S111, a state parameter of the blockchain network is obtained, and a first state parameter is obtained.
Wherein the first state parameters include one or more of transaction concurrency, throughput, transaction success rate, and response duration. In some implementation scenarios, the state parameter may also include other parameters in the blockchain network according to application requirements, which is not limited by this disclosure.
In S112, a first status type of the blockchain network is determined according to the first status parameter.
Fig. 3 is a flow chart illustrating a method for determining a status type of a blockchain network, which may be performed in some embodiments as follows.
And S31, performing linear mapping on the state parameters of the block chain network to obtain a mapping result.
Illustratively, the state parameters of the blockchain network may include transaction concurrency number, throughput, transaction success rate, and response duration. In this case, the linear mapping may be performed as follows:
wherein b is the transaction concurrency number, x1Mapping results for transaction concurrency, p is throughput, x2As a result of the mapping of throughput, k is the transaction success rate, x3As a mapping result of transaction success rate, t is response time length, x4Is the mapping result of the response time length.
And S32, calculating the state description value of the block chain network according to the mapping result.
Illustratively, a linear regression algorithm may be employed, mapping the result x1、x2、x3、x4The state descriptive value is calculated. For example, a function f (x) may be defined, which is expressed as follows:
wherein b is a constant term. Then, based on the gradient descent method, w can be obtained1、w2、w3、w4The value of (c). Here, a loss function J (w) is definedi):
Wherein, f (x)i) Can be calculated based on the expression of the linear mapping and the expression of f (x), yiIn order to characterize the system parameters of the block size of the blockchain network, one transaction concurrency number, throughput, transaction success rate and response duration may be correspondingly stored for each group in the blockchain systemY isiThe value is obtained.
Then, the partial derivative of w may be taken,
thus, w can be calculated by combining equations (1), (2) and (3)iTo obtain f (x) and x1、x2、x3、x4A linear relationship therebetween.
In some implementation scenarios, a Sigmoid function may be further used to normalize f (x) to obtain a state description value f (x)'.
S33, dividing the state description value into a plurality of range intervals, wherein each range interval corresponds to a state type of the blockchain network.
As an example, the state type S of the blockchain network is related to the state description value f (x)' as follows:
said determining a first state type of the blockchain network from the first state parameter (S112) comprises:
and calculating a target state description value according to the first state parameter, and determining a first state type of the block chain network according to a range interval in which the target state description value is positioned.
Please refer to the above description about S32 for the calculation of the target state descriptor, which is not repeated herein.
S113, determining a target block capacity allocation rule based on the first state type and the association relationship between the state type of the block chain network, the block capacity allocation rule, and the adjustment gain parameter.
In some possible embodiments, the block generation configuration information may further include an expiration period of the target block capacity allocation rule, and the like, which is not limited in this disclosure.
In a possible implementation manner, the determining a target block capacity allocation rule based on the first status type and an association relationship between the status type of the blockchain network, the block capacity allocation rule, and the adjustment gain parameter (S113) includes:
determining a plurality of candidate block capacity allocation rules corresponding to the first state type and an adjustment gain parameter corresponding to each candidate capacity allocation rule based on the first state type and the association relation;
and taking the candidate block capacity allocation rule with the maximum adjustment gain parameter as the target block capacity allocation rule.
TABLE 1
Table 1 shows the state type S, block capacity allocation rule A, and adjustment gain parameter Q (i.e., the parameter of the block chain network) of a block chain network exemplary of the present disclosurem∈[1,5],n∈[1,11]And m and n are positive integers). Wherein, Q valueCan be used to describe the excitation obtained after adopting a certain block capacity allocation rule under a certain block chain state,larger means that the block capacity allocation rule is adopted to be beneficial to the block chain state,smaller represents a detrimental block chaining behavior using this block size allocation rule.
An embodiment of step S113 will be described with reference to table 1. Assuming that the first status type is type 0, the block capacity allocation rule corresponding to type 0 includes five types, i.e., -10, -5, 0, 5, and 10, and their respective corresponding Q values areAndthus, can selectAndthe block capacity allocation rule corresponding to the largest one of the target block capacity allocation rules is used as the target block capacity allocation rule. In this way, greater incentives can be obtained by applying the target block capacity allocation rules.
By adopting the technical scheme, the nodes in the block chain network can acquire the block generation configuration information determined based on the state parameters of the block chain network, and determine the block storage capacity according to the block generation configuration information. In this way, the node may pack the data to be uplinked according to the determined block storage capacity, thereby generating a new block. The block generation configuration information is determined based on the state parameters of the blockchain network, so the technical scheme can achieve the effects of adjusting the block size and optimizing the blockchain network according to the state of the blockchain network.
Fig. 4 is a flowchart of a block generation method shown in this disclosure, and as shown in fig. 4, after the step of packing data to be stored in a block chain into blocks (step 13), the method further includes:
and S14, acquiring the state parameter of the block chain network again to obtain a second state parameter. The second status parameters include one or more of transaction concurrency, throughput, transaction success rate, and response duration.
S15, determining the second state type of the block chain network according to the second state parameter.
Please refer to the description of the embodiment in fig. 3 for a method for determining a status type of a blockchain network according to a status parameter, which is not described herein again for brevity of the description.
And S16, calculating a target adjusting gain value according to the first state type, the second state type and the incidence relation.
In one possible embodiment, the target adjustment gain value may be calculated by:
inquiring the incidence relation to obtain an initial adjustment gain parameter corresponding to the first state type, the first state type and an adjustment gain parameter corresponding to the target block capacity allocation rule;
calculating the target adjustment gain value r' by:
r′=Q(s,a)+α(r+γmaxQ(s′,a′)-Q(s,a))
wherein Q (s, a) is the initial adjustment gain parameter, α is a learning rate, γ is a discount rate, and the learning rate and the discount rate can be set according to application requirements in specific implementation. For example, in the example of table 1, the learning rate may be preset to 0.15, and the discount rate may be preset to 0.965. maxQ (s ', a') is the adjustment gain parameter corresponding to the first state type and the target block capacity allocation rule, r is the excitation value for switching the block chain network from the first state type to the second state type, s isA description value, s, of said first state type′Is a descriptive value of the second state type.
Taking table 1 as an example, if the first state type is 0, the initial adjustment gain parameter corresponding to the first state typeThe target block size allocation rule is-10 (corresponding to) And the second state type is 5. Then:
and S17, updating the adjustment gain parameter corresponding to the first state type and the target block capacity allocation rule in the association relationship according to the target adjustment gain value.
By adopting the technical scheme, the capacity value of the block can be dynamically adjusted according to the state of the block chain network in the operation process of the block chain network, so that the problem of poor performance of the block chain network caused by setting the capacity value of the block by manual experience in the related art is solved. In addition, after the block capacity is adjusted, the adjustment result can be continuously monitored, the adjustment gain is calculated, and the adjustment gain parameters in the association relationship are continuously updated through the adjustment gain obtained through calculation. In this way, the accuracy of block capacity control decisions can be improved.
The generation flow of the association relationship is exemplified below, and in some implementation scenarios, the association relationship may be in an initial state, for example, each adjustment gain parameter in the association relationship is 0.
In this case, the method further includes:
and based on the historical block generation configuration information acquired last time, taking a block capacity configuration rule in the historical block generation configuration information as an initial block capacity configuration rule corresponding to the first state type.
And inquiring the association relation according to the initial block capacity allocation rule and the first state type to obtain initial adjustment gain parameters corresponding to the initial block capacity allocation rule and the first state type.
It should be noted that the status type of the current blockchain network may be obtained by adjusting the blockchain network in response to the previous block capacity allocation rule, and thus changing the current blockchain network. Therefore, the initial block capacity allocation rule in the previous historical block generation allocation information and the first state type can be used for querying the association relationship to obtain the initial adjustment gain parameter of the first state type.
And then, under the condition that no historical block generation configuration information exists or the initial adjustment gain parameter is smaller than a preset threshold value, randomly determining a block capacity configuration rule as the target block capacity configuration rule.
It should be noted that, if there is no history block generation configuration information or the initial adjustment gain parameter is smaller than a preset threshold, it may be determined that the association is in an initial state, and at this time, the reference value of the adjustment gain parameter in the association is low. Therefore, the block size allocation rule can be randomly determined as the target block size allocation rule.
When the initial adjustment gain parameter is smaller than the preset threshold value, the reference value of the adjustment gain parameter in the incidence relation is low. Therefore, in a possible embodiment, before determining the target block capacity allocation rule based on the first state type and the association relationship between the state type of the blockchain network, the block capacity allocation rule, and the adjustment gain parameter, the method further includes:
and determining that the initial adjustment gain parameter is larger than the preset threshold value.
According to the technical scheme, the incidence relation among the state types of the block chain networks, the block capacity allocation rules and the adjustment gain parameters is constructed, so that the block capacity control of the current block chain network can be decided based on the incidence relation and the state of the block chain network. In this way, the performance of the blockchain network is improved.
Based on the same inventive concept, the present disclosure also provides a block generation apparatus. Fig. 5 is a block diagram of a tile generation apparatus shown in the present disclosure, and referring to fig. 5, the apparatus 500 includes:
a first obtaining module 501, configured to obtain block generation configuration information, where the block generation configuration information is determined based on a state parameter of a block chain network;
a storage capacity determining module 502, configured to determine a block storage capacity according to the block generation configuration information;
a block packing module 503, configured to pack data to be stored in the block chain into blocks based on the block storage capacity.
In the above technical solution, a node in the blockchain network may obtain block generation configuration information determined based on a state parameter of the blockchain network, and determine a block storage capacity according to the block generation configuration information. In this way, the node may pack the data to be uplinked according to the determined block storage capacity, thereby generating a new block. Since the block generation configuration information is determined based on the state parameter of the blockchain network, the above technical solution can achieve the effect of adjusting the block size according to the state of the blockchain network. For example, in the case that the block generation frequency of the blockchain network is high, the capacity of a single block can be increased, so that the block generation frequency is reduced, the input/output frequency of the node is reduced, and the performance of the blockchain network is optimized.
Optionally, the first obtaining module includes:
the first obtaining submodule is used for obtaining state parameters of the block chain network to obtain first state parameters, and the first state parameters comprise one or more of transaction concurrency number, throughput, transaction success rate and response duration;
a first determining submodule, configured to determine a first state type of the blockchain network according to the first state parameter;
a second determining submodule, configured to determine a target block capacity allocation rule based on the first state type and an association relationship between the state type of the block chain network, the block capacity allocation rule, and the adjustment gain parameter;
wherein the block generation allocation information includes the target block capacity allocation rule.
Optionally, the second determining sub-module includes:
a first determining subunit, configured to determine, based on the first state type and the association relationship, a plurality of candidate block capacity allocation rules corresponding to the first state type and an adjustment gain parameter corresponding to each of the candidate block capacity allocation rules;
the first execution subunit is configured to use the candidate block size allocation rule with the largest adjustment gain parameter as the target block size allocation rule.
Optionally, the apparatus further comprises:
the second obtaining module is used for obtaining the state parameters of the block chain network again after the block packing module packs the data to be stored in the block chain into the block, so as to obtain second state parameters;
a first determining module, configured to determine a second state type of the blockchain network according to the second state parameter;
a first calculation module, configured to calculate a target adjustment gain value according to the first state type, the second state type, and the association relationship;
and the first updating module is used for updating the adjustment gain parameters corresponding to the first state type in the association relation and the target block capacity allocation rule according to the target adjustment gain value.
Optionally, the first computing module includes:
the query submodule is used for querying the association relationship to obtain an initial adjustment gain parameter corresponding to the first state type, the first state type and an adjustment gain parameter corresponding to the target block capacity allocation rule;
a first calculation sub-module for calculating the target adjustment gain value r' by:
r′=Q(s,a)+α(r+γmaxQ(s′,a′)-Q(s,a))
wherein Q (s, a) is the initial adjustment gain parameter, α is a learning rate, γ is a discount rate, maxQ (s ', a ') is the adjustment gain parameter corresponding to the first state type and the target block capacity allocation rule, r is an excitation value for switching the block chain network from the first state type to the second state type, s is a description value of the first state type, and s ' is a description value of the second state type.
Optionally, the method further comprises:
a first execution module, configured to generate configuration information based on a history block obtained last time, and use a block capacity configuration rule in the history block generation configuration information as an initial block capacity configuration rule corresponding to the first status type;
a query module, configured to query the association relationship according to the initial block capacity allocation rule and the first state type, so as to obtain an initial adjustment gain parameter corresponding to the initial block capacity allocation rule and the first state type;
a second determining module, configured to randomly determine a block capacity allocation rule as the target block capacity allocation rule when there is no history block generation allocation information or the initial adjustment gain parameter is smaller than a preset threshold;
the device further comprises:
a third determining module, configured to determine that the initial adjustment gain parameter is greater than the preset threshold before the second determining sub-module determines a target block capacity allocation rule based on the first state type and an association relationship between a state type of a block chain network, a block capacity allocation rule, and an adjustment gain parameter.
Optionally, the method further comprises:
the mapping module is used for carrying out linear mapping on the state parameters of the block chain network to obtain a mapping result;
the second calculation module is used for calculating the state description value of the block chain network according to the mapping result;
a second execution module, configured to divide the state description value into a plurality of range intervals, where each range interval corresponds to a state type of the blockchain network;
the first determination submodule includes:
the second calculation submodule is used for calculating a target state description value according to the first state parameter;
and the third determining submodule is used for determining the first state type of the block chain network according to the range interval in which the target state description value is positioned.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
According to a third aspect of embodiments of the present disclosure, there is provided a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the method of any one of the above first aspects.
According to a fourth aspect of the embodiments of the present disclosure, there is provided an electronic apparatus including:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to implement the steps of the method of any of the first aspects above.
Fig. 6 is a block diagram illustrating an electronic device 600 according to an example embodiment. As shown in fig. 6, the electronic device 600 may include: a processor 601 and a memory 602. The electronic device 600 may also include one or more of a multimedia component 603, an input/output (I/O) interface 604, and a communications component 605.
The processor 601 is configured to control the overall operation of the electronic device 600, so as to complete all or part of the steps in the block generation method. The memory 602 is used to store various types of data to support operation at the electronic device 600, such as instructions for any application or method operating on the electronic device 600 and application-related data, such as contact data, transmitted and received messages, pictures, audio, video, and so forth. The Memory 602 may be implemented by any type of volatile or non-volatile Memory device or combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic Memory, flash Memory, magnetic disk or optical disk. The multimedia components 603 may include a screen and audio components. Wherein the screen may be, for example, a touch screen and the audio component is used for outputting and/or inputting audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may further be stored in the memory 602 or transmitted through the communication component 605. The audio assembly also includes at least one speaker for outputting audio signals. The I/O interface 604 provides an interface between the processor 601 and other interface modules, such as a keyboard, mouse, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 605 is used for wired or wireless communication between the electronic device 600 and other devices. Wireless Communication, such as Wi-Fi, bluetooth, Near Field Communication (NFC), 2G, 3G, 4G, NB-IOT, eMTC, or other 5G, etc., or a combination of one or more of them, which is not limited herein. The corresponding communication component 605 may therefore include: Wi-Fi module, Bluetooth module, NFC module, etc.
In an exemplary embodiment, the electronic Device 600 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components for performing the block generating method.
In another exemplary embodiment, there is also provided a computer readable storage medium including program instructions which, when executed by a processor, implement the steps of the block generation method described above. For example, the computer readable storage medium may be the memory 602 described above that includes program instructions that are executable by the processor 601 of the electronic device 600 to perform the block generation method described above.
In another exemplary embodiment, a computer program product is also provided, which comprises a computer program executable by a programmable apparatus, the computer program having code portions for performing the above-described block generation method when executed by the programmable apparatus.
The preferred embodiments of the present disclosure are described in detail with reference to the accompanying drawings, however, the present disclosure is not limited to the specific details of the above embodiments, and various simple modifications may be made to the technical solution of the present disclosure within the technical idea of the present disclosure, and these simple modifications all belong to the protection scope of the present disclosure.
It should be noted that, in the foregoing embodiments, various features described in the above embodiments may be combined in any suitable manner, and in order to avoid unnecessary repetition, various combinations that are possible in the present disclosure are not described again.
In addition, any combination of various embodiments of the present disclosure may be made, and the same should be considered as the disclosure of the present disclosure, as long as it does not depart from the spirit of the present disclosure.
Claims (10)
1. A block generation method, comprising:
acquiring block generation configuration information, wherein the block generation configuration information is determined based on state parameters of a block chain network;
determining the storage capacity of the block according to the block generation configuration information;
and packing the data to be stored in the block chain into blocks based on the block storage capacity.
2. The method of claim 1, wherein the obtaining the block generation configuration information comprises:
acquiring state parameters of a block chain network to obtain first state parameters, wherein the first state parameters comprise one or more of transaction concurrency number, throughput, transaction success rate and response duration;
determining a first state type of the block chain network according to the first state parameter;
determining a target block capacity allocation rule based on the first state type and the incidence relation among the state type of the block chain network, the block capacity allocation rule and the adjustment gain parameter;
wherein the block generation allocation information includes the target block capacity allocation rule.
3. The method of claim 2, wherein determining a target block capacity allocation rule based on the first status type and an association relationship between a status type of a blockchain network, a block capacity allocation rule, and an adjustment gain parameter comprises:
determining a plurality of candidate block capacity allocation rules corresponding to the first state type and an adjustment gain parameter corresponding to each candidate capacity allocation rule based on the first state type and the association relation;
and taking the candidate block capacity allocation rule with the maximum adjustment gain parameter as the target block capacity allocation rule.
4. The method of claim 2, wherein after the packing the data to be stored into the block chain into blocks, further comprising:
acquiring the state parameter of the block chain network again to obtain a second state parameter;
determining a second state type of the block chain network according to the second state parameter;
calculating a target adjustment gain value according to the first state type, the second state type and the incidence relation;
and updating the adjustment gain parameters corresponding to the first state type in the association relation and the target block capacity allocation rule according to the target adjustment gain value.
5. The method of claim 4, wherein calculating a target adjustment gain value from the first state type, the second state type, and the association comprises:
inquiring the incidence relation to obtain an initial adjustment gain parameter corresponding to the first state type, the first state type and an adjustment gain parameter corresponding to the target block capacity allocation rule;
calculating the target adjustment gain value r' by:
r′=Q(s,a)+α(r+γmaxQ(s′,a′)-Q(s,a))
wherein Q (s, a) is the initial adjustment gain parameter, α is a learning rate, γ is a discount rate, maxQ (s ', a ') is the adjustment gain parameter corresponding to the first state type and the target block capacity allocation rule, r is an excitation value for switching the block chain network from the first state type to the second state type, s is a description value of the first state type, and s ' is a description value of the second state type.
6. The method of claim 2, further comprising:
based on the historical block generation configuration information acquired last time, taking a block capacity configuration rule in the historical block generation configuration information as an initial block capacity configuration rule corresponding to the first state type;
inquiring the association relation according to the initial block capacity allocation rule and the first state type to obtain initial adjustment gain parameters corresponding to the initial block capacity allocation rule and the first state type;
randomly determining a block capacity allocation rule as the target block capacity allocation rule under the condition that no historical block generation allocation information exists or the initial adjustment gain parameter is smaller than a preset threshold value;
before determining the target block capacity allocation rule based on the first state type and the association relationship among the state type of the block chain network, the block capacity allocation rule, and the adjustment gain parameter, the method further includes:
and determining that the initial adjustment gain parameter is larger than the preset threshold value.
7. The method of claim 2, further comprising:
performing linear mapping on the state parameters of the block chain network to obtain a mapping result;
calculating a state description value of the block chain network according to the mapping result;
dividing the state description value into a plurality of range intervals, wherein each range interval corresponds to one state type of the block chain network;
the determining a first state type of the blockchain network according to the first state parameter includes:
calculating a target state description value according to the first state parameter;
and determining a first state type of the block chain network according to the range interval of the target state description value.
8. A block generation apparatus, comprising:
a first obtaining module, configured to obtain block generation configuration information, where the block generation configuration information is determined based on a state parameter of a block chain network;
the storage capacity determining module is used for determining the storage capacity of the block according to the block generation configuration information;
and the block packing module is used for packing the data to be stored in the block chain into blocks based on the block storage capacity.
9. A non-transitory computer readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 7.
10. An electronic device, comprising:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to carry out the steps of the method of any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111397226.6A CN114036237A (en) | 2021-11-23 | 2021-11-23 | Block generation method and device, storage medium and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111397226.6A CN114036237A (en) | 2021-11-23 | 2021-11-23 | Block generation method and device, storage medium and electronic equipment |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114036237A true CN114036237A (en) | 2022-02-11 |
Family
ID=80138451
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111397226.6A Pending CN114036237A (en) | 2021-11-23 | 2021-11-23 | Block generation method and device, storage medium and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114036237A (en) |
-
2021
- 2021-11-23 CN CN202111397226.6A patent/CN114036237A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110457912B (en) | Data processing method and device and electronic equipment | |
US11379271B2 (en) | Parallel processing on data processing servers through even division of data records | |
EP4002795A1 (en) | Trust scoring of network entities in networks | |
CN110262827B (en) | Incremental updating method and device, storage medium and electronic equipment | |
CN110414567A (en) | Data processing method, device and electronic equipment | |
CN112231742B (en) | Model joint training method and device based on privacy protection | |
WO2019199769A1 (en) | Cyber chaff using spatial voting | |
GB2572537A (en) | Generating or obtaining an updated neural network | |
CN112307477A (en) | Code detection method, device, storage medium and terminal | |
CN113011210B (en) | Video processing method and device | |
CN114185860B (en) | Collusion attack resistant data sharing method and device and electronic equipment | |
CN111866101A (en) | Access request processing method and device, storage medium and electronic equipment | |
CN109218211B (en) | Method, device and equipment for adjusting threshold value in control strategy of data stream | |
CN115115004A (en) | Decision tree model construction and application method, device and related equipment | |
US20240256677A1 (en) | Comparative real-time end-to-end security vulnerabilities determination and visualization | |
CN114036237A (en) | Block generation method and device, storage medium and electronic equipment | |
CN116150249B (en) | Table data export method, apparatus, electronic device and computer readable medium | |
CN117349671A (en) | Model training method and device, storage medium and electronic equipment | |
CN111338607A (en) | Method and device for selecting service data for testing and electronic equipment | |
CN109492759B (en) | Neural network model prediction method, device and terminal | |
CN115481440A (en) | Data processing method, device, electronic equipment and medium | |
CN111542052B (en) | Group trust degree-based data forwarding method and device in Internet of things | |
CN111176830B (en) | Information flow distribution method, device and server system | |
Fan et al. | Dynamic regret of randomized online service caching in edge computing | |
CN109344049B (en) | Method and apparatus for testing a data processing system |
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 |