Data compression and query method, device and electronic device based on blockchain

By using compression templates and smart contracts to verify and restore data on the blockchain, the resource consumption problem caused by the increase in the amount of data stored in the blockchain is solved, and efficient storage and accuracy guarantee of data are achieved.

CN112750037BActive Publication Date: 2024-10-29ANTCHAIN TECHNOLOGY PTE LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202110043051.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-04-30
Publication Date
2024-10-29
Estimated Expiration
2039-04-30

AI Technical Summary

Technical Problem

The increase in the amount of certificate data stored on the blockchain has led to an increase in storage resources and network overhead. It is difficult for existing technology to effectively save resources while ensuring the correctness and integrity of the data.

Method used

By using the preset compression template locally on the business side to compress the target data to be deposited, and calling the smart contract on the blockchain node device to verify and audit the compressed data to ensure the correctness of the data format; during data query , using smart contracts to restore compressed data to complete data.

Benefits of technology

It effectively reduces the amount of storage of evidence data and reduces the consumption of storage and network resources, while ensuring the correctness and integrity of the data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112750037B_ABST
    Figure CN112750037B_ABST
Patent Text Reader

Abstract

The embodiments of the present specification provide a data compression method, device and electronic device based on blockchain, the method comprising: a business party compresses the target data to be stored according to a preset compression template; assembles the compressed target data and the unique identifier of the compression template into a storage transaction; sends the storage transaction to a node device of the blockchain, so that the node device responds to the storage transaction, queries the smart contract corresponding to the unique identifier published in the blockchain, calls the compression template declared in the smart contract to verify the data format of the target data, and if the verification passes, stores the target data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of this specification relate to the field of blockchain technology, and in particular to a blockchain-based data compression and query method and device and electronic 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. Blockchain technology is 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. Summary of the invention

[0003] The embodiments of this specification provide a data compression and query method and device based on blockchain and an electronic device:

[0004] According to a first aspect of an embodiment of this specification, a blockchain-based data compression method is provided, the method comprising:

[0005] The business party compresses the target data to be stored according to the preset compression template;

[0006] Assembling the compressed target data and the unique identifier of the compression template into a storage transaction;

[0007] The evidence transaction is sent to the node device of the blockchain, so that the node device responds to the evidence transaction, queries the smart contract corresponding to the unique identifier published in the blockchain, calls the compression template declared in the smart contract to verify the data format of the target data, and if the verification passes, the target data is stored.

[0008] Optionally, compressing the target data to be stored according to a preset compression template specifically includes:

[0009] Determine the data structure of the target data to be stored;

[0010] The target data is compressed according to the compression template corresponding to the data structure.

[0011] Optionally, the data structure of the target data is composed of a self-describing structure and actual data; wherein the self-describing structure is used to represent the meaning expressed by the actual data;

[0012] The compression template records the compression rules of the self-describing structure;

[0013] The compressing the target data comprises:

[0014] According to the compression rule, the self-describing structure of the target data is mapped to the custom data; wherein the amount of the custom data is smaller than the amount of the self-describing structure.

[0015] Optionally, the method further includes:

[0016] Assemble the compressed template into a smart contract creation transaction;

[0017] The creation transaction is sent to a node device of the blockchain, so that the node device responds to the creation transaction, calls the contract audit logic declared in the audit contract published on the blockchain, and writes a voting event in the transaction log. After the audit node of the blockchain monitors the voting event, it submits the voting transaction to the audit contract; the audit contract summarizes and organizes the voting transactions to obtain the audit result of the smart contract.

[0018] Optionally, the method further includes:

[0019] If the audit result is passed, the smart contract is created in the blockchain and the unique identifier of the smart contract is returned to the business party.

[0020] Optionally, the unique identifier includes:

[0021] The hash value obtained by hashing the unique content of the compressed template declared in the smart contract.

[0022] According to a second aspect of an embodiment of this specification, a data compression device based on blockchain is provided, the device comprising:

[0023] The node device of the blockchain receives the evidence storage transaction submitted by the business party; wherein the evidence storage transaction contains a unique identifier and target data to be stored, and the target data is data compressed by the compression template corresponding to the unique identifier;

[0024] In response to the evidence storage transaction, the smart contract corresponding to the unique identifier published in the blockchain is queried, and the compression template declared in the smart contract is called to verify the data format of the target data. If the verification passes, the target data is stored.

[0025] Optionally, the method further includes:

[0026] Receive the creation transaction of the smart contract assembled from the compressed template sent by the business party;

[0027] In response to the creation transaction, the contract audit logic declared in the audit contract published on the blockchain is called, and a voting event is written in the transaction log. After the audit node of the blockchain monitors the voting event, the voting transaction is submitted to the audit contract; the audit contract summarizes and organizes the voting transactions to obtain the audit result of the smart contract.

[0028] Optionally, the method further includes:

[0029] If the audit result is passed, the smart contract is created in the blockchain and the unique identifier of the smart contract is returned to the business party.

[0030] Optionally, the unique identifier includes:

[0031] The hash value obtained by hashing the unique content of the compressed template declared in the smart contract.

[0032] According to a third aspect of the embodiments of this specification, a data query device based on blockchain is provided, wherein the data stored on the blockchain is compressed data after data compression based on the above-mentioned blockchain-based data compression method; the method comprises:

[0033] The business policy treats the queried data and assembles the unique identifier into a query transaction;

[0034] Sending the query transaction to a node device of the blockchain, so that the node device responds to the query transaction and queries the compressed data stored on the blockchain; querying the smart contract corresponding to the unique identifier published in the blockchain, and calling the compression template declared in the smart contract to restore the compressed data to complete data;

[0035] Receive the complete data returned by the node device.

[0036] Optionally, the compression template records compression rules of the self-describing structure;

[0037] The restoring the compressed data to complete data specifically includes:

[0038] According to the compression rule, the custom data in the compressed data is mapped into a self-describing structure; wherein the amount of the custom data is smaller than the amount of data in the self-describing structure.

[0039] According to a fourth aspect of the embodiments of this specification, a data query device based on blockchain is provided, wherein the data stored on the blockchain is compressed data after data compression based on the above-mentioned blockchain-based data compression method; the method comprises:

[0040] The node device of the blockchain receives the query transaction submitted by the business party; wherein the query transaction contains a unique identifier;

[0041] In response to the query transaction, query the compressed data stored on the blockchain;

[0042] Querying the smart contract corresponding to the unique identifier published in the blockchain, and calling the compression template declared in the smart contract to restore the compressed data to complete data;

[0043] The complete data is returned to the business party.

[0044] Optionally, the compression template records compression rules of the self-describing structure;

[0045] The restoring the compressed data to complete data specifically includes:

[0046] According to the compression rule, the custom data in the compressed data is mapped into a self-describing structure; wherein the amount of the custom data is smaller than the amount of data in the self-describing structure.

[0047] According to a fifth aspect of the embodiments of this specification, an electronic device is provided, including:

[0048] processor;

[0049] a memory for storing processor-executable instructions;

[0050] Wherein, the processor is configured as any of the above-mentioned blockchain-based data compression methods.

[0051] According to a sixth aspect of the embodiments of this specification, there is provided an electronic device, including:

[0052] processor;

[0053] a memory for storing processor-executable instructions;

[0054] Wherein, the processor is configured as any of the above-mentioned blockchain-based data query methods.

[0055] The embodiment of this specification provides a data compression solution based on blockchain. The business party compresses the target data to be stored locally based on the compression template, and the corresponding blockchain node device verifies the compressed data based on the smart contract corresponding to the compression template to ensure that the compressed data to be stored meets the data format requirements to avoid data anomalies (such as garbled data, misalignment). In this way, through the format constraints of the compression template and the smart contract, the data is compressed from the source of the data to reduce the amount of data. On the other hand, it provides a data query solution based on blockchain. When the node device of the blockchain receives the query transaction from the business party, since the data stored in the blockchain is compressed data, it can restore the compressed data to complete data based on the compression template declared in the smart contract. In this way, the compressed data of the evidence is restored to complete data based on the compression template of the smart contract to provide it to the business party to ensure data correctness. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] Figure 1 This is a flowchart of a blockchain-based data compression method provided in an embodiment of this specification;

[0057] Figure 2 This is a flowchart of a blockchain-based data compression method provided in an embodiment of this specification;

[0058] Figure 3 This is a flowchart of a data query method based on blockchain provided in an embodiment of this specification;

[0059] Figure 4 This is a flowchart of a data query method based on blockchain provided in an embodiment of this specification;

[0060] Figure 5 This is a hardware structure diagram of a blockchain-based data compression device provided in an embodiment of this specification;

[0061] Figure 6 This is a module diagram of a blockchain-based data compression device provided in an embodiment of this specification;

[0062] Figure 7 This is a module diagram of a blockchain-based data compression device provided in an embodiment of this specification;

[0063] Figure 8 This is a hardware structure diagram of a blockchain-based data query device provided in an embodiment of this specification;

[0064] Fig. 9 This is a module diagram of a blockchain-based data query device provided in an embodiment of this specification;

[0065] Fig.10This is a module diagram of a blockchain-based data query device provided in one embodiment of this specification. DETAILED DESCRIPTION

[0066] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with this specification. Instead, they are merely examples of devices and methods consistent with some aspects of this specification as detailed in the appended claims.

[0067] 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.

[0068] 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".

[0069] The blockchain-based traceability and evidence storage scenario is one of the most widely used scenarios for blockchain technology today. The characteristics of blockchain technology such as anti-tampering, traceability, and fair data storage empower the credibility of evidence traceability data and are widely used in the industry. However, since blockchain is a multi-node device with its own data ledger, that is, a copy of evidence data will be copied and stored by multiple node devices, as the amount of business evidence data increases, the evidence data on the entire blockchain will increase exponentially, which will occupy a large amount of storage resources and network overhead.

[0070] Specifically, the existing data stored on the chain is usually stored on the chain in the form of a data structure, such as XML, JSON and other data structures. This data structure has the advantage of a self-describing structure, which has the advantage of showing the meaning expressed by the data, but the self-describing structure takes up a lot of storage space.

[0071] However, the storage resources and network resources of blockchain are not endless; therefore, how to ensure the realization of business needs while saving resource expenditure has become an urgent problem to be solved.

[0072] The embodiment of this specification provides a data compression solution based on blockchain. The business party compresses the target data to be stored locally based on the compression template, and the corresponding blockchain node device verifies the compressed data based on the smart contract corresponding to the compression template to ensure that the compressed data to be stored meets the data format requirements to avoid data anomalies (such as garbled data, misalignment). In this way, through the format constraints of the compression template and the smart contract, the data is compressed from the source of the data to reduce the amount of data. On the other hand, it provides a data query solution based on blockchain. When the node device of the blockchain receives the query transaction from the business party, since the data stored in the blockchain is compressed data, it can restore the compressed data to complete data based on the compression template declared in the smart contract. In this way, the compressed data of the evidence is restored to complete data based on the compression template of the smart contract to provide it to the business party to ensure data correctness.

[0073] The blockchain described in this specification may specifically include private chains, public chains, and alliance chains, etc., which are not particularly limited in this specification.

[0074] For example, in one scenario, the above blockchain can be a consortium chain composed of business systems, audit systems, public disclosure systems, etc. as consortium members; the operator of the consortium chain can rely on the consortium chain to deploy the above data compression and evidence storage business; and the business systems, audit systems, and public disclosure systems described above as consortium members can all serve as a business node for the above data compression and evidence storage business. Each business node can publish the compressed data generated or received by itself in the consortium chain in the form of a transaction, and after the transaction is processed by the consensus node in the consortium chain, it is stored in the distributed database in the consortium chain to complete the "on-chain" evidence storage of the above logistics inspection results.

[0075] It should be noted that the transaction described in this specification refers to a piece of data created by the business party through the blockchain client and ultimately published to the distributed database of the blockchain.

[0076] Transactions in blockchain are usually divided into narrow transactions and broad transactions. A narrow transaction refers to a value transfer published by the business direction on the blockchain; while a broad transaction refers to a business data with business intent published by the business direction on the blockchain; for example, the operator can build a consortium chain based on actual business needs, and rely on the consortium chain to deploy some other types of online businesses that are not related to value transfer (such as business data storage, business data query, business data processing, etc.), and in this type of consortium chain, a transaction can be a business message or business request with business intent published by the business party in the consortium chain.

[0077] The above-mentioned client may include any type of upper-layer application that uses the underlying business data stored in the blockchain as data support to implement specific business functions.

[0078] Smart contracts are computer protocols designed to be deployed on blockchains to disseminate, verify or execute contracts in an information-based manner. By declaring business logic in a smart contract, corresponding operations can be performed. Smart contracts allow for trusted transactions without a third party. These transactions are traceable and irreversible. Smart contracts can provide security that is superior to traditional contract methods and reduce other transaction costs associated with contracts.

[0079] The solution provided in this manual is mainly divided into two parts: data compression and storage, and compressed data query.

[0080] Please refer to Figure 1 , Figure 1 A flowchart of a blockchain-based data compression method provided in an embodiment of this specification, the method is applied to a business party, and specifically may include the following steps:

[0081] Step 110: The business party compresses the target data to be stored according to a preset compression template;

[0082] Step 120: Assembling the compressed target data and the unique identifier of the compression template into a storage transaction;

[0083] Step 130: Send the evidence transaction to the node device of the blockchain, so that the node device responds to the evidence transaction, queries the smart contract corresponding to the unique identifier published in the blockchain, calls the compression template declared in the smart contract to verify the data format of the target data, and if the verification passes, stores the target data.

[0084] It is worth mentioning that the smart contract corresponding to the unique identifier in the above blockchain is pre-published in the blockchain by any business party. The specific steps are as follows:

[0085] A1: Assemble the compressed template into a smart contract creation transaction;

[0086] A2: Send the creation transaction to the node device of the blockchain, so that the node device responds to the creation transaction, calls the contract audit logic declared in the audit contract published on the blockchain, and writes a voting event in the transaction log. After the audit node of the blockchain monitors the voting event, it submits the voting transaction to the audit contract; the audit contract summarizes and organizes the voting transactions to obtain the audit result of the smart contract.

[0087] In this embodiment, the business party can create a smart contract for verifying business data, and the smart contract is assembled based on a compressed template.

[0088] Generally, smart contracts need to comply with the smart contract specifications. Therefore, for node devices, it is necessary to review the smart contracts submitted by the business party. Specifically, the contract review logic declared in the review contract published on the blockchain is called, and a voting event is written in the transaction log. After the review node of the blockchain monitors the voting event, it submits the voting transaction to the review contract; the review contract summarizes and organizes the voting transactions to obtain the review result of the smart contract.

[0089] If the audit result is passed, the business party will create a smart contract for data compression verification, and the blockchain can generate a unique identifier corresponding to the smart contract. That is, there is a one-to-one correspondence between the unique identifier and the smart contract.

[0090] In one embodiment, the unique identifier may refer to a hash value obtained by performing a hash calculation on the unique content of the compressed template declared in the smart contract, and the hash value is also used as the contract address for storing the smart contract.

[0091] In addition to the hash value, the unique identifier can also be any other unique identifier, such as an ID that increases in sequence. For example, starting from ID=0, each time a smart contract is created, 1 is added to the original ID as the unique identifier of the newly created smart contract.

[0092] As mentioned above, in addition to successfully publishing the smart contract corresponding to the compressed template, the business party can receive a unique identifier assigned by the blockchain. The unique identifier can not only correspond to the smart contract in the blockchain, but also to the compressed template of the business party. That is, there is a one-to-one correspondence between the unique identifier and the compressed template.

[0093] In one embodiment, different compression templates are used to compress business data of different data structures. Therefore, the step 110 compresses the target data to be stored according to the preset compression template, which may specifically include:

[0094] Determine the data structure of the target data to be stored;

[0095] The target data is compressed according to the compression template corresponding to the data structure.

[0096] For example, assuming that the target data belongs to the XML data structure, the business party needs to use the XML compression template to compress the target data;

[0097] If the target data is in a JSON data structure, the business side needs to use a JSON compression template to compress the target data.

[0098] In one embodiment, the data structure of the target data is composed of a self-describing structure and actual data; wherein the self-describing structure is used to represent the meaning expressed by the actual data;

[0099] The compression template records the compression rules of the self-describing structure;

[0100] The compressing the target data comprises:

[0101] According to the compression rule, the self-describing structure of the target data is mapped to the custom data; wherein the amount of the custom data is smaller than the amount of the self-describing structure.

[0102] For example, the XML data structure is characterized by " / / " as a self-describing structure, where " " is the content that describes the actual data meaning; for example: / username / ZhangSan; through / username / , it can be determined that "ZhangSan" expresses the username.

[0103] Similarly, the JSON data structure is characterized by " :" as a self-describing structure, where " " is the content that describes the actual data meaning; for example: username: ZhangSan; through username: it can be determined that "ZhangSan" expresses the username.

