Date storage method, device and computer readable storage mediumTechnical field
The present invention relates to technical field of data storage more particularly to a kind of date storage methods, a kind of data storage deviceWith a kind of computer readable storage medium.
Background technique
Table is divided in conventional center database point library, refers to being stored in the data block storage in a library originally to multiple librariesOn, on the data block storage to multiple tables for being stored in a table originally.Due to the data volume in database is not necessarily canControl, in the case where not carrying out a point library and dividing table, with the development of time and business, the table in library can be more and more, in tableData volume also can be increasing, and correspondingly, data manipulation, additions and deletions change the expense looked into also can be increasing.In addition, due to can not be intoRow distribution formula deployment, and the resource (CPU, disk, memory, IO etc.) of a server is limited, final data library institute energyData volume, the data-handling capacity of carrying will all meet with bottleneck.
Summary of the invention
The present invention is directed to solve at least some of the technical problems in related technologies.For this purpose, of the inventionOne purpose is to propose a kind of date storage method, mixed and disorderly to solve data storage, the big problem waited of data manipulation expense.
Second object of the present invention is to propose a kind of data storage device.
Third object of the present invention is to propose a kind of computer readable storage medium.
In order to achieve the above objectives, first aspect present invention embodiment proposes a kind of date storage method, including following stepIt is rapid: when receiving data to be stored, to obtain the category information of the data to be stored;Block is judged according to the category informationWhether corresponding subchain has been created in chain, wherein the block chain includes a main chain and a plurality of subchain;If the block chainMiddle creation has corresponding subchain, then stores the data to be stored into the subchain;If do not created in the block chain pairThe subchain answered then creates the subchain of the data to be stored on the main chain, and the data to be stored is stored to the sonOn chain, and the category information is saved on current block.
The date storage method of the embodiment of the present invention obtains the classification letter of data to be stored when receiving data to be storedBreath, and then judge corresponding subchain whether has been created in block chain according to category information, if so, then data to be stored is storedInto the subchain, if it is not, creating the subchain of data to be stored on main chain, and data to be stored is stored to the subchainOn, and category information is saved on current block.The date storage method can be realized the storage of block chain multichain as a result, withAnd different chains saves the technical effect of different business datums, and so as to solve data storage in a jumble, data manipulation expenseEqual problem greatly.
In addition, date storage method according to the above embodiment of the present invention can also have the following additional technical features:
Further, date storage method, further includes: obtain the characteristic value of the data to be stored;Creation it is described toWhen the subchain of storing data, the characteristic value is also saved on the current block.
Optionally, the data to be stored includes user information and each business datum of user.
Wherein, when the data to be stored is user information, the intelligent contract of the main chain is also obtained, according to the intelligenceContract creates the subchain of the user information.
According to one embodiment of present invention, date storage method, further includes: when receiving data query instruction, obtainTake the corresponding characteristic value of the inquiry instruction;Judged in the block chain according to the characteristic value with the presence or absence of the number to be inquiredAccording to.
According to one embodiment of present invention, date storage method, further includes: verify the legal of the data to be storedProperty;If the data to be stored is illegal, the data to be stored is abandoned.
Optionally, when in the block chain creation have corresponding subchain, the data to be stored is stored into the subchainWhen, also record the characteristic value stored in the corresponding block of the subchain.
Optionally, the business datum of user includes Transaction Information.
In order to achieve the above objectives, second aspect of the present invention embodiment proposes a kind of data storage device, comprising: obtains mouldBlock, for when receiving data to be stored, obtaining the category information of the data to be stored;Judgment module, for according to instituteIt states category information and judges whether created corresponding subchain in block chain, wherein the block chain includes a main chain and a plurality ofSubchain;Processing module, for when creation has corresponding subchain in the block chain, the data to be stored to be stored to the sonIn chain, and when not creating corresponding subchain in the block chain, the son of the data to be stored is created on the main chainChain, and the data to be stored is stored to the subchain, and the category information is saved on current block.
The data storage device of the embodiment of the present invention is obtained by obtaining module wait deposit when receiving data to be storedThe category information for storing up data, judges corresponding subchain whether has been created in block chain according to category information by judgment module, such asFruit has, then is stored data to be stored into the subchain by processing module, if it is not, through processing module on main chainThe subchain of data to be stored is created, and data to be stored is stored to the subchain, and saves classification letter on current blockBreath.The data storage device can be realized the storage of block chain multichain as a result, and different chains saves different business datumsTechnical effect, the data manipulation expense big problem that waits mixed and disorderly so as to solve data storage.
In order to achieve the above objectives, third aspect present invention embodiment proposes a kind of computer readable storage medium, describedComputer program is stored on computer readable storage medium, the computer program realizes above-mentioned number when being executed by processorAccording to storage method.
The computer readable storage medium of the embodiment of the present invention, what is stored on it is corresponding with above-mentioned date storage methodWhen computer program is executed by processor, it can be realized the storage of block chain multichain and different chains save different business numbersAccording to technical effect, data manipulation expense big equal problem mixed and disorderly so as to solve data storage.
The additional aspect of the present invention and advantage will be set forth in part in the description, and will partially become from the following descriptionObviously, or practice through the invention is recognized.
Detailed description of the invention
Fig. 1 is the flow chart of the date storage method of the embodiment of the present invention;
Fig. 2 is the structural schematic diagram of the block chain of an example of the present invention;
Fig. 3 is the structural block diagram of the data storage device of the embodiment of the present invention;
Specific embodiment
The embodiment of the present invention is described below in detail, examples of the embodiments are shown in the accompanying drawings, wherein from beginning to endSame or similar label indicates same or similar element or element with the same or similar functions.Below with reference to attachedThe embodiment of figure description is exemplary, it is intended to is used to explain the present invention, and is not considered as limiting the invention.
Below with reference to the accompanying drawings the date storage method, device and computer-readable storage medium of the embodiment of the present invention are describedMatter.
Embodiment 1
Fig. 1 is the flow chart of the date storage method of the embodiment of the present invention.
As shown in Figure 1, the date storage method the following steps are included:
S1 obtains the category information of data to be stored when receiving data to be stored.
Wherein, data to be stored may include user information and/or each business datum of user, correspondingly, data to be storedCategory information can be user's subchain category information, each business subchain category information.Optionally, business datum may include transactionInformation, for example, record of transferring accounts, depositing card information etc..
In one embodiment of the invention, when data to be stored is user information, the intelligent contract of main chain is also obtained,The subchain of user information is created according to intelligent contract.
S2 judges corresponding subchain whether has been created in block chain according to category information, wherein block chain includes a masterChain and a plurality of subchain.
S3 stores data to be stored into the subchain if creation has corresponding subchain in block chain.
S4 creates the subchain of data to be stored, and will be to if not creating corresponding subchain in block chain on main chainStoring data is stored to the subchain, and category information is saved on current block.
For example, as shown in Fig. 2, block chain includes a main chain and 4 subchains, each subchain is for storing each classification numberAccording to the corresponding block of each subchain is arranged on main chain, for storing the corresponding category information of each classification data, as a result, when needingWhen storing data enters chain, can be searched according to the category information of the data to be stored whether there is corresponding subchain in block chain.Such asFruit exists, then stores data to be stored into the subchain found;If it does not exist, then the subchain that creation is new, and in the sonThe category information of data to be stored is stored in the corresponding block of chain, and data to be stored is stored into the subchain of creation.
The date storage method can carry out data to be stored by block chain according to the category information of data to be storedStorage can be realized different chains to save different data, guarantees that the data of every chain are simple as far as possible, solves data storageIn a jumble, the big problem of operation overhead.
In one embodiment of the invention, date storage method can also include: the characteristic value for obtaining data to be stored;When creating the subchain of data to be stored, characteristic value is also saved on current block.
Specifically, data to be stored can uniquely be characterized by its characteristic value, wherein and characteristic value can be Nonce random number,It is also possible to combine resulting end value of operation etc. with other numerical value in data to be stored by Nonce random number.It needsBright, when data to be stored includes each business datum of different user, the characteristic value of each business datum of same user canTo be identical, alternatively, being the presence of mapping relations between each other, i.e., this can determine according to the characteristic value of different business datumsUser belonging to business datum.
Further, date storage method further include: when receiving data query instruction, it is corresponding to obtain inquiry instructionCharacteristic value;Judged in block chain according to characteristic value with the presence or absence of the data to be inquired.
It specifically, may include corresponding characteristic value in data query instruction, due to depositing characteristic value when creating subchainEnter corresponding block, therefore, when receiving data query instruction, only need to can determine according to the corresponding characteristic value of inquiry instructionIt whether there is the data to be inquired in block chain, and whole user informations need not be traversed.
In one embodiment of the invention, date storage method can also include: the legal of verifying data to be storedProperty;If data to be stored is illegal (for example, data format does not meet corresponding specification, there are exceptional values etc. in dataDeng), then abandon data to be stored.
Optionally, if being stored with data to be stored in block chain, the data to be stored also be can drop.
In one embodiment of the invention, when in block chain creation have corresponding subchain, by data to be stored store toWhen in the subchain, the characteristic value stored in the corresponding block of the subchain is also recorded.Thus, it is possible to compare the spy stored in the blockWhether the characteristic value of value indicative and data to be stored is consistent, if unanimously, illustrating that the storage location of data to be stored is accurate;IfIt is inconsistent, then illustrate to the storage of data to be stored there are problem, at this time capable of emitting prompt information, to remind operation maintenance personnel to thisProblem is handled, to ensure the accuracy of data to be stored storage.
For ease of understanding, below with reference to Fig. 2, and date storage method of the invention is said by a specific exampleIt is bright:
As shown in Fig. 2, block chain includes a main chain and multiple subchains.Wherein, main chain is for user in subchain blockStore subchain category information and characteristic value;Subchain is used for storage service data.
For by new user's registration and being traded, the detailed process of data storage is as follows:
1) create user: the intelligent contract of request to main chain first, contract create subchain (such as subchain of a user information1) characteristic value of user's subchain category information and corresponding data is saved, and on current block so as to subsequent lookup user informationWhen whether data is directly determined in chain by characteristic value, and whole user informations need not be traversed;
2) customer transaction: main chain creates the subchain (such as subchain 2) of a Transaction Information, and transaction letter is saved in the subchainIt ceases (such as classification data 2), while saving the characteristic value of transaction subchain category information and corresponding data on current block;
3) when there is new data to be packed up in chain, main chain is responsible for selecting the subchain of deposit according to category information, verifies simultaneouslyThe legitimacy of information, and record the characteristic value of current block.
In conclusion the date storage method of the embodiment of the present invention is reached by the technological means of main chain dynamic expansion subchainIt is stored to block chain multichain, realizes different chains and save the technical effect of different business datums, to solve block chainWith the development of time and business, the data derived that are continuously increased of data volume and data class are stored in a jumble, data manipulation,The technical issues of expense of inquiry increases and the single-stranded data volume that can be carried, data-handling capacity meet with bottleneck.
Embodiment 2
Fig. 3 is the structural block diagram of the data storage device of the embodiment of the present invention.
As shown in figure 3, the data storage device 100 includes: to obtain module 110, judgment module 120 and processing module 130.
In an embodiment of the present invention, it obtains module 110 to be used for when receiving data to be stored, obtains data to be storedCategory information.
Wherein, data to be stored may include user information and/or each business datum of user, correspondingly, data to be storedCategory information can be user's subchain category information, each business subchain category information.Optionally, business datum may include transactionInformation, for example, record of transferring accounts, depositing card information etc..
Judgment module 120 is used to judge whether created corresponding subchain in block chain according to category information, wherein blockChain includes a main chain and a plurality of subchain.
Processing module 130 is used to create in block chain when having corresponding subchain, and data to be stored is stored to the subchainIn, and when not creating corresponding subchain in block chain, the subchain of data to be stored is created on main chain, and will number be storedAccording to storing to the subchain, and category information is saved on current block.
For example, as shown in Fig. 2, block chain includes a main chain and 4 subchains, each subchain is for storing each classification numberAccording to the corresponding block of each subchain is arranged on main chain, for storing the corresponding category information of each classification data, as a result, when needingWhen storing data enters chain, judgment module 120 can be searched according to the category information of the data to be stored whether there is phase in block chainThe subchain answered.If it is present processing module 130 stores data to be stored into the subchain found;If it does not exist, thenProcessing module 130 creates new subchain, and the category information of data to be stored is stored in the corresponding block of the subchain, and will be toStoring data is stored into the subchain of creation.
The data storage device can carry out data to be stored by block chain according to the category information of data to be storedStorage can be realized different chains to save different data, guarantees that the data of every chain are simple as far as possible, solves data storageIn a jumble, the big problem of operation overhead.
In one embodiment of the invention, when data to be stored is user information, master can also be obtained by obtaining module 110The intelligent contract of chain, so that processing module 130 creates the subchain of user information according to intelligent contract.
In one embodiment of the invention, the characteristic value of data to be stored can also be obtained by obtaining module 110.Wherein, locateModule 130 is managed when creating the subchain of data to be stored, characteristic value is also saved on current block.
Specifically, data to be stored can uniquely be characterized by its characteristic value, wherein and characteristic value can be Nonce random number,It is also possible to combine resulting end value of operation etc. with other numerical value in data to be stored by Nonce random number.It needsBright, when data to be stored includes each business datum of different user, the characteristic value of each business datum of same user canTo be identical, alternatively, being the presence of mapping relations between each other, i.e., this can determine according to the characteristic value of different business datumsUser belonging to business datum.
Further, obtaining module 110 can also obtain the corresponding feature of inquiry instruction when receiving data query instructionValue.Wherein, judgment module 120 can be also judged in block chain according to characteristic value with the presence or absence of the data to be inquired.
It specifically, may include corresponding characteristic value in data query instruction, due to depositing characteristic value when creating subchainEnter corresponding block, therefore, when receiving data query instruction, only need to can determine according to the corresponding characteristic value of inquiry instructionIt whether there is the data to be inquired in block chain, and whole user informations need not be traversed.
In one embodiment of the invention, judgment module 120 can be also used for the legitimacy of verifying data to be stored.ItsIn, if data to be stored is illegal (for example, data format does not meet corresponding specification, there are exceptional values etc. in dataDeng), then processing module 130 can drop data to be stored.
Optionally, if being stored with data to be stored in block chain, processing module 130 also can drop should be wait storeData.
In one embodiment of the invention, when in block chain creation have corresponding subchain, by data to be stored store toWhen in the subchain, processing module 130 also records the characteristic value stored in the corresponding block of the subchain.Thus, it is possible to compare the areaWhether the characteristic value of the characteristic value and data to be stored that store in block is consistent, if unanimously, illustrating the storage of data to be storedPosition is accurate;If it is inconsistent, there are problems for storage of the explanation to data to be stored, processing module 130 can be by mentioning at this timeShow that module issues prompt information, to remind operation maintenance personnel to handle the problem, to ensure the accurate of data to be stored storageProperty.
In conclusion the data storage device of the embodiment of the present invention is reached by the technological means of main chain dynamic expansion subchainIt is stored to block chain multichain, realizes different chains and save the technical effect of different business datums, to solve block chainWith the development of time and business, the data derived that are continuously increased of data volume and data class are stored in a jumble, data manipulation,The technical issues of expense of inquiry increases and the single-stranded data volume that can be carried, data-handling capacity meet with bottleneck.
Embodiment 3
The invention also provides a kind of computer readable storage medium, calculating is stored on the computer readable storage mediumMachine program realizes above-mentioned date storage method when computer program is executed by processor.
The computer readable storage medium of the embodiment of the present invention, what is stored on it is corresponding with above-mentioned date storage methodWhen computer program is executed by processor, by the technological means of main chain dynamic expansion subchain, it can be realized block chain multichain and depositStorage and different chains save the technical effect of different business datums, to solve block chain with time and businessDevelopment, data volume and data class are continuously increased that the data storage derived is mixed and disorderly, data manipulation, inquiry expense increase,And the technical issues of single-stranded data volume that can be carried, data-handling capacity experience bottleneck.
Although the embodiments of the present invention has been shown and described above, it is to be understood that above-described embodiment is exampleProperty, it is not considered as limiting the invention, those skilled in the art within the scope of the invention can be to above-mentionedEmbodiment is changed, modifies, replacement and variant.