WO2021027252A1 - 块链式账本中的数据存储方法、装置及设备 - Google Patents

块链式账本中的数据存储方法、装置及设备 Download PDF

Info

Publication number
WO2021027252A1
WO2021027252A1 PCT/CN2020/071339 CN2020071339W WO2021027252A1 WO 2021027252 A1 WO2021027252 A1 WO 2021027252A1 CN 2020071339 W CN2020071339 W CN 2020071339W WO 2021027252 A1 WO2021027252 A1 WO 2021027252A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
compression
client
database server
hash value
Prior art date
Application number
PCT/CN2020/071339
Other languages
English (en)
French (fr)
Inventor
杨新颖
Original Assignee
创新先进技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 创新先进技术有限公司 filed Critical 创新先进技术有限公司
Priority to US16/812,036 priority Critical patent/US11249987B2/en
Publication of WO2021027252A1 publication Critical patent/WO2021027252A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0608Saving storage space on storage systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0629Configuration or reconfiguration of storage systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/067Distributed or networked storage systems, e.g. storage area networks [SAN], network attached storage [NAS]

Definitions

  • the embodiments of this specification relate to the field of information technology, and in particular to a data storage method, device, and equipment in a block chain ledger.
  • the purpose of the embodiments of this specification is to provide a data storage method for improving storage efficiency in a block chain ledger.
  • this specification provides a data storage method in a blockchain ledger, which is applied to a client terminal, and the method includes:
  • the compression threshold is used to determine a target object for performing data compression, and the target object for performing data compression includes a client or a database server;
  • the client performs data compression on the service data, generates compressed data for the service data, and sends the compressed data to the database server;
  • the client sends the business data to the database server, so that the database server performs data compression to generate compressed data for the business data.
  • an embodiment of this specification also provides a data storage device in a blockchain ledger, which is applied to a client, and the device includes:
  • the acquiring module acquires the business data of the user and determines the compression threshold of the user, wherein the compression threshold is used to determine the target object for performing data compression, and the target object for performing data compression includes a client or a database server ;
  • the determining module obtains the hardware parameters and/or network environment parameters of the device where the client is located, and determines the compression weights according to the hardware parameters and/or network environment parameters, where the compression weights are positively related to the hardware parameters, and Negative correlation of network environment parameters;
  • a compression module if the compression weight is greater than a preset value, the client performs data compression on the service data to generate compressed data for the service data;
  • the sending module sends the compressed data to the database server; the sending module is also used to send the business data to the database server if the compression weight is not greater than the preset value so that the database server can execute the data Compress, generate compressed data for the service data.
  • the embodiment of this specification also provides a data storage method in a block chain ledger, which is applied to a database server, and the method includes:
  • Receiving compressed data sent by the client where the compressed data is obtained by the client compressing service data; or, receiving the service data sent by the client and compressing the service data to obtain compressed data;
  • each data record to be written in the data block is determined, and the Nth data block containing the hash value of the data block and the data record is generated, which specifically includes:
  • the hash value and block height of the initial data block are given based on a preset method
  • the embodiment of the present specification also provides a data storage device in a blockchain ledger, which is applied to a client, and the device includes:
  • the acquiring module acquires the business data of the user and determines the compression threshold of the user, wherein the compression threshold is used to determine the target object for performing data compression, and the target object for performing data compression includes a client or a database server ;
  • the determining module obtains the hardware parameters and/or network environment parameters of the device where the client is located, and determines the compression weights according to the hardware parameters and/or network environment parameters, where the compression weights are positively related to the hardware parameters, and Negative correlation of network environment parameters;
  • a compression module if the compression weight is greater than a preset value, the client performs data compression on the service data to generate compressed data for the service data;
  • the sending module sends the compressed data to the database server; the sending module is also used to send the business data to the database server if the compression weight is not greater than the preset value so that the database server can execute the data Compress, generate compressed data for the service data.
  • the client when the client receives the service data sent by the user, it dynamically evaluates the hardware equipment and network environment parameters of the client to determine that the client is used to compress the service data. The process is still performed by the database server. After the compression is completed, the database server writes the compressed data into the block chain ledger, which can save the space occupied by the ledger and improve the writing efficiency of the ledger.
  • FIG. 1 is a schematic diagram of the architecture of the system involved in the embodiment of the specification
  • FIG. 2 is a schematic flowchart of a data storage method in a block chain ledger provided by an embodiment of this specification
  • FIG. 3 is a schematic flowchart of another method for storing data in a blockchain ledger provided by an embodiment of this specification
  • FIG. 4 is a schematic structural diagram of a data storage device in a block chain ledger provided by an embodiment of this specification
  • FIG. 5 is a schematic structural diagram of another data storage device in a blockchain ledger provided by an embodiment of this specification.
  • Fig. 6 is a schematic structural diagram of a device for configuring the method of the embodiment of this specification.
  • the database server provides data storage services to clients in a centralized manner.
  • Client users can be organizations or individual users.
  • the user uploads the recorded video or the captured image as evidence to the database server through his own device, or uploads it to the database server through the judicial institution.
  • FIG. 1 is a schematic diagram of the architecture of the system involved in the embodiment of this specification.
  • Figure 2 is a data storage method in a block chain ledger provided by the embodiments of this specification.
  • the schematic diagram of the process, applied to the client, the process specifically includes the following steps:
  • S201 Acquire business data of a user, and determine a compression threshold of the user.
  • the business data may be various consumption records of individual users of the client, or may be business results, intermediate states, and operation records generated when the application server executes business logic based on user instructions.
  • Specific business scenarios can include consumption records, audit logs, supply chains, government supervision records, medical records, and so on.
  • business data can be various reports that financial institutions need to report.
  • the compression threshold can be counted and dynamically adjusted by the database server based on the situation of the connected client, and stored locally in the client, which can be obtained by the client at any time.
  • S203 Obtain hardware parameters and/or network environment parameters of the device where the client is located, and determine compression weights according to the hardware parameters and/or network environment parameters.
  • the hardware parameters of the device may include the CPU frequency of the device, the number of CPU cores, the memory size, etc., and the network environment parameters of the device may include the network connection mode of the device, the upload bandwidth of the device, and so on.
  • Each hardware parameter can be characterized by a corresponding value.
  • the main frequency of 2.2gHz is characterized as 2.2
  • 4CPU is characterized as 4
  • 2g memory is characterized as 2
  • wired Internet is characterized as 4
  • the upload bandwidth of 8M/s is characterized as 8 and so on.
  • the device condition corresponding to the critical compression weight 1 is 2.2gHz, 4CPU, 2g memory, broadband Internet access, and 8M upload bandwidth. It can be known that if the hardware condition of the device is worse or the network condition is better, compression should be performed by the database server.
  • the essence of dynamic compression is based on the client's device hardware conditions and network conditions to achieve more efficient compression and transmission. If the client's device hardware conditions are better and the network conditions are worse, the compression is performed on the client side, and vice versa on the database server side. Perform compression to improve data transmission efficiency.
  • Specific compression methods include conventional reversible lossless compression, in which the original business data can be completely restored based on the compressed data. For example, compress the report into a compressed package such as RAR, ZIP and other formats.
  • another compression method can also be performed, that is, determining the hash value of the business data, determining the hash value of the business data as compressed data, and then determining the hash value as the data to be stored.
  • the "compressed data” cannot be restored to obtain the corresponding business data, but due to the uniqueness of the hash value, the integrity of the data to be stored in the ledger can also be verified.
  • the client can directly send the business data to the database server; or, when the compression weight is not greater than the preset value (that is, it needs to be compressed by the database server at this time), then the corresponding Compression identifier, which is used to indicate that the service data needs to be compressed.
  • the client can further differentiate the business data. For example, some business data is small and does not need to be compressed, while some business data is large and needs to be compressed.
  • a compression identifier it is possible to add a compression identifier to only part of the service data, and then add the function of parsing the service request and identifying the identifier on the database server. For example, a compression flag is added to service data that occupies a space exceeding a certain size, but no compression flag is added to smaller service data.
  • FIG. 3 is a schematic flowchart of another method for storing data in a blockchain ledger provided by an embodiment of this specification, and the method includes:
  • S301 Receive compressed data sent by the client, where the compressed data is obtained by the client compressing service data; or, receive the service data sent by the client, and compress the service data to obtain compressed data.
  • the service data needs to be compressed and then stored.
  • the database server may perform a corresponding follow-up process according to whether the service data sent by the client includes a compression identifier. If there is, compression is performed on the database server. No, it means that the client has been compressed, and the received data is compressed data.
  • the user's hardware conditions and network conditions can also be saved.
  • the user's hardware conditions and network conditions have not changed, the same as the last time Compression method. That is, if the compression was performed by the database server the previous time, the compression will continue on the database server this time; if the compression was not performed on the database server the previous time, no compression will be performed this time.
  • the database server can obtain the data record to be stored (ie the aforementioned data to be stored), determine the hash value of each data record to be stored, and return the hash value of the data record to be stored to the client , So that the client can query at any time.
  • the hash value of the business data can be directly determined as the hash value of the data record to be stored; if the compression is executed Lossless compression is to determine the hash value of the compressed package as the hash value of the data record to be stored.
  • S305 When the preset blocking condition is reached, determine each data record to be written in the data block, and generate an Nth data block including the hash value of the data block and the data record.
  • the preset block conditions include: the number of data records to be stored reaches the number threshold, for example, every time one thousand data records are received, a new data block is generated and one thousand data records are written into the block; or , The time interval from the last block formation time reaches the time threshold, for example, every 5 minutes, a new data block is generated, and the data records received within these 5 minutes are written into the block.
  • the N here refers to the serial number of the data block.
  • the data block is in the form of a block chain, which is arranged sequentially based on the order of the block time, and has a strong timing characteristic.
  • the block height of the data block increases monotonically based on the sequence of the block time.
  • the block height can be a sequence number, at this time the block height of the Nth data block is N; the block height can also be generated in other ways.
  • the data block at this time is the initial data block.
  • the current data block (the first data block) can be generated based on the hash value of the previous data block (that is, the N-1th data block). For example, a feasible way is to determine the hash value of each data record to be written in the Nth block, and generate a Merck according to the sequence in the block. In the Er tree, the root hash value of the Merkel tree and the hash value of the previous data block are spliced together, and the hash algorithm is used again to generate the hash value of the current block.
  • the hash value of each compressed data needs to be calculated when calculating the root hash value of the Merkel tree ; If the data to be stored is the hash value of business data, the hash value of the hash value of each business data needs to be calculated when calculating the root hash value of the molar number.
  • the specific verification method includes recalculating the hash value of the data record itself and the hash value of the data block where it is located, and comparing with the locally stored hash value.
  • the data block generated in the above manner may include two parts: a block header and a block body.
  • the block body can be used to store the plaintext of the spliced data, or the hash value of the spliced data, etc.;
  • the block header can be used to store metadata about the data block, for example, the version number of the ledger, the hash of the previous data block Value, the root hash value of the Merkel tree composed of the spliced data in the own data block, the hash value of the own data block, the state array used to record the operated state of the spliced data, and so on.
  • the client when the client receives the service data sent by the user, it dynamically evaluates the hardware equipment and network environment parameters of the client to determine that the client is used to compress the service data. The process is still performed by the database server. After the compression is completed, the database server writes the compressed data into the block chain ledger, which can save the space occupied by the ledger and improve the writing efficiency of the ledger.
  • the database server compresses the business data
  • it also needs to store the business data locally, and record the correspondence between the business data and the compressed data of the business data.
  • the compressed data can be recorded The corresponding relationship between the name of the business data and the name and storage location of the business data. If the compressed data is the hash value of the business data, at this time, the corresponding relationship between the storage location of the business data and the hash value of the business data can also be recorded for query.
  • the client may also initiate a query based on the hash value stored by itself, and send a query request including the hash value to the database server.
  • the hash value may be the hash value of the compressed package or the hash value of the service data.
  • the database server When the database server receives the query request, it can query the corresponding compressed data based on the hash value: when the compressed data is a compressed package, it can obtain the compressed package corresponding to the hash value from the ledger, and return the compressed package to the client
  • the hash value is the hash value of the business data
  • the business data can be queried based on the correspondence between the storage location of the business data and the hash value of the business data, and the business data and business data are returned
  • the hash value is sent to the client so that the client can use the business data or verify the integrity of the business data.
  • the embodiment of this specification also provides a data storage device in the block chain ledger, which is applied to the client, as shown in FIG. 4, which is a block chain type provided by the embodiment of this specification.
  • the structure diagram of the data storage device in the ledger includes:
  • the acquiring module acquires the business data of the user and determines the compression threshold of the user, wherein the compression threshold is used to determine the target object for performing data compression, and the target object for performing data compression includes a client or a database server ;
  • the determining module 401 obtains hardware parameters and/or network environment parameters of the device where the client is located, and determines compression weights according to the hardware parameters and/or network environment parameters, where the compression weights are positively related to the hardware parameters, Negatively correlate with network environment parameters;
  • the compression module 403 if the compression weight is greater than a preset value, perform data compression on the service data in the client to generate compressed data for the service data;
  • the sending module 405 sends the compressed data to the database server; the sending module is also used to send the business data to the database server if the compression weight is not greater than the preset value, so that the database server can execute Data compression generates compressed data for the service data.
  • the compression module 403 performs lossless compression on the service data to generate a compressed package that can restore the service data; or, determine the hash value of the service data, and determine the hash value of the service data as Compress the data.
  • the sending module 405 sends the service data and the compression identifier to the database server, and the compression identifier indicates that the service data needs to be compressed by the database server.
  • the sending module 405 is further configured to send a query request including a hash value to the database server, so that the database server obtains corresponding compressed data according to the hash value query; the device further includes receiving Module 407, receiving compressed data returned by the database server, and decompressing the compressed data to obtain corresponding business data.
  • the embodiment of this specification also provides a data storage device in the block chain ledger, which is applied to the database server, as shown in FIG. 5, which is another type provided by the embodiment of this specification.
  • the structure diagram of the data storage device in the block chain ledger including:
  • the receiving module 501 receives compressed data sent by the client, where the compressed data is obtained by the client compressing the service data; or, receiving the service data sent by the client;
  • the compression module 503 performs compression on the service data to obtain compressed data
  • a determination module 505 which confirms the compressed data as a data record to be stored, and determines the hash value of each data record
  • the data block generation module 507 determines each data record to be written in the data block when the preset blocking condition is reached, and generates the Nth data block containing the hash value of the data block and the data record, which specifically includes:
  • the hash value and block height of the initial data block are given based on a preset method; when N>1, according to the data records in the data block to be written and the hash value of the N-1th data block
  • the H value determines the hash value of the Nth data block, and generates the Nth data block containing the hash value of the Nth data block and each data record.
  • the preset blocking condition includes: the number of data records to be stored reaches the number threshold; or, the time interval from the last blocking time reaches the time threshold.
  • the device further includes a query module 509, which receives a query request containing a hash value sent by the client; queries to obtain the compressed data corresponding to the hash value; and sends the compressed data to the client for the client Decompress the compressed data at the end.
  • a query module 509 which receives a query request containing a hash value sent by the client; queries to obtain the compressed data corresponding to the hash value; and sends the compressed data to the client for the client Decompress the compressed data at the end.
  • the receiving module 501 is further configured to receive the service data sent by the client; detect whether the service data contains a compression identifier, and the compression identifier indicates that the service data needs to be compressed on the database server; if Contains, compressing the business data to generate compressed data.
  • the embodiment of this specification also provides a computer device, which at least includes a memory, a processor, and a computer program stored in the memory and capable of running on the processor, wherein the processor implements the blocks shown in FIG. 2 when the program is executed.
  • a computer device which at least includes a memory, a processor, and a computer program stored in the memory and capable of running on the processor, wherein the processor implements the blocks shown in FIG. 2 when the program is executed.
  • Data storage method in the chain ledger is a computer device, which at least includes a memory, a processor, and a computer program stored in the memory and capable of running on the processor, wherein the processor implements the blocks shown in FIG. 2 when the program is executed. Data storage method in the chain ledger.
  • the embodiments of this specification also provide a computer device, which at least includes a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor implements the blocks shown in FIG. 3 when the program is executed. Data storage method in the chain ledger.
  • the device may include a processor 1010, a memory 1020, an input/output interface 1030, a communication interface 1040, and a bus 1050.
  • the processor 1010, the memory 1020, the input/output interface 1030, and the communication interface 1040 realize the communication connection between each other in the device through the bus 1050.
  • the processor 1010 may be implemented in a general-purpose CPU (Central Processing Unit, central processing unit), microprocessor, application specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits for execution related Program to implement the technical solutions provided in the embodiments of this specification.
  • a general-purpose CPU Central Processing Unit, central processing unit
  • microprocessor microprocessor
  • application specific integrated circuit Application Specific Integrated Circuit, ASIC
  • ASIC Application Specific Integrated Circuit
  • the memory 1020 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory, random access memory), static storage device, dynamic storage device, etc.
  • the memory 1020 may store an operating system and other application programs. When the technical solutions provided in the embodiments of the present specification are implemented through software or firmware, related program codes are stored in the memory 1020 and called and executed by the processor 1010.
  • the input/output interface 1030 is used to connect an input/output module to realize information input and output.
  • the input/output/module can be configured in the device as a component (not shown in the figure), or can be connected to the device to provide corresponding functions.
  • the input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and an output device may include a display, a speaker, a vibrator, an indicator light, and the like.
  • the communication interface 1040 is used to connect a communication module (not shown in the figure) to realize the communication interaction between the device and other devices.
  • the communication module can realize communication through wired means (such as USB, network cable, etc.), or through wireless means (such as mobile network, WIFI, Bluetooth, etc.).
  • the bus 1050 includes a path to transmit information between various components of the device (for example, the processor 1010, the memory 1020, the input/output interface 1030, and the communication interface 1040).
  • the device may also include the necessary equipment for normal operation.
  • the above-mentioned device may also include only the components necessary to implement the solutions of the embodiments of the present specification, rather than all the components shown in the figures.
  • the embodiment of this specification also provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the data storage method in the block chain ledger shown in FIG. 2 is realized.
  • the embodiment of this specification also provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the data storage method in the block chain ledger shown in FIG. 3 is implemented.
  • Computer-readable media include permanent and non-permanent, removable and non-removable media, and information storage can be realized by any method or technology.
  • the information can be computer-readable instructions, data structures, program modules, or other data.
  • Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, CD-ROM, digital versatile disc (DVD) or other optical storage, Magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media can be used to store information that can be accessed by computing devices. According to the definition in this article, computer-readable media does not include transitory media, such as modulated data signals and carrier waves.
  • a typical implementation device is a computer.
  • the specific form of the computer can be 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 receiving and sending device, and a game control A console, a tablet computer, a wearable device, or a combination of any of these devices.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

公开了块链式账本中的数据存储方法、装置及设备。通过本说明书实施例所提供的方案,客户端在接收到用户所发送的业务数据时,即通过获取客户端的硬件设备和网络环境参数进行动态评估,以确定对于业务数据进行压缩时是由客户端进行还是由数据库服务端进行,在压缩完成后,数据库服务端将压缩数据写入块链式的账本。

Description

块链式账本中的数据存储方法、装置及设备 技术领域
本说明书实施例涉及信息技术领域,尤其涉及块链式账本中的数据存储方法、装置及设备。
背景技术
在以中心化的块链式账本存储用户的业务数据时,用户经常一次性上传较多的数据作为一个整体进行存储。例如,一张数据量较大的报表;或者多张同一业务的同类型报表;或者,多份视频、图片等构成的一份证据等等。
这个过程中,经常会有用户需要一次性上传多份文件,或者一次性上传一份较大的数据,账本如果将用户上传的原文件写入账本,则效率太低,影响账本的写入速度。
发明内容
本说明书实施例的目的是提供一种块链式账本中提高存储效率的数据存储方法。
为解决上述技术问题,本说明书实施例是这样实现的:
一方面,本说明书提供一种块链式账本中的数据存储方法,应用于客户端中,所述方法包括:
获取用户的业务数据,以及,确定所述用户的压缩临界值,其中,所述压缩临界值用于判断执行数据压缩的目标对象,所述执行数据压缩的目标对象包括客户端或者数据库服务端;
获取客户端所处设备的硬件参数和/或网络环境参数,根据所述硬件参数和/或网络环境参数确定出压缩权值,其中,所述压缩权值与硬件参数正相关,与网络环境参数负相关;
若所述压缩权值大于预设值,则所述客户端中对所述业务数据执行数据压缩,生成对于所述业务数据的压缩数据,并发送压缩数据至数据库服务端;
否则,客户端将所述业务数据发送至数据库服务端,以便所述数据库服务端执行数据压缩,生成对于所述业务数据的压缩数据。
以一方面对应的,本说明书实施例还提供一种一种块链式账本中的数据存储装置,应用于客户端中,所述装置包括:
获取模块,获取用户的业务数据,确定所述用户的压缩临界值,其中,所述压缩临界值用于判断执行数据压缩的目标对象,所述执行数据压缩的目标对象包括客户端或者数据库服务端;
确定模块,获取客户端所处设备的硬件参数和/或网络环境参数,根据所述硬件参数和/或网络环境参数确定出压缩权值,其中,所述压缩权值与硬件参数正相关,与网络环境参数负相关;
压缩模块,若所述压缩权值大于预设值,则所述客户端中对所述业务数据执行数据压缩,生成对于所述业务数据的压缩数据;
发送模块,发送压缩数据至数据库服务端;所述发送模块还用于,若所述压缩权值不大于预设值,将所述业务数据发送至数据库服务端,以便所述数据库服务端执行数据压缩,生成对于所述业务数据的压缩数据。
另一方面,本说明书实施例还提供一种块链式账本中的数据存储方法,应用于数据库服务端中,所述方法包括:
接收客户端所发送的压缩数据,其中,所述压缩数据由客户端对业务数据执行压缩得到;或者,接收客户端所发送的业务数据,对所述业务数据执行压缩,得到压缩数据;
将所述压缩数据确认为待存储的数据记录,确定各数据记录的哈希值;
当达到预设的成块条件时,确定待写入数据块中的各数据记录,生成包含数据块的哈希值和数据记录的第N个数据块,具体包括:
当N=1时,初始数据块的哈希值和块高基于预设方式给定;
当N>1时,根据待写入数据块中的各数据记录和第N-1个数据块的哈希值确定第N个数据块的哈希值,生成包含第N个数据块的哈希值和各数据记录的第N个数据块。
与另一方面对应的,本说明书实施例还提供一种块链式账本中的数据存储装置,应用于客户端中,所述装置包括:
获取模块,获取用户的业务数据,确定所述用户的压缩临界值,其中,所述压缩临界值用于判断执行数据压缩的目标对象,所述执行数据压缩的目标对象包括客户端或者数据库服务端;
确定模块,获取客户端所处设备的硬件参数和/或网络环境参数,根据所述硬件参数和/或网络环境参数确定出压缩权值,其中,所述压缩权值与硬件参数正相关,与网络环境参数负相关;
压缩模块,若所述压缩权值大于预设值,则所述客户端中对所述业务数据执行数据压缩,生成对于所述业务数据的压缩数据;
发送模块,发送压缩数据至数据库服务端;所述发送模块还用于,若所述压缩权值不大于预设值,将所述业务数据发送至数据库服务端,以便所述数据库服务端执行数据压缩,生成对于所述业务数据的压缩数据。
通过本说明书实施例所提供的方案,客户端在接收到用户所发送的业务数据时,即通过获取客户端的硬件设备和网络环境参数进行动态评估,以确定对于业务数据进行压缩时是由客户端进行还是由数据库服务端进行,在压缩完成后,数据库服务端将压缩数据写入块链式的账本,从而可以节省账本的占用空间,提高账本的写入效率。
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本说明书实施例。
此外,本说明书实施例中的任一实施例并不需要达到上述的全部效果。
附图说明
为了更清楚地说明本说明书实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本说明书实施例中记载的一些实施例,对于本领域普通技术人员来讲,还可以根据这些附图获得其他的附图。
图1为本说明书实施例所涉及的***的架构示意图;
图2是本说明书实施例所提供的一种块链式账本中的数据存储方法的流程示意图;
图3为本说明书实施例所提供的另一种块链式账本中的数据存储方法的流程示意图;
图4是本说明书实施例提供的一种块链式账本中的数据存储装置的结构示意图;
图5是本说明书实施例提供的另一种块链式账本中的数据存储装置的结构示意图;
图6是用于配置本说明书实施例方法的一种设备的结构示意图。
具体实施方式
为了使本领域技术人员更好地理解本说明书实施例中的技术方案,下面将结合本说明书实施例中的附图,对本说明书实施例中的技术方案进行详细地描述,显然,所描述的实施例仅仅是本说明书的一部分实施例,而不是全部的实施例。基于本说明书中的实施例,本领域普通技术人员所获得的所有其他实施例,都应当属于保护的范围。
在本说明书实施例中,数据库服务端以中心化的方式面向客户端提供数据存储服务。客户端的用户可以是机构组织,也可以是个人用户。例如,用户将录制得到的视频或者拍摄得到的图像,作为证据,通过自身设备上传至数据库服务端,或者通过司法机构上传至数据库服务端。如图1所示,图1为本说明书实施例所涉及的***的架构示意图。
以下结合附图,详细说明本说明书各实施例提供的技术方案,本说明书的一方面,如图2所示,图2是本说明书实施例所提供的一种块链式账本中的数据存储方法的流程示意图,应用于客户端中,该流程具体包括如下步骤:
S201,获取用户的业务数据,以及,确定所述用户的压缩临界值。
所述业务数据,可以是客户端个人用户的各种消费记录,也可以是应用服务器基于用户的指令,在执行业务逻辑时产生的业务结果、中间状态以及操作记录等等。具体的业务场景可以包括消费记录、审计日志、供应链条、政府监管记录、医疗记录等等。例如,在金融监管中,业务数据可以是金融机构需要进行上报的各种报表。
用户的压缩临界值可以是基于用户的硬件参数和/或网络环境参数事先所确定一个常数。例如,压缩临界值=1。通常而言,压缩临界值可以对应于某种常见的设备条件。例如,若临界压缩权值1对应的设备条件为2.2gHz、4CPU、2g内存、宽带上网、8M上传带宽。
压缩临界值可以由数据库服务端基于接入的客户端的情形进行统计以及动态调整,并且保存于客户端本地中,客户端可以随时获取。
S203,获取客户端所处设备的硬件参数和/或网络环境参数,根据所述硬件参数和/或网络环境参数确定出压缩权值。
设备的硬件参数可以包括设备的CPU主频、CPU核数、内存大小等等,设备的网络环境参数可以包括设备的网络连接模式、设备的上传带宽等等。每种硬件参数均可以用相应的数值来表征。例如,主频2.2gHz表征为2.2,4CPU表征为4,2g内存表征为 2;有线上网表征为4,上传带宽8M/s表征为8等等。
通常而言,硬件性能越好,硬件参数值越大;网络环境越好,网络环境参数越大。
通过各参数值综合计算出压缩权值,并与临界压缩权值进行比较。例如,一种计算方式为压缩权值M=k*(主频*核数*内存)/(上网方式*上传带宽),其中k为经验参数,可由用户设置。若压缩权值大于临界压缩权值,则由客户端进行压缩,反之,则由数据库服务端进行压缩。
例如,若临界压缩权值1对应的设备条件为2.2gHz、4CPU、2g内存、宽带上网、8M上传带宽。则可以知道,若设备的硬件条件更差或者网络条件更好时,应该由数据库服务端进行压缩。
动态压缩的本质是基于客户端的设备硬件条件和网络条件,实现更高效的压缩以及传输,若客户端的设备硬件条件更好,网络条件更差,则在客户端执行压缩,反之则在数据库服务端进行压缩,以提高数据传输效率。
S205,若所述压缩权值大于预设值,则所述客户端中对所述业务数据执行数据压缩,生成对于所述业务数据的压缩数据,并发送压缩数据至数据库服务端;
具体的压缩方式包括常规的可逆的无损压缩,在这种压缩方式下可以根据压缩数据完全恢复原始的业务数据。例如,将报表压缩为诸如RAR、ZIP等格式的压缩包。
在本说明书实施例中,还可以进行另一种压缩方式,即确定业务数据的哈希值,将业务数据的哈希值确定为压缩数据,进而将所述哈希值确定为待存储数据。在这种方式下,“压缩数据”无法还原得到对应的业务数据,但是由于哈希值的唯一性,同样可以验证账本中的待存储数据的完整性。
S207,否则,客户端将所述业务数据发送至数据库服务端,以便所述数据库服务端执行数据压缩,生成对于所述业务数据的压缩数据。
具体而言,客户端可以直接将业务数据发送至数据库服务端;或者,在压缩权值不大于预设值时(即此时需要由数据库服务端进行压缩),则此时还可以添加相应的压缩标识,压缩标识用于表征该业务数据需要进行压缩。
在实际应用中,客户端还可以对业务数据进行进一步的区分,例如,某些业务数据较小,不需要压缩,而某些业务数据较大,需要进行压缩。
在一种实施方式中,可以仅对部分业务数据中增加压缩标识,然后在数据库服务端 增加解析业务请求并识别该标识位的功能。例如,对占用空间超过一定大小的业务数据添加压缩标识,而对于较小的业务数据不添加压缩标识。
当然,也可以在所有的业务数据中统一增加标识位,通过赋予不同标识位取值的方式来实现对区分,本申请对此并不需要进行限定。
前述部分对于本说明书实施例中的客户端进行了相应说明,在另一方面,本说明书实施例还提供一种块链式账本中的数据存储方法,应用于数据库服务端中,如图3所示,图3为本说明书实施例所提供的另一种块链式账本中数据存储方法的流程示意图,所述方法包括:
S301,接收客户端所发送的压缩数据,其中,所述压缩数据由客户端对业务数据执行压缩得到;或者,接收客户端所发送的业务数据,对所述业务数据执行压缩,得到压缩数据。
如前所述,在本说明书实施例中,需要对于业务数据进行压缩再存储。具体而言,在一种实施方式中,数据库服务端可以根据客户端所发送的业务数据中是否包含有压缩标识进行相应的后续流程。若有,则在数据库服务端进行压缩,没有,则表明客户端已经进行了压缩,接收到的即为压缩数据。
在一种实施方式中,由于用户的硬件条件和网络条件一般比较稳定,因此,还可以保存用户的硬件条件和网络条件,在用户的硬件条件和网络条件没有变化时,采取与上一次相同的压缩方式。即,若前一次由数据库服务端执行压缩,则本次也继续在数据库服务端进行压缩;若前一次没有在数据库服务端进行压缩,则本次也不进行压缩。
S303,将所述压缩数据确认为待存储的数据记录,确定各数据记录的哈希值。
具体而言,数据库服务端可以获取待存储的数据记录(即前述的待存储数据),确定各待存储的数据记录的哈希值,并且将待存储的数据记录的哈希值返回至客户端,以便客户端随时查询。
需要说明的是,如果在压缩时,将业务数据的哈希值确定为压缩数据,则可以直接将业务数据的哈希值确定为待存储的数据记录的哈希值;若压缩时执行的是无损压缩,则是将得到的压缩包的哈希值确定为待存储的数据记录的哈希值。
S305,当达到预设的成块条件时,确定待写入数据块中的各数据记录,生成包含数据块的哈希值和数据记录的第N个数据块。
所述预设的成块条件包括:待存储的数据记录数量达到数量阈值,例如,每接收到一千条数据记录时,生成一个新数据块,将一千条数据记录写入块中;或者,距离上一次成块时刻的时间间隔达到时间阈值,例如,每隔5分钟,生成一个新数据块,将在这5分钟内接收到的数据记录写入块中。
此处的N指的是数据块的序号,换言之,在本说明书实施例中,数据块是以块链的形式,基于成块时间的顺序先后排列,具有很强的时序特征。其中,数据块的块高基于成块时间的先后顺序单调递增。块高可以是序号,此时第N个数据块的块高即为N;块高也可以其它方式生成。
当N=1时,即此时的数据块为为初始数据块。初始数据块的哈希值和块高基于预设方式给定。例如,初始数据块中不包含数据记录,哈希值则为任一给定的哈希值,块高blknum=0;又例如,初始数据块的生成触发条件与其它数据块的触发条件一致,但是初始数据块的哈希值由对初始数据块中的所有内容取哈希确定。
当N>1时,由于前一数据块的内容和哈希值已经确定,则此时,可以基于前一数据块(即第N-1个数据块)的哈希值生成当前数据块(第N个数据块)的哈希值,例如,一种可行的方式为,确定每一条将要写入第N个块中的数据记录的哈希值,按照在块中的排列顺序,生成一个默克尔树,将默克尔树的根哈希值和前一数据块的哈希值拼接在一起,再次采用哈希算法,生成当前块的哈希值。又例如,还可以按照块中数据记录的顺序进行拼接并取哈希得到整体数据记录的哈希值,拼接前一数据块的哈希值和整体数据记录的哈希值,并对拼接得到的字串进行哈希运算,生成数据块的哈希值。
需要说明的是,在这个过程中,基于不同的压缩方式,如果待存储的数据是业务数据的压缩数据,则计算默克尔树的根哈希值时需要计算每个压缩数据的哈希值;如果待存储的数据是业务数据的哈希值,则计算摩尔克数的根哈希值时需要计算每个业务数据的哈希值的哈希值。
用户在上传数据成功后,即可以得到对应的数据记录的哈希值以及所处的数据块的哈希值,并保存,并且可以基于该哈希值发起完整性验证。具体的验证方式包括重新计算数据记录自身的哈希值以及所处的数据块的哈希值,与本地所保存的进行对比。
上述方式生成的数据块,可以包括块头和块体两个部分。块体中可以用于存储拼接数据的明文,或者拼接数据的哈希值等等;块头中可以用于存储有关本数据块的元数据,例如,账本的版本号,前一数据块的哈希值,自身数据块中的拼接数据所组成的默克尔 树的根哈希值,自身数据块的哈希值,用于记录拼接数据的***作状态的状态数组等等。
通过本说明书实施例所提供的方案,客户端在接收到用户所发送的业务数据时,即通过获取客户端的硬件设备和网络环境参数进行动态评估,以确定对于业务数据进行压缩时是由客户端进行还是由数据库服务端进行,在压缩完成后,数据库服务端将压缩数据写入块链式的账本,从而可以节省账本的占用空间,提高账本的写入效率。
在一种实施方式中,数据库服务端在对业务数据进行了压缩之后,还需要将业务数据进行本地存储,并且记录业务数据和业务数据的压缩数据的对应关系,具体而言,可以记录压缩数据的名称和业务数据的名称、存储位置之间的对应关系。若压缩数据为业务数据的哈希值,此时,还可以记录业务数据的存储位置和所述业务数据的哈希值之间的对应关系,以便查询。
在一种实施方式中,客户端还可以基于自身错保存的哈希值发起查询,发送包含哈希值的查询请求至数据库服务端。所述哈希值即可以是压缩包的哈希值,或者,也可以是业务数据的哈希值。
数据库服务端接收到查询请求,即可以基于哈希值查询得到相应的压缩数据:在压缩数据为压缩包时,可以从账本中获取得到哈希值所对应的压缩包,并且返回压缩包至客户端;在哈希值为业务数据的哈希值时,可以基于业务数据的存储位置和所述业务数据的哈希值之间的对应关系查询得到业务数据,并且,并且返回业务数据和业务数据的哈希值至客户端,以便客户端使用业务数据或者验证业务数据的完整性。
与一方面对应的,本说明书实施例还提供一种块链式账本中的数据存储装置,应用于客户端中,如图4所示,图4是本说明书实施例提供的一种块链式账本中的数据存储装置的结构示意图,包括:
获取模块,获取用户的业务数据,确定所述用户的压缩临界值,其中,所述压缩临界值用于判断执行数据压缩的目标对象,所述执行数据压缩的目标对象包括客户端或者数据库服务端;
确定模块401,获取客户端所处设备的硬件参数和/或网络环境参数,根据所述硬件参数和/或网络环境参数确定出压缩权值,其中,所述压缩权值与硬件参数正相关,与网络环境参数负相关;
压缩模块403,若所述压缩权值大于预设值,则所述客户端中对所述业务数据执行数据压缩,生成对于所述业务数据的压缩数据;
发送模块405,发送压缩数据至数据库服务端;所述发送模块还用于,若所述压缩权值不大于预设值,将所述业务数据发送至数据库服务端,以便所述数据库服务端执行数据压缩,生成对于所述业务数据的压缩数据。
进一步地,所述压缩模块403,对所述业务数据执行无损压缩,生成可恢复业务数据的压缩包;或者,确定所述业务数据的哈希值,将所述业务数据的哈希值确定为压缩数据。
进一步地,所述发送模块405,将所述业务数据和压缩标识发送至数据库服务端,所述压缩标识表征该业务数据需要由数据库服务端执行数据压缩。
进一步地,所述发送模块405还用于,发送包含哈希值的查询请求至数据库服务端,以便所述数据库服务端根据所述哈希值查询得到对应的压缩数据;所述装置还包括接收模块407,接收数据库服务端所返回的压缩数据,解压所述压缩数据得到对应的业务数据。
与另一方面对应的,本说明书实施例还提供一种块链式账本中的数据存储装置,应用于数据库服务端中,如图5所示,图5是本说明书实施例提供的另一种块链式账本中的数据存储装置的结构示意图,包括:
接收模块501,接收客户端所发送的压缩数据,其中,所述压缩数据由客户端对业务数据执行压缩得到;或者,接收客户端所发送的业务数据;
压缩模块503,对所述业务数据执行压缩,得到压缩数据;
确定模块505,将所述压缩数据确认为待存储的数据记录,确定各数据记录的哈希值;
数据块生成模块507,当达到预设的成块条件时,确定待写入数据块中的各数据记录,生成包含数据块的哈希值和数据记录的第N个数据块,具体包括:
当N=1时,初始数据块的哈希值和块高基于预设方式给定;当N>1时,根据待写入数据块中的各数据记录和第N-1个数据块的哈希值确定第N个数据块的哈希值,生成包含第N个数据块的哈希值和各数据记录的第N个数据块。
进一步地,所述预设的成块条件包括:待存储的数据记录数量达到数量阈值;或者,距离上一次成块时刻的时间间隔达到时间阈值。
进一步地,所述装置还包括查询模块509,接收客户端所发送的包含哈希值的查询 请求;查询获取所述哈希值所对应的压缩数据;发送所述压缩数据至客户端,以便客户端解压所述压缩数据。
进一步地,所述接收模块501还用于,接收客户端所发送的业务数据;检测所述业务数据是否包含有压缩标识,所述压缩标识表征该业务数据需要在数据库服务端进行数据压缩;若包含,对所述业务数据执行压缩,生成压缩数据。
本说明书实施例还提供一种计算机设备,其至少包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,其中,处理器执行所述程序时实现图2所示的块链式账本中的数据存储方法。
本说明书实施例还提供一种计算机设备,其至少包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,其中,处理器执行所述程序时实现图3所示的块链式账本中的数据存储方法。
图6示出了本说明书实施例所提供的一种更为具体的计算设备硬件结构示意图,该设备可以包括:处理器1010、存储器1020、输入/输出接口1030、通信接口1040和总线1050。其中处理器1010、存储器1020、输入/输出接口1030和通信接口1040通过总线1050实现彼此之间在设备内部的通信连接。
处理器1010可以采用通用的CPU(Central Processing Unit,中央处理器)、微处理器、应用专用集成电路(Application Specific Integrated Circuit,ASIC)、或者一个或多个集成电路等方式实现,用于执行相关程序,以实现本说明书实施例所提供的技术方案。
存储器1020可以采用ROM(Read Only Memory,只读存储器)、RAM(Random Access Memory,随机存取存储器)、静态存储设备,动态存储设备等形式实现。存储器1020可以存储操作***和其他应用程序,在通过软件或者固件来实现本说明书实施例所提供的技术方案时,相关的程序代码保存在存储器1020中,并由处理器1010来调用执行。
输入/输出接口1030用于连接输入/输出模块,以实现信息输入及输出。输入输出/模块可以作为组件配置在设备中(图中未示出),也可以外接于设备以提供相应功能。其中输入设备可以包括键盘、鼠标、触摸屏、麦克风、各类传感器等,输出设备可以包括显示器、扬声器、振动器、指示灯等。
通信接口1040用于连接通信模块(图中未示出),以实现本设备与其他设备的通信交互。其中通信模块可以通过有线方式(例如USB、网线等)实现通信,也可以通过无线方式(例如移动网络、WIFI、蓝牙等)实现通信。
总线1050包括一通路,在设备的各个组件(例如处理器1010、存储器1020、输入/输出接口1030和通信接口1040)之间传输信息。
需要说明的是,尽管上述设备仅示出了处理器1010、存储器1020、输入/输出接口1030、通信接口1040以及总线1050,但是在具体实施过程中,该设备还可以包括实现正常运行所必需的其他组件。此外,本领域的技术人员可以理解的是,上述设备中也可以仅包含实现本说明书实施例方案所必需的组件,而不必包含图中所示的全部组件。
本说明书实施例还提供一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现图2所示的块链式账本中的数据存储方法。
本说明书实施例还提供一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现图3所示的块链式账本中的数据存储方法。
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。
通过以上的实施方式的描述可知,本领域的技术人员可以清楚地了解到本说明书实施例可借助软件加必需的通用硬件平台的方式来实现。基于这样的理解,本说明书实施例的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在存储介质中,如ROM/RAM、磁碟、光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本说明书实施例各个实施例或者实施例的某些部分所述的方法。
上述实施例阐明的***、方法、模块或单元,具体可以由计算机芯片或实体实现,或者由具有某种功能的产品来实现。一种典型的实现设备为计算机,计算机的具体形式可以是个人计算机、膝上型计算机、蜂窝电话、相机电话、智能电话、个人数字助理、媒体播放器、导航设备、电子邮件收发设备、游戏控制台、平板计算机、可穿戴设 备或者这些设备中的任意几种设备的组合。
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于方法实施例而言,由于其基本相似于方法实施例,所以描述得比较简单,相关之处参见方法实施例的部分说明即可。以上所描述的方法实施例仅仅是示意性的,其中所述作为分离部件说明的模块可以是或者也可以不是物理上分开的,在实施本说明书实施例方案时可以把各模块的功能在同一个或多个软件和/或硬件中实现。也可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性劳动的情况下,即可以理解并实施。
以上所述仅是本说明书实施例的具体实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本说明书实施例原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也应视为本说明书实施例的保护范围。

Claims (18)

  1. 一种块链式账本中的数据存储方法,应用于客户端中,所述方法包括:
    获取用户的业务数据,以及,确定所述用户的压缩临界值,其中,所述压缩临界值用于判断执行数据压缩的目标对象,所述执行数据压缩的目标对象包括客户端或者数据库服务端;
    获取客户端所处设备的硬件参数和/或网络环境参数,根据所述硬件参数和/或网络环境参数确定出压缩权值,其中,所述压缩权值与硬件参数正相关,与网络环境参数负相关;
    若所述压缩权值大于预设值,则所述客户端中对所述业务数据执行数据压缩,生成对于所述业务数据的压缩数据,并发送压缩数据至数据库服务端;
    否则,客户端将所述业务数据发送至数据库服务端,以便所述数据库服务端执行数据压缩,生成对于所述业务数据的压缩数据。
  2. 如权利要求1所述的方法,所述客户端中对所述业务数据执行数据压缩,生成对于所述业务数据的压缩数据,包括:
    对所述业务数据执行无损压缩,生成可恢复业务数据的压缩包;或者,
    确定所述业务数据的哈希值,将所述业务数据的哈希值确定为压缩数据。
  3. 如权利要求1所述的方法,将所述业务数据发送至数据库服务端,包括:
    将所述业务数据和压缩标识发送至数据库服务端,所述压缩标识表征该业务数据需要由数据库服务端执行数据压缩。
  4. 如权利要求1所述的方法,还包括:
    发送包含哈希值的查询请求至数据库服务端,以便所述数据库服务端根据所述哈希值查询得到对应的压缩数据;
    接收数据库服务端所返回的压缩数据,解压所述压缩数据得到对应的业务数据。
  5. 一种块链式账本中的数据存储方法,应用于数据库服务端中,所述方法包括:
    接收客户端所发送的压缩数据,其中,所述压缩数据由客户端对业务数据执行压缩得到;或者,接收客户端所发送的业务数据,对所述业务数据执行压缩,得到压缩数据;
    将所述压缩数据确认为待存储的数据记录,确定各数据记录的哈希值;
    当达到预设的成块条件时,确定待写入数据块中的各数据记录,生成包含数据块的哈希值和数据记录的第N个数据块,具体包括:
    当N=1时,初始数据块的哈希值和块高基于预设方式给定;
    当N>1时,根据待写入数据块中的各数据记录和第N-1个数据块的哈希值确定第 N个数据块的哈希值,生成包含第N个数据块的哈希值和各数据记录的第N个数据块。
  6. 如权利要求5所述的方法,所述预设的成块条件包括:
    待存储的数据记录数量达到数量阈值;或者,
    距离上一次成块时刻的时间间隔达到时间阈值。
  7. 如权利要求5所述的方法,所述方法还包括:
    接收客户端所发送的包含哈希值的查询请求;
    查询获取所述哈希值所对应的压缩数据;
    发送所述压缩数据至客户端,以便客户端解压所述压缩数据。
  8. 如权利要求5所述的方法,接收客户端所发送的业务数据,包括:
    接收客户端所发送的业务数据;
    检测所述业务数据是否包含有压缩标识,所述压缩标识表征该业务数据需要在数据库服务端进行数据压缩;
    若包含,对所述业务数据执行压缩,生成压缩数据。
  9. 一种块链式账本中的数据存储装置,应用于客户端中,所述装置包括:
    获取模块,获取用户的业务数据,确定所述用户的压缩临界值,其中,所述压缩临界值用于判断执行数据压缩的目标对象,所述执行数据压缩的目标对象包括客户端或者数据库服务端;
    确定模块,获取客户端所处设备的硬件参数和/或网络环境参数,根据所述硬件参数和/或网络环境参数确定出压缩权值,其中,所述压缩权值与硬件参数正相关,与网络环境参数负相关;
    压缩模块,若所述压缩权值大于预设值,则所述客户端中对所述业务数据执行数据压缩,生成对于所述业务数据的压缩数据;
    发送模块,发送压缩数据至数据库服务端;所述发送模块还用于,若所述压缩权值不大于预设值,将所述业务数据发送至数据库服务端,以便所述数据库服务端执行数据压缩,生成对于所述业务数据的压缩数据。
  10. 如权利要求9所述的装置,所述压缩模块,对所述业务数据执行无损压缩,生成可恢复业务数据的压缩包;或者,确定所述业务数据的哈希值,将所述业务数据的哈希值确定为压缩数据。
  11. 如权利要求9所述的装置,所述发送模块,将所述业务数据和压缩标识发送至数据库服务端,所述压缩标识表征该业务数据需要由数据库服务端执行数据压缩。
  12. 如权利要求9所述的装置,所述发送模块还用于,发送包含哈希值的查询请求 至数据库服务端,以便所述数据库服务端根据所述哈希值查询得到对应的压缩数据;所述装置还包括接收模块,接收数据库服务端所返回的压缩数据,解压所述压缩数据得到对应的业务数据。
  13. 一种块链式账本中的数据存储装置,应用于数据库服务端中,所述装置包括:
    接收模块,接收客户端所发送的压缩数据,其中,所述压缩数据由客户端对业务数据执行压缩得到;或者,接收客户端所发送的业务数据;
    压缩模块,对所述业务数据执行压缩,得到压缩数据;
    确定模块,将所述压缩数据确认为待存储的数据记录,确定各数据记录的哈希值;
    数据块生成模块,当达到预设的成块条件时,确定待写入数据块中的各数据记录,生成包含数据块的哈希值和数据记录的第N个数据块,具体包括:
    当N=1时,初始数据块的哈希值和块高基于预设方式给定;
    当N>1时,根据待写入数据块中的各数据记录和第N-1个数据块的哈希值确定第N个数据块的哈希值,生成包含第N个数据块的哈希值和各数据记录的第N个数据块。
  14. 如权利要求13所述的装置,所述预设的成块条件包括:
    待存储的数据记录数量达到数量阈值;或者,距离上一次成块时刻的时间间隔达到时间阈值。
  15. 如权利要求13所述的装置,所述装置还包括查询模块,接收客户端所发送的包含哈希值的查询请求;查询获取所述哈希值所对应的压缩数据;发送所述压缩数据至客户端,以便客户端解压所述压缩数据。
  16. 如权利要求13所述的装置,所述接收模块还用于,接收客户端所发送的业务数据;检测所述业务数据是否包含有压缩标识,所述压缩标识表征该业务数据需要在数据库服务端进行数据压缩;若包含,对所述业务数据执行压缩,生成压缩数据。
  17. 一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,其中,所述处理器执行所述程序时实现如权利要求1至4任一项所述的方法。
  18. 一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,其中,所述处理器执行所述程序时实现如权利要求5至8任一项所述的方法。