[0104] Regardless of the data structure, the mapping relationship between each self-describing structure and the custom data can be predefined in the corresponding compression template, so that the business party can map the self-describing structure of the target data to the custom data according to the compression rule; wherein the amount of the custom data is smaller than the amount of the self-describing structure.

[0105] For example, for the target data: / username / ZhangSan; since the data structure of the target data is an XML data structure, assuming that the mapping of / username / is defined as "1" in the XML compression template; then the compressed target data becomes: 1 ZhangSan. It can be seen that the amount of target data is reduced a lot before and after compression.

[0106] The embodiment of this specification provides a data compression solution based on blockchain. The business party compresses the target data to be stored locally based on the compression template, and the corresponding blockchain node device verifies the compressed data based on the smart contract corresponding to the compression template to ensure that the compressed data to be stored meets the data format requirements to avoid data anomalies (such as garbled data and misalignment). In this way, through the format constraints of the compression template and the smart contract, the data is compressed from the source of the data to reduce the amount of data.

[0107] Please refer to Figure 2 , Figure 2 A flowchart of a blockchain-based data compression method provided in an embodiment of this specification, wherein the method is applied to a node device of a blockchain, and specifically may include the following steps:

[0108] Step 210: The node device of the blockchain receives the evidence storage transaction submitted by the business party; wherein the evidence storage transaction includes a unique identifier and target data to be stored, and the target data is data compressed by the compression template corresponding to the unique identifier;

[0109] Step 220: In response to the evidence transaction, query the smart contract corresponding to the unique identifier published in the blockchain, call the compression template declared in the smart contract to verify the data format of the target data, and if the verification passes, store the target data.

[0110] In this embodiment, Figure 1 The embodiments shown are different in execution subject. For specific implementation, please refer to Figure 1 Description in the examples.

[0111] Business parties can create smart contracts for verifying business data. The smart contracts are assembled based on compressed templates.

[0112] Generally, smart contracts need to comply with the smart contract specifications. Therefore, for node devices, it is necessary to review the smart contracts submitted by the business party.

[0113] In one embodiment, a node device of the blockchain receives a creation transaction for a smart contract assembled from a compressed template sent by a business party;

[0114] In response to the creation transaction, the contract audit logic declared in the audit contract published on the blockchain is called, and a voting event is written in the transaction log. After the audit node of the blockchain monitors the voting event, the voting transaction is submitted to the audit contract; the audit contract summarizes and organizes the voting transactions to obtain the audit result of the smart contract.

[0115] If the audit result is passed, the smart contract is created in the blockchain, and the unique identifier of the smart contract is returned to the business party. That is, there is a one-to-one correspondence between the unique identifier and the smart contract.

[0116] In one embodiment, the unique identifier may refer to a hash value obtained by performing a hash calculation on the unique content of the compressed template declared in the smart contract, and the hash value is also used as the contract address for storing the smart contract.

[0117] In addition to the hash value, the unique identifier can also be any other unique identifier, such as an ID that increases in sequence. For example, starting from ID=0, each time a smart contract is created, 1 is added to the original ID as the unique identifier of the newly created smart contract.

[0118] For the target data uploaded by the business party and compressed locally based on the compression template, the node device needs to verify the target data. Only when the data format of the target data conforms to the data format specified by the compression template, can the verification be determined to be passed, thereby storing the compressed target data.

[0119] The embodiment of this specification provides a data compression solution based on blockchain. The business party compresses the target data to be stored locally based on the compression template, and the corresponding blockchain node device verifies the compressed data based on the smart contract corresponding to the compression template to ensure that the compressed data to be stored meets the data format requirements to avoid data anomalies (such as garbled data and misalignment). In this way, through the format constraints of the compression template and the smart contract, the data is compressed from the source of the data to reduce the amount of data.

[0120] As mentioned earlier, the business party can compress the target data and store it on the chain. In this way, the amount of data stored on the chain will be greatly reduced, thereby reducing the storage resources required for data storage. However, since the data has been compressed, after reading the compressed data, how to restore the compressed data to complete data also needs to be solved.

[0121] Please refer to Figure 3 , Figure 3 This is a flowchart of a data query method based on blockchain provided in an embodiment of this specification. The method is applied to a business party. The data stored on the blockchain is based on the aforementioned Figure 1 The embodiment shown is the compressed data after data compression; this embodiment may specifically include the following steps:

[0122] Step 310: The business policy assembles the unique identifier into a query transaction for the data to be queried;

[0123] Step 320: Send the query transaction to a node device of the blockchain, so that the node device responds to the query transaction, queries the compressed data stored on the blockchain; queries the smart contract corresponding to the unique identifier published in the blockchain, and calls the compression template declared in the smart contract to restore the compressed data to complete data;

[0124] Step 330: Receive the complete data returned by the node device.

[0125] When the business party needs to obtain the target data, it can assemble a query transaction based on the unique identifier corresponding to the data structure to which the target data belongs, that is, the query transaction contains the unique identifier.

[0126] The node device responds to the query transaction and can first query the compressed data of the target data stored on the blockchain; and query the smart contract corresponding to the unique identifier.

[0127] There is no absolute time sequence for querying compressed data and executing smart contracts. They can be executed at the same time, or the compressed data can be executed first, or the query smart contract can be executed first.

[0128] After querying the smart contract and compressed data, it is necessary to call the compression template declared in the smart contract to restore the compressed data to complete data.

[0129] In one embodiment, the compression template records compression rules of a self-describing structure;

[0130] The restoring the compressed data to complete data specifically includes:

[0131] According to the compression rule, the custom data in the compressed data is mapped into a self-describing structure; wherein the amount of the custom data is smaller than the amount of data in the self-describing structure.

[0132] Continuing with the above example: for the target data: / username / ZhangSan; since the data structure of the target data is an XML data structure, assuming that the mapping of / username / is defined as "1" in the XML compression template; then the compressed target data becomes: 1 ZhangSan;

[0133] If the business party needs to obtain the target data, since the evidence stored in the blockchain is 1 ZhangSan, the custom data needs to be restored to the self-describing structure. Since the mapping relationship between " / username / " and "1" is defined in the XML compression template declared in the smart contract, the node device can convert the custom data "1" in the compressed data into the self-describing structure " / username / ", that is, the restored complete data is / username / ZhangSan. The meaning of the queried data ZhangSan is the user name.

[0134] In the embodiment of this specification, a data query solution based on blockchain is provided. When the node device of blockchain receives the query transaction from the business party, since the data stored in blockchain is compressed data, the compressed data can be restored to complete data based on the compression template declared in the smart contract. In this way, the compressed data stored is restored to complete data based on the compression template of the smart contract to provide it to the business party, ensuring the correctness of the data.

[0135] Please refer to Figure 4 , Figure 4 A flowchart of a data query method based on blockchain provided in an embodiment of this specification, wherein the method is applied to a node device of blockchain, and the data stored on the blockchain is based on the aforementioned Figure 1 The embodiment shown is the compressed data after data compression; this embodiment may specifically include the following steps:

[0136] Step 410: The node device of the blockchain receives the query transaction submitted by the business party; wherein the query transaction includes a unique identifier;

[0137] Step 420: In response to the query transaction, query the compressed data stored on the blockchain;

[0138] Step 430: query the smart contract corresponding to the unique identifier published in the blockchain, and call the compression template declared in the smart contract to restore the compressed data to complete data;

[0139] Step 440: Return the complete data to the business party.

[0140] In this embodiment, Figure 3 The embodiments shown are different in execution subject. For specific implementation, please refer to Figure 3 Description in the examples.

[0141] The business party can initiate a query transaction to the node device of the blockchain to query the target data stored on the blockchain. The query transaction contains a unique identifier.

[0142] The node device responds to the query transaction and can first query the compressed data of the target data stored on the blockchain; and query the smart contract corresponding to the unique identifier.

[0143] There is no absolute time sequence for querying compressed data and executing smart contracts. They can be executed at the same time, or the compressed data can be executed first, or the query smart contract can be executed first.

[0144] After querying the smart contract and compressed data, it is necessary to call the compression template declared in the smart contract to restore the compressed data to complete data.

[0145] In one embodiment, the compression template records compression rules of a self-describing structure;

[0146] The restoring the compressed data to complete data specifically includes:

[0147] According to the compression rule, the custom data in the compressed data is mapped into a self-describing structure; wherein the amount of the custom data is smaller than the amount of data in the self-describing structure.

[0148] Continuing with the above example: for the target data: / username / ZhangSan; since the data structure of the target data is an XML data structure, assuming that the mapping of / username / is defined as "1" in the XML compression template; then the compressed target data becomes: 1 ZhangSan;

[0149] If the business party needs to obtain the target data, since the evidence stored in the blockchain is 1 ZhangSan, the custom data needs to be restored to the self-describing structure. Since the mapping relationship between " / username / " and "1" is defined in the XML compression template declared in the smart contract, the node device can convert the custom data "1" in the compressed data into the self-describing structure " / username / ", that is, the restored complete data is / username / ZhangSan. The meaning of the queried data ZhangSan is the user name.

[0150] In the embodiment of this specification, a data query solution based on blockchain is provided. When the node device of blockchain receives the query transaction from the business party, since the data stored in blockchain is compressed data, the compressed data can be restored to complete data based on the compression template declared in the smart contract. In this way, the compressed data stored is restored to complete data based on the compression template of the smart contract to provide it to the business party, ensuring the correctness of the data.

[0151] Corresponding to the aforementioned blockchain-based reward fund allocation method embodiment, this specification also provides a blockchain-based reward fund allocation device embodiment. The device embodiment can be implemented by software, or by hardware or a combination of software and hardware. Taking software implementation as an example, as a device in a logical sense, it is formed by the processor of the device in which it is located reading the corresponding computer business program instructions in the non-volatile memory into the memory for execution. From the hardware level, if Figure 5 The figure is a hardware structure diagram of the device where the reward fund allocation device based on blockchain is located in this specification, except Figure 5 In addition to the processor, network interface, memory, and non-volatile memory shown, the device in the embodiment where the apparatus is located generally allocates actual functions based on blockchain-based reward funds and may also include other hardware, which will not be described in detail.

[0152] See also Figure 6 , is a module diagram of a data compression device based on blockchain provided in an embodiment of this specification, and the device corresponds to Figure 1 The embodiment shown is applied to a business party, and the device includes:

[0153] Compression unit 510, the business party compresses the target data to be stored according to a preset compression template;

[0154] An assembling unit 520 assembles the compressed target data and the unique identifier of the compression template into a storage transaction;

[0155] The evidence storage unit 530 sends the evidence storage transaction to the node device of the blockchain, so that the node device responds to the evidence storage transaction, queries the smart contract corresponding to the unique identifier published in the blockchain, and calls the compression template declared in the smart contract to verify the data format of the target data. If the verification passes, the target data is stored.

[0156] Optionally, the compression unit 510 specifically includes:

[0157] Determine the subunit and the data structure of the target data to be stored;

[0158] The compression subunit compresses the target data according to the compression template corresponding to the data structure.

[0159] Optionally, the data structure of the target data is composed of a self-describing structure and actual data; wherein the self-describing structure is used to represent the meaning expressed by the actual data;

[0160] The compression template records the compression rules of the self-describing structure;

[0161] In the compression subunit, compressing the target data includes:

[0162] According to the compression rule, the self-describing structure of the target data is mapped to the custom data; wherein the amount of the custom data is smaller than the amount of the self-describing structure.

[0163] Optionally, the device further comprises:

[0164] The transaction assembly subunit assembles the compressed template into a smart contract creation transaction;

[0165] The contract creation subunit sends the creation transaction to the node device of the blockchain, so that the node device responds to the creation transaction, calls the contract audit logic declared in the audit contract published on the blockchain, and writes a voting event in the transaction log. After the audit node of the blockchain monitors the voting event, it submits the voting transaction to the audit contract; the audit contract summarizes and organizes the voting transactions to obtain the audit result of the smart contract.

[0166] Optionally, the contract creation subunit further includes:

[0167] If the audit result is passed, the smart contract is created in the blockchain and the unique identifier of the smart contract is returned to the business party.

[0168] Optionally, the unique identifier includes:

[0169] The hash value obtained by hashing the unique content of the compressed template declared in the smart contract.

[0170] See also Figure 7 , is a module diagram of a data compression device based on blockchain provided in an embodiment of this specification, and the device corresponds to Figure 2 The embodiment shown is applied to a node device of a blockchain, and the device includes:

[0171] The receiving unit 610, a node device of the blockchain receives a certificate transaction submitted by a business party; wherein the certificate transaction includes a unique identifier and target data to be stored, and the target data is data compressed by a compression template corresponding to the unique identifier;

[0172] The response unit 620, in response to the evidence transaction, queries the smart contract corresponding to the unique identifier published in the blockchain, calls the compression template declared in the smart contract to verify the data format of the target data, and if the verification passes, the target data is stored.

[0173] The node device of the blockchain receives the evidence storage transaction submitted by the business party; wherein the evidence storage transaction contains a unique identifier and target data to be stored, and the target data is data compressed by the compression template corresponding to the unique identifier;

[0174] In response to the evidence storage transaction, the smart contract corresponding to the unique identifier published in the blockchain is queried, and the compression template declared in the smart contract is called to verify the data format of the target data. If the verification passes, the target data is stored.

[0175] Optionally, the device further comprises:

[0176] The receiving subunit receives the creation transaction of the smart contract assembled from the compressed template sent by the business party;

[0177] A creation subunit is provided, which, in response to the creation transaction, calls the contract audit logic declared in the audit contract published on the blockchain, writes a voting event in the transaction log, and after the audit node of the blockchain listens to the voting event, submits the voting transaction to the audit contract; the audit contract summarizes and organizes the voting transactions to obtain the audit result of the smart contract.

[0178] Optionally, the creating subunit further includes:

[0179] If the audit result is passed, the smart contract is created in the blockchain and the unique identifier of the smart contract is returned to the business party.

[0180] Optionally, the unique identifier includes:

[0181] The hash value obtained by hashing the unique content of the compressed template declared in the smart contract.

[0182] Corresponding to the aforementioned blockchain-based data query method embodiment, this specification also provides a blockchain-based data query device embodiment. The device embodiment can be implemented by software, or by hardware or a combination of software and hardware. Taking software implementation as an example, as a device in a logical sense, it is formed by the processor of the device in which it is located reading the corresponding computer business program instructions in the non-volatile memory into the memory for execution. From the hardware level, such as Figure 8The following is a hardware structure diagram of the device where the data query device based on blockchain is located in this manual, except Figure 8 In addition to the processor, network interface, memory, and non-volatile memory shown, the device in the embodiment where the apparatus is located generally queries actual functions based on blockchain-based data and may also include other hardware, which will not be described in detail.

[0183] See also Fig. 9 , is a module diagram of a data compression device based on blockchain provided in an embodiment of this specification, and the device corresponds to Figure 3 The embodiment shown is applied to the business side, and the data stored on the blockchain is compressed data after the data compression method based on the blockchain is used; the device includes:

[0184] Assembling unit 710, the business policy assembles the unique identifier into a query transaction for the data to be queried;

[0185] The query unit 720 sends the query transaction to a node device of the blockchain, so that the node device responds to the query transaction, queries the compressed data stored on the blockchain; queries the smart contract corresponding to the unique identifier published in the blockchain, and calls the compression template declared in the smart contract to restore the compressed data to complete data;

[0186] The receiving unit 730 receives the complete data returned by the node device.

[0187] Optionally, the compression template records compression rules of the self-describing structure;

[0188] In the query unit 720, restoring the compressed data to complete data specifically includes:

[0189] According to the compression rule, the custom data in the compressed data is mapped into a self-describing structure; wherein the amount of the custom data is smaller than the amount of data in the self-describing structure.

[0190] See also Fig.10 , is a module diagram of a data compression device based on blockchain provided in an embodiment of this specification, and the device corresponds to Figure 4 The embodiment shown is applied to a node device of a blockchain, wherein the data stored on the blockchain is compressed data after data compression by the aforementioned blockchain-based data compression method; the device comprises:

[0191] The receiving unit 810, a node device of the blockchain receives a query transaction submitted by a business party; wherein the query transaction includes a unique identifier;

[0192] A query unit 820, in response to the query transaction, queries the compressed data stored on the blockchain;

[0193] The decompression unit 830 queries the smart contract corresponding to the unique identifier published in the blockchain, and calls the compression template declared in the smart contract to restore the compressed data to complete data;

[0194] The returning unit 840 returns the complete data to the business party.

[0195] Optionally, the compression template records compression rules of the self-describing structure;

[0196] The decompression unit 830 restores the compressed data to complete data, specifically including:

[0197] According to the compression rule, the custom data in the compressed data is mapped into a self-describing structure; wherein the amount of the custom data is smaller than the amount of data in the self-describing structure.

[0198] 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.

