A file compression method and apparatus

By automatically selecting and compressing block files in the blockchain system, the problem of insufficient blockchain data storage space is solved, achieving efficient compression without user intervention, reducing storage costs and improving user experience.

CN116707537BActive Publication Date: 2026-02-03HUAWEI CLOUD COMPUTING TECHNOLOGIES CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210185380.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-28
Publication Date
2026-02-03
Estimated Expiration
2042-02-28

AI Technical Summary

Technical Problem

Existing blockchain technologies suffer from insufficient data storage space, and users must manually select data compression strategies, making the process cumbersome.

Method used

When the blockchain system meets preset conditions, it automatically selects and compresses block files, including standard compression and Huffman coding replacement. After replacement, the compressed file replaces the original file.

Benefits of technology

Automatic compression of block files is achieved, reducing storage costs, minimizing user operations, and improving user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116707537B_ABST
    Figure CN116707537B_ABST
Patent Text Reader

Abstract

The application provides a file compression method and device applied to a blockchain system. In the method, a compression scheduler can start a compression process when the blockchain system meets a preset condition, select a block file to be compressed, and then compress the block file to be compressed. In this process, the client does not need to perceive the compression process, and the user does not need to select a block file, a compression mode, etc. on the client, which can reduce user operation and improve user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of blockchain technology, and in particular to a file compression method and apparatus. Background Technology

[0002] Blockchain can be understood as a distributed ledger, characterized by decentralization, tamper-proofing, traceability, and transparency. Currently, blockchain is applied in various business scenarios, such as financial asset transaction settlement, digital government, evidence preservation and anti-counterfeiting, and data services. As time and transaction volume increase, blockchain ledgers become longer, requiring more storage space, thus creating a new problem of insufficient data storage. Therefore, data compression can be performed on the blockchain to address this issue.

[0003] Currently, data compression typically involves users selecting the data to be compressed, the compression strategy, etc., on the client side before the data is compressed. This method requires user intervention and is rather cumbersome. Summary of the Invention

[0004] This application provides a file compression method and apparatus to reduce user operations and improve user experience.

[0005] Firstly, this application provides a file compression method applicable to a blockchain system. Specifically, the method includes: when it is determined that the blockchain system meets preset compression conditions, selecting a first block file from the blockchain ledger of the blockchain system; then compressing the first block file to obtain a second block file; and finally, replacing the first block file in the blockchain ledger with the second block file.

[0006] The above technical solution enables automatic compression of block files, reducing storage costs. Furthermore, the compression process is automated, minimizing user intervention and improving user experience.

[0007] In one possible design, the preset compression conditions may include, but are not limited to, at least one of the following conditions:

[0008] The disk capacity used is greater than the set threshold; the system memory usage is less than the set threshold; the system CPU usage is less than the set threshold; the system disk I / O is less than the set threshold; the system network I / O is less than the set threshold.

[0009] The above technical solution enables the compression process to be initiated when the blockchain system meets the compression conditions, meaning that the client does not need to select the compression timing, thus reducing the intrusiveness of the application.

[0010] In one possible design, the block file compression process can be performed in the following ways:

[0011] Method 1: Perform standard compression on the first block file to obtain the second block file.

[0012] Method 2: Determine the Huffman codes corresponding to the fields included in the first block file, and then use the Huffman codes to replace the corresponding values ​​of the fields.

[0013] Specifically, a first compression mode library corresponding to the first block file can be determined based on the fields included in the first block file; then, the Huffman code corresponding to the values ​​of the fields included in the first block file can be determined based on the first compression mode library; finally, the values ​​of the fields included in the first block file can be replaced with the Huffman code to obtain the second block file.

[0014] Method 3: Based on Method 2, which uses Huffman coding to replace the corresponding values ​​of the fields included in the first block file, the replaced block file is then subjected to standard compression.

[0015] Specifically, the first compression mode library corresponding to the first block file can be determined based on the fields included in the first block file; then, the Huffman code corresponding to the values ​​of the fields included in the first block file can be determined based on the first compression mode library; then, the values ​​of the fields included in the first block file can be replaced with the Huffman code to obtain the third block file; finally, the third block file can be compressed using standard compression to obtain the second block file.

