CN108846753B - Method and apparatus for processing data - Google Patents
Method and apparatus for processing data Download PDFInfo
- Publication number
- CN108846753B CN108846753B CN201810587534.7A CN201810587534A CN108846753B CN 108846753 B CN108846753 B CN 108846753B CN 201810587534 A CN201810587534 A CN 201810587534A CN 108846753 B CN108846753 B CN 108846753B
- Authority
- CN
- China
- Prior art keywords
- data
- transaction
- blockchain
- transaction identifier
- modification information
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000012545 processing Methods 0.000 title claims abstract description 56
- 238000000034 method Methods 0.000 title claims abstract description 54
- 230000004048 modification Effects 0.000 claims abstract description 183
- 238000012986 modification Methods 0.000 claims abstract description 183
- 238000013507 mapping Methods 0.000 claims abstract description 29
- 230000004044 response Effects 0.000 claims description 16
- 238000004590 computer program Methods 0.000 claims description 9
- 238000013500 data storage Methods 0.000 claims description 7
- 238000000605 extraction Methods 0.000 claims description 5
- 238000010586 diagram Methods 0.000 description 12
- 239000000284 extract Substances 0.000 description 10
- 230000006870 function Effects 0.000 description 10
- 238000004891 communication Methods 0.000 description 6
- 230000003287 optical effect Effects 0.000 description 4
- 230000008859 change Effects 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 2
- 239000000835 fiber Substances 0.000 description 2
- 230000008569 process Effects 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 239000004065 semiconductor Substances 0.000 description 2
- 230000005540 biological transmission Effects 0.000 description 1
- 238000004422 calculation algorithm Methods 0.000 description 1
- 238000001914 filtration Methods 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000002715 modification method Methods 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q40/00—Finance; Insurance; Tax strategies; Processing of corporate or income taxes
- G06Q40/04—Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
Landscapes
- Business, Economics & Management (AREA)
- Accounting & Taxation (AREA)
- Finance (AREA)
- Engineering & Computer Science (AREA)
- Development Economics (AREA)
- Economics (AREA)
- Marketing (AREA)
- Strategic Management (AREA)
- Technology Law (AREA)
- Physics & Mathematics (AREA)
- General Business, Economics & Management (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The embodiment of the application discloses a method and a device for processing data. One embodiment of the method comprises: receiving a data query request which is sent by a client and contains a first transaction identifier; extracting the target data and a second transaction identifier which establishes mapping with the first transaction identifier from the blockchain; extracting the data modification information indicated by the second transaction identifier from the blockchain, and modifying the extracted target data by using the data modification information; and returning the modified data to the client. This embodiment increases the flexibility of processing data in the blockchain.
Description
Technical Field
The embodiment of the application relates to the technical field of computers, in particular to a method and a device for processing data.
Background
The blockchain technology is a brand new distributed infrastructure and computing mode that uses blockchain data structures to verify and store data, uses distributed node consensus algorithms to generate and update data, uses cryptography to secure data transmission and access, and uses intelligent contracts composed of automated script codes to program and manipulate data.
The block chain has the property of tamper resistance and does not support data modification. In the existing modification method for data in a block chain, modified complete data is usually written into the block chain again, and the original data and the modified complete data are associated to store the association relationship.
Disclosure of Invention
The embodiment of the application provides a method and a device for processing data.
In a first aspect, an embodiment of the present application provides a method for processing data, where the method includes: receiving a data query request which is sent by a client and contains a first transaction identifier, wherein the first transaction identifier is used for indicating target data stored in a maintained block chain; extracting target data and a second transaction identifier mapped with the first transaction identifier from the blockchain, wherein the second transaction identifier is used for indicating data modification information stored in the blockchain, and the data modification information is used for indicating modification of the target data; extracting data modification information indicated by the second transaction identification from the blockchain, and modifying the extracted target data by using the data modification information; and returning the modified data to the client.
In some embodiments, before receiving the data query request containing the first transaction identifier sent by the client, the method further comprises: receiving a data modification request comprising a first transaction identification and data modification information; determining whether the block chain stores the data modification information, if not, storing the data modification information to the block chain, and generating a second transaction identifier for indicating the data modification information stored in the block chain; a mapping of the first transaction identity and the second transaction identity is established in the blockchain.
In some embodiments, after determining whether data modification information is stored in the blockchain, the method further comprises: in response to determining that the blockchain has data modification information stored therein, a second transaction identification indicating the data modification information stored in the blockchain is extracted.
In some embodiments, prior to receiving the data modification request including the first transaction identification and the data modification information, the method further comprises: receiving a data storage request comprising target data; the target data is stored to the blockchain, and a first transaction identifier indicating the target data stored in the blockchain is generated.
In some embodiments, establishing a mapping of the first transaction identity to the second transaction identity in the blockchain comprises: and storing the key-value pairs in the blockchain by taking the first transaction identifier as a key of the key-value pair and taking the second transaction identifier as a value of the key-value pair, and generating a third transaction identifier for indicating the key-value pairs stored in the blockchain.
In some embodiments, after generating the second transaction identification indicating the data modification information stored in the blockchain, the method further comprises: and returning the second transaction identification.
In some embodiments, extracting data modification information indicated by the second transaction identification from the blockchain, and modifying the extracted target data with the data modification information includes: in response to the fact that the number of the second transaction identifications mapped with the first transaction identification is larger than a preset value, according to the sequence of mapping with the first transaction identification, the second transaction identification mapped with the first transaction identification is used as a target transaction identification, and the following data modification steps are executed: extracting data modification information indicated by the target transaction identification from the blockchain; modifying the extracted target data by using the extracted data modification information; and taking the modified data as target data, taking the next second transaction identifier as a target transaction identifier according to the sequence of establishing mapping with the first transaction identifier, and continuously executing the data modification step.
In some embodiments, the data modification information is a regular expression used to modify the target data.
In a second aspect, an embodiment of the present application provides an apparatus for processing data, the apparatus including: the system comprises a first receiving unit, a second receiving unit and a third receiving unit, wherein the first receiving unit is configured to receive a data query request which is sent by a client and contains a first transaction identifier, and the first transaction identifier is used for indicating target data stored in a maintained block chain; the first extraction unit is configured to extract target data and a second transaction identifier mapped with the first transaction identifier from the blockchain, wherein the second transaction identifier is used for indicating data modification information stored in the blockchain, and the data modification information is used for indicating modification of the target data; a modification unit configured to extract data modification information indicated by the second transaction identifier from the blockchain, and modify the extracted target data using the data modification information; a first returning unit configured to return the modified data to the client.
In some embodiments, the apparatus further comprises: a second receiving unit configured to receive a data modification request including the first transaction identification and data modification information; the determining unit is configured to determine whether the block chain stores the data modification information, if not, the data modification information is stored in the block chain, and a second transaction identifier used for indicating the data modification information stored in the block chain is generated; an establishing unit configured to establish a mapping of the first transaction identity and the second transaction identity in the blockchain.
In some embodiments, the apparatus further comprises: and the second extraction unit is configured to extract a second transaction identifier which is used for indicating the data modification information stored in the blockchain in response to the fact that the data modification information is stored in the blockchain.
In some embodiments, the apparatus further comprises: a third receiving unit configured to receive a data storage request including target data; the storage unit is configured to store the target data to the blockchain, and generate a first transaction identifier indicating the target data stored in the blockchain.
In some embodiments, the establishing unit is further configured to: and storing the key-value pairs in the blockchain by taking the first transaction identifier as a key of the key-value pair and taking the second transaction identifier as a value of the key-value pair, and generating a third transaction identifier for indicating the key-value pairs stored in the blockchain.
In some embodiments, the apparatus further comprises: a second return unit configured to return a second transaction identification.
In some embodiments, the modifying unit comprises: the first execution module is configured to respond to the fact that the number of the second transaction identifications mapped with the first transaction identifications is larger than a preset value, and the second transaction identifications mapped with the first transaction identifications are used as target transaction identifications according to the sequence of mapping with the first transaction identifications, and the following data modification steps are executed: extracting data modification information indicated by the target transaction identification from the blockchain; modifying the extracted target data by using the extracted data modification information; and the second execution module is configured to take the modified data as target data, take the next second transaction identifier as a target transaction identifier according to the sequence of establishing mapping with the first transaction identifier, and continue to execute the data modification step.
In some embodiments, the data modification information is a regular expression used to modify the target data.
In a third aspect, an embodiment of the present application provides a server, including: one or more processors; a storage device having one or more programs stored thereon which, when executed by one or more processors, cause the one or more processors to implement a method as in any embodiment of a method for processing data.
In a fourth aspect, embodiments of the present application provide a computer-readable medium on which a computer program is stored, which program, when executed by a processor, implements a method as in any one of the embodiments of the method for processing data.
According to the method and the device for processing data, the data query request containing the first transaction identifier is received, so that the target data indicated by the first transaction identifier and the second transaction identifier mapped with the first transaction identifier are extracted from the maintained blockchain, then the data modification information indicated by the second transaction identifier is extracted from the blockchain, the target data is modified by using the data modification information, and finally the modified data are returned to the client. Therefore, the target data can be modified by using the data modification information for indicating the modification of the target data, the modified complete data does not need to be written in the block chain, and the flexibility of processing the data in the block chain is improved.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 is an exemplary system architecture diagram in which the present application may be applied;
FIG. 2 is a flow diagram of one embodiment of a method for processing data according to the present application;
FIG. 3 is a schematic diagram of an application scenario of a method for processing data according to the present application;
FIG. 4 is a flow diagram of yet another embodiment of a method for processing data according to the present application;
FIG. 5 is a schematic block diagram illustrating one embodiment of an apparatus for processing data according to the present application;
FIG. 6 is a schematic block diagram of a computer system suitable for use in implementing a server according to embodiments of the present application.
Detailed Description
The present application will be described in further detail with reference to the following drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.
Fig. 1 shows an exemplary system architecture 100 to which the method for processing data or the apparatus for processing data of the present application may be applied.
As shown in fig. 1, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The terminal devices 101, 102, 103 may interact with the server 105 via the network 104 to receive or send messages or the like. The terminal apparatuses 101, 102, and 103 may be hardware or software. When the terminal devices 101, 102, 103 are hardware, they may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like. When the terminal apparatuses 101, 102, 103 are software, they can be installed in the electronic apparatuses listed above. It may be implemented as multiple pieces of software or software modules (e.g., to provide distributed services) or as a single piece of software or software module. And is not particularly limited herein.
The server 105 may be hardware or software. When the server is hardware, it may be implemented as a distributed server cluster formed by multiple servers, or may be implemented as a single server. When the server is software, it may be implemented as multiple pieces of software or software modules (e.g., to provide distributed services), or as a single piece of software or software module. And is not particularly limited herein.
It should be noted that the method for processing data provided in the embodiment of the present application is generally performed by the server 105, and accordingly, the apparatus for processing data is generally disposed in the server 105.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
With continued reference to FIG. 2, a flow 200 of one embodiment of a method for processing data in accordance with the present application is shown. The method for processing data comprises the following steps:
In this embodiment, an execution subject (for example, the server 105 shown in fig. 1) of the method for processing data may receive a data query request containing a first transaction identifier sent by a client (for example, the terminal devices 101, 102, 103 shown in fig. 1) by using a wired connection or a wireless connection. It should be noted that the wireless connection means may include, but is not limited to, a 3G/4G connection, a WiFi connection, a bluetooth connection, a WiMAX connection, a Zigbee connection, a uwb (ultra wideband) connection, and other wireless connection means now known or developed in the future.
It should be noted that one transaction of the blockchain may be one operation that causes the ledger state of the blockchain to change. Since data already stored in the blockchain cannot be directly modified, the operation causing the change of the book state of the blockchain is usually to add a new record in the blockchain, that is, to store the data in the blockchain.
Here, each operation that results in a change of ledger state for a blockchain may be characterized by one transaction identification. The transaction identifier may be used to distinguish and determine the operation performed on the blockchain, and may indicate the data stored in the blockchain to which the operation corresponds. Typically, the transaction identifier may be generated when storing data in the blockchain, and is typically a string of numbers and letters. As an example, for each transaction, the data stored for the transaction may be processed by a hash function, and the resulting hash value is used as the transaction identification for the transaction. As yet another example, the transaction identification for the transaction may be generated by generating a random string, and the random string is not repeated with other transaction identifications that have been generated.
Thus, the transaction identifier generated when the target data (which may refer to the original data to be modified currently) is stored to the blockchain maintained by the execution subject may be used as the first transaction identifier. The first transaction identifier may be used to indicate the target data stored in the blockchain. Therefore, when the first transaction identifier is known, the target data corresponding to the first transaction identifier may be queried from the blockchain.
In step 202, target data and a second transaction identifier mapped with the first transaction identifier are extracted from the blockchain.
In this embodiment, mapping information for representing a mapping relationship between the first transaction identifier and the second transaction identifier may be stored in the block chain in advance. Through the mapping information, the execution body may extract the target data and a second transaction identifier mapped with the first transaction identifier from the block chain. The second transaction identifier may be a transaction identifier generated when data modification information indicating that the target data is modified is stored in the block chain. The second transaction identification may be used to indicate the data modification information.
It should be noted that the data modification information indicated by the second transaction identifier may be various forms of information for indicating modification of the target data. For example, the data modification statement may include a wildcard, or may be a Regular Expression (RE).
As an example, the format of the regular expression may be "[ first regular expression ] [ second regular expression ] - > [ content after replacement ]". The first regular expression may be used to match the text to be processed in the target data. The second regular expression may be configured to match a character or a character string to be replaced in the text to be processed, and replace the character or the character string to be replaced with the replaced content. See in particular the following examples: the target data includes a text "01 We are currently in Beijing, China" to be processed and a text "02 You are currently in Beijing, China". Here, the character string "Beijing" in the text to be processed "01 We are currently in Beijing, China" beginning with "01" needs to be replaced with "New York". At this time, the data modification information may include a first regular expression (for example, a regular expression "^ 01.{35} $") for matching the text to be processed "01 We are currently in Beijing, China" in the target data, a second regular expression (for example, the regular expression "Beijing") for matching the character string to be replaced "Beijing" in the text to be processed "01 We are currently in Beijing, China", and the content after replacement "New York".
In practice, a regular expression is a logical formula that operates on strings of characters, including common characters (e.g., letters from character a to character z) and special characters (called "meta characters"). That is, specific characters defined in advance and combinations of the specific characters are used to form a "regular character string", and the "regular character string" is used to express a filtering logic for the character string. A regular expression is a text pattern that describes one or more strings of characters to be matched when searching for text.
And step 203, extracting data modification information indicated by the second transaction identification from the blockchain, and modifying the extracted target data by using the data modification information.
In this embodiment, the execution subject may extract data modification information indicated by the second transaction identifier from the blockchain, and modify the extracted target data by using the data modification information. Here, the data modification information may be a data modification statement including a wildcard, or may be a regular expression, so that the execution subject may directly read the data modification information to modify the target data, thereby obtaining modified data.
And step 204, returning the modified data to the client.
In this embodiment, after modifying the target data and obtaining modified data, the execution main body may return the modified data to the client.
With continued reference to fig. 3, fig. 3 is a schematic diagram of an application scenario of the method for processing data according to the present embodiment. In the application scenario of fig. 3, a user first sends a data query request 303 to a server 302 using a terminal device 301. The data query request 303 includes a first transaction identifier 304 indicating target data stored in a blockchain maintained by the server 302. Then, the server 302 extracts the target data and a second transaction id mapped with the first transaction id from the blockchain. Then, the server 302 extracts the data modification information indicated by the second transaction identifier from the blockchain, and modifies the extracted target data by using the data modification information to obtain modified data. Finally, the server 302 returns the modified data 305 to the terminal device 301.
In the method provided by the above embodiment of the present application, a data query request including a first transaction identifier is received, so as to extract target data indicated by the first transaction identifier and a second transaction identifier mapped with the first transaction identifier from a maintained blockchain, then data modification information indicated by the second transaction identifier is extracted from the blockchain, the target data is modified by using the data modification information, and finally, the modified data is returned to the client. Therefore, the target data can be modified by using the data modification information for indicating the modification of the target data, the modified complete data does not need to be written in the block chain, the data modification efficiency is improved under the conditions that the target data is large but the content to be modified is less, or the same content needs to be modified in multiple transactions, and the like, the storage space is saved, and the flexibility of processing the data in the block chain is improved.
With further reference to FIG. 4, a flow 400 of yet another embodiment of a method for processing data is shown. The flow 400 of the method for processing data includes the steps of:
In this embodiment, an execution subject of the method for processing data (e.g., the server 105 shown in fig. 1) may receive a data storage request including target data. The target data may be any data to be stored in the block chain maintained by the execution main body.
In this embodiment, the execution subject may store the target data to a blockchain, and generate a first transaction identifier indicating the target data stored in the blockchain. Here, the target data may be processed by a hash function, and the obtained hash value may be used as the first transaction identifier. Under the condition that any kind of first transaction identification is known, the target data corresponding to the first transaction identification can be inquired from the block chain.
At step 403, a data modification request including the first transaction identification and data modification information is received.
In this embodiment, the executing entity may receive a data modification request including the first transaction identifier and data modification information. The data modification information may be used to indicate that the target data is modified. Here, the data modification information may be a regular expression.
It should be noted that the executing entity may receive a data modification request containing the first transaction identifier multiple times. Each received data modification request may contain different data modification information. As examples, the target data includes a text "01 We are currently in Beijing, China" and a text "02 You are currently in Beijing, China" to be processed. The data modification information in the data modification request received for the first time may be used to indicate that the character string "Beijing" in the pending text "01 We are currently in Beijing, China" beginning with "01" is replaced with "New York". The data modification information in the data modification request received the second time may be used to indicate that the character string "China" in the text to be processed "01 We are currently in Beijing, China" beginning with "01" is replaced with "America".
In this embodiment, the execution body may determine whether the block chain stores the data modification information. Specifically, the target data may be first processed by a hash function to obtain a target hash value. Then, since each transaction of the block chain may be a method of processing the stored data by using a hash function and using the obtained hash value as a transaction identifier, the execution body may match the target hash value with the transaction identifier of each transaction of the block chain. In response to determining that there is a transaction identifier that matches the target hash value, it may be determined that the data modification information is stored in the blockchain. In response to determining that there is no transaction identifier matching the target hash value, it may be determined that the data modification information is not stored in the blockchain.
In this embodiment, in response to determining that the data modification information is not stored in the blockchain, the execution main body may store the data modification information in the blockchain, and generate a second transaction identifier indicating the data modification information stored in the blockchain. Here, the target hash value may be used as the second transaction identifier.
It is noted that, in response to determining that the data modification information is stored in the blockchain, the execution body may extract a second transaction id indicating the data modification information stored in the blockchain.
It should be noted that, if the execution main body receives a data modification request including the first transaction identifier for multiple times, and each received data modification request includes different data modification information, it may be determined in sequence according to the sequence sent by the data modification request whether each piece of data modification information is stored in the block chain, and if not, a second transaction identifier of the data modification information is generated.
In this embodiment, the execution subject may establish a mapping between the first transaction identifier and the second transaction identifier in the block chain. Here, the mapping may be characterized in various forms, such as a correspondence table and the like.
In some optional implementations of this embodiment, the executing entity may use the first transaction identifier as a key of a key-value pair, use the second transaction identifier as a value of the key-value pair, characterize a mapping between the first transaction identifier and the second transaction identifier with the key-value pair, and store the key-value pair in the block chain. When storing the key-value pair to the blockchain, a transaction identifier of the operation (i.e., transaction) may be generated as a third transaction identifier. The third transaction identifier is used to indicate the key-value pair stored in the blockchain. It should be noted that the generation manner of the third transaction identifier is substantially the same as the generation manner of the first transaction identifier, and details are not repeated here.
In this embodiment, the execution subject may receive a data query request that includes the first transaction identifier and is sent by a client.
In step 407, the target data and the second transaction identifier mapped to the first transaction identifier are extracted from the blockchain.
In this embodiment, the execution body may extract the target data and the second transaction identifier mapped to the first transaction identifier from the blockchain.
It should be noted that the operation of step 406 is substantially the same as the operation of step 201, and is not described herein again.
And 408, extracting data modification information indicated by the second transaction identifier from the blockchain, and modifying the extracted target data by using the data modification information.
In this embodiment, in response to determining that the number of the second transaction identifiers mapped with the first transaction identifier is a preset value (e.g., 1), the execution main body may directly extract the data modification information indicated by the second transaction identifiers from the blockchain, and modify the extracted target data by using the data modification information.
In this embodiment, in response to determining that the number of the second transaction identifiers mapped with the first transaction identifier is greater than a preset value, in this embodiment, in response to determining that the number of the second transaction identifiers mapped with the first transaction identifier is greater than a preset value (for example, 1), the execution main body may use, as a target transaction identifier, the second transaction identifier mapped with the first transaction identifier first according to the sequence of mapping with the first transaction identifier, and execute the following data modification step: extracting data modification information indicated by the target transaction identification from the block chain; and modifying the target data by using the extracted data modification information.
Then, the executing body may use the modified data obtained after the data modification step is executed as the target data, and continue to execute the data modification step by using the next second transaction identifier as the target transaction identifier according to the sequence of establishing the mapping with the first transaction identifier. And modifying the new target data by using the data modification information indicated by the last second transaction identifier which is mapped with the first transaction identifier to obtain the final modified data.
As examples, the target data includes a text "01 We are currently in Beijing, China" and a text "02 You are currently in Beijing, China" to be processed. The data modification information indicated by the first and second transaction identifications mapped with the first transaction identification may be used to indicate that the character string "Beijing" in the text "01 We are currently in Beijing, China" beginning with "01" is replaced with "New York". The data modification information indicated by the second transaction identifier mapped with the first transaction identifier may be used to indicate that the character string "China" in the text "01 We are currently in Beijing, China" beginning with "01" is replaced with "America". The execution main body may first extract data modification information indicated by the first second transaction identifier from the block chain, and modify the text "01 We are currently in Beijing, China" to be processed into the text "01 We are currently in New York, China". Then, data including the modified text "01 We are currently in New York, China" and the text "02 You are currently in Beijing, China" may be used as target data, data modification information indicated by the second transaction identifier may be extracted from the block chain, and the modified text "01 We are currently in New York, China" may be modified to "01 We are currently in New York, America". The final modified data contains the text "01 We are currently in New York, America" and the text "02 You are currently in Beijing, China".
In this embodiment, after modifying the target data and obtaining modified data, the execution main body may return the modified data to the client.
As can be seen from fig. 4, compared with the embodiment corresponding to fig. 2, the flow 400 of the method for processing data in this embodiment highlights the step of storing the data modification information to the block chain, and does not need to write the modified complete data in the block chain, so that under the conditions that the target data is large but the content to be modified is small, or the same content needs to be modified in multiple transactions, and the like, the efficiency of data modification is improved, the storage space is saved, and the flexibility of storing the data in the block chain is improved. Meanwhile, the flow 400 of the method for processing data in the present embodiment highlights a step of modifying data multiple times using a regular expression as data modification information. Therefore, the scheme described in the embodiment can greatly reduce the information stored in the block chain, improve the storage performance and the transaction efficiency, and reduce the storage cost. And, for the same modification, the basic structure of the regular expression can be shared without additional storage. The flexibility of processing data in the blockchain is further improved.
With further reference to fig. 5, as an implementation of the methods shown in the above-mentioned figures, the present application provides an embodiment of an apparatus for processing data, which corresponds to the method embodiment shown in fig. 2, and which is particularly applicable to various electronic devices.
As shown in fig. 5, the apparatus 500 for processing data according to the present embodiment includes: a first receiving unit 501, configured to receive a data query request sent by a client and including a first transaction identifier, where the first transaction identifier is used to indicate target data stored in a maintained blockchain; a first extracting unit 502 configured to extract, from the blockchain, the target data and a second transaction identifier mapped to the first transaction identifier, where the second transaction identifier is used to indicate data modification information stored in the blockchain, and the data modification information is used to indicate that the target data is modified; a modification unit 503 configured to extract the data modification information indicated by the second transaction identifier from the blockchain, and modify the extracted target data by using the data modification information; a first returning unit 504 configured to return the modified data to the client.
In some optional implementations of this embodiment, the apparatus may further include a second receiving unit, a determining unit, and a establishing unit (not shown in the figure). Wherein the second receiving unit may be configured to receive a data modification request including the first transaction identification and the data modification information. The determining unit may be configured to determine whether the block chain stores the data modification information, and if not, store the data modification information to the block chain, and generate a second transaction identifier indicating the data modification information stored in the block chain. The establishing unit may be configured to establish a mapping of the first transaction identity and the second transaction identity in the blockchain.
In some optional implementations of this embodiment, the apparatus may further include a second extraction unit (not shown in the figure). Wherein the second extracting unit may be configured to extract a second transaction identifier indicating the data modification information stored in the blockchain in response to determining that the data modification information is stored in the blockchain.
In some optional implementations of this embodiment, the apparatus may further include a third receiving unit and a storage unit (not shown in the figure). Wherein the third receiving unit may be configured to receive a data storage request including target data. The storage unit may be configured to store the target data to a blockchain, and generate a first transaction identifier indicating the target data stored in the blockchain.
In some optional implementations of this embodiment, the establishing unit may be further configured to store the key-value pair in the blockchain with the first transaction identifier as a key of the key-value pair and the second transaction identifier as a value of the key-value pair, and generate a third transaction identifier indicating the key-value pair stored in the blockchain.
In some optional implementations of this embodiment, the apparatus may further include a second returning unit (not shown in the figure). Wherein the second returning unit may be configured to return the second transaction identifier.
In some optional implementations of this embodiment, the modification unit may include a first execution module and a second execution module (not shown in the figure). The first executing module may be configured to, in response to determining that the number of the second transaction identifiers mapped with the first transaction identifier is greater than a preset value, in the order of mapping with the first transaction identifier, take the second transaction identifier mapped with the first transaction identifier first as a target transaction identifier, and execute the following data modifying steps: extracting data modification information indicated by the target transaction identification from the block chain; and modifying the extracted target data by using the extracted data modification information. The second execution module may be configured to take the modified data as target data, take a next second transaction identifier as a target transaction identifier according to a sequence of establishing mapping with the first transaction identifier, and continue to execute the data modification step.
In some optional implementations of the embodiment, the data modification information may be a regular expression used for modifying the target data.
In the apparatus provided by the above embodiment of the present application, the first receiving unit 501 receives a data query request including a first transaction identifier, so that the first extracting unit 502 extracts target data indicated by the first transaction identifier and a second transaction identifier mapped with the first transaction identifier from a maintained blockchain, the modifying unit extracts data modification information indicated by the second transaction identifier from the blockchain, modifies the target data by using the data modification information, and finally the first returning unit returns the modified data to the client. Therefore, the target data can be modified by using the data modification information for indicating the modification of the target data, the modified complete data does not need to be written in the block chain, the data modification efficiency is improved under the conditions that the target data is large but the content to be modified is less, or the same content needs to be modified in multiple transactions, and the like, the storage space is saved, and the flexibility of processing the data in the block chain is improved.
Referring now to FIG. 6, shown is a block diagram of a computer system 600 suitable for use in implementing a server according to embodiments of the present application. The server shown in fig. 6 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present application.
As shown in fig. 6, the computer system 600 includes a Central Processing Unit (CPU)601 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data necessary for the operation of the system 600 are also stored. The CPU 601, ROM 602, and RAM 603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
The following components are connected to the I/O interface 605: an input portion 606 including a keyboard, a mouse, and the like; an output portion 607 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The driver 610 is also connected to the I/O interface 605 as needed. A removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 610 as necessary, so that a computer program read out therefrom is mounted in the storage section 608 as necessary.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 609, and/or installed from the removable medium 611. The computer program performs the above-described functions defined in the method of the present application when executed by a Central Processing Unit (CPU) 601. It should be noted that the computer readable medium described herein can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present application, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In this application, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, 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.
The units described in the embodiments of the present application may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes a first receiving unit, a first extracting unit, a modifying unit, and a first returning unit. The names of these units do not in some cases form a limitation on the unit itself, for example, the first receiving unit may also be described as a "unit that receives a data query request sent by a client and containing the first transaction identifier".
As another aspect, the present application also provides a computer-readable medium, which may be contained in the apparatus described in the above embodiments; or may be present separately and not assembled into the device. The computer readable medium carries one or more programs which, when executed by the apparatus, cause the apparatus to: receiving a data query request which is sent by a client and contains a first transaction identifier; extracting the target data and a second transaction identifier which establishes mapping with the first transaction identifier from the blockchain; extracting the data modification information indicated by the second transaction identifier from the blockchain, and modifying the extracted target data by using the data modification information; and returning the modified data to the client.
The above description is only a preferred embodiment of the application and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention herein disclosed is not limited to the particular combination of features described above, but also encompasses other arrangements formed by any combination of the above features or their equivalents without departing from the spirit of the invention. For example, the above features may be replaced with (but not limited to) features having similar functions disclosed in the present application.
Claims (18)
1. A method for processing data, comprising:
receiving a data query request which is sent by a client and contains a first transaction identifier, wherein the first transaction identifier is used for indicating target data stored in a maintained block chain;
extracting the target data and a second transaction identifier mapped with the first transaction identifier from the blockchain, wherein the second transaction identifier is used for indicating data modification information stored in the blockchain, and the data modification information is used for indicating modification of the target data;
extracting the data modification information indicated by the second transaction identification from the blockchain, and modifying the extracted target data by using the data modification information;
and returning the modified data to the client.
2. The method for processing data of claim 1, wherein prior to receiving a data query request sent by a client containing a first transaction identification, the method further comprises:
receiving a data modification request comprising a first transaction identification and data modification information;
determining whether the block chain stores the data modification information or not, if not, storing the data modification information to the block chain, and generating a second transaction identifier for indicating the data modification information stored in the block chain;
establishing a mapping of the first transaction identity and the second transaction identity in the blockchain.
3. The method for processing data according to claim 2, wherein after said determining whether said data modification information is stored in said block chain, said method further comprises:
in response to determining that the data modification information is stored in the blockchain, a second transaction identification indicating the data modification information stored in the blockchain is extracted.
4. The method for processing data of claim 2, wherein prior to said receiving a data modification request including a first transaction identification and data modification information, the method further comprises:
receiving a data storage request comprising target data;
storing the target data to a blockchain, and generating a first transaction identifier for indicating the target data stored in the blockchain.
5. The method for processing data according to claim 2, wherein said establishing a mapping of said first transaction identity to said second transaction identity in said blockchain comprises:
and storing the key-value pair in the blockchain by taking the first transaction identifier as a key of the key-value pair and taking the second transaction identifier as a value of the key-value pair, and generating a third transaction identifier for indicating the key-value pair stored in the blockchain.
6. The method for processing data of claim 2, wherein after said generating a second transaction identification indicating the data modification information stored in the blockchain, the method further comprises:
and returning the second transaction identification.
7. The method for processing data according to claim 1, wherein said extracting the data modification information indicated by the second transaction identification from the blockchain, modifying the extracted target data with the data modification information, comprises:
in response to determining that the number of the second transaction identifications mapped with the first transaction identification is larger than a preset value, according to the sequence of mapping with the first transaction identification, taking the second transaction identification mapped with the first transaction identification as a target transaction identification, and executing the following data modification steps: extracting data modification information indicated by a target transaction identification from the blockchain; modifying the target data by using the extracted data modification information;
and taking the modified data as target data, taking the next second transaction identifier as a target transaction identifier according to the sequence of establishing mapping with the first transaction identifier, and continuously executing the data modification step.
8. The method for processing data according to one of claims 1 to 7, wherein the data modification information is a regular expression for modifying the target data.
9. An apparatus for processing data, comprising:
a first receiving unit, configured to receive a data query request sent by a client and containing a first transaction identifier, where the first transaction identifier is used to indicate target data stored in the maintained blockchain;
a first extraction unit configured to extract, from the blockchain, the target data and a second transaction identifier mapped to the first transaction identifier, the second transaction identifier indicating data modification information stored in the blockchain, the data modification information indicating that the target data is modified;
a modification unit configured to extract the data modification information indicated by the second transaction identification from the blockchain, and modify the extracted target data using the data modification information;
a first returning unit configured to return the modified data to the client.
10. The apparatus for processing data of claim 9, wherein the apparatus further comprises:
a second receiving unit configured to receive a data modification request including the first transaction identification and data modification information;
the determining unit is configured to determine whether the block chain stores the data modification information, if not, the data modification information is stored in the block chain, and a second transaction identifier used for indicating the data modification information stored in the block chain is generated;
an establishing unit configured to establish a mapping of the first transaction identity and the second transaction identity in the blockchain.
11. The apparatus for processing data of claim 10, wherein the apparatus further comprises:
a second extraction unit configured to extract a second transaction identification indicating the data modification information stored in the blockchain in response to determining that the data modification information is stored in the blockchain.
12. The apparatus for processing data of claim 10, wherein the apparatus further comprises:
a third receiving unit configured to receive a data storage request including target data;
a storage unit configured to store the target data to a blockchain, and generate a first transaction identifier indicating the target data stored in the blockchain.
13. The apparatus for processing data of claim 10, wherein the establishing unit is further configured to:
and storing the key-value pair in the blockchain by taking the first transaction identifier as a key of the key-value pair and taking the second transaction identifier as a value of the key-value pair, and generating a third transaction identifier for indicating the key-value pair stored in the blockchain.
14. The apparatus for processing data of claim 10, wherein the apparatus further comprises:
a second return unit configured to return the second transaction identification.
15. The apparatus for processing data of claim 9, wherein the modifying unit comprises:
a first execution module, configured to, in response to determining that the number of second transaction identifiers mapped with the first transaction identifier is greater than a preset value, in an order of establishing mapping with the first transaction identifier, take the second transaction identifier mapped with the first transaction identifier first as a target transaction identifier, and execute the following data modification steps: extracting data modification information indicated by a target transaction identification from the blockchain; modifying the extracted target data using the extracted data modification information;
and the second execution module is configured to take the modified data as target data, take the next second transaction identifier as a target transaction identifier according to the sequence of establishing mapping with the first transaction identifier, and continue to execute the data modification step.
16. Apparatus for processing data according to any of claims 9 to 15, wherein the data modification information is a regular expression for modifying the target data.
17. A server, comprising:
one or more processors;
a storage device having one or more programs stored thereon,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-8.
18. A computer-readable medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810587534.7A CN108846753B (en) | 2018-06-06 | 2018-06-06 | Method and apparatus for processing data |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810587534.7A CN108846753B (en) | 2018-06-06 | 2018-06-06 | Method and apparatus for processing data |
Publications (2)
Publication Number | Publication Date |
---|---|
CN108846753A CN108846753A (en) | 2018-11-20 |
CN108846753B true CN108846753B (en) | 2021-11-09 |
Family
ID=64210684
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810587534.7A Active CN108846753B (en) | 2018-06-06 | 2018-06-06 | Method and apparatus for processing data |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108846753B (en) |
Families Citing this family (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109697249A (en) * | 2018-12-07 | 2019-04-30 | 深圳市云歌人工智能技术有限公司 | Search for method, system and the storage medium of target object and issue object |
CN109815226B (en) * | 2018-12-13 | 2023-10-31 | 平安科技(深圳)有限公司 | Block chain-based data storage method, device, equipment and storage medium |
CN111475309A (en) * | 2019-01-24 | 2020-07-31 | 北京京东尚科信息技术有限公司 | Data processing method, device, block chain service system and storage medium |
CN109902080A (en) * | 2019-01-24 | 2019-06-18 | 北京太一智源科技有限公司 | The data monitoring and managing method of block chain |
CN109919622B (en) * | 2019-02-22 | 2020-10-23 | 杭州复杂美科技有限公司 | Transaction replacement method, apparatus and storage medium |
CN110070445B (en) * | 2019-04-28 | 2024-03-01 | 深圳前海微众银行股份有限公司 | Transaction processing method and device based on blockchain system |
CN110443052B (en) * | 2019-07-30 | 2021-05-07 | 深圳市科迈爱康科技有限公司 | Modification method and system for block chain block |
CN112416910A (en) * | 2019-08-22 | 2021-02-26 | 顺丰科技有限公司 | Data processing method, device, server and computer readable storage medium |
CN110825363B (en) * | 2019-11-01 | 2024-05-17 | 北京知道创宇信息技术股份有限公司 | Intelligent contract acquisition method and device, electronic equipment and storage medium |
CN113256301B (en) * | 2021-07-13 | 2022-03-29 | 杭州趣链科技有限公司 | Data shielding method, device, server and medium |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101866405A (en) * | 2010-06-23 | 2010-10-20 | 江苏大学 | A method for protecting private data in association rule mining |
CN103631774A (en) * | 2012-08-20 | 2014-03-12 | 腾讯科技(深圳)有限公司 | Data storing method and system |
CN103853774A (en) * | 2012-12-04 | 2014-06-11 | 金蝶软件(中国)有限公司 | Page data configuration method, device and system |
WO2017044554A1 (en) * | 2015-09-11 | 2017-03-16 | Aware, Inc. | Biometric verification of a blockchain database transaction contributor |
CN106897352A (en) * | 2016-12-29 | 2017-06-27 | 北京瑞卓喜投科技发展有限公司 | The generation method and system of the block chain modified in expansion |
WO2018043865A2 (en) * | 2016-08-31 | 2018-03-08 | 서강대학교 산학협력단 | Blockchain-based file management/search system and file management/search method |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9870562B2 (en) * | 2015-05-21 | 2018-01-16 | Mastercard International Incorporated | Method and system for integration of market exchange and issuer processing for blockchain-based transactions |
-
2018
- 2018-06-06 CN CN201810587534.7A patent/CN108846753B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101866405A (en) * | 2010-06-23 | 2010-10-20 | 江苏大学 | A method for protecting private data in association rule mining |
CN103631774A (en) * | 2012-08-20 | 2014-03-12 | 腾讯科技(深圳)有限公司 | Data storing method and system |
CN103853774A (en) * | 2012-12-04 | 2014-06-11 | 金蝶软件(中国)有限公司 | Page data configuration method, device and system |
WO2017044554A1 (en) * | 2015-09-11 | 2017-03-16 | Aware, Inc. | Biometric verification of a blockchain database transaction contributor |
WO2018043865A2 (en) * | 2016-08-31 | 2018-03-08 | 서강대학교 산학협력단 | Blockchain-based file management/search system and file management/search method |
CN106897352A (en) * | 2016-12-29 | 2017-06-27 | 北京瑞卓喜投科技发展有限公司 | The generation method and system of the block chain modified in expansion |
Non-Patent Citations (1)
Title |
---|
去中心化的分布式存储模型;郝琨 等;《计算机工程与应用》;20171231;第53卷(第24期);第1-7、22页 * |
Also Published As
Publication number | Publication date |
---|---|
CN108846753A (en) | 2018-11-20 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108846753B (en) | Method and apparatus for processing data | |
CN110019350B (en) | Data query method and device based on configuration information | |
CN107622135B (en) | Method and apparatus for displaying information | |
US20200151017A1 (en) | Event-driven blockchain workflow processing | |
CN109359194B (en) | Method and apparatus for predicting information categories | |
CN111339743B (en) | Account number generation method and device | |
CN110019080A (en) | Data access method and device | |
CN108897874B (en) | Method and apparatus for processing data | |
CN112948138B (en) | A method and device for processing messages | |
CN110109983B (en) | Method and device for operating Redis database | |
US20190012362A1 (en) | Method and apparatus for processing information | |
CN112883009A (en) | Method and apparatus for processing data | |
CN109766127A (en) | Methods for updating application version information | |
CN113010405A (en) | Application program testing method and device | |
CN109753424B (en) | AB test method and device | |
CN111552715B (en) | User query method and device | |
CN113704222B (en) | A method and device for processing a service request | |
US11368297B2 (en) | Method and apparatus for updating digital certificate | |
CN108399046B (en) | File operation request processing method and device | |
CN107291923B (en) | Information processing method and device | |
CN108804442B (en) | Serial number generation method and device | |
CN113760860A (en) | Data reading method and device | |
CN112579428B (en) | Interface testing method, device, electronic equipment and storage medium | |
CN111460273B (en) | Information pushing method and device | |
CN111951112A (en) | Intelligent contract execution method based on block chain, terminal equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |