Specific embodiment
In order to make those skilled in the art more fully understand the technical solution in this specification embodiment, below in conjunction with this
Attached drawing in specification embodiment is described in detail the technical solution in this specification embodiment, it is clear that described
Embodiment is only a part of the embodiment of this specification, instead of all the embodiments.The embodiment of base in this manual,
Those of ordinary skill in the art's every other embodiment obtained, all should belong to the range of protection.
On ordinary meaning, block chain type account book includes two kinds: block chain and class block chain account book.Block chain is normally divided into
Three types: publicly-owned chain (Public Blockchain), privately owned chain (Private Blockchain) and alliance's chain
(Consortium Blockchain).In addition, there are also a plurality of types of combinations, such as privately owned chain+alliance's chain, alliance's chain+publicly-owned
The different combinations such as chain.No matter which kind of block chain, be construed as decentralization, needed in data write-in block chain into
The common recognition of each node of row, reaches data in the consistency of each node, realization is difficult to tamper with.And the account book of class block chain is then a kind of
The mode of data storage is carried out under the scene of centralization, but it equally has the characteristic that can not be distorted.
The either account book of block chain or class block chain, in form can be as shown in Figure 1.Fig. 1 is this specification
The structural schematic diagram of a kind of piece of chain type account book involved in embodiment.One block chain type account book, by multiple data chunks at data
It is arranged between block according to Chunky Time sequence.From primary data BOB(beginning of block), each data block has a sub-block, each number
It is determined according to the cryptographic Hash of block by the cryptographic Hash and the data record that itself is included of last data block.In each data block,
It include build and block, build is used to store the metadata of some data blocks (such as in block height, parent data block Hash, block
The root Hash of Merkel tree etc. that constitutes of data record), block is then used to store specific data record.
It should be noted that data record is difficult to be tampered in the account book of block chain type.But this is not meant to use
Family cannot carry out certain specific operations to data record.
For example, node can initiate a use in the limited alliance's chain of node or the block chain account book of privately owned chain type
In the transaction of the data record of designated position of the concealment comprising sensitive data, after common recognition passes through in block chain, to include original
The concealment data of the cryptographic Hash of data record replace former data record, and do not influence the simple payment verification of block chain
(Simplified Payment Verification, SPV) or other verifyings.In another example in the class block chain account of centralization
In this, user then can such as add the data in data block by different instruction predetermined, remove, hide
Etc. operation.Specific mode of operation will be described below in detail.
As user operates the data record in block chain type account book, the state of data record is just corresponding to be occurred
Change.User needs for business at this time, it may be necessary to which understanding has what change has occurred in which data record, and carries out
Corresponding statistics.Based on this, this specification embodiment provides a kind of scheme that the attribute for data record is recorded.
To keep the scheme of this specification embodiment more clear and easy to understand, first in involved in this specification embodiment
The generation method and form of the class block chain account book of the heart are described.In a specific embodiment, the account of class block chain
Originally it can be generated by such as under type:
Firstly, the database service provider of centralization receives data record to be stored, the Kazakhstan of each data record is determined
Uncommon value.The data record of to be stored can be the various consumer records of client personal user herein, be also possible to using clothes
Business instruction of the device based on user, business result, intermediate state and the operation note etc. generated when executing service logic.Tool
The business scenario of body may include consumer record, audit log, supply chain, government regulation record, medical records etc..
Then, when reaching preset blocking condition, database service provider determines each number in data block to be written
According to record, the n-th data block of the cryptographic Hash comprising data block and data record is generated.
The preset blocking condition includes: that data record quantity to be stored reaches amount threshold, for example, often receiving
When 1000 datas record, a new data block is generated, 1,000 datas are recorded in write-in block;Alternatively, apart from the last time at
The time interval at block moment reaches time threshold, for example, a new data block was generated every 5 minutes, it will be inscribed at this 5 minutes
In the data record write-in block received.
N herein refers to the serial number of data block, and in other words, in this specification embodiment, data block is with block chain
Form, the sequence based on Chunky Time successively arrange, and have very strong temporal aspect.Wherein, the block height of data block is based on blocking
The sequencing monotonic increase of time.Block height can be serial number, and the block height of n-th data block is N at this time;Block height can also be with it
Its mode generates, for example, converting the big integers of monotonic increases a series of for the block high generation time, (generally 12 to 15 whole
Type data), as block height.
As N=1, i.e., data block at this time is initial data block.The cryptographic Hash and block height of initial data block are based on pre-
If mode is given.For example, not including data record in initial data block, cryptographic Hash is then any given cryptographic Hash, and block is high
Blknum=0;In another example the generation trigger condition of initial data block is consistent with the trigger condition of other data blocks, but it is initial
The cryptographic Hash of data block takes Hash to determine by the content to all data records in initial data block.
As N > 1, since content and the cryptographic Hash of last data block are it has been determined that then at this point it is possible to be based on last data
The cryptographic Hash of block (i.e. the N-1 data block) generates the cryptographic Hash of current data block (n-th data block), for example, a kind of feasible
Mode be to determine that the cryptographic Hash of the data record in n-th block will be written in each, according to putting in order in block,
A Merkel tree is generated, the cryptographic Hash of the root cryptographic Hash of Merkel tree and last data block is stitched together, is used again
Hash algorithm generates the cryptographic Hash of current block.In another example can also be spliced according to the sequence of data record in block and take Kazakhstan
The uncommon cryptographic Hash for obtaining overall data record splices the cryptographic Hash of last data block and the cryptographic Hash of overall data record, and right
Splice obtained word string and carry out Hash operation, generates the cryptographic Hash of data block.
By the generating mode of data block above-mentioned, in the database service provider of centralization, without carrying out node
Common recognition, each data block is determining by cryptographic Hash, content, sequence of the cryptographic Hash of data block by the data record in data block
And the cryptographic Hash of last data block determines.
Under one the smallest verifying granularity, each data record has a corresponding cryptographic Hash, and user can be with
When initiate to verify based on the cryptographic Hash of data record or data block, for content any in data block (including for data block
Middle data record content or sequence) modification can all cause the cryptographic Hash and data block of the data block that are calculated in verifying
Cryptographic Hash when generation is inconsistent, and leads to authentication failed, thus can not distort under realizing centralization.
Below in conjunction with attached drawing, the technical solution that each embodiment of this specification provides is described in detail.As shown in Fig. 2, Fig. 2 is this
The flow diagram for the data attribute identification method in a kind of piece of chain type account book that specification embodiment provides, is applied to block chain type
It include the build for recording metadata for storing data in account book, in the data block in block chain type account book, which specifically includes
Following steps:
S201 receives operational order, determines the type of operational order and need to be implemented operation determined by operational order
Data record.
In class block chain account book, operational order can derive from one or several authorized users, can also derive from
Database service side.Operational order may include multiple types, for example, addition, removing, concealment, verifying, inquiry etc..Data
Library service side always can determine the data record operated by operational order.
Simply provide below several specific operational orders form and its respective implementation.
Addition instruction, APPEND (v , &khash): user adds data record " v ", the service side of centralization into account book
The cryptographic Hash " khash " of returned data record gives user.
Verifying instruction, VERIFY (' khash ' , &v): user inputs cryptographic Hash " khash ", to determined by cryptographic Hash
Data block or data record execute verifying, return to verification result " &v ".The mode of verifying is remembered according to the data in data block
Record building Merkel tree, obtains the root Hash of Merkel tree, is calculated one according to the cryptographic Hash of the root Hash and parent data block
A cryptographic Hash, and it is whether consistent with the comparison of the cryptographic Hash of the data block.
Clearance order, PURGE (lgid, blkbound): user specifies account book mark " lgid " and block high
" blkbound ", the data block before service side determines block height based on block height is the data block for needing to remove, and then removes this
It is a little to determine the data block for needing to remove.And a pseudo- initial data block is generated, the cryptographic Hash of pseudo- initial data block is equal to true
The cryptographic Hash for the last one data block that fixed needs are removed, this way it is possible to avoid occurring mistake when being verified afterwards.Quilt
The data of removing actually in the window phase of certain time (for example, 72 hours) are still present in database service side, only
It is to be removed from the account book in form.
Hide instruction, OCCULT (blkheight, txoff): user specifies by block high " blkheight " and specifies Offsets
The record of a data determined by " txoff " is measured, the data record is replaced with concealmentization data, includes institute in concealmentization data
State the transaction Hash of data record.
Inquiry instruction, RETRIEVE (khash): user inputs the cryptographic Hash " khash " of a data record, inquiry
The block height and data that obtain data block locating for data record corresponding to the cryptographic Hash are recorded in the offset in the data block
“&v”。
Above-mentioned part simply gives several examples, in practical applications, database service only for operational order
Side is also based on business and needs to provide more executable operational order, and other parameters are added in operational order,
To realize more complicated database service, this does not constitute the limitation to the application.
By parameter included in operational order, data record or data block to be executed can be always determined.
When operation object is data block, it is believed that same one will be performed to all data records included in the data block
Kind operation.
S203 determines attribute tab character corresponding to the operational order according to the type of the operational order, described
Attribute tab character is used for the last change state of mark data record.
The type of operational order and the mapping relations of attribute tab character can be established in advance, and be stored in database service
In the address that side can call at any time, corresponding attribute tab character is provided so as to the type based on operational order.
For example, for the database service side of centralization tab character can be given based on operation " addition "
" 01 " gives tab character " 02 " for operation " removing ", for operation " concealment ", gives tab character " FF " etc..To
The current state of the data record can be known by attribute tab character, and will be seen that the nearest progress of the data record
Which kind of operation.
S205 establishes the corresponding relationship of the attribute tab character and the data record, the corresponding relationship is written
State array in the build of data block locating for the data record.
In the account book of block chain type, content included in build and block and reading manner are all can be customized
's.As shown in figure 3, Fig. 3 is a kind of schematic diagram of the build comprising state array provided by this specification embodiment.Status number
For group for storing corresponding relationship above-mentioned, corresponding relationship among these can be the one of attribute tab character and the data record
One corresponding relationship is also possible to an attribute tab character corresponding to multiple data records.Under different corresponding relationship relationships,
State array has the different forms of expression.Information for expressing data record can be the unique identification of data record,
Cryptographic Hash including data record, or location information within the data block etc..
In the account book of block chain type storage, when user makes certain type of operation for data record, i.e., accordingly
Provide attribute tab character corresponding to an operation note, establish the attribute tab character it is corresponding with data record close
System, and the state array being located in the build of data block is written.By the above-mentioned means, can be flexibly to the state of data record
It is marked, and easily the state of data record in data block is counted, and attribute tab character is stored in
Reading data, storage and the other operations of block body are not interfered in block head, it is more convenient.
Specifically, can be believed by the position of the data record within the data block in data record in a data block
Breath uniquely determines.Location information can be the offset that data are recorded in block, alternatively, location information can also be that data are remembered
Record the storage serial number in block.
So at this point it is possible to which the state array is written in the corresponding relationship for establishing location information and attribute tab character.Tool
For body, it can determine the correspondence element in array according to location information, and the element is written in attribute tab character
In, the position of the data element and the corresponding relationship of attribute tab character are contained in the element in array.
For example, the element in array can be using location information as key, to be the key-value pair of value with attribute tab character
Form: (location information, attribute tab character), the form of array may is that { (location information 1, attribute tab character 1), (position
Confidence breath 2, attribute tab character 3), (location information 6, attribute tab character 1) ... ... }.When user carried out data record
After operation, that is, a corresponding array element is generated, or modify to the attribute tab character in array element.
Under this embodiment, the location information in different array elements will not be identical.At this point, need not be deposited in array
The status information of all data records is stored up, the status information that the data record of state change occurred need to be only stored with.
In another example the element in array can be using attribute tab character as key, it take location information as the key-value pair of value
Form: (attribute tab character 1;Location information 1, location information 2 ... ...), the form of array can be as follows: { (attribute mark
Remember character 1;Location information 1, location information 2 ... ...), (attribute tab character 2;Location information 9, location information
10 ... ...) ... ... }.
Under this embodiment, the attribute tab character in different array elements will not be identical, an attribute label
Character can correspond to multiple location informations.At this point, describing the identical multiple numbers of nearest state in a data element
According to record, it is convenient for subsequent statistical.
In one embodiment, each array element in array sequentially corresponds to data record, each number
Group element is the initial markers character of a default, and the value of initial markers character can be given based on predetermined manner, for example, giving
Determining initial markers character is " 00 ".When data record performs certain operation by user, corresponding array element is repaired
It is changed to corresponding attribute tab character.
For example, have 1000 datas record in the block of a data block, then it is corresponding to be generated in the build of data block
It accordingly include the array of 1000 array elements, each array element sequentially corresponds to data record, at this point, in array
Comprising 1000 elements, each element is a tab character, and form can be as follows: { initial markers character, attribute
Tab character 1, attribute tab character 2, attribute tab character 3, initial markers character ... ... }.Whenever to a data record into
Gone certain operation when, directly being modified according to the serial number of data record to corresponding element in the data can.
Under this embodiment, the location information of data record has been hidden in data record by way of sequence
Element in, in array need not again in the form of plaintext storing data record location information, memory space can be saved.
Further, it is also possible to establish a corresponding state index, except the account book of block chain type to inquire.Specific rope
Draw the mode of foundation are as follows: the block height for determining data block locating for the data record and the offset in the data block;It establishes
The concordance list of corresponding relationship comprising described piece of height, offset and attribute tab character, and store.At this point, the member in concordance list
The form of element are as follows: (cryptographic Hash of data record, block is high, offset, attribute tab character).User is if it is desired to inquire a certain item number
According to record state when, then the cryptographic Hash that can input the data record is inquired from index.In above-mentioned index,
The mark that the cryptographic Hash of data record can be used as data record is deposited in the index.
In practical applications, each operation of data record also can be written into and carries out depositing card in account book.For example, can be with
By way of database service provider disposes intelligent contract, database service provider is whenever receiving operational order
When, it can operational order is packaged into the account book of data record write area, the authenticity of data-recording status is further increased.
Corresponding, this specification embodiment also provides the data attribute identity device in a kind of piece of chain type account book, is applied to
It include the build for recording metadata for storing data in block chain type account book, in the data block in block chain type account book, such as Fig. 4 institute
Show, Fig. 4 is the structural schematic diagram of the data attribute identity device in a kind of piece of chain type account book that this specification embodiment provides, packet
It includes:
Command reception module 401 receives operational order, determines the type of operational order and need determined by operational order
Execute the data record of operation;
Character determining module 403 determines attribute mark corresponding to the operational order according to the type of the operational order
Remember that character, the attribute tab character are used for the last change state of mark data record;
Relationship establishes module 405, establishes the corresponding relationship of the attribute tab character and the data record;
The state in the build of data block locating for the data record is written in the corresponding relationship by writing module 407
Array;
Wherein, in addition to initial data block, include at least one data record in each data block, wrapped in each data block
Cryptographic Hash containing the data block that the cryptographic Hash by last data block and the data record for itself being included determine, data block
Sequencing monotonic increase of the block height based on Chunky Time.
Further, described device further includes data block generation module 409, receives data record to be stored, and is determined each
The cryptographic Hash of data record;When reaching preset blocking condition, each data record in data block to be written is determined, generate packet
The n-th data block of cryptographic Hash and data record containing data block, specifically includes: as N=1, the cryptographic Hash of initial data block
It is given based on predetermined manner with block height;As N > 1, according to each data record and the N-1 data block in data block to be written
Cryptographic Hash determine the cryptographic Hash of n-th data block, generate the N of the cryptographic Hash comprising n-th data block and each data record
A data block.
Further, the relationship establishes module 405, determines the position letter that the data are recorded in the data block
Breath, wherein the location information includes the offset or storage serial number of the data record within the data block;Said write mould
The state array is written in the corresponding relationship of the location information and attribute tab character by block 407.
Further, in the state array, each of array element is attribute mark corresponding to data record
Remember character, is arranged according to the sequence of data record within the data block.
Further, in the state array, the form of element is key-value pair, and the element in array is marked with attribute
Character is key, is value with location information;Alternatively, the element in array is value with attribute tab character using location information as key.
Further, described further includes index creation module 411, determines that the block of data block locating for the data record is high
With the offset in the data block;Establish the rope of the corresponding relationship comprising described piece of height, offset and attribute tab character
Draw table, and stores.
This specification embodiment also provides a kind of computer equipment, includes at least memory, processor and is stored in
On reservoir and the computer program that can run on a processor, wherein processor realizes number shown in Fig. 2 when executing described program
According to attribute-bit method.
Fig. 5 shows one kind provided by this specification embodiment and more specifically calculates device hardware structural schematic diagram,
The equipment may include: processor 1010, memory 1020, input/output interface 1030, communication interface 1040 and bus
1050.Wherein processor 1010, memory 1020, input/output interface 1030 and communication interface 1040 are real by bus 1050
The now communication connection inside equipment each other.
Processor 1010 can use general CPU (Central Processing Unit, central processing unit), micro- place
Reason device, application specific integrated circuit (Application Specific Integrated Circuit, ASIC) or one
Or the modes such as multiple integrated circuits are realized, for executing relative program, to realize technical side provided by this specification embodiment
Case.
Memory 1020 can use ROM (Read Only Memory, read-only memory), RAM (Random Access
Memory, random access memory), static storage device, the forms such as dynamic memory realize.Memory 1020 can store
Operating system and other applications are realizing technical solution provided by this specification embodiment by software or firmware
When, relevant program code is stored in memory 1020, and execution is called by processor 1010.
Input/output interface 1030 is for connecting input/output module, to realize information input and output.Input and output/
Module can be used as component Configuration (not shown) in a device, can also be external in equipment to provide corresponding function.Wherein
Input equipment may include keyboard, mouse, touch screen, microphone, various kinds of sensors etc., output equipment may include display,
Loudspeaker, vibrator, indicator light etc..
Communication interface 1040 is used for connection communication module (not shown), to realize the communication of this equipment and other equipment
Interaction.Wherein communication module can be realized by wired mode (such as USB, cable etc.) and be communicated, can also be wirelessly
(such as mobile network, WIFI, bluetooth etc.) realizes communication.
Bus 1050 include an access, equipment various components (such as processor 1010, memory 1020, input/it is defeated
Outgoing interface 1030 and communication interface 1040) between transmit information.
It should be noted that although above equipment illustrates only processor 1010, memory 1020, input/output interface
1030, communication interface 1040 and bus 1050, but in the specific implementation process, which can also include realizing normal fortune
Other assemblies necessary to row.In addition, it will be appreciated by those skilled in the art that, it can also be only comprising real in above equipment
Component necessary to existing this specification example scheme, without including all components shown in figure.
This specification embodiment also provides a kind of computer readable storage medium, is stored thereon with computer program, the journey
Data attribute identification method shown in Fig. 2 is realized when sequence is executed by processor.
Computer-readable medium includes permanent and non-permanent, removable and non-removable media can be by any method
Or technology come realize information store.Information can be computer readable instructions, data structure, the module of program or other data.
The example of the storage medium of computer includes, but are not limited to phase change memory (PRAM), static random access memory (SRAM), moves
State random access memory (DRAM), other kinds of random access memory (RAM), read-only memory (ROM), electric erasable
Programmable read only memory (EEPROM), flash memory or other memory techniques, read-only disc read only memory (CD-ROM) (CD-ROM),
Digital versatile disc (DVD) or other optical storage, magnetic cassettes, tape magnetic disk storage or other magnetic storage devices
Or any other non-transmission medium, can be used for storage can be accessed by a computing device information.As defined in this article, it calculates
Machine readable medium does not include temporary computer readable media (transitory media), such as the data-signal and carrier wave of modulation.
As seen through the above description of the embodiments, those skilled in the art can be understood that this specification
Embodiment can be realized by means of software and necessary general hardware platform.Based on this understanding, this specification is implemented
Substantially the part that contributes to existing technology can be embodied in the form of software products the technical solution of example in other words,
The computer software product can store in storage medium, such as ROM/RAM, magnetic disk, CD, including some instructions are to make
It is each to obtain computer equipment (can be personal computer, server or the network equipment etc.) execution this specification embodiment
Method described in certain parts of a embodiment or embodiment.
System, method, module or the unit that above-described embodiment illustrates can specifically realize by computer chip or entity,
Or it is realized by the product with certain function.A kind of typically to realize that equipment is computer, the concrete form of computer can
To be personal computer, laptop computer, cellular phone, camera phone, smart phone, personal digital assistant, media play
In device, navigation equipment, E-mail receiver/send equipment, game console, tablet computer, wearable device or these equipment
The combination of any several equipment.
All the embodiments in this specification are described in a progressive manner, same and similar portion between each embodiment
Dividing may refer to each other, and each embodiment focuses on the differences from other embodiments.Especially for method reality
For applying example, since it is substantially similar to the method embodiment, so describing fairly simple, related place is referring to embodiment of the method
Part explanation.Embodiment of the method described above is only schematical, wherein described be used as separate part description
Module may or may not be physically separated, can be each module when implementing this specification example scheme
Function realize in the same or multiple software and or hardware.Can also select according to the actual needs part therein or
Person's whole module achieves the purpose of the solution of this embodiment.Those of ordinary skill in the art are not the case where making the creative labor
Under, it can it understands and implements.
The above is only the specific embodiment of this specification embodiment, it is noted that for the general of the art
For logical technical staff, under the premise of not departing from this specification embodiment principle, several improvements and modifications can also be made, this
A little improvements and modifications also should be regarded as the protection scope of this specification embodiment.