[0016] By using the compression methods described above, the compression ratio of block files can be improved, and the storage cost of block files can be reduced.

[0017] Secondly, this application provides a file compression device, which may include: a selection unit, used to select a first block file in the blockchain ledger of the blockchain system when it is determined that the blockchain system meets preset compression conditions; a compression unit, used to compress the first block file to obtain a second block file; and a replacement unit, used to replace the first block file in the blockchain ledger with the second block file.

[0018] In one possible design, the preset compression conditions may include, but are not limited to, at least one of the following conditions:

[0019] The disk capacity used is greater than the set threshold; the system memory usage is less than the set threshold; the system CPU usage is less than the set threshold; the system disk I / O is less than the set threshold; the system network I / O is less than the set threshold.

[0020] In one possible design, the compression unit can compress the first block file to obtain the second block file in the following manner:

[0021] The first block file is compressed using standard compression to obtain the second block file.

[0022] In another possible design, the compression unit can further compress the first block file to obtain the second block file in the following manner:

[0023] A first compression mode library corresponding to the first block file is determined based on the fields included in the first block file; the Huffman code corresponding to the values ​​of the fields included in the first block file is determined based on the first compression mode library; the values ​​of the fields included in the first block file are replaced with the Huffman code to obtain the second block file.

[0024] In another possible design, the compression unit can also compress the first block file to obtain the second block file in the following manner:

[0025] A first compression mode library corresponding to the first block file is determined based on the fields included in the first block file; the Huffman code corresponding to the values ​​of the fields included in the first block file is determined based on the first compression mode library; the values ​​of the fields included in the first block file are replaced with the Huffman code to obtain a third block file; the third block file is subjected to standard compression to obtain a second block file.

[0026] Thirdly, this application provides a file compression device that has the function of implementing the method in the first aspect or any possible implementation of the first aspect. The function can be implemented by hardware or by hardware executing corresponding software.

[0027] The file compression device includes: a memory and a processor; the memory is used to store computer instructions; the processor is used to execute the computer instructions stored in the memory to cause the file compression device to perform the method described in the first aspect or any possible implementation thereof.

[0028] Fourthly, this application also provides a computer-readable storage medium storing computer instructions that, when executed by a computer, cause the computer to perform the method described in the first aspect or any possible implementation thereof.

[0029] Fifthly, this application also provides a computer program product, the computer program product including computer instructions, which, when executed by a computer, cause the computer to perform the method described in the first aspect or any possible implementation thereof.

[0030] Regarding the technical effects of the various implementation methods of the second to fifth aspects, please refer to the introduction of the technical effects of the first aspect or the various implementation methods of the first aspect, which will not be elaborated here. Attached Figure Description

[0031] Figure 1 This is a schematic diagram of an application scenario provided by an embodiment of this application;

[0032] Figure 2 A flowchart of a file compression method provided in this application embodiment;

[0033] Figure 3 A flowchart of another file compression method provided in this application embodiment;

[0034] Figure 4 A schematic diagram of a block structure provided in an embodiment of this application;

[0035] Figure 5 A schematic diagram of a file compression process provided in an embodiment of this application;

[0036] Figure 6 This is a schematic diagram of the structure of a file compression device provided in an embodiment of this application;

[0037] Figure 7 This is a schematic diagram of a file compression device provided in an embodiment of this application. Detailed Implementation

[0038] The implementation of this embodiment will now be described in detail with reference to the accompanying drawings.

[0039] The following section will first explain some of the terms used in the embodiments of this application so that those skilled in the art can understand them.

[0040] 1) Blockchain: A shared database where data or information is stored, possessing characteristics such as "unforgeable," "fully traceable," "transparent," and "collectively maintained." Based on these characteristics, blockchain technology lays a solid foundation of "trust," creates a reliable "cooperation" mechanism, and has broad application prospects.

