Block chain automatic grouping method and device and computer readable storage medium
1. An automatic grouping method for a block chain, comprising:
determining at least two different Nth-level service information blocks according to a preset Nth-level service matching relationship; wherein N is an integer greater than or equal to 1;
sequentially matching each newly added service information block meeting a preset N +1 level service matching relationship with one of the at least two N level service information blocks to form the newly added service information block into an N +1 level service information block;
and according to the newly added sequence, connecting a plurality of N + 1-level service information blocks which meet the same N + 1-level service matching relationship in series to form the same service chain.
2. The method of claim 1, further comprising:
and if the newly added service information block does not meet the preset N +1 level service matching relationship, classifying the newly added service information block as a new N level service information block.
3. The method according to claim 1 or 2, further comprising, after the step of determining at least two different nth level service information blocks according to a preset nth level service matching relationship:
and connecting a plurality of Nth-level service information blocks in series to form the same service chain.
4. The method according to claim 1 or 2, characterized in that:
in the same service chain, the hash values of any two adjacent service information blocks are continuous.
5. The method according to claim 1 or 2, characterized in that:
the heights of all the service information blocks are superposed according to the uplink time sequence.
6. The method of claim 1, wherein:
the determining factors of each business matching relationship include but are not limited to: region information, service type, identity information.
7. The method of claim 2, wherein:
the matching relation between the Nth-level service information block and the corresponding (N + 1) th-level service information block is unique.
8. The method of claim 7, wherein after the step of grouping the newly added service information blocks that do not satisfy all the preset N +1 th-level service matching relationships into a new nth-level service information block, the method further comprises:
and adding a service matching relation corresponding to the new Nth-level service information block.
9. An automatic grouping device for a block chain, comprising:
the Nth-level matching unit is configured to determine at least two different Nth-level service information blocks according to a preset Nth-level service matching relationship; wherein N is an integer greater than or equal to 1;
an N + 1-th-level matching unit configured to sequentially match each newly added service information block satisfying a preset N + 1-th-level service matching relationship with one of the at least two nth-level service information blocks, so that the newly added service information block is formed as an N + 1-th-level service information block;
and the N + 1-level service chain forming unit is configured to connect a plurality of N + 1-level service information blocks which meet the same N + 1-level service matching relationship in series according to the newly added sequence to form the same service chain.
10. A computer-readable storage medium, having stored thereon a computer program which, when executed, performs the steps of the blockchain automatic grouping method of any one of claims 1 to 8.
Background
In a conventional blockchain, hash values of each of a public chain, a federation chain and a private chain are continuous, and hash values are continuous between chains and between a lower chain and an upper chain.
Due to the traditional chain structure, in a multi-chain block chain environment, blocks which are not related to a service scene are often chained together, which causes that the retrieval efficiency of a specific block and related blocks thereof is low, and the block height effect is reduced; at the same time, additional resources are required to be provided by the system to mask irrelevant user information.
As can be known from the link structure of the conventional block chain, as shown in fig. 1, taking "foshan city chain" as an example, the service information blocks in the chain are sorted by time sequence, wherein the social security service information block is linked up at the earliest so that the social security service information block is ranked first; the chain of service information blocks of the education office is linked last, so the lines are ranked last and are all arranged on one chain spaciously.
As can be seen, there is no clearly visible business relationship, and the business information blocks including office, home and individual are chaotic. Once the data volume is large and the business information query is needed, a lot of time is spent on retrieval, and the structure is difficult to provide flexible and rapid business statistical capability and support the development and application development of various business scenes.
Disclosure of Invention
The invention aims to provide a block chain automatic chaining method, which can clearly and orderly combine data blocks and services.
In order to achieve the purpose, the invention provides the following technical scheme:
the embodiment of the invention provides an automatic block chain grouping method, which comprises the following steps:
determining at least two different Nth-level service information blocks according to a preset Nth-level service matching relationship; wherein N is an integer greater than or equal to 1;
sequentially matching each newly added service information block meeting a preset N +1 level service matching relationship with one of the at least two N level service information blocks to form the newly added service information block into an N +1 level service information block;
and according to the newly added sequence, connecting a plurality of N + 1-level service information blocks which meet the same N + 1-level service matching relationship in series to form the same service chain.
Further, still include: and if the newly added service information block does not meet the preset N +1 level service matching relationship, classifying the newly added service information block as a new N level service information block.
Further, after the step of determining at least two different nth-level service information blocks according to the preset nth-level service matching relationship, the method further includes: and connecting a plurality of Nth-level service information blocks in series to form the same service chain.
Preferably, in the same service chain, the hash values of any two adjacent service information blocks are consecutive.
Preferably, the heights of all the service information blocks are overlapped according to the uplink time sequence.
Optionally, the determining factor of each business matching relationship includes but is not limited to: region information, service type, identity information.
Preferably, the nth level service information block has a unique service matching relationship with the corresponding N +1 level service information block.
Further, after the step of classifying a newly added service information block that does not satisfy all preset N + 1-th level service matching relationships as a new nth level service information block, the method further includes: and adding a service matching relation corresponding to the new Nth-level service information block.
An embodiment of the present invention further provides an automatic block chain grouping device, which includes:
the Nth-level matching unit is configured to determine at least two different Nth-level service information blocks according to a preset Nth-level service matching relationship; wherein N is an integer greater than or equal to 1;
an N + 1-th-level matching unit configured to sequentially match each newly added service information block satisfying a preset N + 1-th-level service matching relationship with one of the at least two nth-level service information blocks, so that the newly added service information block is formed as an N + 1-th-level service information block;
and the N + 1-level service chain forming unit is configured to connect a plurality of N + 1-level service information blocks which meet the same N + 1-level service matching relationship in series according to the newly added sequence to form the same service chain.
The embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed, implements the steps of the block chain automatic grouping method described in any one of the above.
Compared with the prior art, the scheme of the invention has the following advantages:
the automatic block chain grouping method enables different service block information to be classified and form service chains respectively through the preset service matching relation, can effectively support the storage of the service information of various industries through the flexible expansion and combination of the service chains, and enables the blocks to be clearly and orderly combined with the services.
The block chain automatic grouping device of the present invention has the same beneficial effects as the block chain automatic grouping method, and details are not repeated herein.
Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention.
Drawings
The foregoing and/or additional aspects and advantages of the present invention will become apparent and readily appreciated from the following description of the embodiments, taken in conjunction with the accompanying drawings of which:
FIG. 1 is a diagram illustrating a blockchain grouping method according to an embodiment of the prior art;
FIG. 2 is a flowchart illustrating an exemplary method for automatically grouping blockchains according to an embodiment of the present invention;
FIG. 3 is a diagram illustrating an embodiment of a method for automatically grouping blockchains according to the present invention;
fig. 4 is a schematic diagram of an automatic block chain grouping apparatus according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the 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 invention.
In some of the flows described in the present specification and claims and in the above figures, a number of operations are included which occur in a particular order, but it should be clearly understood that these operations may be performed out of order or in parallel as they occur herein, the order of the operations being numbered 11, 12, etc. merely to distinguish between various operations, the order of which does not represent any order of performance by itself. Additionally, the flows may include more or fewer operations, and the operations may be performed sequentially or in parallel. It should be noted that the descriptions of "first", "second", and the like, which may be presented herein, are used for distinguishing different messages, devices, modules, units, and the like, and do not represent a sequential order, nor limit the types of "first" and "second" to be different.
In the description herein, references to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., mean that a particular method, feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
Referring to fig. 2, the present invention provides an automatic block chain grouping method, which includes the following steps:
step S11: determining at least two different Nth-level service information blocks according to a preset Nth-level service matching relationship;
step S12: and sequentially matching each newly added service information block meeting the preset N +1 level service matching relationship with one of the at least two N level service information blocks so as to form the newly added service information block into an N +1 level service information block.
Before building a block chain, the service information needs to be blocked, usually one service information forming one block. It should be noted that the business is a general term and may refer to different objects, for example, the population of Guangdong province may be divided into one business, and correspondingly, the total number of the population of the Guangdong province is one business information; similarly, the population total of each city such as Guangzhou city, Foshan city, Shenzhen city, etc. can also be divided into different business information. For another example, the social security information of a company is a business information, and the social security information of each employee in the company can also be classified into different business information. Other service information can be analogized, and is not described herein. Typically, specific traffic information may be established by the user who established the blockchain.
As can be seen from the description of the background art, in a multi-chain blockchain environment, when there are many service information blocks and the fields or layers related to the service information blocks are complicated, if all the service information blocks are uplinked according to the link grouping method of the conventional blockchain, the retrieval efficiency is reduced, and resource waste is caused. Therefore, different service information needs to be divided, and uplink is performed according to the divided service information blocks.
As illustrated below in connection with fig. 3. Specifically, in order to divide different service information, different service information blocks need to be classified, and each service information block can be divided into different levels, that is, an nth level service information block and an N +1 th level service information block, according to a range covered by the service information, where N is greater than or equal to 1 and N is an integer, and the specific number of levels is determined according to the range covered by the service information. The service information blocks between different levels may be associated, and therefore a service matching relationship needs to be set for the service information blocks between different levels having the association, that is, the nth level service information block is matched with the (N + 1) th level service information block, and the service matching relationship may be manually set or may be automatically set by a computer according to the service information.
Referring to fig. 3, it is assumed that there is a "foshan city service information block" system (not shown in the figure) which includes a "social security service information block", "education office service information block", "traffic office service information block", and a home social security service information block, a home education service information block, a home traffic service information block, etc. of individuals such as zhang san, lie si, wang. Setting the service matching relationship may be considered from the following aspects: the region information, because other service information blocks except the 'Buddha mountain business information block' are all in the range covered by the 'Buddha mountain business information block', the 'social security service information block', 'education office service information block' and 'traffic office service information block' can be divided into a level 1 service information block according to the region information; the service types, for example, under the "social security service information block", include the social security service information of thousands of families in foshan city, so that the social security service information blocks of all the families can be matched to the "social security service information block", to form a level 2 service information block, such as a "zhang third family social security service information block" (zhang third is the household owner of the family or a member in the family, and so on), a "li fourth family social security service information block", a "wang fifth family social security service block", and so on, and others such as an "education office service information block" and a "traffic office service information block", and so on; the identity information further comprises personal social security service information of each family member under each family social security service information block, so that the personal social security service information block of each family member can be matched under the family social security service information block to form a level 3 service information block, for example, the personal social security service information block 1 of Wang is matched with the family social security service information block of Wang, and the rest can be analogized in turn.
Certainly, the setting of the service matching relationship is not limited to the three aspects of the above geographic information, service type, identity information, and the like, the number of service information blocks in each hierarchy is not limited to the number shown in fig. 3, and the rectangular box with "… …" in fig. 3 indicates that there are other service information blocks, which may be determined according to the service information. Moreover, the matching order in the above embodiment should not be regarded as fixed, for example, the first, second, and third-level service information blocks may be sequentially divided according to the order of the region information, the service type, and the identity information, and therefore the matching order shown in the above embodiment should not form a limitation on the automatic block chain grouping method of the present invention. For example, in fig. 3, the service information block of each family in the fossa city may be determined according to the region information, so that the number of the level 1 service information blocks corresponds to the total number of the families in the fossa city; then, determining a social security service information block, an education service information block and a traffic service information block of each family according to the service types; and finally, determining the personal social security service information block, the personal education service information block, the personal traffic service information block and the like of each family member according to the identity information.
Step S13: and according to the newly added sequence, connecting a plurality of N + 1-level service information blocks which meet the same N + 1-level service matching relationship in series to form the same service chain.
The new adding sequence is a time sequence. As can be seen from the above description, a plurality of N + 1-th level service information blocks satisfying the same N + 1-th level service matching relationship are all matched under the same N-th level service information block, so that the plurality of N + 1-th level service information blocks have the same or similar service information, and therefore, the plurality of N + 1-th level service information blocks need to be connected in series to form the same service chain, so as to perform statistics, management, retrieval and other operations on the plurality of N + 1-th level service information blocks. For example, in fig. 3, a plurality of level 2 service information blocks connected in series by solid arrows form the same service chain, such as a social security service home chain, an educational service home chain, and the like, which belong to a parallel chain relationship, and each service does not affect; the multiple 3 rd-level service information blocks connected in series by solid arrows form the same service chain, such as the social security service personal chain of wang five, the education service personal chain of li four, and the traffic service personal chain of zhang three. The dotted line between the level 1 service information block and the level 2 service information block indicates that the level 2 service information block is matched with the level 1 service information block; the dashed line between the level 2 service information block and the level 3 service information block indicates that the level 3 service information block matches the level 2 service information block.
Similarly, the same process is also required for the nth class service information block. Therefore, after the step of determining at least two different nth-level service information blocks according to the preset nth-level service matching relationship, the method further includes: step S111, a plurality of nth-level service information blocks are connected in series to form a same service chain. For example, in fig. 3, a plurality of level 1 service information blocks of the same hierarchy connected in series by solid arrows form the same service chain, such as a "foshan city chain".
Further, it is necessary to make the service matching relationship between the nth level service information block and the corresponding N +1 level service information block unique to avoid mismatching.
In the step S12, since it is determined that there may be missing matching relationships or all possible matching relationships cannot be exhausted when the matching relationships are determined originally, a plurality of newly added service information blocks may not satisfy all the preset N + 1-th-level service matching relationships, so that the newly added service information blocks may be classified as new nth-level service information blocks, and meanwhile, the service matching relationships corresponding to the new nth-level service information blocks are added, which may not only avoid matching the newly added service information blocks to unrelated service information blocks, but also facilitate more precise matching of the later newly added blocks.
In addition, on the one hand, the following settings are also required: in the same service chain, the hash values of any two adjacent service information blocks are continuous. This is illustrated in connection with fig. 3.
In the Foshan city chain, hash values of a social security bureau service information block, an education bureau service information block and a traffic bureau service information block are sequentially given as 11, 12 and 13 (for the convenience of understanding, the hash values are represented by simple numbers);
furthermore, in the social security service family chain, the hash values of the three-piece family social security service information block, the four-piece family social security service information block and the five-king family social security service information block are sequentially given as 111, 112 and 113; in the "family chain of education services", hash values of "family education service information block of Zhan three", "family education service information block of Li four" and "family education service information block of Wang five" are given as 121, 122 and 123 in sequence; in the "traffic service family chain", hash values of "three pieces of family traffic service information block", "four pieces of family traffic service information block", and "five pieces of family traffic service information block" are assigned to 131, 132, 133 in sequence;
furthermore, in the social security service individual chain, hash values of a five-person social security service information block 1 and a five-person social security service information block 2 are sequentially given as 1131 and 1132; in the 'personal chain of education service', hash values of 'Liquan elementary school graduation service information blocks' and 'Liquan elementary school graduation service information blocks' are sequentially given as 1221 and 1222; in the "traffic service personal chain", hash values of "three travel license service information blocks" and "three driver license service information blocks" are 1311 and 1312, respectively.
It can be known that, by setting the hash values of any two adjacent service information blocks in the same service chain to be continuous, the continuity of the service information blocks in the same service chain can be ensured, and the N +1 th-level service information block and the N-th-level service information block can be kept connected.
On the other hand, the following settings are also required: the heights of all the service information blocks are superposed according to the uplink time sequence. In other words, the block height of the newly added service information block depends only on the time sequence of the chain, no matter which service chain the block belongs to, and no matter which level the block belongs to. Referring to fig. 3, for example, if the "social security service information block", "education office service information block", "Zhao family social security service information block", and "transportation office service information block" are linked in time sequence, the block heights of the four blocks are 1, 2, 3, and 4 in sequence. Others may be analogized.
Through the set Hash value continuity rule and the block height calculation rule, the block system can be ensured to have the capacity of establishing a branch service chain and the capacity of overall planning.
The above details and fully discloses one or more embodiments of the block chain automatic grouping method of the present invention, from which it can be known that the block chain automatic grouping method classifies different service block information and forms service chains respectively through a preset service matching relationship, and through flexible extension and combination of such service chains, service information storage of various industries can be effectively supported, and blocks and services are clearly and orderly combined.
According to the modular programming concept, the invention also provides a corresponding device for the method. As shown in fig. 4, the block chain automatic grouping apparatus of the present invention includes an nth stage matching unit 11, an N +1 th stage matching unit 12, and an N +1 th stage service chain forming unit 13, specifically:
the nth matching unit 11 is configured to determine at least two different nth service information blocks according to a preset nth service matching relationship; wherein N is an integer greater than or equal to 1;
the N +1 th-level matching unit 12 is configured to sequentially match each newly added service information block satisfying a preset N +1 th-level service matching relationship with one of the at least two nth-level service information blocks, so that the newly added service information block is formed into an N +1 th-level service information block;
the N +1 th service chain forming unit 13 is configured to connect a plurality of N +1 th service information blocks satisfying the same N +1 th service matching relationship in series according to a new adding sequence to form the same service chain.
The block chain automatic grouping device corresponds to the block chain automatic grouping method, has the same service execution logic as the block chain automatic grouping method, has the same technical effect, and is not further described herein.
An embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed to implement the block chain automatic grouping method according to any one of the foregoing embodiments. The computer readable storage medium may be, but is not limited to, various media that can store program codes, such as a U disk, a removable hard disk, a ROM, a RAM, a PROM, an EPROM, an EEPROM, a magnetic or optical disk, etc.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The apparatus embodiments described above are merely illustrative, and for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, functional modules/units in the embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
The foregoing is only a partial embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.