PCT/CN2020/071339 2019-08-14 2020-01-10 块链式账本中的数据存储方法、装置及设备 WO2021027252A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US16/812,036 US11249987B2 (en) 2019-08-14 2020-03-06 Data storage in blockchain-type ledger

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910747305.1 2019-08-14
CN201910747305.1A CN110597461B (zh) 2019-08-14 2019-08-14 块链式账本中的数据存储方法、装置及设备

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US16/812,036 Continuation US11249987B2 (en) 2019-08-14 2020-03-06 Data storage in blockchain-type ledger

Publications (1)

Publication Number Publication Date
WO2021027252A1 true WO2021027252A1 (zh) 2021-02-18

Family

ID=68854078

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/071339 WO2021027252A1 (zh) 2019-08-14 2020-01-10 块链式账本中的数据存储方法、装置及设备

Country Status (2)

Country Link
CN (1) CN110597461B (zh)
WO (1) WO2021027252A1 (zh)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11249987B2 (en) 2019-08-14 2022-02-15 Advanced New Technologies Co., Ltd. Data storage in blockchain-type ledger
CN110597461B (zh) * 2019-08-14 2020-08-18 阿里巴巴集团控股有限公司 块链式账本中的数据存储方法、装置及设备
CN114125071B (zh) * 2021-11-23 2024-02-09 北京人大金仓信息技术股份有限公司 数据压缩传输方法及装置

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8156241B1 (en) * 2007-05-17 2012-04-10 Netapp, Inc. System and method for compressing data transferred over a network for storage purposes
CN109614043A (zh) * 2018-12-04 2019-04-12 郑州云海信息技术有限公司 一种数据压缩方法、装置、***及计算机可读存储介质
CN110022315A (zh) * 2019-03-26 2019-07-16 阿里巴巴集团控股有限公司 一种块链式账本中的权重管理方法、装置及设备
CN110597461A (zh) * 2019-08-14 2019-12-20 阿里巴巴集团控股有限公司 块链式账本中的数据存储方法、装置及设备
CN110597462A (zh) * 2019-08-14 2019-12-20 阿里巴巴集团控股有限公司 块链式账本中的数据存储方法、***、装置及设备

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106484852B (zh) * 2016-09-30 2019-10-18 华为技术有限公司 数据压缩方法、设备与计算设备
CN107728941B (zh) * 2017-09-28 2019-09-24 中国银行股份有限公司 一种区块链数据压缩方法及***

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8156241B1 (en) * 2007-05-17 2012-04-10 Netapp, Inc. System and method for compressing data transferred over a network for storage purposes
CN109614043A (zh) * 2018-12-04 2019-04-12 郑州云海信息技术有限公司 一种数据压缩方法、装置、***及计算机可读存储介质
CN110022315A (zh) * 2019-03-26 2019-07-16 阿里巴巴集团控股有限公司 一种块链式账本中的权重管理方法、装置及设备
CN110597461A (zh) * 2019-08-14 2019-12-20 阿里巴巴集团控股有限公司 块链式账本中的数据存储方法、装置及设备
CN110597462A (zh) * 2019-08-14 2019-12-20 阿里巴巴集团控股有限公司 块链式账本中的数据存储方法、***、装置及设备