[0041] 2) Consortium Blockchain: This type of blockchain is only accessible to members of a specific group and a limited number of third parties. Internally, multiple pre-selected nodes are designated as ledger keepers. The generation of each block is jointly determined by all pre-selected nodes. Other access nodes can participate in transactions but do not interfere with the ledger process. Other third parties can perform limited queries through the blockchain's open API. To achieve better performance, consortium blockchains have certain requirements regarding the configuration of consensus or verification nodes and the network environment. The admission mechanism makes it easier to improve transaction performance and avoids problems caused by participants of varying levels of expertise.

[0042] 3) Huffman coding: Also known as Huffman encoding, it is an encoding method, a type of variable word length (VLC) coding. Huffman proposed an encoding method in 1952, which constructs codewords with the shortest average length based entirely on the probability of character occurrence. Sometimes it is called the optimal coding, but it is generally called Huffman coding.

[0043] 4) Lossless compression: also known as standard compression. Lossless compression formats utilize the statistical redundancy of data for compression, which can completely restore the original data without causing any distortion. However, the compression ratio is theoretically limited by the statistical redundancy of the data, generally ranging from 2:1 to 5:1. This type of method is widely used for compressing text data, program data, and image data in special applications (such as fingerprint images, medical images, etc.).

[0044] The "multiple" mentioned in the embodiments of this application refers to two or more. It should be noted that in the description of the embodiments of this application, terms such as "first" and "second" are used only for the purpose of distinguishing descriptions and should not be construed as indicating or implying relative importance, nor should they be construed as indicating or implying order.

[0045] like Figure 1 The diagram shown is an application scenario illustration provided by an embodiment of this application. (See attached image.) Figure 1 As shown, the scenario includes a client 10 and a server 20. The client 10 can be a mobile phone, tablet, laptop, personal computer, etc., and the server 20 can be any server device capable of supporting data compression on the blockchain. For example, the server 20 can be a blockchain node.

[0046] In some embodiments, a blockchain node may include a compression scheduler, a compression mode library, and multiple blocks (each block may correspond to a blockchain ledger, and each blockchain ledger may include at least one block file). The compression scheduler is used to select the block file to be compressed from the multiple blocks, select the compression timing, and execute the compression task.

[0047] Figure 1In the diagram shown, client 10 and server 20 can establish a communication connection via a communication network. A user can upload block files (also called transaction files) to client 10, which can then send the block files to server 20 for storage. Server 20 can select the block files to be compressed and the compression timing, and then compress the block files.

[0048] It should be noted that the communication network can be a local area network (LAN) or a wide area network (WAN) relayed through a relay device. When the communication network is a LAN, examples include Wi-Fi hotspots, Bluetooth (BT) networks, or near-field communication (NFC) networks. When the communication network is a WAN, examples include 3G, 4G, 5G, future public land mobile networks (PLMNs), or the Internet.

[0049] like Figure 2 The diagram shown is a flowchart of a file compression method provided in an embodiment of this application. (See attached diagram.) Figure 2 As shown, the method may include the following steps:

[0050] Step 201: When the compression scheduler detects that the blockchain system meets the preset compression conditions, it selects the first block file.

[0051] For ease of description, the block file to be compressed in this embodiment may be referred to as the "first block file". It should be understood that there may be one or more first block files, and this application does not limit this.

[0052] In this embodiment of the application, the preset compression conditions may include the following situations:

[0053] The first scenario: The used disk capacity of the blockchain node exceeds a set threshold. For example, when the used capacity of the blockchain node exceeds 80% of the disk capacity, the compression scheduler initiates the compression process.

[0054] The second scenario: When the system memory usage of a blockchain node is less than a set threshold, such as when the system memory usage of a blockchain node is less than 70%, the compression scheduler starts the compression process.

[0055] The third scenario: When the utilization rate of the blockchain node's system central processing unit (CPU) is less than a set threshold, such as when the system CPU utilization rate of the blockchain node is less than 70%, the compression scheduler starts the compression process.

[0056] The fourth scenario: When the system disk input / output (IO) of the blockchain node is less than a set threshold, such as when the disk IO of the blockchain node is less than 80%, the compression scheduler starts the compression process.

[0057] The fifth scenario: When the system network IO of a blockchain node is less than a set threshold, such as when the system network IO of a blockchain node is less than 80%, the compression scheduler starts the compression process.

[0058] It should be understood that the above threshold is only an example. In practical applications, the threshold can also be set to other values, such as starting the compression process when the system network IO is less than 70%. This application does not limit this.

[0059] In other words, the compression scheduler can choose when to start the compression process based on factors such as disk capacity and system memory; that is, the compression scheduler selects the compression timing.

[0060] In some embodiments, the compression scheduler may select at least one uncompressed block file as the block file to be compressed from at least one block file. For example, block 1 includes block file 1, block file 2, and block file 3, where block file 1 and block file 2 are compressed block files, and block file 3 is an uncompressed block file. In this case, block file 3 may be selected as the first block file.

[0061] In other embodiments, the compression scheduler can select at least one uncompressed block file from at least one block file, whose storage space is larger than a set memory size, as the block file to be compressed. For example, block 1 includes block file 1, block file 2, block file 3, and block file 4. Block file 1 and block file 2 are compressed, while block file 3 and block file 4 are uncompressed. The size of block file 3 is A1, and the size of block file 4 is A2. Assuming the set memory size is A3, if A1...<A3,A2> If A3 is selected, then block file 4 can be chosen as the block file to be compressed.

[0062] Step 202: The compression scheduler compresses the first block file to obtain the second block file.

[0063] In this embodiment of the application, the compression scheduler can use a compression algorithm to perform standard compression on the first block file to obtain a compressed block file, for example, denoted as the "second block file". For example, assuming the input of the compression algorithm is: AAABBCCCCDEEEEEEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, then compressing the above input content will yield: 3A2B4C1D6E38A.

[0064] It should be understood that the compression algorithm is not limited in the embodiments of this application, and any algorithm that can achieve compression is included within the protection scope of this application.

[0065] Step 203: The compression scheduler replaces the first block file with the second block file.

[0066] After the compression scheduler compresses the first block file, it can replace the first block file with the second block file in the blockchain ledger. This ensures that the first block file in the blockchain ledger is the compressed file, which can reduce the storage space of the block file and improve the storage space utilization.

[0067] Through the above embodiments, the compression scheduler can initiate the compression process based on the system memory, disk capacity information, etc. of the blockchain system. Then, the compression scheduler selects the block files to be compressed, eliminating the need for users to select on the client side, thus reducing user operations and improving the user experience.

[0068] like Figure 3 The diagram shown is a flowchart of another file compression method provided in an embodiment of this application. (See attached diagram.) Figure 3 As shown, the method may include the following steps:

[0069] Step 301: When the compression scheduler detects that the blockchain system meets the preset compression conditions, it selects the first block file.

[0070] like Figure 4 The diagram shown is a schematic representation of the structure of a block provided in an embodiment of this application. B1 represents block (also known as block file) 1, H1 represents the header information of block 1, D1 represents the blockchain ledger of block 1, which may include transaction files T1, T2, T3, and T4, and M1 represents block metadata.

[0071] Specifically, transaction file T4 may include H4, S4, P4, R4, and E4. Here, H4 represents the header information of transaction file T4, S4 represents the signature of transaction file T4, P4 represents the transaction proposal of transaction file T4, R4 represents the response of transaction file T4, and E4 represents the transaction endorsement of transaction file T4. H4, S4, P4, R4, and E4 can be understood as different fields in the transaction file.

[0072] Step 302: The compression scheduler determines the first compression mode library corresponding to the first block file based on the first block file.

[0073] In some embodiments, a compression mode library can be pre-configured. For example, the compression mode library may include multiple mode libraries such as a certificate mode library and a metadata mode library. The compression scheduler can determine the mode library corresponding to a field based on the fields included in the first block file. Figure 4 Taking block B1 as an example, M1 represents the block metadata of block B1, and T4 may include certificate data. Therefore, the first compression mode library corresponding to block B1 may include a metadata mode library and a certificate mode library.