[0199] The implementation process of the functions and effects of each unit in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.

[0200] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can refer to the partial description of the method embodiments. The device embodiments described above are only schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this specification. Ordinary technicians in this field can understand and implement it without paying creative work.

[0201] above Figure 6 The internal functional modules and structural schematic diagram of the data compression device based on blockchain are described. Its actual execution subject can be an electronic device, including:

[0202] processor;

[0203] a memory for storing processor-executable instructions;

[0204] Wherein, the processor is configured to:

[0205] The business party compresses the target data to be stored according to the preset compression template;

[0206] Assembling the compressed target data and the unique identifier of the compression template into a storage transaction;

[0207] The evidence transaction is sent to the node device of the blockchain, so that the node device responds to the evidence transaction, queries the smart contract corresponding to the unique identifier published in the blockchain, calls the compression template declared in the smart contract to verify the data format of the target data, and if the verification passes, the target data is stored.

[0208] above Figure 7 The internal functional modules and structural schematic diagram of the data compression device based on blockchain are described. Its actual execution subject can be an electronic device, including:

[0209] processor;

[0210] a memory for storing processor-executable instructions;

[0211] Wherein, the processor is configured to:

[0212] The node device of the blockchain receives the evidence storage transaction submitted by the business party; wherein the evidence storage transaction contains a unique identifier and target data to be stored, and the target data is data compressed by the compression template corresponding to the unique identifier;

[0213] In response to the evidence storage transaction, the smart contract corresponding to the unique identifier published in the blockchain is queried, and the compression template declared in the smart contract is called to verify the data format of the target data. If the verification passes, the target data is stored.

[0214] above Fig. 9 The internal functional modules and structural schematic diagram of the data query device based on blockchain are described. Its actual execution subject can be an electronic device, including:

[0215] processor;

[0216] a memory for storing processor-executable instructions;

[0217] Wherein, the processor is configured to:

[0218] The business policy assembles the unique identifier into a query transaction for the data to be queried; wherein the data stored on the blockchain is compressed data after data compression by any of the aforementioned blockchain-based data compression methods;

[0219] Sending the query transaction to a node device of the blockchain, so that the node device responds to the query transaction and queries the compressed data stored on the blockchain; querying the smart contract corresponding to the unique identifier published in the blockchain, and calling the compression template declared in the smart contract to restore the compressed data to complete data;

[0220] Receive the complete data returned by the node device.

[0221] above Fig.10 The internal functional modules and structural schematic diagram of the data query device based on blockchain are described. Its actual execution subject can be an electronic device, including:

[0222] processor;

[0223] a memory for storing processor-executable instructions;

[0224] Wherein, the processor is configured to:

[0225] The node device of the blockchain receives the query transaction submitted by the business party; wherein the query transaction contains a unique identifier; the data stored on the blockchain is compressed data after data compression by any of the aforementioned blockchain-based data compression methods;

[0226] In response to the query transaction, query the compressed data stored on the blockchain;

[0227] Querying the smart contract corresponding to the unique identifier published in the blockchain, and calling the compression template declared in the smart contract to restore the compressed data to complete data;

[0228] The complete data is returned to the business party.

[0229] In the above-mentioned embodiment of the electronic device, it should be understood that the processor can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. The general-purpose processor can be a microprocessor or the processor can be any conventional processor, etc., and the aforementioned memory can be a read-only memory (ROM), a random access memory (RAM), a flash memory, a hard disk or a solid-state drive. The steps of the method disclosed in the embodiment of the present invention can be directly embodied as being executed by a hardware processor, or can be executed by a combination of hardware and software modules in the processor.

[0230] Each embodiment in this specification is described in a progressive manner, and the same or 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 electronic 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.

[0231] Those skilled in the art will readily appreciate other embodiments of the specification after considering the specification and practicing the invention disclosed herein. The specification is intended to cover any variations, uses, or adaptations of the specification that follow the general principles of the specification and include common knowledge or customary techniques in the art that are not disclosed in the specification. The specification and examples are to be considered exemplary only, and the true scope and spirit of the specification are indicated by the following claims.

[0232] It should be understood that the present description is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present description is limited only by the appended claims.

Claims

1. A data compression method based on blockchain, the method comprising: Determine the self-describing structure and compression template of the target data to be stored; According to the mapping relationship between the self-describing structure and the custom data predefined in the compression template, the self-describing structure of the target data is mapped locally to the custom data; wherein the amount of the custom data is smaller than the amount of data in the self-describing structure; Assembling the compressed target data and the unique identifier of the compression template into a storage transaction; The evidence transaction is sent to the node device of the blockchain, so that the node device responds to the evidence transaction, queries the smart contract corresponding to the unique identifier published in the blockchain, calls the compression template declared in the smart contract to verify the data format of the target data, and if the verification passes, the target data is stored.

2. The method according to claim 1, further comprising: Assemble the compressed template into a smart contract creation transaction; The creation transaction is sent to a node device of the blockchain, so that the node device responds to the creation transaction, calls the contract audit logic declared in the audit contract published on the blockchain, and writes a voting event in the transaction log. After the audit node of the blockchain monitors the voting event, it submits the voting transaction to the audit contract; the audit contract summarizes and organizes the voting transactions to obtain the audit result of the smart contract.

3. The method according to claim 2, further comprising: If the audit result is passed, the smart contract is created in the blockchain and the unique identifier of the smart contract is returned to the business party.

4. The method according to claim 3, wherein the unique identifier comprises: The hash value obtained by hashing the unique content of the compressed template declared in the smart contract.