Also Published As

Publication number Publication date
CN110597461B (zh) 2020-08-18
CN110597461A (zh) 2019-12-20

Similar Documents

Publication Publication Date Title
CN110188096B (zh) 一种数据记录的索引创建方法、装置及设备
WO2021027252A1 (zh) 块链式账本中的数据存储方法、装置及设备
US11249987B2 (en) Data storage in blockchain-type ledger
US11379836B2 (en) Methods and systems for recording data based on plurality of blockchain networks
US20130067237A1 (en) Providing random access to archives with block maps
WO2021147935A1 (zh) 一种日志回放方法及装置
US11275814B2 (en) Recording ledger data on a blockchain
CN110347679B (zh) 一种基于收据的数据存储方法、装置及设备
US10958744B2 (en) Identifying and managing redundant digital content transfers
US20210157801A1 (en) Methods and systems for recording data based on plurality of blockchain networks
US11126751B2 (en) Index creation for data records
US10958440B2 (en) Blockchain ledger compression
CN110837502A (zh) 一种块链式账本中的数据存储方法、装置及设备
CN110362568B (zh) 一种针对块链式账本的压缩方法、装置及设备
US11223692B2 (en) Service execution methods and apparatuses
CN110597462A (zh) 块链式账本中的数据存储方法、***、装置及设备
CN110740138A (zh) 数据传输方法和装置
US11343272B2 (en) Proof of work based on compressed video
CN110636042B (zh) 一种服务端已验证块高的更新方法、装置及设备
US11086849B2 (en) Methods and systems for reading data based on plurality of blockchain networks
US20200177390A1 (en) Providing data verification in a blockchain ledger
CN111444194B (zh) 一种块链式账本中索引的清除方法、装置及设备
US20190258728A1 (en) Footers for compressed objects
US11977525B2 (en) Method to optimize ingest in dedupe systems by using compressibility hints
CN112307010B (zh) 一种数据存储方法、装置及设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20852839

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20852839

Country of ref document: EP

Kind code of ref document: A1