[0074] It's important to note that the compressed pattern library performs Huffman coding on high-frequency elements and then stores these high-frequency elements along with their corresponding Huffman encoded values ​​within the library. These high-frequency elements include member certificates, channel names, contract names, and function names. As a permissioned network supporting the compressed pattern library, consortium blockchains, compared to public blockchains, feature fewer consortium members, fewer contracts, and the ability to support dedicated and stable business operations.

[0075] Step 303: The compression scheduler replaces the fields included in the first block file with the Huffman codes corresponding to the fields included in the first block file in the first compression mode library, and obtains the third block file.

[0076] Since different block files may contain the same or different fields, different block files can correspond to the same or different pattern libraries. Furthermore, the values ​​of the same field are usually the same in different block files. The pattern library can pre-store fields and their corresponding Huffman codes. Examples are shown in Table 1 below.

[0077] Table 1

[0078]

[0079] The compression scheduler can find the corresponding compression mode library based on the fields included in the first block file, and then replace the fields with the corresponding Huffman codes to obtain the third block file.

[0080] Step 304: The compression scheduler compresses the third block file to obtain the fourth block file.

[0081] It should be understood that the process of replacing the fields included in the first block file with the corresponding Huffman codes in steps 302 and 303 can be understood as a preprocessing or preliminary compression process of the first block file, resulting in a third block file that is smaller than the first block file. The compression of the third block file in step 304 can be understood as a secondary compression process. In other words, both replacing the Huffman codes and the compression in step 304 can be considered compression processes.

[0082] As one possible implementation, in this embodiment, only the fields included in the first block file can be replaced with the corresponding Huffman codes without performing step 304. Alternatively, only the first block file can be compressed without performing the process of replacing the fields included in the first block file with the corresponding Huffman codes. Of course, both processes can also be performed, and this application does not limit this.

[0083] Step 305: The compression scheduler replaces the first block file with the fourth block file.

[0084] It should be noted that, Figure 3 For details on the implementation of steps 301, 304, and 305 in the illustrated embodiment, please refer to [link / reference needed]. Figure 2 The detailed descriptions of steps 201, 202, and 203 in the illustrated embodiment will not be repeated here.

[0085] Figure 3 The compression method in the illustrated embodiment is similar to Figure 2 Compared to the compression method in the illustrated embodiment, Figure 3 The first step is to replace the fields in the first block file with the corresponding Huffman codes. Then, the block file after Huffman coding is compressed, which improves the compression ratio and reduces the storage space occupied by the block file. Moreover, this is done without the user's awareness, thus improving the user experience.

[0086] like Figure 5 The diagram shown is a schematic representation of a file compression process provided in an embodiment of this application. (See attached image.) Figure 5 As shown, the steps may include the following:

[0087] 1. The compression scheduler starts compression at an opportune time; 2. The compression scheduler selects a block file; 3. The compression scheduler matches the pattern library based on the fields in the selected block file; 4. The compression scheduler performs compression based on the matched pattern library to obtain a compressed file; 5. The compression scheduler replaces the original block file with the compressed file.

[0088] It should be understood that the specific implementation process of steps 1 and 2 can be found in [reference needed]. Figure 2For a detailed description of step 201, see step 3. Figure 3 For a detailed description of steps 302 and 303 in the illustrated embodiment, please refer to the following for step 4. Figure 3 For a detailed description of step 304, see step 5. Figure 3 The detailed description of step 305 shown will not be repeated here.

[0089] The above embodiments can improve the block file compression ratio, reduce storage costs, and enhance the user experience by ensuring that the client is unaware of the compression process (i.e., non-intrusive application). Simultaneously, asynchronous processing can avoid peak periods and reduce server load.

[0090] Based on the above embodiments, this application also provides a file compression device, which can be the compression scheduler in the foregoing embodiments. See also... Figure 6 As shown, the file compression device 600 may include: a selection unit 601, a compression unit 602, and a replacement unit 603.

