A data storage method and device
By using compensation transaction queues to deal with proof storage service failures in blockchain proof storage technology, the problem of mismatch between the data generation rate of to-be-stored proof and the proof storage rate is solved, and the data security proof storage and business performance are improved.
Patent Information
- Application Number
- CN202111194320.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-13
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2041-10-13
AI Technical Summary
In blockchain proof storage technology, the rate of business data generation to be stored does not match the rate of proof storage, resulting in the synchronous linking method having an adverse impact on business performance. If the asynchronous linking method fails, data loss or proof storage failure may be caused.
When the evidence storage service fails, obtain the data to be stored for failure, create corresponding compensation transactions and deposit them into the preset compensation transaction queue. After the evidence storage service fails to recover, obtain compensation transactions from the queue and send them to the blockchain for evidence storage.
By compensating the transaction queue, we ensure that the data that failed to store evidence can be successfully put on the link and stored evidence after the failure of the proof storage service is restored, avoiding data loss and waiting time for too long to store evidence, and improving the business user experience.
Smart Images

Figure CN113986915B_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of computer applications, and in particular to a data storage method and device. Background Art
[0002] Blockchain technology, also known as distributed ledger technology, is an emerging technology in which several computing devices jointly participate in "bookkeeping" and jointly maintain a complete distributed database. Among them, data notarization is an important application of blockchain technology; in business processing, the server connected to the blockchain usually needs to generate transactions carrying business data and publish them to the above blockchain, so as to store the above business data in the above blockchain. However, in the actual application of the above-mentioned notarization technology, the rate at which the business data to be notarized is generated may not match the rate of notarization. Therefore, if the synchronous on-chain method is adopted, the business end is likely to be suspended and wait because it needs to wait for the server to publish the transaction to the blockchain, which will have an adverse impact on business performance.
[0003] In the related technology, data can be uploaded to the chain asynchronously. In this case, the business side does not need to wait for the server to publish the execution result of the transaction to the blockchain, thereby reducing the adverse impact of the synchronous chain method on business performance; however, when adopting the above method, if the evidence storage service used for chain evidence storage fails, it may result in data loss, evidence invalidation and other consequences. Summary of the invention
[0004] In view of this, this specification discloses a data storage method and device.
[0005] According to a first aspect of an embodiment of this specification, a data evidence storage method is disclosed, which is applied to a server connected to a blockchain, wherein the server is equipped with an evidence storage service for storing data on the blockchain; the method comprises:
[0006] In the event of a failure in the evidence storage service, obtaining the data to be stored that failed to be stored;
[0007] Creating a compensation transaction corresponding to the data to be stored, and storing the compensation transaction in a preset compensation transaction queue;
[0008] After the failure of the evidence storage service is recovered, any compensation transaction is obtained from the compensation transaction queue, and any compensation transaction is sent to the blockchain through the evidence storage service, so as to store the data to be stored corresponding to any compensation transaction on the blockchain.
[0009] According to a second aspect of the embodiments of this specification, a data evidence storage device is disclosed.
[0010] The device is applied to a server connected to a blockchain, wherein the server is equipped with a storage service for storing data on the blockchain; the device comprises:
[0011] An acquisition module, for acquiring the data to be stored that failed to be stored when the storage service fails;
[0012] A creation module, which creates a compensation transaction corresponding to the data to be stored, and stores the compensation transaction in a preset compensation transaction queue;
[0013] The sending module obtains any compensation transaction from the compensation transaction queue after the failure of the evidence service is recovered, and sends any compensation transaction to the blockchain through the evidence service, so as to store the data to be stored corresponding to any compensation transaction on the blockchain.
[0014] In the above technical solution, on the one hand, since the created compensation transaction corresponds to the data to be stored that failed to be stored, and the compensation transaction can be sent to the blockchain after the storage service failure is restored, the data to be stored that previously failed to be stored due to the failure of the storage service can be successfully stored on the blockchain, avoiding problems such as data loss.
[0015] On the other hand, since the above-mentioned compensation transactions are stored in the form of a compensation transaction queue, and the queue data structure has a first-in-first-out read-write feature, the compensation transactions are taken out from the compensation transaction queue and sent to the blockchain. The order in which the compensation transactions were stored in the compensation transaction queue can be maintained, so that the data to be stored that failed to be stored due to a fault earlier can be completed and stored on the chain as soon as possible, avoiding long waiting time for storage and improving the user experience of the business. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the specification and, together with the description, serve to explain the principles.
[0017] Figure 1 This is a diagram showing an example of the structure of the data evidence storage system described in this specification;
[0018] Figure 2 This is a flowchart of the data evidence storage method described in this manual;
[0019] Figure 3 is a diagram showing an example of the structure of the correspondence table described in this specification;
[0020] Figure 4 It is a structural example diagram of the data evidence storage device described in this specification;
[0021] Figure 5 This is a diagram showing an example of the structure of the server used for data storage as described in this manual. DETAILED DESCRIPTION
[0022] In order to enable those skilled in the art to better understand the technical solutions in one or more embodiments of this specification, the technical solutions in one or more embodiments of this specification will be clearly and completely described below in conjunction with the drawings in one or more embodiments of this specification. Obviously, the described embodiments are only some embodiments, not all embodiments. Based on one or more embodiments of this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this specification.
[0023] When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this specification. Instead, they are only examples of systems and methods consistent with some aspects of this specification as detailed in the attached claims.
[0024] The terms used in this specification are for the purpose of describing specific embodiments only and are not intended to limit this specification. The singular forms "a", "the" and "the" used in this specification and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0025] It should be understood that although the terms first, second, third, etc. may be used in this specification to describe various information, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0026] Blockchain technology, also known as distributed ledger technology, is an emerging technology in which several computing devices jointly participate in "bookkeeping" and jointly maintain a complete distributed database. Blockchain technology has been widely used in many fields because of its decentralized, open and transparent characteristics, each computing device can participate in database records, and data can be quickly synchronized between computing devices.
[0027] Evidence storage is an important application of blockchain. For real data generated in the physical world, it can be constructed into a standard transaction format supported by blockchain, and then published to the blockchain. The node devices in the blockchain will perform consensus processing on the received transactions. After reaching a consensus, the node devices in the blockchain that serve as accounting nodes will package the transaction into blocks and store it persistently in the blockchain.
[0028] See also Figure 1 , Figure 1 This is a structural example diagram of a data evidence storage system shown in this specification; Figure 1 As shown, the data storage system may include a blockchain network and a server connected to the blockchain network.
[0029] Among them, the above-mentioned blockchain network can be a network composed of multiple blockchain node devices, and the above-mentioned blockchain node devices can be physical devices or virtual devices implemented in a server or server cluster; for example, the blockchain node device can be a physical host in a server cluster, or it can be a virtual machine created by virtualizing the hardware resources carried by the server or server cluster based on virtualization technology. Each blockchain node can be connected together to form a network through various types of communication methods (such as TCP / IP) to carry one or more blockchains. Generally, blockchains can be divided into three types: public blockchain, private blockchain and consortium blockchain. In addition, there can also be a combination of the above types, such as private chain + consortium chain, consortium chain + public chain, etc.
[0030] Among them, the most decentralized is the public chain. Public chains are represented by Bitcoin and Ethereum. Participants who join the public chain (also called nodes in the blockchain) can read data records on the chain, participate in transactions, and compete for the right to record new blocks. Moreover, each node can freely join or exit the network and perform related operations.
[0031] On the contrary, the private chain has a network whose write permission is controlled by a certain organization or institution, and the data read permission is regulated by the organization. In simple terms, a private chain can be a weakly centralized system with strict restrictions on nodes and a small number of nodes. This type of blockchain is more suitable for use within a specific institution.
[0032] The consortium chain is a blockchain between the public chain and the private chain, which can achieve "partial decentralization". Each node in the consortium chain usually has a corresponding entity or organization; the nodes join the network through authorization and form a stakeholder alliance to jointly maintain the operation of the blockchain.
[0033] Based on the basic characteristics of blockchain, blockchain is usually composed of several blocks. In each of these blocks, a timestamp corresponding to the creation time of the block is recorded. All blocks strictly follow the timestamp recorded in the block to form a data chain that is ordered in time.
[0034] The above-mentioned server can be any form of server connected to the above-mentioned blockchain; for example, the server can be a single physical server, a server cluster composed of multiple physical servers, or a server virtual machine running in a cloud service; the above-mentioned server and the blockchain node can be connected through a communication network, and the communication network can include a wired and / or wireless communication network; for example, it can be a local area network (LAN), a wide area network (WAN), the Internet or a combination thereof implemented based on a wired access network or a wireless access network (such as a mobile cellular network) provided by an operator; technical personnel in this field can select the specific implementation form of the above-mentioned server and the network connection method between the above-mentioned server and the above-mentioned blockchain according to specific business needs.
[0035] Based on the above-mentioned evidence storage system, the server connected to the blockchain can generate transactions carrying business data and publish the generated transactions to the above-mentioned blockchain, so as to store the corresponding business data in the above-mentioned blockchain. However, in the actual application of the above-mentioned evidence storage technology, the rate at which the business data to be stored is generated may not match the rate of storage; for example, during business peak hours, the rate at which the business data to be stored may be generated may be high, while the rate of blockchain storage may be low due to network congestion and other reasons. Therefore, in the above-mentioned situation, if the synchronous chain-up method is adopted, the business end is likely to be suspended and wait because it needs to wait for the server to publish the transaction to the blockchain, resulting in the accumulation of a large amount of business data to be stored, which in turn has an adverse effect on business performance.
[0036] In the related technology, data can be uploaded to the chain asynchronously. In this case, the business side does not need to wait for the server to publish the execution result of the transaction to the blockchain, thereby reducing the adverse impact of the synchronous chain method on business performance; however, when adopting the above method, if the evidence storage service used for chain evidence storage fails, it may result in data loss, evidence invalidation and other consequences.
[0037] Based on this, this specification proposes a technical solution for compensating the data that failed to be stored and storing it on the chain by using a compensatory transaction corresponding to the data that failed to be stored.
[0038] During implementation, in the event of a failure in the evidence storage service, a compensation transaction corresponding to the data for which the evidence storage failed can be generated, and the generated compensation transaction can be stored in a preset compensation transaction queue; after the evidence storage service failure is restored, the compensation transaction can be extracted from the compensation transaction queue and sent to the blockchain, thereby completing the on-chain evidence storage of the corresponding data for which the evidence storage failed.
[0039] For example, assuming that the network communication between the above-mentioned server and the blockchain is interrupted, the evidence service used by the above-mentioned server to store data in the above-mentioned blockchain cannot work normally, resulting in the failure of the electronic evidence numbered 101010 to be stored. In this case, the server can generate a compensation transaction corresponding to the electronic evidence numbered 101010 to be stored, and store the compensation transaction in a compensation transaction queue. After the problem of the above-mentioned network communication interruption is resolved and the above-mentioned evidence service fault is restored, the previously generated compensation transaction can be extracted from the compensation transaction queue and sent to the blockchain, thereby completing the corresponding on-chain storage of the electronic evidence numbered 101010 to be stored.
[0040] In the above technical solution, on the one hand, since the created compensation transaction corresponds to the data to be stored that failed to be stored, and the compensation transaction can be sent to the blockchain after the storage service failure is restored, the data to be stored that previously failed to be stored due to the failure of the storage service can be successfully stored on the blockchain, avoiding problems such as data loss.
[0041] On the other hand, since the above-mentioned compensation transactions are stored in the form of a compensation transaction queue, and the queue data structure has a first-in-first-out read-write feature, the compensation transactions are taken out from the compensation transaction queue and sent to the blockchain. The order in which the compensation transactions were stored in the compensation transaction queue can be maintained, so that the data to be stored that failed to be stored due to a fault earlier can be completed and stored on the chain as soon as possible, avoiding long waiting time for storage and improving the user experience of the business.
[0042] The present specification is described below through specific embodiments and in combination with specific application scenarios.
[0043] Please refer to Figure 2 , Figure 2 This is a flow chart of a data storage method provided in an embodiment of this specification. The method can be applied to a server connected to a blockchain network. The server can be equipped with a storage service for storing data on the blockchain. The method may include the following steps:
[0044] S201, when the evidence storage service fails, obtaining the to-be-stored data that failed to be stored;
[0045] S202, creating a compensation transaction corresponding to the data to be stored, and storing the compensation transaction in a preset compensation transaction queue;
[0046] S203, after the failure of the evidence storage service is recovered, obtain any compensation transaction from the compensation transaction queue, and send any compensation transaction to the blockchain through the evidence storage service, so as to store the data to be stored corresponding to any compensation transaction on the blockchain.
[0047] The above-mentioned server and blockchain may include: Figure 1 The server and blockchain in the evidence storage system, that is, the server can be a single physical server, a server cluster composed of multiple physical servers, or a server virtual machine running in a cloud service. The blockchain can be a public chain, a consortium chain, or a private chain, or private chain + consortium chain, consortium chain + public chain, etc. Technical personnel in this field can select the specific types of the server and blockchain according to specific business needs, and this specification does not need to be limited in detail.
[0048] The above-mentioned evidence storage service may include a software service configured in the above-mentioned server end for storing data in the blockchain to which the above-mentioned server end is connected. For example, the blockchain gateway software module in the server end can be regarded as the above-mentioned evidence storage service, or the entire process software such as the blockchain gateway software module, transaction creation software module, signature verification software module, network communication software module in the server end can be regarded as the above-mentioned evidence storage service, and this specification does not need to be strictly limited to this.
[0049] The above-mentioned evidence storage service failure may include any situation where the above-mentioned evidence storage service cannot work; it is understandable that although the above-mentioned evidence storage service is a software service, the above-mentioned evidence storage service failure may include software failures, such as the operating system of the above-mentioned server crashing and not responding, network communication parameter configuration errors, blockchain gateway program crashes, etc., and may also include hardware failures, such as the network communication line being physically cut off, the power supply of the server being interrupted, the fire in the computer room, etc. Those skilled in the art may apply the above-mentioned solution to any fault recovery scenario of the above-mentioned server-side evidence storage service.
[0050] In this specification, the above-mentioned server can obtain the data to be stored that failed to be stored in the event of a failure in the above-mentioned evidence service; specifically, in the event that the above-mentioned evidence service cannot work normally, it will usually cause the failure of the storage of some data to be stored, and the above-mentioned server can obtain the data to be stored that failed to be stored in preparation for subsequent related operations. For example, assuming that the above-mentioned server is a server used by the e-commerce backend to connect to the order evidence blockchain, under normal conditions, the evidence service in the above-mentioned server can use the orders generated by the above-mentioned e-commerce as data to be stored, generate corresponding transactions and publish them to the blockchain, and complete the on-chain evidence storage of the orders generated by the above-mentioned e-commerce; assuming that the above-mentioned evidence transaction fails from 14:00 onwards, the orders generated by the above-mentioned e-commerce will not be able to complete the on-chain evidence storage normally from 14:00 onwards, and therefore can be obtained by the above-mentioned server as data to be stored that failed to be stored.
[0051] In one embodiment shown, the data to be stored that failed to be stored can be obtained by parsing the original transaction that failed to be successfully published to the blockchain; wherein the original transaction can refer to a transaction in a normal business process that carries the data to be stored and completes the on-chain storage task by being published to the blockchain. For example, assuming that the above-mentioned evidence storage service failure is caused by the unavailability of the blockchain gateway, in this case, there may be several original transactions that have been generated and carry the data to be stored that cannot be published to the blockchain due to the unavailability of the above-mentioned blockchain gateway; therefore, the server can parse the above-mentioned original transaction that failed to be successfully published to the blockchain to obtain the data to be stored carried by it from the parsed original transaction.
[0052] In one embodiment shown, the above-mentioned original transaction that failed to be successfully published to the blockchain may include an original transaction whose number of publishing retries is greater than a preset threshold, and may also include an original transaction whose carried authentication signature has expired. For example, in the default on-chain evidence storage business process, a failure retry mechanism can be preset to reduce the adverse effects of events such as temporary network fluctuations on the business. If the failure number threshold in the above-mentioned failure retry mechanism is preset to 10, then after the number of retries of any original transaction is greater than 10, the original transaction can be regarded as an original transaction that failed to be successfully published to the blockchain; in addition, the validity of the original transaction can also be managed through the signature mechanism. For example, in order to reduce the risk of the original transaction being misappropriated, the validity period can be set for the authentication signature it carries to ensure that only within the validity period, the signature carried by the original transaction can pass the signature verification. In this case, after the authentication signature carried by the original transaction expires, the original transaction naturally cannot be further published on the blockchain, so it can also be regarded as an original transaction that failed to be successfully published to the blockchain.
[0053] It is understandable that obtaining the data to be stored that fails to be stored from the original transaction that has been generated is only a feasible example, and those skilled in the art may also obtain the data to be stored that fails to be stored through other means; for example, if the server includes a cache area for storing the data to be stored corresponding to the original transaction to be generated, and the above-mentioned evidence service failure is caused by the unavailability of the transaction creation mechanism, then in this case, the data to be stored in the above-mentioned cache area cannot be normally created as the original transaction, so the server can directly obtain the data to be stored in the above-mentioned cache area as the data to be stored that fails to be stored.
[0054] It is also understandable that, before obtaining the data to be stored that failed to be stored, the specific method used by the server to determine whether the storage service fails does not need to be specified in detail in this specification; for example, a network monitoring software plug-in can be used to monitor the storage service failure caused by network communication problems, and a temperature sensor can be used to monitor the storage service failure caused by hardware overheating and other problems, etc. Those skilled in the art can make their own choices according to specific needs and refer to relevant technical documents.
[0055] In this specification, after acquiring the above-mentioned data to be deposited, the above-mentioned server can create a compensation transaction corresponding to the above-mentioned data to be deposited, and store the created compensation transaction in a preset compensation transaction queue. Specifically, the above-mentioned server can create a compensation transaction carrying the above-mentioned data to be deposited based on a transaction creation method similar to a normal business process. Moreover, since the above-mentioned evidence service is in a faulty state, the created compensation transaction corresponding to the above-mentioned data to be deposited needs to be stored in a specific data structure for subsequent use; wherein, since the above-mentioned data to be deposited may contain data to be deposited that has a limited order for being uploaded to the chain, the use of a queue as a data structure can ensure the "first in, first out" feature of the compensation transaction in the compensation transaction queue, thereby meeting the requirements of the data to be deposited for the order of being uploaded to the chain.
[0056] It is understandable that if the above-mentioned data to be stored also includes data to be stored that does not require the order of on-chain storage, a non-queue storage structure can be used to store the corresponding compensation transactions, in order to utilize the characteristics of other non-queue data structures to achieve additional technical effects; for example, the above-mentioned compensation transactions can be stored in a hash table data structure, and a large number of compensation transactions can be quickly retrieved according to the hash index of the hash table. Those skilled in the art can choose other data structures that match the above-mentioned compensation transaction queue according to specific needs, and this specification does not need to list them all.
[0057] In this specification, after the above-mentioned evidence service failure is restored, the above-mentioned server can obtain any compensation transaction from the above-mentioned compensation transaction queue, and send any of the above-mentioned compensation transactions to the above-mentioned blockchain through the above-mentioned evidence service, so as to store the data to be stored corresponding to any of the above-mentioned compensation transactions on the above-mentioned blockchain. Specifically, after the above-mentioned evidence service failure is restored, the transaction can be processed on the chain. At this time, the server can obtain the previously deposited compensation transaction from the above-mentioned compensation transaction queue and send the obtained compensation transaction to the blockchain; because the compensation transaction actually carries the data to be stored that failed to be stored due to the failure of the evidence service, after the above-mentioned compensation transaction is sent to the blockchain, the data to be stored carried by it has completed the on-chain evidence process; continuing to take the above-mentioned e-commerce order evidence scenario as an example, assuming that there was an order A generated at 14:02 that needed to be stored, but the evidence service failed at that time, and the server generated a compensation transaction carrying the above-mentioned order A and stored it in the compensation transaction queue. Assuming that the evidence service failure is restored at 15:00, the server can take out the compensation transaction carrying the above-mentioned order A from the above-mentioned compensation transaction queue and send it to the blockchain, and the above-mentioned order A has completed the on-chain evidence.
[0058] It can be understood that, similar to the aforementioned identification process of the evidence service failure, the specific method of recovering the evidence service failure and the method of determining whether the evidence service failure has been recovered do not need to be limited in this specification. Technical personnel in this field can choose the appropriate specific method of recovering the evidence service failure and the method of determining whether the evidence service failure has been recovered according to the business application scenario.
[0059] In an embodiment shown, the compensation transaction queue may include compensation transaction sub-queues corresponding to multiple priorities; when adding the created compensation transaction to the compensation transaction queue, the priority of the created compensation transaction may be determined first, and then the created compensation transaction may be added to the compensation transaction sub-queue corresponding to the determined priority according to the determined priority. For example, the compensation transaction queue may include three compensation transaction sub-queues, corresponding to high, medium and low priorities respectively. Assuming that the priority of the created compensation transaction is high priority, the created compensation transaction may be stored in the compensation transaction sub-queue corresponding to the high priority; if the priority of the created compensation transaction is low priority, the created compensation transaction may be stored in the compensation transaction sub-queue corresponding to the low priority. The priority of the created compensation transaction may be determined by identifying the preset priority identifier in the corresponding data to be stored; in addition, the source of the data to be stored corresponding to the created compensation transaction may be determined first, such as the customer ID, and then the priority of the created compensation transaction may be indirectly determined according to the priority corresponding to the customer ID; those skilled in the art may refer to the relevant technology and select the specific method of determining the priority of the created compensation transaction, and this specification does not need to be further limited.
[0060] It is understandable that the above three-level priority mechanism is only a feasible example for easy description. Those skilled in the art can also design and select the priority mechanism according to specific business needs, and set up compensation transaction sub-queues corresponding to multiple priorities.
[0061] In one embodiment shown, the server can also save the corresponding relationship between the data to be stored and the compensation transaction to provide feedback to the initiator of the evidence. Specifically, after creating the compensation transaction corresponding to the data to be stored, the server can store the corresponding relationship between the data to be stored and the corresponding compensation transaction in a preset corresponding relationship table. After sending any of the compensation transactions to the blockchain through the evidence service, the server can query the data to be stored corresponding to any of the compensation transactions in the preset corresponding relationship table. Then generate the evidence success feedback information corresponding to the queried data to be stored, and send the evidence success feedback information to the evidence initiator corresponding to the queried data to be stored. Usually, the corresponding relationship between the data to be stored and the evidence initiator can be directly carried in the data to be stored, for example, the identification of the corresponding evidence initiator is retained in the data to be stored, or it can be stored in the historical record of the evidence request. Therefore, after the data to be stored corresponding to any compensation transaction is queried through the corresponding relationship table, the evidence initiator corresponding to the queried data to be stored can be further determined.
[0062] See also Figure 3 , Figure 3 is a structural example diagram of the above-mentioned correspondence table. In this example, the correspondence table stores the data serial number of the data to be stored and the transaction serial number of the corresponding compensation transaction; for example, assuming that after the above-mentioned evidence service failure is restored, the server obtains the transaction serial number of the compensation transaction from the compensation transaction queue as B00002, then it can be determined that the data serial number of the corresponding data to be stored is A00002. After the compensation transaction with the transaction serial number B00002 is sent to the blockchain, the server can generate a successful evidence feedback information corresponding to the data to be stored with the data serial number A00002, and send the successful evidence feedback information to the evidence initiator corresponding to the data to be stored with the data serial number A00002, such as the business backend of an e-commerce company.
[0063] Through the above solution, when there is a large time span between the occurrence of a fault and the recovery of the fault, the initiator of evidence can be given clear feedback information on the success of the evidence storage, so that the initiator of the evidence storage can clearly understand the latest status of the data to be stored that failed to be stored on the chain before, making the business process more perfect and improving the user experience.
[0064] The above content is all the embodiments of the data evidence storage method in this specification. This specification also provides the corresponding embodiments of the data evidence storage device as follows:
[0065] Please refer to Figure 4 , Figure 4 This is a structural example diagram of a data evidence storage device provided in an embodiment of this specification. The device can be applied to a server connected to a blockchain network. The server can be equipped with an evidence storage service for storing data on the above blockchain. The device may include the following modules:
[0066] Acquisition module 401, in case of failure of the evidence storage service, acquires the data to be stored that failed to be stored;
[0067] A creation module 402 creates a compensation transaction corresponding to the data to be stored, and stores the compensation transaction in a preset compensation transaction queue;
[0068] The sending module 403 obtains any compensation transaction from the compensation transaction queue after the failure of the evidence service is recovered, and sends any compensation transaction to the blockchain through the evidence service to store the data to be stored corresponding to any compensation transaction on the blockchain.
[0069] In one embodiment shown, the acquisition module 401 can further acquire the data to be stored that failed to be stored by parsing the original transaction that failed to be successfully published to the blockchain; wherein the original transaction can refer to a transaction in a normal business process that carries the data to be stored and completes the on-chain storage task by being published to the blockchain. For example, assuming that the failure of the above-mentioned storage service is caused by the unavailability of the blockchain gateway, in this case, there may be several original transactions that have been generated and carry the data to be stored that cannot be published to the blockchain due to the unavailability of the above-mentioned blockchain gateway; therefore, the server can parse the original transaction that failed to be successfully published to the blockchain to obtain the data to be stored carried by it from the parsed original transaction.
[0070] In one embodiment shown, the above-mentioned original transaction that failed to be successfully published to the blockchain may include an original transaction whose number of publishing retries is greater than a preset threshold, and may also include an original transaction whose carried authentication signature has expired. For example, in the default on-chain evidence storage business process, a failure retry mechanism can be preset to reduce the adverse effects of events such as temporary network fluctuations on the business. If the failure number threshold in the above-mentioned failure retry mechanism is preset to 10, then after the number of retries of any original transaction is greater than 10, the original transaction can be regarded as an original transaction that failed to be successfully published to the blockchain; in addition, the validity of the original transaction can also be managed through the signature mechanism. For example, in order to reduce the risk of the original transaction being misappropriated, the validity period can be set for the authentication signature it carries to ensure that only within the validity period, the signature carried by the original transaction can pass the signature verification. In this case, after the authentication signature carried by the original transaction expires, the original transaction naturally cannot be further published on the blockchain, so it can also be regarded as an original transaction that failed to be successfully published to the blockchain.
[0071] In an embodiment shown, the compensation transaction queue may include compensation transaction subqueues corresponding to multiple priorities; when adding the created compensation transaction to the compensation transaction queue, the creation module 402 may first determine the priority of the created compensation transaction, and then add the created compensation transaction to the compensation transaction subqueue corresponding to the determined priority according to the determined priority. For example, the compensation transaction queue may include three compensation transaction subqueues, corresponding to high, medium and low priorities respectively. Assuming that the priority of the created compensation transaction is high priority, the created compensation transaction may be stored in the compensation transaction subqueue corresponding to the high priority; if the priority of the created compensation transaction is low priority, the created compensation transaction may be stored in the compensation transaction subqueue corresponding to the low priority. The priority of the created compensation transaction may be determined by identifying the preset priority identifier in the corresponding data to be stored; in addition, the source of the data to be stored corresponding to the created compensation transaction may be first determined, such as the customer ID, and then the priority of the created compensation transaction may be indirectly determined according to the priority corresponding to the customer ID; those skilled in the art may refer to the relevant technology and select the specific method of determining the priority of the created compensation transaction, and this specification does not need to be further limited.
[0072] It is understandable that the above three-level priority mechanism is only a feasible example for easy description. Those skilled in the art can also design and select the priority mechanism according to specific business needs, and set up compensation transaction sub-queues corresponding to multiple priorities.
[0073] In one embodiment shown, the above-mentioned device may also include a storage module for storing the correspondence between the data to be deposited and the compensation transaction, and a feedback module for providing feedback to the evidence initiator; specifically, the above-mentioned storage module may store the correspondence between the above-mentioned data to be deposited and the corresponding compensation transaction in a preset correspondence table after creating a compensation transaction corresponding to the above-mentioned data to be deposited; the above-mentioned feedback module may query the data to be deposited corresponding to any of the above-mentioned compensation transactions in the above-mentioned preset correspondence table after sending any of the above-mentioned compensation transactions to the above-mentioned blockchain through the above-mentioned evidence service; and then generate evidence success feedback information corresponding to the queried data to be deposited, and send the above-mentioned evidence success feedback information to the evidence initiator corresponding to the queried data to be deposited. Generally, the correspondence between the data to be deposited and the initiator of the evidence can be directly carried in the data to be deposited, for example, the identification of the corresponding initiator of the evidence can be retained in the data to be deposited, or it can be stored in the historical record of the evidence request; therefore, after querying the data to be deposited corresponding to any compensation transaction through the above-mentioned correspondence table, the initiator of the evidence corresponding to the queried data to be deposited can be further determined.
[0074] The embodiments of the present specification also provide a computer device, which includes at least a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the aforementioned data storage method is implemented when the processor executes the program.
[0075] Figure 5 A more specific hardware structure diagram of a computing device provided in an embodiment of this specification is shown, and the device may include: a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040 are connected to each other through the bus 1050 in the device.
[0076] The processor 1010 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.
[0077] The memory 1020 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 1020 may store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program codes are stored in the memory 1020 and are called and executed by the processor 1010.
[0078] The input / output interface 1030 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.
[0079] The communication interface 1040 is used to connect a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through a wired mode (such as USB, network cable, etc.) or a wireless mode (such as mobile network, WIFI, Bluetooth, etc.).
[0080] The bus 1050 includes a path that transmits information between the various components of the device (eg, the processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040).
[0081] It should be noted that, although the above device only shows the processor 1010, the memory 1020, the input / output interface 1030, the communication interface 1040 and the bus 1050, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include the components necessary for implementing the embodiments of the present specification, and does not necessarily include all the components shown in the figure.
[0082] The embodiments of the present specification also provide a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the aforementioned data storage method is implemented.
[0083] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0084] It can be known from the above description of the implementation mode that the technicians in this field can clearly understand that the embodiments of this specification can be implemented by means of software plus the necessary general hardware platform. Based on such an understanding, the technical solution of the embodiments of this specification can be essentially or the part that contributes to the prior art can be embodied in the form of a software product, which can be stored in a storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments of this specification.
[0085] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which may be in the form of a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver, a game console, a tablet computer, a wearable device or a combination of any of these devices.
[0086] Each embodiment in this specification is described in a progressive manner, and the same and similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. The device embodiment described above is merely schematic, wherein the modules described as separate components may or may not be physically separated, and the functions of each module can be implemented in the same one or more software and / or hardware when implementing the embodiment scheme of this specification. It is also possible to select some or all of the modules according to actual needs to achieve the purpose of the embodiment scheme. A person of ordinary skill in the art can understand and implement it without paying creative labor.
[0087] The above is only a specific implementation of the embodiments of this specification. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the embodiments of this specification. These improvements and modifications should also be regarded as the protection scope of the embodiments of this specification.
Claims
1. A data evidence storage method, applied to a server connected to a blockchain, wherein the server is equipped with an evidence storage service for storing data on the blockchain; the method comprises: In the event of a failure in the evidence storage service, obtaining the data to be stored that failed to be stored; Creating a compensation transaction corresponding to the data to be stored, storing the compensation transaction in a preset compensation transaction queue, and storing the correspondence between the data to be stored and the corresponding compensation transaction in a preset correspondence table; After the failure of the evidence storage service is recovered, any compensation transaction is obtained from the compensation transaction queue, and the compensation transaction is sent to the blockchain through the evidence storage service, so as to store the data to be stored corresponding to the compensation transaction on the blockchain; After sending any compensation transaction to the blockchain through the evidence service, the data to be stored corresponding to any compensation transaction is queried in the preset correspondence table, and successful evidence feedback information corresponding to the queried data to be stored is generated, and the successful evidence feedback information is sent to the evidence initiator corresponding to the queried data to be stored.
2. According to the method of claim 1, the step of obtaining the data to be stored that failed to be stored comprises: The original transaction that failed to be successfully published to the blockchain is parsed to obtain the data to be stored in the original transaction.
3. According to the method of claim 2, the original transaction that failed to be successfully published to the blockchain includes: Publish the original transaction whose number of retries is greater than the preset threshold; and / or The original transaction that carried the authentication signature expired.
4. The method according to claim 1, wherein the compensation transaction queue comprises compensation transaction sub-queues corresponding to a plurality of priorities; wherein storing the compensation transaction into a preset compensation transaction queue comprises: determining a priority of said compensatory transactions; The compensation transaction is stored in a compensation transaction subqueue corresponding to the priority.
5. A data evidence storage device, applied to a server end connected to a blockchain, wherein the server end is equipped with an evidence storage service for storing data on the blockchain; the device comprises: An acquisition module, for acquiring the data to be stored that failed to be stored when the storage service fails; A creation module, which creates a compensation transaction corresponding to the data to be stored, and stores the compensation transaction in a preset compensation transaction queue; a sending module, after the failure of the evidence storage service is recovered, obtaining any compensation transaction from the compensation transaction queue, and sending the any compensation transaction to the blockchain through the evidence storage service, so as to store the to-be-stored data corresponding to the any compensation transaction on the blockchain; A storage module, after creating a compensation transaction corresponding to the data to be stored, stores the correspondence between the data to be stored and the corresponding compensation transaction in a preset correspondence table; A feedback module, after sending any compensation transaction to the blockchain through the evidence storage service, queries the preset corresponding relationship table for the to-be-stored data corresponding to any compensation transaction; Generate successful evidence feedback information corresponding to the queried data to be stored, and send the successful evidence feedback information to the evidence initiator corresponding to the queried data to be stored.
6. The device according to claim 5, wherein the acquisition module further: The original transaction that failed to be successfully published to the blockchain is parsed to obtain the data to be stored in the original transaction.
7. The apparatus according to claim 6, wherein the original transaction that failed to be successfully published to the blockchain comprises: Publish the original transaction whose number of retries is greater than the preset threshold; and / or The original transaction that carried the authentication signature expired.
8. The device according to claim 7, wherein the compensation transaction queue comprises compensation transaction sub-queues corresponding to a plurality of priorities; and the storage module further: determining a priority of said compensatory transactions; The compensation transaction is stored in a compensation transaction subqueue corresponding to the priority.
9. A computer device comprising at least a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the method described in any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Data processing method based on blockchain, database blockchain uploading system and node equipment
CN112383441A