5. A data compression method based on blockchain, the method comprising: The node device of the blockchain receives the evidence storage transaction submitted by the business party; wherein the evidence storage transaction contains a unique identifier and target data to be stored, and the target data is data compressed by the compression template corresponding to the unique identifier; In response to the evidence storage transaction, query the smart contract corresponding to the unique identifier published in the blockchain, call the compression template declared in the smart contract to verify the data format of the target data, and if the verification passes, store the target data; The target data compression process includes: According to the mapping relationship between the self-describing structure and the custom data predefined in the compression template, the self-describing structure of the data before compression is mapped to the custom data locally at the business party; wherein the amount of the custom data is smaller than the amount of the self-describing structure.

6. The method according to claim 5, further comprising: Receive the creation transaction of the smart contract assembled from the compressed template sent by the business party; In response to the creation transaction, the contract audit logic declared in the audit contract published on the blockchain is called, and a voting event is written in the transaction log. After the audit node of the blockchain monitors the voting event, the voting transaction is submitted to the audit contract; the audit contract summarizes and organizes the voting transactions to obtain the audit result of the smart contract.

7. The method according to claim 6, further comprising: If the audit result is passed, the smart contract is created in the blockchain and the unique identifier of the smart contract is returned to the business party; There is a one-to-one correspondence between the unique identifier and the smart contract.

8. The method according to claim 7, wherein the unique identifier comprises: The hash value obtained by hashing the unique content of the compressed template declared in the smart contract.

9. A data query method based on blockchain, wherein the data stored on the blockchain is compressed data after data compression according to the method of claim 1; the method comprises: For the data to be queried, assembling the unique identifier into a query transaction; Sending the query transaction to a node device of the blockchain, so that the node device responds to the query transaction and queries the compressed data stored on the blockchain; Querying the smart contract corresponding to the unique identifier published in the blockchain, and calling the compression template declared in the smart contract to restore the compressed data to complete data; Receive the complete data returned by the node device.

10. The method according to claim 9, wherein the compression template records the compression rules of the self-describing structure; The restoring the compressed data to complete data specifically includes: According to the compression rule, the custom data in the compressed data is mapped into a self-describing structure; wherein the amount of the custom data is smaller than the amount of data in the self-describing structure.

11. A data query method based on blockchain, wherein the data stored on the blockchain is compressed data after data compression according to the method of claim 5; the method comprises: The node device of the blockchain receives the query transaction submitted by the business party; wherein the query transaction contains a unique identifier; In response to the query transaction, query the compressed data stored on the blockchain; Querying the smart contract corresponding to the unique identifier published in the blockchain, and calling the compression template declared in the smart contract to restore the compressed data to complete data; The complete data is returned to the business party.

12. The method according to claim 11, wherein the compression template records the compression rules of the self-describing structure; The restoring the compressed data to complete data specifically includes: According to the compression rule, the custom data in the compressed data is mapped into a self-describing structure; wherein the amount of the custom data is smaller than the amount of data in the self-describing structure.

13. A data compression device based on blockchain, the device comprising: A compression unit, which determines the self-describing structure and compression template of the target data to be stored; According to the mapping relationship between the self-describing structure and the custom data predefined in the compression template, the self-describing structure of the target data is mapped locally to the custom data; wherein the amount of the custom data is smaller than the amount of data in the self-describing structure; An assembling unit, assembling the compressed target data and the unique identifier of the compression template into a storage transaction; The response unit sends the evidence transaction to the node device of the blockchain, so that the node device responds to the evidence transaction, queries the smart contract corresponding to the unique identifier published in the blockchain, calls the compression template declared in the smart contract to verify the data format of the target data, and if the verification passes, the target data is stored.

14. A data compression device based on blockchain, the device comprising: A receiving unit, a node device of the blockchain receives a certificate transaction submitted by a business party; wherein the certificate transaction contains a unique identifier and target data to be stored, and the target data is data compressed by a compression template corresponding to the unique identifier; wherein the compression process of the target data comprises: mapping the self-describing structure of the data before compression to the custom data locally on the business party according to the mapping relationship between the self-describing structure and the custom data pre-defined in the compression template; wherein the amount of the custom data is less than the amount of the self-describing structure; The response unit, in response to the evidence storage transaction, queries the smart contract corresponding to the unique identifier published in the blockchain, calls the compression template declared in the smart contract to verify the data format of the target data, and if the verification passes, stores the target data.

15. A data query device based on blockchain, wherein the data stored on the blockchain is compressed data after data compression according to the method of claim 1; The device comprises: An assembling unit, for the data to be queried, assembling the unique identifier into a query transaction; A query unit sends the query transaction to a node device of the blockchain, so that the node device responds to the query transaction, queries the compressed data stored on the blockchain; queries the smart contract corresponding to the unique identifier published in the blockchain, and calls the compression template declared in the smart contract to restore the compressed data to complete data; A receiving unit receives the complete data returned by the node device.

16. A data query device based on blockchain, wherein the data stored on the blockchain is compressed data after data compression according to the method of claim 5; the device comprises: A receiving unit, a node device of the blockchain receives a query transaction submitted by a business party; wherein the query transaction contains a unique identifier; A query unit, in response to the query transaction, queries the compressed data stored on the blockchain; A decompression unit, querying the smart contract corresponding to the unique identifier published in the blockchain, and calling the compression template declared in the smart contract to restore the compressed data to complete data; The returning unit returns the complete data to the business party.

17. An electronic device comprising: processor; a memory for storing processor-executable instructions; Wherein, the processor is configured to implement the method described in any one of claims 1-12.

Citation Information

Patent Citations

  • Dynamic lossless compression method of JSON data packet

    CN108156173A

  • Test data-based storage method and medium

    CN108256354A

  • Method and system for vehicle accident processing based on blockchain

    CN108446991A

  • Data processing method, device, medium and electronic device for block chain network

    CN109274377A

  • Intelligent contract execution method and an intelligent contract execution system

    CN109615517A