[0091] The selection unit 601 is used to select a first block file in the blockchain ledger of the blockchain system when it is determined that the blockchain system meets the preset compression conditions; the compression unit 602 is used to compress the first block file to obtain a second block file; and the replacement unit 603 is used to replace the first block file in the blockchain ledger with the second block file.

[0092] In one possible implementation, the preset compression conditions include at least one of the following conditions:

[0093] The disk capacity used is greater than the set threshold; the system memory usage is less than the set threshold; the system CPU usage is less than the set threshold; the system disk I / O is less than the set threshold; the system network I / O is less than the set threshold.

[0094] In one possible implementation, compression unit 602 is specifically used to compress the first block file in the following manner to obtain a second block file:

[0095] The first block file is compressed using standard compression to obtain the second block file.

[0096] In one possible implementation, compression unit 602 is specifically used to compress the first block file in the following manner to obtain a second block file:

[0097] A first compression mode library corresponding to the first block file is determined based on the fields included in the first block file; the Huffman code corresponding to the value of the field is determined based on the first compression mode library; the value of the field included in the first block file is replaced with the Huffman code to obtain the second block file.

[0098] In one possible implementation, compression unit 602 is specifically used to compress the first block file in the following manner to obtain a second block file:

[0099] A first compression mode library corresponding to the first block file is determined based on the fields included in the first block file; the Huffman code corresponding to the value of the field is determined based on the first compression mode library; the value of the field included in the first block file is replaced with the Huffman code to obtain a third block file; the third block file is subjected to standard compression to obtain a second block file.

[0100] The module division in this embodiment is illustrative and represents only one logical functional division. In actual implementation, other division methods may be used. Furthermore, the functional modules in each embodiment of this application can be integrated into a single processor, exist as separate physical entities, or be integrated into a single module. The integrated modules described above can be implemented in hardware or as software functional modules.

[0101] like Figure 7 The illustration shows a file compression device 700 provided in an embodiment of this application. This device can be a server or one or more devices within a server. The file compression device 700 includes at least one processor 702, used to implement or support the file compression device 700 in implementing the functionality provided in the embodiment of this application. Figure 6 The functions of the selection unit, compression unit, etc., are shown. For example, the processor 702 can compress the first block file to obtain a second block file, etc. For details, please refer to the detailed description in the method example, which will not be repeated here.

[0102] The file compression device 700 may further include at least one memory 701 for storing program instructions. The memory 701 and the processor 702 are coupled. The coupling in this embodiment is an indirect coupling or communication connection between devices, units, or modules, and can be electrical, mechanical, or other forms, for information exchange between devices, units, or modules. The processor 702 may operate in conjunction with the memory 701. The processor 702 may execute program instructions and / or data stored in the memory 701. At least one of the at least one memory may be included in the processor.

[0103] The file compression device 700 may also include a communication interface 703 for communicating with other devices via a transmission medium. The processor 702 can use the communication interface 703 to send and receive data.

[0104] This application does not limit the specific connection medium between the communication interface 703, the processor 702, and the memory 701 described above. Embodiments of this application... Figure 7 The memory 701, processor 702, and communication interface 703 are connected via a bus 704. Figure 7 The bus is represented by thick lines. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 7 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0105] In the embodiments of this application, the processor 702 may be a general-purpose processor, a digital signal processor, an application-specific integrated circuit, a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components, and may implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application may be directly executed by the hardware processor, or may be executed by a combination of hardware and software modules within the processor.

[0106] In this embodiment, the memory 701 can be non-volatile memory, such as a hard disk drive (HDD) or a solid-state drive (SSD), or it can be volatile memory, such as RAM. Memory is any medium capable of carrying or storing desired program code in the form of instructions or data structures, and accessible by a computer, but is not limited thereto. The memory in this embodiment can also be a circuit or any other device capable of implementing storage functions for storing program instructions.

[0107] Optionally, the computer execution instructions in the embodiments of this application may also be referred to as application code, and the embodiments of this application do not specifically limit this.

