WO2022121345A1 - Distributed data storage method, data query method, device, and storage medium - Google Patents

Distributed data storage method, data query method, device, and storage medium Download PDF

Info

Publication number
WO2022121345A1
WO2022121345A1 PCT/CN2021/111851 CN2021111851W WO2022121345A1 WO 2022121345 A1 WO2022121345 A1 WO 2022121345A1 CN 2021111851 W CN2021111851 W CN 2021111851W WO 2022121345 A1 WO2022121345 A1 WO 2022121345A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
block
height
blockchain
index table
Prior art date
Application number
PCT/CN2021/111851
Other languages
French (fr)
Chinese (zh)
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 杭州复杂美科技有限公司
Publication of WO2022121345A1 publication Critical patent/WO2022121345A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/901Indexing; Data structures therefor; Storage structures
    • G06F16/9024Graphs; Linked lists
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/901Indexing; Data structures therefor; Storage structures
    • G06F16/9014Indexing; Data structures therefor; Storage structures hash tables
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the present application relates to the field of blockchain technology, and in particular to a distributed data storage method, data query method, device and storage medium.
  • the state data storage of the blockchain can also be stored in a global index table to improve query efficiency.
  • each blockchain node stores a global index table, but most of the data in the global index table is historical status data, not the latest status data. Saving historical status data is only for the convenience of query, wasteful A lot of disk space.
  • the present invention provides a distributed data storage method suitable for blockchain nodes.
  • the storage method of state data includes storing in the form of a global index table.
  • Each blockchain node stores an mvcc index table, and the mvcc index table includes: A number of first key-value pairs, the first key of the first key-value pair includes the first address of the first user, and the first value of the first key-value pair includes the first block height of the first address where the state changes.
  • a height set, the above method includes:
  • the first archive information is used for blockchain nodes:
  • the first query instruction includes the second address of the second user and the queried second block interval height;
  • the present invention provides a data query method applicable to a blockchain node.
  • the blockchain node stores data in a distributed manner according to the method of the first aspect, and the method includes:
  • the first query instruction includes the second address of the second user and the queried second block interval height;
  • S251 Generate second data according to the block hash of the continuous block corresponding to the second archive data where the third block height is located;
  • S252 Find several second blockchain nodes storing the second archive data according to the second data and the distributed data storage rules
  • S253 Send the first query instruction to at least one second blockchain node requesting the second archive data to search for corresponding target data.
  • the present invention also provides an apparatus comprising one or more processors and a memory, wherein the memory contains instructions executable by the one or more processors to cause the one or more processors to perform various functions according to the present invention.
  • the distributed data storage method and the data query method provided by the embodiments.
  • the present invention further provides a storage medium storing a computer program, and the computer program enables a computer to execute the distributed data storage method and data query method provided according to various embodiments of the present invention.
  • the distributed data storage method, data query method, device and storage medium provided by various embodiments of the present invention generate first data according to the block hash of the first number of consecutive blocks to be stored;
  • the first global index table corresponding to the block generates the first archived data; according to the first data and the preconfigured distributed data storage rules, several first blockchain nodes that will receive the first archived data are determined; the first archived data is sent to Each first block chain node is used to store the first archive data; when the current node is not included in the first block chain node, the method of deleting the stored first global index table after a first time period improves query efficiency.
  • FIG. 1 is a flowchart of a distributed data storage method according to an embodiment of the present invention.
  • FIG. 2 is a flowchart of a data query method according to an embodiment of the present invention.
  • FIG. 3 is a schematic structural diagram of a device according to an embodiment of the present invention.
  • FIG. 1 is a flowchart of a distributed data storage method according to an embodiment of the present invention.
  • the present invention provides a distributed data storage method suitable for blockchain nodes.
  • the storage method of state data includes storing in the form of a global index table, and each blockchain node stores a mvcc index table, the mvcc index table includes several first key-value pairs, the first key of the first key-value pair includes the first address of the first user, and the first value of the first key-value pair includes the state of the first address changes.
  • the first height set of each first block height, and the above method includes:
  • S11 Generate first data according to the block hashes of the first number of consecutive blocks to be stored
  • S15 Determine a number of first blockchain nodes that will receive the first archived data according to the first data and the preconfigured distributed data storage rules;
  • S17 Send the first archive data to each first blockchain node for storing the first archive data
  • the first archive information is used for blockchain nodes:
  • the first query instruction includes the second address of the second user and the queried second block interval height;
  • S15 includes "calculating the first distance between the node id of each blockchain node and the first data; determining the second number of blockchain nodes with the smallest first distance as the first blockchain node", the corresponding , according to the second data and distributed data storage rules to find several second blockchain nodes that store the second archived data, including "calculating the second distance between the node id of each blockchain node and the second data; the second distance is the smallest
  • the second number of blockchain nodes is determined as the second blockchain node”, the first number is 100, the second number is 5, and the first duration is 2min as an example; assuming that according to the first number of consecutive areas to be stored
  • the block is block(1) ⁇ block(100);
  • the blockchain node executes step S11, and generates data chunkhash (1-100) according to blockhash (1)-blockhash (100);
  • the blockchain node executes step S13, and generates archive data chunk (1-100) according to the global index table T (1-100) corresponding to block (1)-block (100);
  • the blockchain node executes step S15 to calculate the distance between the node id of each blockchain node and the chunkhash (1-100); the 5 blockchain nodes with the smallest distance are determined as the blockchain that will receive the chunk (1-100). Node; assume that the blockchain nodes that will receive chunks (1-100) are N1-N5;
  • the blockchain node executes step S17, and sends the chunk (1-100) to N1-N5, and N1-N5 stores the chunk (1-100);
  • the blockchain node executes step S19, when the current node is not included in N1-N5, deletes the stored T(1-100) after 2 minutes.
  • the blockchain node N50 receives the query command "addr(A), [50,70]"; the height set that addr(A) searches in the mvcc index table is ⁇ 65, 105, 185 ⁇ ; N1 ⁇ N5 store chunks (1 ⁇ 100) , N6 ⁇ N10 store chunks (101 ⁇ 200), N11 ⁇ N15 store chunks (201 ⁇ 300), N16 ⁇ N20 store chunks (301 ⁇ 400), N21 ⁇ N25 store chunks (401 ⁇ 500), other status data has not been distributed data storage;
  • N50 searches for the corresponding height set in the mvcc index table according to [50,70] and addr(A), and the found corresponding set is ⁇ 65 ⁇ ;
  • N50 generates data chunk (1-100) according to the block hash (ie blockhash(1)-blockhash(100)) of the continuous block corresponding to the archived data where 65 is located;
  • N50 calculates the distance between the node id of each blockchain node and the chunk (1-100); the 5 blockchain nodes N1-N5 with the smallest distance are determined as the blockchain nodes that store the chunk (1-100);
  • N50 sends addr(A),[50,70] to one or more nodes in N1 ⁇ N5 (assuming that it is only sent to N1);
  • N1 traverses [50,70] to find the target data according to addr(A):
  • N1 finds the data corresponding to addr(A) at 65 in chunk(1 ⁇ 100);
  • N1 returns the data corresponding to addr(A) at 65 to N50.
  • S15 can also be configured according to actual needs, for example, configured to calculate the first distance between the node id of each blockchain node and the first data;
  • the node is determined to be the first blockchain node, and accordingly, according to the second data and distributed data storage rules to find several second blockchain nodes that store the second archived data, they should also be configured as "calculate the nodes of each blockchain node".
  • the second distance between the id and the second data; determining the second number of blockchain nodes with the largest second distance as the second blockchain node” can achieve the same technical effect.
  • the first number can also be configured according to actual requirements, for example, it is configured as 1000, which can achieve the same technical effect.
  • the second number can also be configured according to actual needs, for example, it is configured as 10, which can achieve the same technical effect.
  • the first duration may also be configured according to actual requirements, for example, configured to be 1 min, which can achieve the same technical effect.
  • This embodiment makes it more convenient to obtain historical state data of a specified account in a certain height interval.
  • the historical status data of the specified account only needs to be obtained from one node, and the data of one month, one quarter, one year or more can be queried, which improves the efficiency of data query.
  • determining a number of first blockchain nodes that will receive the first archived data includes:
  • Finding several second blockchain nodes storing the second archived data according to the second data and distributed data storage rules includes:
  • the second number of blockchain nodes with the smallest second distance is determined as the second blockchain node.
  • the fourth block height of the first block with the largest block height among the first number of consecutive blocks is smaller than the difference between the current block height and the safe rollback depth.
  • the above-mentioned embodiment ensures that the fragmented data will not be rolled back, which improves user experience.
  • deleting the stored first global index table after the first duration includes:
  • FIG. 2 is a flowchart of a data query method according to an embodiment of the present invention.
  • the present invention provides a data query method suitable for blockchain nodes.
  • the blockchain nodes perform distributed storage of data according to the above distributed data storage method, and the above method includes:
  • S21 Receive a first query instruction; wherein, the first query instruction includes the second address of the second user and the queried second block interval height;
  • S251 Generate second data according to the block hash of the continuous block corresponding to the second archive data where the third block height is located;
  • S252 according to the second data and distributed data storage rules, find several second block chain nodes that store the second archive data;
  • S253 Send the first query instruction to at least one second blockchain node requesting the second archive data to search for corresponding target data.
  • the above embodiment makes it more convenient to obtain the historical status data of a specified account in a certain height interval, and can query data of one month, one quarter, one year or more, which improves the efficiency of data query.
  • FIG. 3 is a schematic structural diagram of a device according to an embodiment of the present invention.
  • the present application also provides a device including one or more central processing units (CPUs) 301 , which can be stored in a read-only memory (ROM) 302 according to a program or from The storage section 308 loads programs into the random access memory (RAM) 303 to execute various appropriate actions and processes.
  • RAM random access memory
  • various programs and data necessary for the operation of the device 300 are also stored.
  • the CPU 301 , the ROM 302 , and the RAM 303 are connected to each other through a bus 304 .
  • An input/output (I/O) interface 305 is also connected to bus 304 .
  • the following components are connected to the I/O interface 305: an input section 306 including a keyboard, a mouse, etc.; an output section 307 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 308 including a hard disk, etc. ; and a communication section 309 including a network interface card such as a LAN card, a modem, and the like. The communication section 309 performs communication processing via a network such as the Internet.
  • a drive 310 is also connected to the I/O interface 305 as needed.
  • a removable medium 311, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is mounted on the drive 310 as needed so that a computer program read therefrom is installed into the storage section 308 as needed.
  • the method described in any of the above embodiments may be implemented as a computer software program.
  • embodiments of the present disclosure include a computer program product comprising a computer program tangibly embodied on a machine-readable medium, the computer program containing program code for performing any of the methods described above.
  • the computer program may be downloaded and installed from the network via the communication portion 309 and/or installed from the removable medium 311 .
  • the present application also provides a computer-readable storage medium.
  • the computer-readable storage medium may be a computer-readable storage medium included in the apparatus of the foregoing embodiment; A computer-readable storage medium in a device.
  • the computer-readable storage medium stores one or more programs that are used by one or more processors to perform the methods described in the present application.
  • each block in the flowchart or block diagrams may represent a module, segment, or portion of code that contains one or more logical functions for implementing the specified functions executable instructions.
  • the functions noted in the blocks may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved.
  • each block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations can be implemented by dedicated hardware-based systems that perform the specified functions or operations , or can be implemented by a combination of dedicated hardware and computer instructions.
  • the units or modules involved in the embodiments of the present application may be implemented in a software manner, and may also be implemented in a hardware manner.
  • the described units or modules may also be provided in the processor, for example, each of the units may be a software program provided in a computer or a mobile smart device, or may be a separately configured hardware device. Wherein, the names of these units or modules do not constitute limitations on the units or modules themselves under certain circumstances.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Finance (AREA)
  • Software Systems (AREA)
  • Accounting & Taxation (AREA)
  • Computational Linguistics (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Strategic Management (AREA)
  • Technology Law (AREA)
  • General Business, Economics & Management (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

A distributed data storage method, which relates to the technical field of blockchains. The method comprises: S11, generating first data according to a block hash of a first number of consecutive blocks to be stored; S13, generating first archival data according to a first global index table corresponding to the first number of consecutive blocks; S15, according to the first data and a preset distributed data storage rule, determining a plurality of first blockchain nodes that are to receive the first archival data; S17, sending the first archival data to the first blockchain nodes for storing the first archival data; and S19, when a current node is not comprised in the first blockchain nodes, deleting the stored first global index table after a first period of time.

Description

分布式数据存储方法、数据查询方法、设备和存储介质Distributed data storage method, data query method, device and storage medium 技术领域technical field
本申请涉及区块链技术领域,具体涉及一种分布式数据存储方法、数据查询方法、设备和存储介质。The present application relates to the field of blockchain technology, and in particular to a distributed data storage method, data query method, device and storage medium.
背景技术Background technique
在申请人所提出的专利文本(具体可参考申请人的专利文本2018108842951和2018108840354)中,区块链的状态数据存储还可以用全局索引表进行存储以提高查询效率。In the patent text proposed by the applicant (for details, please refer to the patent texts 2018108842951 and 2018108840354 of the applicant), the state data storage of the blockchain can also be stored in a global index table to improve query efficiency.
在上述机制中,每个区块链节点都存储有全局索引表,但全局索引表中的大多数数据为历史状态数据,而非最新的状态数据,保存历史状态数据仅仅是为了便于查询,浪费了大量磁盘空间。In the above mechanism, each blockchain node stores a global index table, but most of the data in the global index table is historical status data, not the latest status data. Saving historical status data is only for the convenience of query, wasteful A lot of disk space.
发明内容SUMMARY OF THE INVENTION
鉴于现有技术中的上述缺陷或不足,期望提供一种在提高查询效率的基础上,节约磁盘空间的分布式数据存储方法、数据查询方法、设备和存储介质。In view of the above-mentioned defects or deficiencies in the prior art, it is desirable to provide a distributed data storage method, data query method, device and storage medium that save disk space on the basis of improving query efficiency.
第一方面,本发明提供一种适用于区块链节点的分布式数据存储方法,状态数据的存储方式包括以全局索引表的方式存储,各区块链节点存有mvcc索引表,mvcc索引表包括若干第一键值对,第一键值对的第一键包括第一用户的第一地址,第一键值对的第一值包括第一地址发生状态变化的各第一区块高度的第一高度集合,上述方法包括:In the first aspect, the present invention provides a distributed data storage method suitable for blockchain nodes. The storage method of state data includes storing in the form of a global index table. Each blockchain node stores an mvcc index table, and the mvcc index table includes: A number of first key-value pairs, the first key of the first key-value pair includes the first address of the first user, and the first value of the first key-value pair includes the first block height of the first address where the state changes. A height set, the above method includes:
根据待存储的第一数量个连续区块的区块哈希生成第一数据;Generate the first data according to the block hash of the first number of consecutive blocks to be stored;
根据第一数量个连续区块对应的第一全局索引表生成第一归档数据;Generate the first archive data according to the first global index table corresponding to the first number of consecutive blocks;
根据第一数据、预配置的分布式数据存储规则确定将要接收第一归档数据的若干第一区块链节点;Determine a number of first blockchain nodes that will receive the first archived data according to the first data and the preconfigured distributed data storage rules;
将第一归档数据发送至各第一区块链节点以供存储第一归档数据;sending the first archived data to each of the first blockchain nodes for storing the first archived data;
在当前节点不包括于第一区块链节点时,在第一时长后删除所存储的第一全局索引表;When the current node is not included in the first blockchain node, delete the stored first global index table after the first duration;
其中,第一归档信息用于供区块链节点:Among them, the first archive information is used for blockchain nodes:
接收第一查询指令;其中,第一查询指令包括第二用户的第二地址和所查询的第二区块区间高度;Receive a first query instruction; wherein, the first query instruction includes the second address of the second user and the queried second block interval height;
根据第二区块区间高度和第二地址在mvcc索引表中查找对应的第二高度集合;Find the corresponding second height set in the mvcc index table according to the second block interval height and the second address;
对第二高度集合中的各第三区块高度执行如下操作:Perform the following operations on each of the third block heights in the second set of heights:
根据第三区块高度所在的第二归档数据对应的连续区块的区块哈希生成第二数据;Generate the second data according to the block hash of the continuous block corresponding to the second archive data where the third block height is located;
根据第二数据、分布式数据存储规则找到存储有第二归档数据的若干第二区块链节点;Find several second blockchain nodes storing the second archived data according to the second data and the distributed data storage rules;
向至少一个第二区块链节点发送第一查询指令以查找对应的目标数据。Send a first query instruction to at least one second blockchain node to find corresponding target data.
第二方面,本发明提供一种适用于区块链节点的数据查询方法,区块链节点根据上述第一方面的方法分布式存储数据,上述方法包括:In a second aspect, the present invention provides a data query method applicable to a blockchain node. The blockchain node stores data in a distributed manner according to the method of the first aspect, and the method includes:
接收第一查询指令;其中,第一查询指令包括第二用户的第二地址和所查询的第二区块区间高度;Receive a first query instruction; wherein, the first query instruction includes the second address of the second user and the queried second block interval height;
根据第二地址在mvcc索引表中查找对应的第二高度集合;Find the corresponding second height set in the mvcc index table according to the second address;
对第二高度集合中的各第三区块高度执行如下操作:Perform the following operations on each of the third block heights in the second set of heights:
S251:根据第三区块高度所在的第二归档数据对应的连续区块的区块哈希生成第二数据;S251: Generate second data according to the block hash of the continuous block corresponding to the second archive data where the third block height is located;
S252:根据第二数据、分布式数据存储规则找到存储有第二归档数据的若干第二区块链节点;S252: Find several second blockchain nodes storing the second archive data according to the second data and the distributed data storage rules;
S253:向至少一个第二区块链节点请求第二归档数据发送所述第一查询指令以查找对应的目标数据。S253: Send the first query instruction to at least one second blockchain node requesting the second archive data to search for corresponding target data.
第三方面,本发明还提供一种设备,包括一个或多个处理器和存储器,其中存储器包含可由该一个或多个处理器执行的指令以使得该 一个或多个处理器执行根据本发明各实施例提供的分布式数据存储方法和数据查询方法。In a third aspect, the present invention also provides an apparatus comprising one or more processors and a memory, wherein the memory contains instructions executable by the one or more processors to cause the one or more processors to perform various functions according to the present invention. The distributed data storage method and the data query method provided by the embodiments.
第四方面,本发明还提供一种存储有计算机程序的存储介质,该计算机程序使计算机执行根据本发明各实施例提供的分布式数据存储方法和数据查询方法。In a fourth aspect, the present invention further provides a storage medium storing a computer program, and the computer program enables a computer to execute the distributed data storage method and data query method provided according to various embodiments of the present invention.
本发明诸多实施例提供的分布式数据存储方法、数据查询方法、设备和存储介质通过根据待存储的第一数量个连续区块的区块哈希生成第一数据;根据第一数量个连续区块对应的第一全局索引表生成第一归档数据;根据第一数据、预配置的分布式数据存储规则确定将要接收第一归档数据的若干第一区块链节点;将第一归档数据发送至各第一区块链节点以供存储第一归档数据;在当前节点不包括于第一区块链节点时,在第一时长后删除所存储的第一全局索引表的方法,提高查询效率。The distributed data storage method, data query method, device and storage medium provided by various embodiments of the present invention generate first data according to the block hash of the first number of consecutive blocks to be stored; The first global index table corresponding to the block generates the first archived data; according to the first data and the preconfigured distributed data storage rules, several first blockchain nodes that will receive the first archived data are determined; the first archived data is sent to Each first block chain node is used to store the first archive data; when the current node is not included in the first block chain node, the method of deleting the stored first global index table after a first time period improves query efficiency.
附图说明Description of drawings
通过阅读参照以下附图所作的对非限制性实施例所作的详细描述,本申请的其它特征、目的和优点将会变得更明显:Other features, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:
图1为本发明一实施例提供的一种分布式数据存储方法的流程图。FIG. 1 is a flowchart of a distributed data storage method according to an embodiment of the present invention.
图2为本发明一实施例提供的一种数据查询方法的流程图。FIG. 2 is a flowchart of a data query method according to an embodiment of the present invention.
图3为本发明一实施例提供的一种设备的结构示意图。FIG. 3 is a schematic structural diagram of a device according to an embodiment of the present invention.
具体实施方式Detailed ways
下面结合附图和实施例对本申请作进一步的详细说明。可以理解的是,此处所描述的具体实施例仅仅用于解释相关发明,而非对该发明的限定。另外还需要说明的是,为了便于描述,附图中仅示出了与发明相关的部分。The present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the related invention, but not to limit the invention. In addition, it should be noted that, for the convenience of description, only the parts related to the invention are shown in the drawings.
需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互组合。下面将参考附图并结合实施例来详细说明本申请。It should be noted that the embodiments in the present application and the features of the embodiments may be combined with each other in the case of no conflict. The present application will be described in detail below with reference to the accompanying drawings and in conjunction with the embodiments.
图1为本发明一实施例提供的一种分布式数据存储方法的流程图。如图1所示,在本实施例中,本发明提供一种适用于区块链节点的分布式数据存储方法,状态数据的存储方式包括以全局索引表的方式存储,各区块链节点存有mvcc索引表,mvcc索引表包括若干第一键值对,第一键值对的第一键包括第一用户的第一地址,第一键值对的第一值包括第一地址发生状态变化的各第一区块高度的第一高度集合,上述方法包括:FIG. 1 is a flowchart of a distributed data storage method according to an embodiment of the present invention. As shown in FIG. 1, in this embodiment, the present invention provides a distributed data storage method suitable for blockchain nodes. The storage method of state data includes storing in the form of a global index table, and each blockchain node stores a mvcc index table, the mvcc index table includes several first key-value pairs, the first key of the first key-value pair includes the first address of the first user, and the first value of the first key-value pair includes the state of the first address changes. The first height set of each first block height, and the above method includes:
S11:根据待存储的第一数量个连续区块的区块哈希生成第一数据;S11: Generate first data according to the block hashes of the first number of consecutive blocks to be stored;
S13:根据第一数量个连续区块对应的第一全局索引表生成第一归档数据;S13: Generate first archive data according to the first global index table corresponding to the first number of consecutive blocks;
S15:根据第一数据、预配置的分布式数据存储规则确定将要接收第一归档数据的若干第一区块链节点;S15: Determine a number of first blockchain nodes that will receive the first archived data according to the first data and the preconfigured distributed data storage rules;
S17:将第一归档数据发送至各第一区块链节点以供存储第一归档数据;S17: Send the first archive data to each first blockchain node for storing the first archive data;
S19:在当前节点不包括于第一区块链节点时,在第一时长后删除所存储的第一全局索引表;S19: when the current node is not included in the first blockchain node, delete the stored first global index table after the first duration;
其中,第一归档信息用于供区块链节点:Among them, the first archive information is used for blockchain nodes:
接收第一查询指令;其中,第一查询指令包括第二用户的第二地址和所查询的第二区块区间高度;Receive a first query instruction; wherein, the first query instruction includes the second address of the second user and the queried second block interval height;
根据第二区块区间高度和第二地址在mvcc索引表中查找对应的第二高度集合;Find the corresponding second height set in the mvcc index table according to the second block interval height and the second address;
对第二高度集合中的各第三区块高度执行如下操作:Perform the following operations on each of the third block heights in the second set of heights:
根据第三区块高度所在的第二归档数据对应的连续区块的区块哈希生成第二数据;Generate the second data according to the block hash of the continuous block corresponding to the second archive data where the third block height is located;
根据第二数据、分布式数据存储规则找到存储有第二归档数据的若干第二区块链节点;Find several second blockchain nodes storing the second archived data according to the second data and the distributed data storage rules;
向至少一个第二区块链节点发送第一查询指令以查找对应的目标数据。Send a first query instruction to at least one second blockchain node to find corresponding target data.
具体地,以S15包括“计算各区块链节点的节点id与第一数 据的第一距离;将第一距离最小的第二数量个区块链节点确定为第一区块链节点”,相应的,根据第二数据、分布式数据存储规则找到存储有第二归档数据的若干第二区块链节点包括“计算各区块链节点的节点id与第二数据的第二距离;将第二距离最小的第二数量个区块链节点确定为第二区块链节点”,第一数量为100,第二数量为5,第一时长为2min为例;假设根据待存储的第一数量个连续区块为block(1)~block(100);Specifically, S15 includes "calculating the first distance between the node id of each blockchain node and the first data; determining the second number of blockchain nodes with the smallest first distance as the first blockchain node", the corresponding , according to the second data and distributed data storage rules to find several second blockchain nodes that store the second archived data, including "calculating the second distance between the node id of each blockchain node and the second data; the second distance is the smallest The second number of blockchain nodes is determined as the second blockchain node”, the first number is 100, the second number is 5, and the first duration is 2min as an example; assuming that according to the first number of consecutive areas to be stored The block is block(1)~block(100);
区块链节点执行步骤S11,根据blockhash(1)~blockhash(100)生成数据chunkhash(1~100);The blockchain node executes step S11, and generates data chunkhash (1-100) according to blockhash (1)-blockhash (100);
区块链节点执行步骤S13,根据block(1)~block(100)对应的全局索引表T(1~100)生成归档数据chunk(1~100);The blockchain node executes step S13, and generates archive data chunk (1-100) according to the global index table T (1-100) corresponding to block (1)-block (100);
区块链节点执行步骤S15,计算各区块链节点的节点id与chunkhash(1~100)的距离;将距离最小的5个区块链节点确定为将要接收chunk(1~100)的区块链节点;假设将要接收chunk(1~100)的区块链节点为N1~N5;The blockchain node executes step S15 to calculate the distance between the node id of each blockchain node and the chunkhash (1-100); the 5 blockchain nodes with the smallest distance are determined as the blockchain that will receive the chunk (1-100). Node; assume that the blockchain nodes that will receive chunks (1-100) are N1-N5;
区块链节点执行步骤S17,将chunk(1~100)发送至N1~N5,N1~N5存储chunk(1~100);The blockchain node executes step S17, and sends the chunk (1-100) to N1-N5, and N1-N5 stores the chunk (1-100);
区块链节点执行步骤S19,在当前节点不包括于N1~N5时,在2min后删除所存储的T(1~100)。The blockchain node executes step S19, when the current node is not included in N1-N5, deletes the stored T(1-100) after 2 minutes.
假设区块链节点N50接收查询指令“addr(A),[50,70]”;addr(A)在mvcc索引表中查找的高度集合为{65,105,185};N1~N5存储chunk(1~100),N6~N10存储chunk(101~200),N11~N15存储chunk(201~300),N16~N20存储chunk(301~400),N21~N25存储chunk(401~500),其它状态数据尚未分布式数据存储;Suppose that the blockchain node N50 receives the query command "addr(A), [50,70]"; the height set that addr(A) searches in the mvcc index table is {65, 105, 185}; N1~N5 store chunks (1~100) , N6~N10 store chunks (101~200), N11~N15 store chunks (201~300), N16~N20 store chunks (301~400), N21~N25 store chunks (401~500), other status data has not been distributed data storage;
N50根据[50,70]和addr(A)在mvcc索引表中查找对应的高度集合,所查找到的对应集合为{65};N50 searches for the corresponding height set in the mvcc index table according to [50,70] and addr(A), and the found corresponding set is {65};
对于65:For 65:
N50根据65所在的归档数据对应的连续区块的区块哈希(即blockhash(1)~blockhash(100))生成数据chunk(1~100);N50 generates data chunk (1-100) according to the block hash (ie blockhash(1)-blockhash(100)) of the continuous block corresponding to the archived data where 65 is located;
N50计算各区块链节点的节点id与chunk(1~100)的距离;将距离 最小的5个区块链节点N1~N5确定为存储有chunk(1~100)的区块链节点;N50 calculates the distance between the node id of each blockchain node and the chunk (1-100); the 5 blockchain nodes N1-N5 with the smallest distance are determined as the blockchain nodes that store the chunk (1-100);
N50向N1~N5中的1个或多个节点(假设仅向N1发送)发送addr(A),[50,70];N50 sends addr(A),[50,70] to one or more nodes in N1~N5 (assuming that it is only sent to N1);
N1根据addr(A)在[50,70]遍历查找目标数据:N1 traverses [50,70] to find the target data according to addr(A):
N1在chunk(1~100)中找到addr(A)在65对应的数据;N1 finds the data corresponding to addr(A) at 65 in chunk(1~100);
N1向N50返回addr(A)在65对应的数据。N1 returns the data corresponding to addr(A) at 65 to N50.
在更多实施例中,S15还可以根据实际需求进行配置,例如配置为,计算各区块链节点的节点id与第一数据的第一距离;将第一距离最大的第二数量个区块链节点确定为第一区块链节点,相应的,根据第二数据、分布式数据存储规则找到存储有第二归档数据的若干第二区块链节点也应当配置为“计算各区块链节点的节点id与第二数据的第二距离;将第二距离最大的第二数量个区块链节点确定为第二区块链节点”,可实现相同的技术效果。In more embodiments, S15 can also be configured according to actual needs, for example, configured to calculate the first distance between the node id of each blockchain node and the first data; The node is determined to be the first blockchain node, and accordingly, according to the second data and distributed data storage rules to find several second blockchain nodes that store the second archived data, they should also be configured as "calculate the nodes of each blockchain node". The second distance between the id and the second data; determining the second number of blockchain nodes with the largest second distance as the second blockchain node” can achieve the same technical effect.
在更多实施例中,第一数量还可以根据实际需求进行配置,例如配置为1000,可实现相同的技术效果。In more embodiments, the first number can also be configured according to actual requirements, for example, it is configured as 1000, which can achieve the same technical effect.
在更多实施例中,第二数量还可以根据实际需求进行配置,例如配置为10,可实现相同的技术效果。In more embodiments, the second number can also be configured according to actual needs, for example, it is configured as 10, which can achieve the same technical effect.
在更多实施例中,第一时长还可以根据实际需求进行配置,例如配置为1min,可实现相同的技术效果。In more embodiments, the first duration may also be configured according to actual requirements, for example, configured to be 1 min, which can achieve the same technical effect.
本实施例使得更方便的获取指定账户在某个高度区间的历史状态数据。指定账户的历史状态数据只需要从一个节点获取即可,查询一个月、一个季度、一年或者更多的数据,提高了数据查询效率。This embodiment makes it more convenient to obtain historical state data of a specified account in a certain height interval. The historical status data of the specified account only needs to be obtained from one node, and the data of one month, one quarter, one year or more can be queried, which improves the efficiency of data query.
优选地,根据第一数据、预配置的分布式数据存储规则确定将要接收第一归档数据的若干第一区块链节点包括:Preferably, according to the first data and preconfigured distributed data storage rules, determining a number of first blockchain nodes that will receive the first archived data includes:
计算各区块链节点的节点id与第一数据的第一距离;Calculate the first distance between the node id of each blockchain node and the first data;
将第一距离最小的第二数量个区块链节点确定为第一区块链节点;Determine the second number of blockchain nodes with the smallest first distance as the first blockchain node;
根据第二数据、分布式数据存储规则找到存储有第二归档数据的若干第二区块链节点包括:Finding several second blockchain nodes storing the second archived data according to the second data and distributed data storage rules includes:
计算各区块链节点的节点id与第二数据的第二距离;Calculate the second distance between the node id of each blockchain node and the second data;
将第二距离最小的第二数量个区块链节点确定为第二区块链节点。The second number of blockchain nodes with the smallest second distance is determined as the second blockchain node.
上述实施例的分布式数据存储原理可参考图1所示的方法,此处不再赘述。For the principle of distributed data storage in the foregoing embodiment, reference may be made to the method shown in FIG. 1 , which will not be repeated here.
优选地,第一数量个连续区块中的区块高度最大的第一区块的第四区块高度小于当前区块高度与安全回滚深度之差。Preferably, the fourth block height of the first block with the largest block height among the first number of consecutive blocks is smaller than the difference between the current block height and the safe rollback depth.
上述实施例保证了进行分片的数据不会被回滚,提高了用户体验。The above-mentioned embodiment ensures that the fragmented data will not be rolled back, which improves user experience.
优选地,在第一时长后删除所存储的第一全局索引表包括:Preferably, deleting the stored first global index table after the first duration includes:
对第一全局索引表的各第二键值对执行如下操作:Perform the following operations on each second key-value pair of the first global index table:
判断第二键值对的第二值是否为区块链上的最新状态数据:Determine whether the second value of the second key-value pair is the latest state data on the blockchain:
是,则保留第二键值对;If yes, keep the second key-value pair;
在第一时长后,删除除去各第二键值对外的第一全局索引表。After the first time period, delete the first global index table excluding each second key value to the outside.
交易执行时,需要获取一个最新版本的状态数据;因此,在本地保留一个最新版本的数据,而历史版本的数据则可以进行分布式存储。When a transaction is executed, a latest version of the state data needs to be obtained; therefore, a latest version of the data is kept locally, and the data of the historical version can be stored in a distributed manner.
本领域技术人员应当可以联想,如果某一个第二键在最近的若干高度内都没有更新过,比如当前高度为100万,某个第二键的最新版本为89万9999,超过10万个高度没有更新过该第二键了,则说明该第二键的访问频率非常低,此时应当将该第二键进行分布式存储。Those skilled in the art should be able to imagine that if a certain second key has not been updated in the last several heights, for example, the current height is 1 million, the latest version of a certain second key is 899,999, and the height exceeds 100,000. If the second key has not been updated, it means that the access frequency of the second key is very low, and at this time, the second key should be stored in a distributed manner.
图2为本发明一实施例提供的一种数据查询方法的流程图。如图2所示,在本实施例中,本发明提供一种适用于区块链节点的数据查询方法,区块链节点根据上述分布式数据存储方法对数据进行分布式存储,上述方法包括:FIG. 2 is a flowchart of a data query method according to an embodiment of the present invention. As shown in FIG. 2, in this embodiment, the present invention provides a data query method suitable for blockchain nodes. The blockchain nodes perform distributed storage of data according to the above distributed data storage method, and the above method includes:
S21:接收第一查询指令;其中,第一查询指令包括第二用户的第二地址和所查询的第二区块区间高度;S21: Receive a first query instruction; wherein, the first query instruction includes the second address of the second user and the queried second block interval height;
S23:根据第二地址在mvcc索引表中查找对应的第二高度集合;S23: Find the corresponding second height set in the mvcc index table according to the second address;
对第二高度集合中的各第三区块高度执行如下操作:Perform the following operations on each of the third block heights in the second set of heights:
S251:根据第三区块高度所在的第二归档数据对应的连续区块的区块哈希生成第二数据;S251: Generate second data according to the block hash of the continuous block corresponding to the second archive data where the third block height is located;
S252:根据第二数据、分布式数据存储规则找到存储有第二 归档数据的若干第二区块链节点;S252: according to the second data and distributed data storage rules, find several second block chain nodes that store the second archive data;
S253:向至少一个第二区块链节点请求第二归档数据发送所述第一查询指令以查找对应的目标数据。S253: Send the first query instruction to at least one second blockchain node requesting the second archive data to search for corresponding target data.
上述实施例使得更方便的获取指定账户在某个高度区间的历史状态数据,可以查询一个月、一个季度、一年或者更多的数据,提高了数据查询效率。The above embodiment makes it more convenient to obtain the historical status data of a specified account in a certain height interval, and can query data of one month, one quarter, one year or more, which improves the efficiency of data query.
上述实施例的数据查询原理可参考图1所示的方法,此处不再赘述。For the data query principle of the foregoing embodiment, reference may be made to the method shown in FIG. 1 , which will not be repeated here.
图3为本发明一实施例提供的一种设备的结构示意图。FIG. 3 is a schematic structural diagram of a device according to an embodiment of the present invention.
如图3所示,作为另一方面,本申请还提供了一种设备,包括一个或多个中央处理单元(CPU)301,其可以根据存储在只读存储器(ROM)302中的程序或者从存储部分308加载到随机访问存储器(RAM)303中的程序而执行各种适当的动作和处理。在RAM303中,还存储有设备300操作所需的各种程序和数据。CPU301、ROM302以及RAM303通过总线304彼此相连。输入/输出(I/O)接口305也连接至总线304。As shown in FIG. 3 , as another aspect, the present application also provides a device including one or more central processing units (CPUs) 301 , which can be stored in a read-only memory (ROM) 302 according to a program or from The storage section 308 loads programs into the random access memory (RAM) 303 to execute various appropriate actions and processes. In the RAM 303, various programs and data necessary for the operation of the device 300 are also stored. The CPU 301 , the ROM 302 , and the RAM 303 are connected to each other through a bus 304 . An input/output (I/O) interface 305 is also connected to bus 304 .
以下部件连接至I/O接口305:包括键盘、鼠标等的输入部分306;包括诸如阴极射线管(CRT)、液晶显示器(LCD)等以及扬声器等的输出部分307;包括硬盘等的存储部分308;以及包括诸如LAN卡、调制解调器等的网络接口卡的通信部分309。通信部分309经由诸如因特网的网络执行通信处理。驱动器310也根据需要连接至I/O接口305。可拆卸介质311,诸如磁盘、光盘、磁光盘、半导体存储器等等,根据需要安装在驱动器310上,以便于从其上读出的计算机程序根据需要被安装入存储部分308。The following components are connected to the I/O interface 305: an input section 306 including a keyboard, a mouse, etc.; an output section 307 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 308 including a hard disk, etc. ; and a communication section 309 including a network interface card such as a LAN card, a modem, and the like. The communication section 309 performs communication processing via a network such as the Internet. A drive 310 is also connected to the I/O interface 305 as needed. A removable medium 311, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is mounted on the drive 310 as needed so that a computer program read therefrom is installed into the storage section 308 as needed.
特别地,根据本公开的实施例,上述任一实施例描述的方法可以被实现为计算机软件程序。例如,本公开的实施例包括一种计算机程序产品,其包括有形地包含在机器可读介质上的计算机程序,所述计算机程序包含用于执行上述任一方法的程序代码。在这样的实施例中,该计算机程序可以通过通信部分309从网络上被下载和安装,和/或从可拆卸介质311被安装。In particular, according to an embodiment of the present disclosure, the method described in any of the above embodiments may be implemented as a computer software program. For example, embodiments of the present disclosure include a computer program product comprising a computer program tangibly embodied on a machine-readable medium, the computer program containing program code for performing any of the methods described above. In such an embodiment, the computer program may be downloaded and installed from the network via the communication portion 309 and/or installed from the removable medium 311 .
作为又一方面,本申请还提供了一种计算机可读存储介质,该计算机可读存储介质可以是上述实施例的装置中所包含的计算机可读存储介质;也可以是单独存在,未装配入设备中的计算机可读存储介质。计算机可读存储介质存储有一个或者一个以上程序,该程序被一个或者一个以上的处理器用来执行描述于本申请提供的方法。As yet another aspect, the present application also provides a computer-readable storage medium. The computer-readable storage medium may be a computer-readable storage medium included in the apparatus of the foregoing embodiment; A computer-readable storage medium in a device. The computer-readable storage medium stores one or more programs that are used by one or more processors to perform the methods described in the present application.
附图中的流程图和框图,图示了按照本发明各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,该模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这根据所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以通过执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以通过专用硬件与计算机指令的组合来实现。The flowchart and block diagrams in the Figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code that contains one or more logical functions for implementing the specified functions executable instructions. It should also be noted that, in some alternative implementations, the functions noted in the blocks may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It is also noted that each block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations, can be implemented by dedicated hardware-based systems that perform the specified functions or operations , or can be implemented by a combination of dedicated hardware and computer instructions.
描述于本申请实施例中所涉及到的单元或模块可以通过软件的方式实现,也可以通过硬件的方式来实现。所描述的单元或模块也可以设置在处理器中,例如,各所述单元可以是设置在计算机或移动智能设备中的软件程序,也可以是单独配置的硬件装置。其中,这些单元或模块的名称在某种情况下并不构成对该单元或模块本身的限定。The units or modules involved in the embodiments of the present application may be implemented in a software manner, and may also be implemented in a hardware manner. The described units or modules may also be provided in the processor, for example, each of the units may be a software program provided in a computer or a mobile smart device, or may be a separately configured hardware device. Wherein, the names of these units or modules do not constitute limitations on the units or modules themselves under certain circumstances.
以上描述仅为本申请的较佳实施例以及对所运用技术原理的说明。本领域技术人员应当理解,本申请中所涉及的发明范围,并不限于上述技术特征的特定组合而成的技术方案,同时也应涵盖在不脱离本申请构思的情况下,由上述技术特征或其等同特征进行任意组合而形成的其它技术方案。例如上述特征与本申请中公开的(但不限于)具有类似功能的技术特征进行互相替换而形成的技术方案。The above description is only a preferred embodiment of the present application and an illustration of the applied technical principles. Those skilled in the art should understand that the scope of the invention involved in the present application is not limited to the technical solutions formed by the specific combination of the above-mentioned technical features, and should also cover, without departing from the concept of the present application, the above-mentioned technical features or Other technical solutions formed by any combination of its equivalent features. For example, a technical solution is formed by replacing the above-mentioned features with the technical features disclosed in this application (but not limited to) with similar functions.

Claims (7)

  1. 一种分布式数据存储方法,其特征在于,状态数据的存储方式包括以全局索引表的方式存储,各区块链节点存有mvcc索引表,所述mvcc索引表包括若干第一键值对,所述第一键值对的第一键包括第一用户的第一地址,所述第一键值对的第一值包括所述第一地址发生状态变化的各第一区块高度的第一高度集合,所述方法适用于区块链节点,所述方法包括:A distributed data storage method, characterized in that the storage method of state data includes storing in the form of a global index table, each block chain node stores an mvcc index table, and the mvcc index table includes several first key-value pairs, so The first key of the first key-value pair includes the first address of the first user, and the first value of the first key-value pair includes the first height of each first block height where the state of the first address changes collection, the method is applicable to a blockchain node, and the method includes:
    根据待存储的第一数量个连续区块的区块哈希生成第一数据;Generate the first data according to the block hash of the first number of consecutive blocks to be stored;
    根据所述第一数量个连续区块对应的第一全局索引表生成第一归档数据;generating first archive data according to the first global index table corresponding to the first number of consecutive blocks;
    根据所述第一数据、预配置的分布式数据存储规则确定将要接收所述第一归档数据的若干第一区块链节点;Determine a number of first blockchain nodes that will receive the first archived data according to the first data and preconfigured distributed data storage rules;
    将所述第一归档数据发送至各所述第一区块链节点以供存储所述第一归档数据;sending the first archived data to each of the first blockchain nodes for storing the first archived data;
    在当前节点不包括于所述第一区块链节点时,在第一时长后删除所存储的所述第一全局索引表;When the current node is not included in the first blockchain node, delete the stored first global index table after a first duration;
    其中,所述第一归档信息用于供区块链节点:Wherein, the first archive information is used for blockchain nodes:
    接收第一查询指令;其中,所述第一查询指令包括第二用户的第二地址和所查询的第二区块区间高度;Receive a first query instruction; wherein, the first query instruction includes the second address of the second user and the queried second block interval height;
    根据所述第二区块区间高度和所述第二地址在所述mvcc索引表中查找对应的第二高度集合;Search for a corresponding second height set in the mvcc index table according to the second block interval height and the second address;
    对所述第二高度集合中的各第三区块高度执行如下操作:Perform the following operations on each of the third block heights in the second height set:
    根据所述第三区块高度所在的第二归档数据对应的连续区块的区块哈希生成第二数据;Generate second data according to the block hash of the continuous block corresponding to the second archive data where the third block height is located;
    根据所述第二数据、所述分布式数据存储规则找到存储有所述第二归档数据的若干第二区块链节点;Find several second blockchain nodes storing the second archived data according to the second data and the distributed data storage rules;
    向至少一个所述第二区块链节点发送所述第一查询指令以查找对应的目标数据。Send the first query instruction to at least one of the second blockchain nodes to find corresponding target data.
  2. 根据权利要求1所述的方法,其特征在于,所述根据所述第一数据、预配置的分布式数据存储规则确定将要接收所述第一归档数据的若干第一区块链节点包括:The method according to claim 1, wherein the determining, according to the first data and a preconfigured distributed data storage rule, a plurality of first blockchain nodes that will receive the first archived data comprises:
    计算各区块链节点的节点id与所述第一数据的第一距离;Calculate the first distance between the node id of each blockchain node and the first data;
    将所述第一距离最小的第二数量个区块链节点确定为所述第一区块链节点;Determining a second number of blockchain nodes with the smallest first distance as the first blockchain node;
    所述根据所述第二数据、所述分布式数据存储规则找到存储有所述第二归档数据的若干第二区块链节点包括:The finding, according to the second data and the distributed data storage rules, several second blockchain nodes that store the second archive data includes:
    计算各区块链节点的节点id与所述第二数据的第二距离;Calculate the second distance between the node id of each blockchain node and the second data;
    将所述第二距离最小的所述第二数量个区块链节点确定为所述第二区块链节点。The second number of blockchain nodes with the smallest second distance is determined as the second blockchain node.
  3. 根据权利要求1或2所述的方法,其特征在于,所述第一数量个连续区块中的区块高度最大的第一区块的第四区块高度小于当前区块高度与安全回滚深度之差。The method according to claim 1 or 2, wherein the fourth block height of the first block with the largest block height in the first number of consecutive blocks is smaller than the current block height and the security rollback difference in depth.
  4. 根据权利要求1或2所述的方法,其特征在于,所述在第一时长后删除所存储的所述第一全局索引表包括:The method according to claim 1 or 2, wherein the deleting the stored first global index table after a first time period comprises:
    对所述第一全局索引表的各第二键值对执行如下操作:Perform the following operations on each second key-value pair of the first global index table:
    判断所述第二键值对的第二值是否为区块链上的最新状态数据:Determine whether the second value of the second key-value pair is the latest state data on the blockchain:
    是,则保留所述第二键值对;If yes, keep the second key-value pair;
    在第一时长后,删除除去各所述第二键值对外的所述第一全局索引表。After the first time period, the first global index table excluding each of the second key values to the outside is deleted.
  5. 一种数据查询方法,其特征在于,各区块链节点根据如权利要求1-4任一项所述的方法分布式存储数据,所述方法适用于区块链节点,所述方法包括:A data query method, characterized in that each blockchain node stores data in a distributed manner according to the method according to any one of claims 1-4, the method is applicable to blockchain nodes, and the method includes:
    接收第一查询指令;其中,所述第一查询指令包括第二用户的第二地址和所查询的第二区块区间高度;Receive a first query instruction; wherein, the first query instruction includes the second address of the second user and the queried second block interval height;
    根据第二区块区间高度和第二地址在mvcc索引表中查找对应的第二高度集合;Find the corresponding second height set in the mvcc index table according to the second block interval height and the second address;
    对所述第二高度集合中的各第三区块高度执行如下操作:Perform the following operations on each of the third block heights in the second height set:
    根据所述第三区块高度所在的第二归档数据对应的连续区块的区块哈希生成第二数据;Generate second data according to the block hash of the continuous block corresponding to the second archive data where the third block height is located;
    根据所述第二数据、所述分布式数据存储规则找到存储有所述第二归档数据的若干第二区块链节点;Find several second blockchain nodes storing the second archived data according to the second data and the distributed data storage rules;
    向至少一个所述第二区块链节点发送所述第一查询指令以查找对应的目标数据。Send the first query instruction to at least one of the second blockchain nodes to find corresponding target data.
  6. 一种计算机设备,其特征在于,所述设备包括:A computer device, characterized in that the device comprises:
    一个或多个处理器;one or more processors;
    存储器,用于存储一个或多个程序,memory for storing one or more programs,
    当所述一个或多个程序被所述一个或多个处理器执行时,使得所述一个或多个处理器执行如权利要求1-5中任一项所述的方法。The one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method of any of claims 1-5.
  7. 一种存储有计算机程序的存储介质,其特征在于,该程序被处理器执行时实现如权利要求1-5中任一项所述的方法。A storage medium storing a computer program, characterized in that, when the program is executed by a processor, the method according to any one of claims 1-5 is implemented.
PCT/CN2021/111851 2020-12-09 2021-08-10 Distributed data storage method, data query method, device, and storage medium WO2022121345A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011426904.2 2020-12-09
CN202011426904.2A CN112364209B (en) 2020-12-09 2020-12-09 Distributed data storage method, data query method, device and storage medium

Publications (1)

Publication Number Publication Date
WO2022121345A1 true WO2022121345A1 (en) 2022-06-16

Family

ID=74536773

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/111851 WO2022121345A1 (en) 2020-12-09 2021-08-10 Distributed data storage method, data query method, device, and storage medium

Country Status (2)

Country Link
CN (1) CN112364209B (en)
WO (1) WO2022121345A1 (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112364209B (en) * 2020-12-09 2023-11-28 杭州复杂美科技有限公司 Distributed data storage method, data query method, device and storage medium
CN112948438B (en) * 2021-03-05 2022-06-24 杭州复杂美科技有限公司 Data query method, computer device and storage medium
CN113254505B (en) * 2021-06-17 2021-10-08 湖南视觉伟业智能科技有限公司 Distributed data storage method, retrieval method, system and readable storage medium
CN113420169B (en) * 2021-06-22 2023-03-21 重庆紫光华山智安科技有限公司 File storage and query method, system, electronic equipment and medium
CN113886124B (en) * 2021-10-04 2023-05-30 杭州复杂美科技有限公司 Illegal node identification method, computer device, and storage medium
CN114723444A (en) * 2022-01-21 2022-07-08 佛山赛思禅科技有限公司 Data fragmentation method for parallel voting consensus
CN114928622A (en) * 2022-05-07 2022-08-19 杭州复杂美科技有限公司 Multi-subnet blockchain network, data storage method and device thereof, and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109359222A (en) * 2018-08-06 2019-02-19 杭州复杂美科技有限公司 Date storage method and system, equipment and storage medium
CN109408551A (en) * 2018-08-06 2019-03-01 杭州复杂美科技有限公司 Data query method and system, common recognition method and system, equipment and storage medium
US20190147106A1 (en) * 2017-11-14 2019-05-16 International Business Machines Corporation Providing accountability of blockchain queries
CN111708835A (en) * 2020-05-28 2020-09-25 西安纸贵互联网科技有限公司 Block chain data storage method and device
CN112364209A (en) * 2020-12-09 2021-02-12 杭州复杂美科技有限公司 Distributed data storage method, data query method, device and storage medium

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170124490A1 (en) * 2015-10-28 2017-05-04 Fractal Industries, Inc. Inclusion of time series geospatial markers in analyses employing an advanced cyber-decision platform
CN109299336B (en) * 2018-09-30 2022-07-01 腾讯科技(深圳)有限公司 Data backup method and device, storage medium and computing equipment
CN110704506B (en) * 2019-09-24 2022-05-24 杭州复杂美科技有限公司 State data storage method and data query method
CN111611319A (en) * 2020-06-08 2020-09-01 杭州复杂美科技有限公司 Distributed data storage method, device and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190147106A1 (en) * 2017-11-14 2019-05-16 International Business Machines Corporation Providing accountability of blockchain queries
CN109359222A (en) * 2018-08-06 2019-02-19 杭州复杂美科技有限公司 Date storage method and system, equipment and storage medium
CN109408551A (en) * 2018-08-06 2019-03-01 杭州复杂美科技有限公司 Data query method and system, common recognition method and system, equipment and storage medium
CN111708835A (en) * 2020-05-28 2020-09-25 西安纸贵互联网科技有限公司 Block chain data storage method and device
CN112364209A (en) * 2020-12-09 2021-02-12 杭州复杂美科技有限公司 Distributed data storage method, data query method, device and storage medium

Also Published As

Publication number Publication date
CN112364209B (en) 2023-11-28
CN112364209A (en) 2021-02-12

Similar Documents

Publication Publication Date Title
WO2022121345A1 (en) Distributed data storage method, data query method, device, and storage medium
WO2020192316A1 (en) Data storage method, data rollback method, device and storage medium
US10417265B2 (en) High performance parallel indexing for forensics and electronic discovery
WO2020135435A1 (en) Main chain and parallel chain architecture system, block synchronization method, device, and storage medium
US9576013B2 (en) Optimizing update operations in in-memory database systems
CN109657174B (en) Method and device for updating data
US9411531B2 (en) Managing memory and storage space for a data operation
US10614070B2 (en) Preventing staleness in query results when using asynchronously updated indexes
CN110858194A (en) Method and device for expanding database
WO2016070529A1 (en) Method and device for achieving duplicated data deletion
US20120197925A1 (en) Optimization of Database Driver Performance
WO2023098724A1 (en) Database parameter tuning method, network equipment, and computer-readable storage medium
WO2021218033A1 (en) Dictionary data operation method and apparatus, readable storage medium, and terminal device
CN112182029B (en) Data query method, device and storage medium
US11321374B2 (en) External storage of unstructured database objects
CN111723092A (en) Data processing method and device
CN112417054B (en) Distributed data storage method, data query method, device and storage medium
US10657126B2 (en) Meta-join and meta-group-by indexes for big data
US20170031909A1 (en) Locality-sensitive hashing for algebraic expressions
Naeem et al. Skewed distributions in semi-stream joins: How much can caching help?
US11188501B1 (en) Transactional and batch-updated data store search
WO2015161550A1 (en) Index management method and device, and computer storage medium
Naeem A caching approach to process stream data in data warehouse
Naeem et al. An Efficient Stream-based Join to Process End User Transactions in Real-Time Data Warehousing.
US11847334B2 (en) Method or apparatus to integrate physical file verification and garbage collection (GC) by tracking special segments

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: 21902055

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: 21902055

Country of ref document: EP

Kind code of ref document: A1