[0108] This application also provides a computer-readable storage medium including instructions that, when run on a computer, cause the computer to perform the methods of the above embodiments.

[0109] This application also provides a computer program product, including instructions that, when run on a computer, cause the computer to perform the methods described above.

[0110] This application also provides a chip, the logic in which is used to execute the methods of the above embodiments.

[0111] This application describes embodiments of methods, apparatus (systems), and computer program products according to embodiments of this application with reference to flowchart illustrations and / or block diagrams. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by instructions. These instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0112] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0113] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0114] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A file compression method applied to a blockchain system, characterized in that, include: When it is determined that the blockchain system meets the preset compression conditions, the first block file is selected in the blockchain ledger of the blockchain system; The first compression mode library corresponding to the first block file is determined based on the fields included in the first block file; The Huffman code corresponding to the value of the field is determined based on the first compression mode library; The values ​​of the fields included in the first block file are replaced with the Huffman codes to obtain the third block file; The third block file is compressed using standard compression to obtain the second block file; Replace the first block file in the blockchain ledger with the second block file.

2. The method as described in claim 1, characterized in that, The preset compression conditions include at least one of the following conditions: The used disk capacity exceeds the set threshold. System memory usage is less than the set threshold; The system's central processing unit (CPU) utilization is less than the set threshold. The system disk input / output I / O is less than the set threshold; The system network I / O is less than the set threshold.

3. The method as described in claim 1 or 2, characterized in that, The first block file is compressed to obtain a second block file, which includes: The first block file is compressed using standard compression to obtain the second block file.

4. The method as described in claim 1 or 2, characterized in that, The first block file is compressed to obtain a second block file, which includes: The first compression mode library corresponding to the first block file is determined based on the fields included in the first block file; The Huffman code corresponding to the value of the field is determined based on the first compression mode library; The values ​​of the fields included in the first block file are replaced with the Huffman codes to obtain the second block file.

5. A file compression device, characterized in that, include: The selection unit is used to select the first block file in the blockchain ledger of the blockchain system when it is determined that the blockchain system meets the preset compression conditions. A compression unit is used to determine a first compression mode library corresponding to the first block file based on the fields included in the first block file; The Huffman code corresponding to the value of the field is determined according to the first compression mode library; the value of the field included in the first block file is replaced with the Huffman code to obtain the third block file; the third block file is compressed according to standard to obtain the second block file; The replacement unit is used to replace the first block file in the blockchain ledger with the second block file.

6. The apparatus as claimed in claim 5, characterized in that, The preset compression conditions include at least one of the following conditions: The used disk capacity exceeds the set threshold. System memory usage is less than the set threshold; The system's central processing unit (CPU) utilization is less than the set threshold. The system disk input / output I / O is less than the set threshold; The system network I / O is less than the set threshold.

7. The apparatus as described in claim 5 or 6, characterized in that, The compression unit is specifically used to compress the first block file in the following manner to obtain the second block file: The first block file is compressed using standard compression to obtain the second block file.

8. The apparatus as described in claim 5 or 6, characterized in that, The compression unit is specifically used to compress the first block file in the following manner to obtain the second block file: The first compression mode library corresponding to the first block file is determined based on the fields included in the first block file; The Huffman code corresponding to the value of the field is determined based on the first compression mode library; The values ​​of the fields included in the first block file are replaced with the Huffman codes to obtain the second block file.

9. A file compression device, characterized in that, include: Memory and processor; The memory is used to store computer instructions; The processor is configured to execute computer instructions stored in the memory to cause the file compression device to perform the method as described in any one of claims 1-4.

10. A computer-readable storage medium, characterized in that, The storage medium stores computer instructions that, when executed by a computer, cause the computer to perform the method as described in any one of claims 1-4.

11. A computer program product, characterized in that, The computer program product includes computer instructions that, when executed by a computer, cause the computer to perform the method as described in any one of claims 1-4.

Citation Information

Patent Citations

  • Method and terminal for improving utilization ratio of memory space

    CN103218224A