WO2022143540A1 - Block chain index storage method and apparatus, computer device and medium - Google Patents

Block chain index storage method and apparatus, computer device and medium Download PDF

Info

Publication number
WO2022143540A1
WO2022143540A1 PCT/CN2021/141698 CN2021141698W WO2022143540A1 WO 2022143540 A1 WO2022143540 A1 WO 2022143540A1 CN 2021141698 W CN2021141698 W CN 2021141698W WO 2022143540 A1 WO2022143540 A1 WO 2022143540A1
Authority
WO
WIPO (PCT)
Prior art keywords
database
transaction
index
target
sub
Prior art date
Application number
PCT/CN2021/141698
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 WO2022143540A1 publication Critical patent/WO2022143540A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2255Hash tables

Definitions

  • the present application relates to the field of blockchain technology, and in particular, to a method, device, computer equipment and medium for storing a blockchain index.
  • the transaction hash index is a random character array calculated by the hash algorithm according to the transaction and block content.
  • the blockchain often needs to provide a type of interface to the outside world to obtain transactions and related information through transaction hashes, including receipts and so on. First, obtain the block number of the block of this exchange through the transaction hash, then obtain the complete block through the block number, and traverse the block to find the transaction. Likewise, blockchain systems need to store index information that hashes transactions to block numbers.
  • the prior art has at least the following problems: the transaction hash is completely random, and at the same time, it is read and written very frequently, so that the storage layer will face the problem of random read and write, and the efficiency is extremely low.
  • the embodiments of the present application provide a method for storing a blockchain index, including:
  • a sub-database matching the timestamp information is obtained from the transaction index storage database as a target database, wherein the transaction index storage database includes at least two sub-databases, and each sub-database uses A transaction hash index for storing fixed time intervals;
  • the constructing the transaction hash index includes:
  • the block link receives the transaction information, according to the transaction information, calculate the transaction hash value, and obtain the transaction time included in the transaction information, and generate timestamp information;
  • the block corresponding to the target block number is obtained as the target block
  • a building module for building a transaction hash index including version information, timestamp information and transaction hash value
  • a storage module configured to use the transaction hash index as a key, use the block number of the transaction corresponding to the transaction hash index as a value, and store the key and the value as a key-value pair in the target database.
  • the target database determination unit is configured to use the sub-database corresponding to the target time interval as the target database.
  • a block number obtaining module used for obtaining the target block number from the sub-database to be queried by means of a key-value pair query
  • an embodiment of the present application further provides a computer-readable storage medium, where the computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the above-mentioned blockchain is implemented The steps of the storage method of the index.
  • FIG. 3 is a schematic structural diagram of an embodiment of a storage device for a blockchain index according to the present application.
  • the transaction hash is to add transaction records to the blockchain through hashing, including the address of sending coins, the address of receiving coins, the sending time, the time of receiving coins, the number of confirmations, etc. Users can check their recharge in their personal wallets Whether there is any error, after all confirmations, the transferred coins can be credited to the account in time.
  • the transaction corresponding to each hash is a unique transaction, which ensures the privacy and security of the transaction.
  • step S201 constructing a transaction hash index includes:
  • the preset storage upper limit may be set according to actual application scenario requirements, for example, set to 20,000, etc., which is not specifically limited here.
  • the storage module 33 is configured to use the transaction hash index as the Key, use the block number of the transaction corresponding to the transaction hash index as the Value, and store the Key and Value as a key-value pair in the target database.
  • building block 31 includes:
  • the matching module 32 includes:
  • the sub-database presets a storage upper limit
  • the storage module 33 includes:
  • a new database unit is used to create a new database with the same fixed time interval as the target database if the judgment result is that the data stored in the target database reaches the preset storage upper limit, and store the key-value pair in the new database.
  • the block determination module is used to obtain the block corresponding to the target block number as the target block according to the method of disk reading;

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present application discloses a block chain index storage method and apparatus, a computer device and a medium. Said method comprises: constructing a transaction hash index, wherein the transaction hash index comprises version information, timestamp information and a transaction hash value; acquiring, on the basis of the timestamp information, a sub-database matching the timestamp information from a transaction index storage database as a target database, wherein the transaction index storage database contains at least two sub-databases, and each sub-database is used to store transaction hash indexes of a fixed time interval; taking the transaction hash index as Key, taking the block number of the transaction corresponding to the transaction hash index as Value, and taking the Key and the Value as a key value pair, and storing same in the target database. The present application improves the data read-write efficiency.

Description

区块链索引的存储方法、装置、计算机设备及介质Storage method, device, computer equipment and medium for blockchain index
本申请要求于2020年12月31日提交中国专利局、申请号为202011640211.3,发明名称为“区块链索引的存储方法、装置、计算机设备及介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application filed on December 31, 2020 with the application number 202011640211.3 and the title of the invention is "Blockchain Index Storage Method, Device, Computer Equipment and Medium", the entire content of which is Incorporated herein by reference.
技术领域technical field
本申请涉及区块链技术领域,尤其涉及一种区块链索引的存储方法、装置、计算机设备及介质。The present application relates to the field of blockchain technology, and in particular, to a method, device, computer equipment and medium for storing a blockchain index.
背景技术Background technique
目前区块链中,交易哈希索引是根据交易与区块内容,通过哈希算法计算得到的无规则字符数组。而区块链往往需要对外提供一类接口,通过交易哈希获取交易及相关信息,包括回执等等。首先通过交易哈希,获取到此交易所在区块的区块号,之后再通过区块号获取完整区块,遍历区块找到此交易。同样,区块链系统需要存储交易哈希到区块号的索引信息。发明人在实现本申请的过程中发现,现有技术至少存在如下问题:交易哈希完全随机,同时对其读写非常频繁,导致存储层将面临随机读写问题,效率极低。In the current blockchain, the transaction hash index is a random character array calculated by the hash algorithm according to the transaction and block content. The blockchain often needs to provide a type of interface to the outside world to obtain transactions and related information through transaction hashes, including receipts and so on. First, obtain the block number of the block of this exchange through the transaction hash, then obtain the complete block through the block number, and traverse the block to find the transaction. Likewise, blockchain systems need to store index information that hashes transactions to block numbers. During the process of realizing the present application, the inventor found that the prior art has at least the following problems: the transaction hash is completely random, and at the same time, it is read and written very frequently, so that the storage layer will face the problem of random read and write, and the efficiency is extremely low.
技术问题technical problem
本申请实施例提供一种区块链索引的存储方法、装置、计算机设备和存储介质,以提高区块链上交易哈希索引读写的效率。The embodiments of the present application provide a storage method, device, computer equipment and storage medium for a blockchain index, so as to improve the efficiency of reading and writing a transaction hash index on the blockchain.
技术解决方案technical solutions
为了解决上述技术问题,本申请实施例提供一种区块链索引的存储方法,包括:In order to solve the above technical problems, the embodiments of the present application provide a method for storing a blockchain index, including:
构建交易哈希索引,所述交易哈希索引包括版本信息、时间戳信息和交易哈希值;constructing a transaction hash index, where the transaction hash index includes version information, timestamp information and transaction hash value;
基于所述时间戳信息,从交易索引存储数据库中获取与所述时间戳信息匹配的子数据库,作为目标数据库,其中,所述交易索引存储数据库包含至少两个子数据库,每个所述子数据库用于存储固定时间区间的交易哈希索引;Based on the timestamp information, a sub-database matching the timestamp information is obtained from the transaction index storage database as a target database, wherein the transaction index storage database includes at least two sub-databases, and each sub-database uses A transaction hash index for storing fixed time intervals;
将所述交易哈希索引作为Key,将所述交易哈希索引对应交易的区块号作为Value,并将所述Key和所述Value作为键值对,存储至所述目标数据库。The transaction hash index is used as the Key, the block number of the transaction corresponding to the transaction hash index is used as the Value, and the Key and the Value are used as a key-value pair, and are stored in the target database.
可选地,所述构建交易哈希索引包括:Optionally, the constructing the transaction hash index includes:
在区块链接收到交易信息时,根据所述交易信息,计算交易哈希值,并获取所述交易信息中包含的交易时间,生成时间戳信息;When the block link receives the transaction information, according to the transaction information, calculate the transaction hash value, and obtain the transaction time included in the transaction information, and generate timestamp information;
基于所述时间戳信息,确定版本信息;determining version information based on the timestamp information;
根据所述版本信息、所述时间戳信息和所述交易哈希值,生成交易哈希索引。A transaction hash index is generated according to the version information, the timestamp information and the transaction hash value.
可选地,所述基于所述时间戳信息,从交易索引存储数据库中获取与所述时间戳信息匹配的子数据库,作为目标数据库包括:Optionally, based on the timestamp information, the sub-database that matches the timestamp information is obtained from the transaction index storage database, and the target database includes:
获取所述子数据库对应的固定时间区间;obtaining a fixed time interval corresponding to the sub-database;
通过遍历匹配,确定所述时间戳信息所属的固定时间区间,作为目标时间区间;Determine the fixed time interval to which the timestamp information belongs by traversing the matching, as the target time interval;
将所述目标时间区间对应的子数据库,作为所述目标数据库。The sub-database corresponding to the target time interval is used as the target database.
可选地,所述子数据库预设存储上限,所述将所述Key和所述Value作为键值对,存储至所述目标数据库包括:Optionally, the sub-database presets a storage upper limit, and storing the Key and the Value as a key-value pair in the target database includes:
判断所述目标数据库中存储数据是否达到所述预设存储上限,得到判断结果;Judging whether the data stored in the target database reaches the preset storage upper limit, and obtaining a judgment result;
若所述判断结果为所述目标数据库中存储数据达到所述预设存储上限,则新建与所述目标数据库的固定时间区间相同的数据库,并将所述键值对存储至所述新建数据库。If the judgment result is that the data stored in the target database reaches the preset storage upper limit, a new database with the same fixed time interval as the target database is created, and the key-value pair is stored in the newly created database.
可选地,所述区块链索引存储方法还包括:Optionally, the blockchain index storage method further includes:
若接收到交易哈希查询请求,则对所述交易哈希查询请求进行解析,得到目标时间戳信息;If a transaction hash query request is received, the transaction hash query request is parsed to obtain target timestamp information;
基于所述目标时间戳信息,确定待查询的子数据库;Determine the sub-database to be queried based on the target timestamp information;
通过键值对查询的方式,从所述待查询的子数据库中,获取目标区块号;Obtain the target block number from the sub-database to be queried by means of a key-value pair query;
根据磁盘读取的方式,获取所述目标区块号对应的区块,作为目标区块;According to the method of disk reading, the block corresponding to the target block number is obtained as the target block;
遍历所述目标区块,获取所述交易哈希查询请求对应的交易信息。Traverse the target block to obtain transaction information corresponding to the transaction hash query request.
为了解决上述技术问题,本申请实施例还提供一种区块链索引的存储装置,包括:In order to solve the above technical problems, the embodiments of the present application also provide a storage device for a blockchain index, including:
构建模块,用于构建交易哈希索引,所述交易哈希索引包括版本信息、时间戳信息和交易哈希值;a building module for building a transaction hash index, the transaction hash index including version information, timestamp information and transaction hash value;
匹配模块,用于基于所述时间戳信息,从交易索引存储数据库中获取与所述时间戳信息匹配的子数据库,作为目标数据库,其中,所述交易索引存储数据库包含至少两个子数据库,每个所述子数据库用于存储固定时间区间的交易哈希索引;The matching module is configured to obtain, based on the timestamp information, a sub-database matching the timestamp information from the transaction index storage database as a target database, wherein the transaction index storage database includes at least two sub-databases, each of which is a sub-database. The sub-database is used to store the transaction hash index of the fixed time interval;
存储模块,用于将所述交易哈希索引作为Key,将所述交易哈希索引对应交易的区块号作为Value,并将所述Key和所述Value作为键值对,存储至所述目标数据库。A storage module, configured to use the transaction hash index as a key, use the block number of the transaction corresponding to the transaction hash index as a value, and store the key and the value as a key-value pair in the target database.
可选地,所述构建模块包括:Optionally, the building blocks include:
哈希值计算单元,用于在区块链接收到交易信息时,根据所述交易信息,计算交易哈希值,并获取所述交易信息中包含的交易时间,生成时间戳信息;a hash value calculation unit, configured to calculate the transaction hash value according to the transaction information when the block link receives the transaction information, and obtain the transaction time included in the transaction information, and generate timestamp information;
版本确定单元,用于基于所述时间戳信息,确定版本信息;a version determination unit, configured to determine version information based on the timestamp information;
索引生成单元,用于根据所述版本信息、所述时间戳信息和所述交易哈希值,生成交易哈希索引。an index generating unit, configured to generate a transaction hash index according to the version information, the timestamp information and the transaction hash value.
可选地,所述匹配模块包括:Optionally, the matching module includes:
区间范围获取单元,用于获取所述子数据库对应的固定时间区间;an interval range obtaining unit, used to obtain a fixed time interval corresponding to the sub-database;
目前区间确定单元,用于通过遍历匹配,确定所述时间戳信息所属的固定时间区间,作为目标时间区间;The current interval determination unit is used to determine the fixed time interval to which the timestamp information belongs by traversing and matching, as the target time interval;
目标数据库确定单元,用于将所述目标时间区间对应的子数据库,作为所述目标数据库。The target database determination unit is configured to use the sub-database corresponding to the target time interval as the target database.
可选地,所述子数据库预设存储上限,所述存储模块包括:Optionally, the sub-database presets a storage upper limit, and the storage module includes:
上限判断单元,用于判断所述目标数据库中存储数据是否达到所述预设存储上限,得到判断结果;an upper limit judgment unit, configured to judge whether the stored data in the target database reaches the preset storage upper limit, and obtain a judgment result;
新建数据库单元,用于若所述判断结果为所述目标数据库中存储数据达到所述预设存储上限,则新建与所述目标数据库的固定时间区间相同的数据库,并将所述键值对存储至所述新建数据库。A new database unit, configured to create a new database with the same fixed time interval as the target database if the judgment result is that the data stored in the target database reaches the preset storage upper limit, and store the key-value pair to the new database.
可选地,所述的区块链索引存储装置还包括:Optionally, the blockchain index storage device further includes:
请求解析模块,用于若接收到交易哈希查询请求,则对所述交易哈希查询请求进行解析,得到目标时间戳信息;a request parsing module, configured to parse the transaction hash query request to obtain target timestamp information if a transaction hash query request is received;
子数据库确定模块,用于基于所述目标时间戳信息,确定待查询的子数据库;a sub-database determination module, configured to determine the sub-database to be queried based on the target timestamp information;
区块号获取模块,用于通过键值对查询的方式,从所述待查询的子数据库中,获取目标区块号;a block number obtaining module, used for obtaining the target block number from the sub-database to be queried by means of a key-value pair query;
区块确定模块,用于根据磁盘读取的方式,获取所述目标区块号对应的区块,作为目标区块;a block determination module, used for obtaining the block corresponding to the target block number according to the method of disk reading, as the target block;
遍历模块,用于遍历所述目标区块,获取所述交易哈希查询请求对应的交易信息。The traversal module is used for traversing the target block to obtain transaction information corresponding to the transaction hash query request.
为了解决上述技术问题,本申请实施例还提供一种计算机设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机可读指令,所述处理器执行所述计算机可读指令时实现上述区块链索引的存储方法的步骤。In order to solve the above technical problem, an embodiment of the present application further provides a computer device, including a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, and the processor executes the The steps of implementing the above-mentioned storage method of the blockchain index when the computer-readable instructions are described.
为了解决上述技术问题,本申请实施例还提供一种计算机可读存储介质,所述计算机可读存储介质存储有计算机可读指令,所述计算机可读指令被处理器执行时实现上述区块链索引的存储方法的步骤。In order to solve the above technical problem, an embodiment of the present application further provides a computer-readable storage medium, where the computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the above-mentioned blockchain is implemented The steps of the storage method of the index.
有益效果beneficial effect
本申请实施例提供的区块链索引的存储方法、装置、计算机设备及存储介质,构建交易哈希索引,交易哈希索引包括版本信息、时间戳信息和交易哈希值,基于时间戳信息,从交易索引存储数据库中获取与时间戳信息匹配的子数据库,作为目标数据库,其中,交易索引存储数据库包含至少两个子数据库,每个子数据库用于存储固定时间区间的交易哈希索引,将交易哈希索引作为Key,将交易哈希索引对应交易的区块号作为Value,并将Key和Value作为键值对,存储至目标数据库,实现将交易索引的随机写优化为顺序写,并将交易索引存储到独立的子数据库,保证数据库的高性能读写,提高数据读写效率。The storage method, device, computer equipment, and storage medium for a blockchain index provided by the embodiments of the present application construct a transaction hash index. The transaction hash index includes version information, timestamp information, and transaction hash value. Based on the timestamp information, The sub-database that matches the timestamp information is obtained from the transaction index storage database as the target database, wherein the transaction index storage database includes at least two sub-databases, each sub-database is used to store transaction hash indexes in a fixed time interval, and the transaction hash index The index is used as the Key, the block number of the transaction corresponding to the transaction hash index is used as the Value, and the Key and Value are used as the key-value pair to store in the target database, so as to optimize the random write of the transaction index to sequential write, and store the transaction index It is stored in an independent sub-database to ensure high-performance reading and writing of the database and improve the efficiency of data reading and writing.
附图说明Description of drawings
为了更清楚地说明本申请实施例的技术方案,下面将对本申请实施例的描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to illustrate the technical solutions of the embodiments of the present application more clearly, the following briefly introduces the drawings that are used in the description of the embodiments of the present application. Obviously, the drawings in the following description are only some embodiments of the present application. , for those of ordinary skill in the art, other drawings can also be obtained from these drawings without creative labor.
图1是本申请可以应用于其中的示例性系统架构图;FIG. 1 is an exemplary system architecture diagram to which the present application can be applied;
图2是本申请的区块链索引的存储方法的一个实施例的流程图;2 is a flowchart of an embodiment of a method for storing a blockchain index of the present application;
图3是根据本申请的区块链索引的存储装置的一个实施例的结构示意图;3 is a schematic structural diagram of an embodiment of a storage device for a blockchain index according to the present application;
图4是根据本申请的计算机设备的一个实施例的结构示意图。FIG. 4 is a schematic structural diagram of an embodiment of a computer device according to the present application.
  
具体实施方式Detailed ways
除非另有定义,本文所使用的所有的技术和科学术语与属于本申请的技术领域的技术人员通常理解的含义相同;本文中在申请的说明书中所使用的术语只是为了描述具体的实施例的目的,不是旨在于限制本申请;本申请的说明书和权利要求书及上述附图说明中的术语“包括”和“具有”以及它们的任何变形,意图在于覆盖不排他的包含。本申请的说明书和权利要求书或上述附图中的术语“第一”、“第二”等是用于区别不同对象,而不是用于描述特定顺序。Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the technical field of this application; the terms used herein in the specification of the application are for the purpose of describing specific embodiments only It is not intended to limit the application; the terms "comprising" and "having" and any variations thereof in the description and claims of this application and the above description of the drawings are intended to cover non-exclusive inclusion. The terms "first", "second" and the like in the description and claims of the present application or the above drawings are used to distinguish different objects, rather than to describe a specific order.
在本文中提及“实施例”意味着,结合实施例描述的特定特征、结构或特性可以包含在本申请的至少一个实施例中。在说明书中的各个位置出现该短语并不一定均是指相同的实施例,也不是与其它实施例互斥的独立的或备选的实施例。本领域技术人员显式地和隐式地理解的是,本文所描述的实施例可以与其它实施例相结合。Reference herein to an "embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the present application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor a separate or alternative embodiment that is mutually exclusive of other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.
请参阅图1,如图1所示,系统架构100可以包括终端设备101、102、103,网络104和服务器105。网络104用以在终端设备101、102、103和服务器105之间提供通信链路的介质。网络104可以包括各种连接类型,例如有线、无线通信链路或者光纤电缆等等。Please refer to FIG. 1 . As shown in FIG. 1 , the system architecture 100 may include terminal devices 101 , 102 , and 103 , a network 104 and a server 105 . The network 104 is a medium used to provide a communication link between the terminal devices 101 , 102 , 103 and the server 105 . The network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
用户可以使用终端设备101、102、103通过网络104与服务器105交互,以接收或发送消息等。The user can use the terminal devices 101, 102, 103 to interact with the server 105 through the network 104 to receive or send messages and the like.
终端设备101、102、103可以是具有显示屏并且支持网页浏览的各种电子设备,包括但不限于智能手机、平板电脑、电子书阅读器、MP3播放器( Moving Picture E界面显示perts Group Audio Layer III,动态影像专家压缩标准音频层面3 )、MP4( Moving Picture E界面显示perts Group Audio Layer IV,动态影像专家压缩标准音频层面4 )播放器、膝上型便携计算机和台式计算机等等。The terminal devices 101, 102, 103 can be various electronic devices with display screens and support web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture E interface display perts Group Audio Layer). III, Motion Picture Expert Compression Standard Audio Layer 3), MP4 (Moving Picture The E interface shows the perts Group Audio Layer IV, the standard audio layer for video expert compression 4) Players, Laptops and Desktops, etc.
服务器105可以是提供各种服务的服务器,例如对终端设备101、102、103上显示的页面提供支持的后台服务器。The server 105 may be a server that provides various services, such as a background server that provides support for the pages displayed on the terminal devices 101 , 102 , and 103 .
需要说明的是,本申请实施例所提供的区块链索引的存储方法由服务器执行,相应地,区块链索引的存储装置设置于服务器中。It should be noted that the storage method of the blockchain index provided by the embodiment of the present application is executed by the server, and correspondingly, the storage device of the blockchain index is set in the server.
应该理解,图1中的终端设备、网络和服务器的数目仅仅是示意性的。根据实现需要,可以具有任意数目的终端设备、网络和服务器,本申请实施例中的终端设备101、102、103具体可以对应的是实际生产中的应用系统。It should be understood that the numbers of terminal devices, networks and servers in FIG. 1 are merely illustrative. According to implementation requirements, there may be any number of terminal devices, networks, and servers, and the terminal devices 101 , 102 , and 103 in the embodiments of the present application may specifically correspond to application systems in actual production.
请参阅图2,图2示出本申请实施例提供的一种区块链索引的存储方法,以该方法应用在图1中的服务端为例进行说明,详述如下:Please refer to FIG. 2. FIG. 2 shows a method for storing a blockchain index provided by an embodiment of the present application. The method is applied to the server in FIG. 1 as an example for description. The details are as follows:
S201:构建交易哈希索引,交易哈希索引包括版本信息、时间戳信息和交易哈希值。S201: Build a transaction hash index, where the transaction hash index includes version information, timestamp information, and transaction hash value.
具体地,在发生交易时,通过交易信息,生成版本信息、时间戳信息和交易哈希值,进而构建交易哈希索引。Specifically, when a transaction occurs, version information, timestamp information and transaction hash value are generated through transaction information, and then a transaction hash index is constructed.
其中,版本信息用于保证交易哈希索引的兼容性,当区块数量增长至超过八字节的时候,将版本信息增加,可以将区块字段延长至十六个字节,缺陷后续兼容性的问题。Among them, the version information is used to ensure the compatibility of the transaction hash index. When the number of blocks increases to more than eight bytes, the version information can be increased to extend the block field to sixteen bytes. The problem.
其中,交易哈希中的时间戳信息直接取自交易携带的时间戳,在正常执行过程中,区块链打包并执行交易的顺序与交易生成的时间基本一致,确保交易在数据库写上的局部性和顺序性。Among them, the timestamp information in the transaction hash is directly taken from the timestamp carried by the transaction. During the normal execution process, the order in which the blockchain packages and executes the transaction is basically the same as the time when the transaction is generated, ensuring that the transaction is written locally in the database. sex and sequence.
其中,交易哈希就是通过哈希将交易记录添加到区块链上,包括发币地址、收币地址、发送时间、收币时间、确认数等等,用户可以在个人钱包中查看自己的充值是否有误,待全部确认之后,转账的币就可以及时到账。每一个哈希对应的交易就是唯一的交易,确保了交易的隐私性和安全性。Among them, the transaction hash is to add transaction records to the blockchain through hashing, including the address of sending coins, the address of receiving coins, the sending time, the time of receiving coins, the number of confirmations, etc. Users can check their recharge in their personal wallets Whether there is any error, after all confirmations, the transferred coins can be credited to the account in time. The transaction corresponding to each hash is a unique transaction, which ensures the privacy and security of the transaction.
构建交易哈希索引的具体实现过程,也可参见后续实施例的描述,为避免重复,此处不再赘述。For the specific implementation process of constructing the transaction hash index, reference may also be made to the descriptions of the subsequent embodiments, which are not repeated here to avoid repetition.
S202:基于时间戳信息,从交易索引存储数据库中获取与时间戳信息匹配的子数据库,作为目标数据库,其中,交易索引存储数据库包含至少两个子数据库,每个子数据库用于存储固定时间区间的交易哈希索引。S202: Based on the timestamp information, obtain a sub-database matching the timestamp information from the transaction index storage database as a target database, wherein the transaction index storage database includes at least two sub-databases, and each sub-database is used to store transactions in a fixed time interval Hash index.
本实施例中预设有交易索引存储数据库,该交易索引存储数据库包含至少两个子数据库,每个子数据库用于存储固定时间区间的交易哈希索引,包含最大时间戳和最小时间戳构成的固定时间区间,子数据库仅存储其对应的的固定时间区间范围内的交易哈希索引,通过将交易对应的时间戳信息与每个子数据进行匹配,确定当前交易数据需要存储的子数据库,作为目标数据库。In this embodiment, a transaction index storage database is preset, and the transaction index storage database includes at least two sub-databases, each sub-database is used to store a transaction hash index of a fixed time interval, including a fixed time consisting of a maximum timestamp and a minimum timestamp The sub-database only stores the transaction hash index within its corresponding fixed time interval. By matching the timestamp information corresponding to the transaction with each sub-data, the sub-database that needs to store the current transaction data is determined as the target database.
需要说明的是,若在已有的子数据库中,未匹配搭配包含当前交易对应的时间戳信息的固定时间区间,则获取最节点的固定时间区间对应的子数据库作为目标数据库,并将目标数据库对应的固定时间区间的最大时间戳或最小时间戳进行调整,使得该目标数据库包含当前交易对应的时间戳信息。It should be noted that, if the existing sub-database does not match the fixed time interval containing the timestamp information corresponding to the current transaction, the sub-database corresponding to the fixed time interval of the most node is obtained as the target database, and the target database is used. The maximum timestamp or minimum timestamp of the corresponding fixed time interval is adjusted so that the target database contains timestamp information corresponding to the current transaction.
例如,在一具体实施方式中,存在三个子数据库,时间分别为8点到9点,9点到10点,10点到11点。如果新的交易哈希时间戳为7点就存在第一个子数据库,并将第一个数据库时间更新为7点到9点,如果新的交易哈希时间戳为八点半,就存在第一个子数据库,九点半就存在第二个数据库,十点半存在第三个。For example, in a specific implementation, there are three sub-databases, and the times are respectively 8:00 to 9:00, 9:00 to 10:00, and 10:00 to 11:00. If the new transaction hash timestamp is 7:00, the first sub-database exists, and the first database time is updated to 7:00 to 9:00. If the new transaction hash timestamp is 8:30, the first sub-database exists. A sub-database, the second database exists at 9:30, and the third exists at 10:30.
需要说明的是,偶尔有较老的交易出现,也能够根据其时间戳信息,找到正确的子数据库进行写入,且由于区块链的读请求集中于新数据,时间较为久远的数据库可以视情况关闭,减少内存占用,当需要读取时,将其重新打开读取即可,有利于提高数据读写效率。It should be noted that if there are occasional older transactions, it is also possible to find the correct sub-database for writing based on its timestamp information, and since the read requests of the blockchain are concentrated on new data, older databases can be viewed as When the situation is closed, the memory usage is reduced. When reading is required, it can be reopened for reading, which is conducive to improving the efficiency of data reading and writing.
S203:将交易哈希索引作为Key,将交易哈希索引对应交易的区块号作为Value,并将Key和Value作为键值对,存储至目标数据库。S203: Use the transaction hash index as the Key, use the block number of the transaction corresponding to the transaction hash index as the Value, and use the Key and Value as a key-value pair, and store them in the target database.
具体地,将交易哈希索引作为Key,将交易哈希索引对应交易的区块号作为Value,实现以键值对的形式,将交易哈希索引和交易的区块号存储至目标数据库。Specifically, the transaction hash index is used as the Key, and the block number of the transaction corresponding to the transaction hash index is used as the Value, so that the transaction hash index and the transaction block number are stored in the target database in the form of a key-value pair.
本实施例中,通过构建交易哈希索引,交易哈希索引包括版本信息、时间戳信息和交易哈希值,基于时间戳信息,从交易索引存储数据库中获取与时间戳信息匹配的子数据库,作为目标数据库,其中,交易索引存储数据库包含至少两个子数据库,每个子数据库用于存储固定时间区间的交易哈希索引,将交易哈希索引作为Key,将交易哈希索引对应交易的区块号作为Value,并将Key和Value作为键值对,存储至目标数据库,实现将交易索引的随机写优化为顺序写,并将交易索引存储到独立的子数据库,保证数据库的高性能读写,提高数据读写效率。In this embodiment, by constructing a transaction hash index, the transaction hash index includes version information, timestamp information and transaction hash value, and based on the timestamp information, a sub-database matching the timestamp information is obtained from the transaction index storage database, As the target database, the transaction index storage database includes at least two sub-databases, each sub-database is used to store the transaction hash index in a fixed time interval, the transaction hash index is used as the key, and the transaction hash index corresponds to the block number of the transaction As Value, and store Key and Value as key-value pairs in the target database, optimize the random write of transaction index to sequential write, and store the transaction index in an independent sub-database to ensure high-performance reading and writing of the database and improve the Data read and write efficiency.
在本实施例的一些可选的实现方式中,步骤S201中,构建交易哈希索引包括:In some optional implementations of this embodiment, in step S201, constructing a transaction hash index includes:
在区块链接收到交易信息时,根据交易信息,计算交易哈希值,并获取交易信息中包含的交易时间,生成时间戳信息;When the block link receives the transaction information, according to the transaction information, the transaction hash value is calculated, and the transaction time contained in the transaction information is obtained, and the timestamp information is generated;
基于时间戳信息,确定版本信息;Based on the timestamp information, determine the version information;
根据版本信息、时间戳信息和交易哈希值,生成交易哈希索引。Generate transaction hash index based on version information, timestamp information and transaction hash value.
具体地,根据交易内信息,包括其时间信息,计算出交易哈希,交易中通常包含了发起方地址、接收方地址、交易payload、签名等等各类信息,交易哈希通常就是整合所有交易信息,使用哈希算法计算得到,哈希算法有非常多的选择。本实施例中,将时间信息嵌入在交易哈希中,在一具体实施方式中,第一个字节为版本信息,后续八个字节填充时间戳信息,最后连接上哈希算法计算得到的交易哈希值,即可组成一个交易哈希索引。Specifically, according to the information in the transaction, including its time information, the transaction hash is calculated. The transaction usually contains various types of information such as the address of the initiator, the address of the receiver, the transaction payload, and the signature. The transaction hash usually integrates all transactions. Information, calculated using a hash algorithm, there are many options for hash algorithms. In this embodiment, the time information is embedded in the transaction hash. In a specific implementation, the first byte is the version information, the subsequent eight bytes are filled with the timestamp information, and finally connected to the hash algorithm calculated by the hash algorithm. The transaction hash value can form a transaction hash index.
例如,假设当前版本为0,当前时间戳为1603975389074698000,以十六进制表示,交易哈希索引的第一个字节即为0x00,后八个字节为0x1642771e3e442f00,即前九个字节为0x001642771e3e442f00,后面再缀上旧哈希计算方式得到的哈希值。在存储时,根据此时间戳,以及上述交易索引存储至索引数据库流程,插入数据库。For example, assuming the current version is 0 and the current timestamp is 1603975389074698000, expressed in hexadecimal, the first byte of the transaction hash index is 0x00, and the last eight bytes are 0x1642771e3e442f00, that is, the first nine bytes are 0x001642771e3e442f00, followed by the hash value obtained by the old hash calculation method. During storage, according to this timestamp and the above-mentioned transaction index storage to index database process, it is inserted into the database.
需要说明的是,版本信息的设定、时间戳信息的设定、哈希所使用的位数都可以根据具体场景做改变,此处不做具体限定。It should be noted that the setting of the version information, the setting of the timestamp information, and the number of bits used for the hash can all be changed according to specific scenarios, which are not specifically limited here.
本实施例中,当区块数量增长至超过八字节的时候,将版本信息增加,可以将区块字段延长至十六个字节。这样的设计保证了后续兼容性的所有问题。In this embodiment, when the number of blocks increases to more than eight bytes, the version information is increased, and the block field can be extended to sixteen bytes. Such a design guarantees all problems of subsequent compatibility.
本实施例中,通过版本信息、时间戳信息和交易哈希值,生成交易哈希索引,将用于进行索引的版本信息和时间戳信息写入到交易哈希索引,而无需通过通过磁盘读写的方式获取索引号,减少磁盘读写的次数,提高数据读写效率,采用时间戳信息作为索引,使得交易索引的随机写优化为顺序写,保证数据库的高性能读写,提高数据读写效率。In this embodiment, a transaction hash index is generated by using version information, timestamp information, and transaction hash value, and the version information and timestamp information used for indexing are written into the transaction hash index, without the need to read through the disk. The index number is obtained by writing, which reduces the number of disk reads and writes, and improves the efficiency of data read and write. Timestamp information is used as an index to optimize the random write of transaction index to sequential write, which ensures high-performance read and write of the database and improves data read and write. efficiency.
在本实施例的一些可选的实现方式中,步骤S202中,基于时间戳信息,从交易索引存储数据库中获取与时间戳信息匹配的子数据库,作为目标数据库包括:In some optional implementations of this embodiment, in step S202, based on the timestamp information, a sub-database matching the timestamp information is obtained from the transaction index storage database, and the target database includes:
获取子数据库对应的固定时间区间;Get the fixed time interval corresponding to the sub-database;
通过遍历匹配,确定时间戳信息的固定时间区间,作为目标时间区间;By traversing the matching, the fixed time interval of the timestamp information is determined as the target time interval;
将目标时间区间对应的子数据库,作为目标数据库。The sub-database corresponding to the target time interval is used as the target database.
具体地,每个子数据库分别用于存储特定时间范围内的交易索引信息,记录该数据库中存储交易最小的时间戳与最大的时间戳,获取每个子数据库对应的固定时间区间,并与时间戳信息中的时间点进行匹配,若固定时间区间的最小的时间戳与最大的时间戳之间,包含的时间戳信息中的时间点,则将该固定时间区间作为目标时间区间,将目标时间区间对应的子数据库,作为目标数据库,后续采用该目标数据库进行该交易数据的读写。Specifically, each sub-database is used to store transaction index information within a specific time range, record the minimum timestamp and the maximum timestamp of the transaction stored in the database, obtain the fixed time interval corresponding to each sub-database, and compare the timestamp information with the timestamp information. If there is a time point in the timestamp information contained between the smallest timestamp and the largest timestamp in the fixed time interval, the fixed time interval is used as the target time interval, and the target time interval corresponds to The sub-database is used as the target database, and the target database is subsequently used to read and write the transaction data.
本实施例中,通过时间戳信息与每个子数据库对应的的固定时间区间进行匹配,确定目标数据库,实现目标数据库的快速确定,有利于提高后续数据读写效率和数据查询效率。In this embodiment, the target database is determined by matching the timestamp information with the fixed time interval corresponding to each sub-database, so as to realize the rapid determination of the target database, which is beneficial to improve the efficiency of subsequent data reading and writing and data query efficiency.
在本实施例的一些可选的实现方式中,子数据库预设存储上限,步骤S203中,将Key和Value作为键值对,存储至目标数据库包括:In some optional implementations of this embodiment, the sub-database presets a storage upper limit, and in step S203, using Key and Value as a key-value pair, and storing them in the target database includes:
判断目标数据库中存储数据是否达到预设存储上限,得到判断结果;Judging whether the stored data in the target database reaches the preset storage upper limit, and obtaining the judgment result;
若判断结果为目标数据库中存储数据达到预设存储上限,则新建与目标数据库的固定时间区间相同的数据库,并将键值对存储至新建数据库。If the judgment result is that the data stored in the target database reaches the preset storage upper limit, a new database with the same fixed time interval as the target database is created, and the key-value pair is stored in the newly created database.
其中,预设存储上限可根据实际应用场景需求进行设定,例如,设定为2万条等,此处不做具体限定。Wherein, the preset storage upper limit may be set according to actual application scenario requirements, for example, set to 20,000, etc., which is not specifically limited here.
应理解,对子数据库预设存储上限,限制了每一子数据库大小,在后续进行数据读写时,确保子数据库性能稳定,有利于提高数据读写效率。It should be understood that the preset storage upper limit for the sub-databases limits the size of each sub-database, and ensures stable performance of the sub-databases during subsequent data reading and writing, which is conducive to improving data reading and writing efficiency.
本实施例中,每个子数据库预设存储上限,在目标数据库存储数据达到预设存储上限时,新建与目标数据库的固定时间区间相同的数据库,进行键值对的存储,由于限制了每一子数据库大小,因此读写性能稳定,提高数据读写效率。In this embodiment, each sub-database presets a storage upper limit, and when the target database stores data reaches the preset storage upper limit, a new database with the same fixed time interval as the target database is created to store key-value pairs. Since each sub-database is limited The size of the database, so the read and write performance is stable, and the data read and write efficiency is improved.
在本实施例的一些可选的实现方式中,该区块链索引的存储方法还包括:In some optional implementations of this embodiment, the storage method of the blockchain index further includes:
若接收到交易哈希查询请求,则对交易哈希查询请求进行解析,得到目标时间戳信息;If a transaction hash query request is received, the transaction hash query request is parsed to obtain target timestamp information;
基于目标时间戳信息,确定待查询的子数据库;Determine the sub-database to be queried based on the target timestamp information;
通过键值对查询的方式,从待查询的子数据库中,获取目标区块号;Obtain the target block number from the sub-database to be queried by means of key-value pair query;
根据磁盘读取的方式,获取目标区块号对应的区块,作为目标区块;According to the method of disk reading, the block corresponding to the target block number is obtained as the target block;
遍历目标区块,获取交易哈希查询请求对应的交易信息。Traverse the target block to obtain the transaction information corresponding to the transaction hash query request.
本实施例中,每个子数据库存储固定时间区间的交易哈希索引,基于目标时间戳信息,确定待查询的子数据库,是通过每个子数据库对应的固定时间区间来进行匹配,将包含目标时间戳信息中时间点的子数据库,确定为存储有目标时间戳信息对应的交易哈希索引的子数据库,进而作为待查询的子数据库。In this embodiment, each sub-database stores a transaction hash index of a fixed time interval, and the sub-database to be queried is determined based on the target timestamp information. Matching is performed through the fixed time interval corresponding to each sub-database, and the target timestamp is included The sub-database of the time point in the information is determined to be the sub-database that stores the transaction hash index corresponding to the target timestamp information, and is further used as the sub-database to be queried.
本实施例中,在接收到交易哈希查询请求时,通过对交易哈希查询请求进行解析,得到目标时间戳信息,再基于目标时间戳信息,确定待查询的子数据库,子数据按照时间区间进行顺序存储,有利于提高确定待查询的子数据库的效率,同时通过键值对查询的方式,从待查询的子数据库中,查询获取目标区块号,再根据磁盘读取的方式,获取目标区块号对应的区块,作为目标区块,进而遍历目标区块,获取交易哈希查询请求对应的交易信息,减少磁盘读取的次数,提高交易信息查询的效率。In this embodiment, when a transaction hash query request is received, the target timestamp information is obtained by parsing the transaction hash query request, and then based on the target timestamp information, the sub-database to be queried is determined, and the sub-data is sorted by time interval. Sequential storage is beneficial to improve the efficiency of determining the sub-database to be queried. At the same time, by querying key-value pairs, the target block number is obtained from the sub-database to be queried, and then the target block number is obtained according to the method of disk reading. The block corresponding to the block number is used as the target block, and then traverses the target block to obtain the transaction information corresponding to the transaction hash query request, reducing the number of disk reads and improving the efficiency of transaction information query.
应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。It should be understood that the size of the sequence numbers of the steps in the above embodiments does not mean the sequence of execution, and the execution sequence of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
图3示出与上述实施例区块链索引的存储方法一一对应的区块链索引的存储装置的原理框图。如图3所示,该区块链索引的存储装置包括构建模块31、匹配模块32和存储模块33。各功能模块详细说明如下:FIG. 3 shows a schematic block diagram of a storage device of a blockchain index corresponding to the storage method of a blockchain index in the above-mentioned embodiment. As shown in FIG. 3 , the storage device of the blockchain index includes a building module 31 , a matching module 32 and a storage module 33 . The detailed description of each functional module is as follows:
构建模块31,用于构建交易哈希索引,交易哈希索引包括版本信息、时间戳信息和交易哈希值;The building module 31 is used to build a transaction hash index, and the transaction hash index includes version information, timestamp information and transaction hash value;
匹配模块32,用于基于时间戳信息,从交易索引存储数据库中获取与时间戳信息匹配的子数据库,作为目标数据库,其中,交易索引存储数据库包含至少两个子数据库,每个子数据库用于存储固定时间区间的交易哈希索引;The matching module 32 is configured to obtain, based on the timestamp information, a sub-database matching the timestamp information from the transaction index storage database as a target database, wherein the transaction index storage database includes at least two sub-databases, and each sub-database is used to store fixed data. The transaction hash index of the time interval;
存储模块33,用于将交易哈希索引作为Key,将交易哈希索引对应交易的区块号作为Value,并将Key和Value作为键值对,存储至目标数据库。The storage module 33 is configured to use the transaction hash index as the Key, use the block number of the transaction corresponding to the transaction hash index as the Value, and store the Key and Value as a key-value pair in the target database.
可选地,构建模块31包括:Optionally, building block 31 includes:
哈希值计算单元,用于在区块链接收到交易信息时,根据交易信息,计算交易哈希值,并获取交易信息中包含的交易时间,生成时间戳信息;The hash value calculation unit is used to calculate the transaction hash value according to the transaction information when the block link receives the transaction information, obtain the transaction time included in the transaction information, and generate timestamp information;
版本确定单元,用于基于时间戳信息,确定版本信息;a version determination unit, configured to determine the version information based on the timestamp information;
索引生成单元,用于根据版本信息、时间戳信息和交易哈希值,生成交易哈希索引。The index generation unit is used to generate the transaction hash index according to the version information, the timestamp information and the transaction hash value.
可选地,匹配模块32包括:Optionally, the matching module 32 includes:
区间范围获取单元,用于获取子数据库对应的固定时间区间;The interval range obtaining unit is used to obtain the fixed time interval corresponding to the sub-database;
目前区间确定单元,用于通过遍历匹配,确定时间戳信息所属的固定时间区间,作为目标时间区间;The current interval determination unit is used to determine the fixed time interval to which the timestamp information belongs by traversing and matching, as the target time interval;
目标数据库确定单元,用于将目标时间区间对应的子数据库,作为目标数据库。The target database determination unit is used for taking the sub-database corresponding to the target time interval as the target database.
可选地,子数据库预设存储上限,存储模块33包括:Optionally, the sub-database presets a storage upper limit, and the storage module 33 includes:
上限判断单元,用于判断目标数据库中存储数据是否达到预设存储上限,得到判断结果;an upper limit judgment unit, configured to judge whether the stored data in the target database reaches a preset storage upper limit, and obtain a judgment result;
新建数据库单元,用于若判断结果为目标数据库中存储数据达到预设存储上限,则新建与目标数据库的固定时间区间相同的数据库,并将键值对存储至新建数据库。A new database unit is used to create a new database with the same fixed time interval as the target database if the judgment result is that the data stored in the target database reaches the preset storage upper limit, and store the key-value pair in the new database.
可选地,的区块链索引存储装置还包括:Optionally, the blockchain index storage device further includes:
请求解析模块,用于若接收到交易哈希查询请求,则对交易哈希查询请求进行解析,得到目标时间戳信息;The request parsing module is used to parse the transaction hash query request to obtain target timestamp information if a transaction hash query request is received;
子数据库确定模块,用于基于目标时间戳信息,确定待查询的子数据库;a sub-database determination module, used for determining the sub-database to be queried based on the target timestamp information;
区块号获取模块,用于通过键值对查询的方式,从待查询的子数据库中,获取目标区块号;The block number acquisition module is used to obtain the target block number from the sub-database to be queried by means of key-value pair query;
区块确定模块,用于根据磁盘读取的方式,获取目标区块号对应的区块,作为目标区块;The block determination module is used to obtain the block corresponding to the target block number as the target block according to the method of disk reading;
遍历模块,用于遍历目标区块,获取交易哈希查询请求对应的交易信息。The traversal module is used to traverse the target block and obtain the transaction information corresponding to the transaction hash query request.
关于区块链索引的存储装置的具体限定可以参见上文中对于区块链索引的存储方法的限定,在此不再赘述。上述区块链索引的存储装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。For the specific limitation of the storage device of the blockchain index, please refer to the limitation on the storage method of the blockchain index above, which will not be repeated here. Each module in the above-mentioned storage device of the blockchain index can be implemented in whole or in part by software, hardware and combinations thereof. The above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
为解决上述技术问题,本申请实施例还提供计算机设备。具体请参阅图4,图4为本实施例计算机设备基本结构框图。To solve the above technical problems, the embodiments of the present application also provide computer equipment. Please refer to FIG. 4 for details. FIG. 4 is a block diagram of a basic structure of a computer device according to this embodiment.
所述计算机设备4包括通过系统总线相互通信连接存储器41、处理器42、网络接口43。需要指出的是,图中仅示出了具有组件连接存储器41、处理器42、网络接口43的计算机设备4,但是应理解的是,并不要求实施所有示出的组件,可以替代的实施更多或者更少的组件。其中,本技术领域技术人员可以理解,这里的计算机设备是一种能够按照事先设定或存储的指令,自动进行数值计算和/或信息处理的设备,其硬件包括但不限于微处理器、专用集成电路(Application Specific Integrated Circuit,ASIC)、可编程门阵列(Field-Programmable Gate Array,FPGA)、数字处理器 (Digital Signal Processor,DSP)、嵌入式设备等。The computer device 4 includes a memory 41, a processor 42, and a network interface 43 that communicate with each other through a system bus. It should be pointed out that the figure only shows the computer device 4 having the components connected to the memory 41, the processor 42, and the network interface 43, but it should be understood that it is not required to implement all the components shown, and alternative implementations of more more or fewer components. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculation and/or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, special-purpose Integrated circuit (Application Specific Integrated Circuit, ASIC), Programmable Gate Array (Field-Programmable Gate Array, FPGA), Digital Signal Processor (Digital Signal Processor, DSP), embedded devices, etc.
所述计算机设备可以是桌上型计算机、笔记本、掌上电脑及云端服务器等计算设备。所述计算机设备可以与用户通过键盘、鼠标、遥控器、触摸板或声控设备等方式进行人机交互。The computer equipment may be a desktop computer, a notebook computer, a palmtop computer, a cloud server and other computing equipment. The computer device can perform human-computer interaction with the user through a keyboard, a mouse, a remote control, a touch pad or a voice control device.
所述存储器41至少包括一种类型的可读存储介质,所述可读存储介质可以是非易失性,也可以是易失性,包括闪存、硬盘、多媒体卡、卡型存储器(例如,SD或D界面显示存储器等)、随机访问存储器(RAM)、静态随机访问存储器(SRAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、可编程只读存储器(PROM)、磁性存储器、磁盘、光盘等。在一些实施例中,所述存储器41可以是所述计算机设备4的内部存储单元,例如该计算机设备4的硬盘或内存。在另一些实施例中,所述存储器41也可以是所述计算机设备4的外部存储设备,例如该计算机设备4上配备的插接式硬盘,智能存储卡(Smart Media Card, SMC),安全数字(Secure Digital, SD)卡,闪存卡(Flash Card)等。当然,所述存储器41还可以既包括所述计算机设备4的内部存储单元也包括其外部存储设备。本实施例中,所述存储器41通常用于存储安装于所述计算机设备4的操作系统和各类应用软件,例如区块链索引的存储的计算机可读指令等。此外,所述存储器41还可以用于暂时地存储已经输出或者将要输出的各类数据。The memory 41 includes at least one type of readable storage medium, which may be non-volatile or volatile, including flash memory, hard disk, multimedia card, card-type storage (for example, SD or D interface display memory, etc.), random access memory (RAM), static random access memory (SRAM), read only memory (ROM), electrically erasable programmable read only memory (EEPROM), programmable read only memory (PROM) , magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 41 may be an internal storage unit of the computer device 4 , such as a hard disk or a memory of the computer device 4 . In other embodiments, the memory 41 may also be an external storage device of the computer device 4 , such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, flash card (Flash Card), etc. Of course, the memory 41 may also include both the internal storage unit of the computer device 4 and its external storage device. In this embodiment, the memory 41 is generally used to store the operating system and various application software installed on the computer device 4, such as computer-readable instructions for storing a blockchain index. In addition, the memory 41 can also be used to temporarily store various types of data that have been output or will be output.
所述处理器42在一些实施例中可以是中央处理器(Central Processing Unit,CPU)、控制器、微控制器、微处理器、或其他数据处理芯片。该处理器42通常用于控制所述计算机设备4的总体操作。本实施例中,所述处理器42用于运行所述存储器41中存储的计算机可读指令处理数据,例如运行区块链索引的存储的计算机可读指令。The processor 42 may be a central processing unit (Central Processing Unit) in some embodiments. Processing Unit, CPU), controller, microcontroller, microprocessor, or other data processing chip. This processor 42 is typically used to control the overall operation of the computer device 4 . In this embodiment, the processor 42 is configured to run the computer-readable instructions stored in the memory 41 to process data, for example, run the stored computer-readable instructions of the blockchain index.
所述网络接口43可包括无线网络接口或有线网络接口,该网络接口43通常用于在所述计算机设备4与其他电子设备之间建立通信连接。The network interface 43 may include a wireless network interface or a wired network interface, and the network interface 43 is generally used to establish a communication connection between the computer device 4 and other electronic devices.
本申请还提供了另一种实施方式,即提供一种计算机可读存储介质,所述计算机可读存储介质存储有界面显示程序,所述界面显示程序可被至少一个处理器执行,以使所述至少一个处理器执行如上述的区块链索引的存储方法的步骤。The present application also provides another implementation manner, which is to provide a computer-readable storage medium, where an interface display program is stored in the computer-readable storage medium, and the interface display program can be executed by at least one processor, so that all The at least one processor executes the steps of the method for storing the blockchain index as described above.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本申请各个实施例所述的方法。From the description of the above embodiments, those skilled in the art can clearly understand that the method of the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is better implementation. Based on this understanding, the technical solution of the present application can be embodied in the form of a software product in essence or the part that contributes to the prior art, and the computer software product is stored in a storage medium (such as ROM/RAM, magnetic disk, CD-ROM), including several instructions to make a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) execute the methods described in the various embodiments of this application.
显然,以上所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例,附图中给出了本申请的较佳实施例,但并不限制本申请的专利范围。本申请可以以许多不同的形式来实现,相反地,提供这些实施例的目的是使对本申请的公开内容的理解更加透彻全面。尽管参照前述实施例对本申请进行了详细的说明,对于本领域的技术人员来而言,其依然可以对前述各具体实施方式所记载的技术方案进行修改,或者对其中部分技术特征进行等效替换。凡是利用本申请说明书及附图内容所做的等效结构,直接或间接运用在其他相关的技术领域,均同理在本申请专利保护范围之内。Obviously, the above-described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The accompanying drawings show the preferred embodiments of the present application, but do not limit the scope of the patent of the present application. This application may be embodied in many different forms, rather these embodiments are provided so that a thorough and complete understanding of the disclosure of this application is provided. Although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing specific embodiments, or perform equivalent replacements for some of the technical features. . Any equivalent structure made by using the contents of the description and drawings of the present application, which is directly or indirectly used in other related technical fields, is also within the scope of protection of the patent of the present application.

Claims (20)

  1. 一种区块链索引的存储方法,其特征在于,所述区块链索引的存储方法包括:A storage method for a blockchain index, characterized in that the storage method for the blockchain index comprises:
    构建交易哈希索引,所述交易哈希索引包括版本信息、时间戳信息和交易哈希值;constructing a transaction hash index, where the transaction hash index includes version information, timestamp information and transaction hash value;
    基于所述时间戳信息,从交易索引存储数据库中获取与所述时间戳信息匹配的子数据库,作为目标数据库,其中,所述交易索引存储数据库包含至少两个子数据库,每个所述子数据库用于存储固定时间区间的交易哈希索引;Based on the timestamp information, a sub-database matching the timestamp information is obtained from the transaction index storage database as a target database, wherein the transaction index storage database includes at least two sub-databases, and each sub-database uses A transaction hash index for storing fixed time intervals;
    将所述交易哈希索引作为Key,将所述交易哈希索引对应交易的区块号作为Value,并将所述Key和所述Value作为键值对,存储至所述目标数据库。The transaction hash index is used as the Key, the block number of the transaction corresponding to the transaction hash index is used as the Value, and the Key and the Value are used as a key-value pair, and are stored in the target database.
  2. 如权利要求1所述的区块链索引的存储方法,其特征在于,所述构建交易哈希索引包括:The method for storing a blockchain index according to claim 1, wherein the constructing the transaction hash index comprises:
    在区块链接收到交易信息时,根据所述交易信息,计算交易哈希值,并获取所述交易信息中包含的交易时间,生成时间戳信息;When the block link receives the transaction information, according to the transaction information, calculate the transaction hash value, and obtain the transaction time included in the transaction information, and generate timestamp information;
    基于所述时间戳信息,确定版本信息;determining version information based on the timestamp information;
    根据所述版本信息、所述时间戳信息和所述交易哈希值,生成交易哈希索引。A transaction hash index is generated according to the version information, the timestamp information and the transaction hash value.
  3. 如权利要求1所述的区块链索引的存储方法,其特征在于,所述基于所述时间戳信息,从交易索引存储数据库中获取与所述时间戳信息匹配的子数据库,作为目标数据库包括:The method for storing a blockchain index according to claim 1, wherein the sub-database that matches the timestamp information is obtained from the transaction index storage database based on the timestamp information, and the target database includes :
    获取所述子数据库对应的固定时间区间;obtaining a fixed time interval corresponding to the sub-database;
    通过遍历匹配,确定所述时间戳信息所属的固定时间区间,作为目标时间区间;Determine the fixed time interval to which the timestamp information belongs by traversing the matching, as the target time interval;
    将所述目标时间区间对应的子数据库,作为所述目标数据库。The sub-database corresponding to the target time interval is used as the target database.
  4. 如权利要求1所述的区块链索引的存储方法,其特征在于,所述子数据库预设存储上限,所述将所述Key和所述Value作为键值对,存储至所述目标数据库包括:The method for storing a blockchain index according to claim 1, wherein the sub-database presets a storage upper limit, and storing the Key and the Value as a key-value pair in the target database comprises: :
    判断所述目标数据库中存储数据是否达到所述预设存储上限,得到判断结果;Judging whether the data stored in the target database reaches the preset storage upper limit, and obtaining a judgment result;
    若所述判断结果为所述目标数据库中存储数据达到所述预设存储上限,则新建与所述目标数据库的固定时间区间相同的数据库,并将所述键值对存储至新建数据库。If the judgment result is that the data stored in the target database reaches the preset storage upper limit, a new database with the same fixed time interval as the target database is newly created, and the key-value pair is stored in the newly created database.
  5. 如权利要求1所述的区块链索引的存储方法,其特征在于,所述区块链索引存储方法还包括:The storage method of the blockchain index according to claim 1, wherein the storage method of the blockchain index further comprises:
    若接收到交易哈希查询请求,则对所述交易哈希查询请求进行解析,得到目标时间戳信息;If a transaction hash query request is received, the transaction hash query request is parsed to obtain target timestamp information;
    基于所述目标时间戳信息,确定待查询的子数据库;Determine the sub-database to be queried based on the target timestamp information;
    通过键值对查询的方式,从所述待查询的子数据库中,获取目标区块号;Obtain the target block number from the sub-database to be queried by means of a key-value pair query;
    根据磁盘读取的方式,获取所述目标区块号对应的区块,作为目标区块;According to the method of disk reading, the block corresponding to the target block number is obtained as the target block;
    遍历所述目标区块,获取所述交易哈希查询请求对应的交易信息。Traverse the target block to obtain transaction information corresponding to the transaction hash query request.
  6. 如权利要求2所述的区块链索引的存储方法,其特征在于,所述区块链索引存储方法还包括:The storage method of the blockchain index according to claim 2, wherein the storage method of the blockchain index further comprises:
    若接收到交易哈希查询请求,则对所述交易哈希查询请求进行解析,得到目标时间戳信息;If a transaction hash query request is received, the transaction hash query request is parsed to obtain target timestamp information;
    基于所述目标时间戳信息,确定待查询的子数据库;Determine the sub-database to be queried based on the target timestamp information;
    通过键值对查询的方式,从所述待查询的子数据库中,获取目标区块号;Obtain the target block number from the sub-database to be queried by means of a key-value pair query;
    根据磁盘读取的方式,获取所述目标区块号对应的区块,作为目标区块;According to the method of disk reading, the block corresponding to the target block number is obtained as the target block;
    遍历所述目标区块,获取所述交易哈希查询请求对应的交易信息。Traverse the target block to obtain transaction information corresponding to the transaction hash query request.
  7. 如权利要求3所述的区块链索引的存储方法,其特征在于,所述区块链索引存储方法还包括:The storage method of the blockchain index according to claim 3, wherein the storage method of the blockchain index further comprises:
    若接收到交易哈希查询请求,则对所述交易哈希查询请求进行解析,得到目标时间戳信息;If a transaction hash query request is received, the transaction hash query request is parsed to obtain target timestamp information;
    基于所述目标时间戳信息,确定待查询的子数据库;Determine the sub-database to be queried based on the target timestamp information;
    通过键值对查询的方式,从所述待查询的子数据库中,获取目标区块号;Obtain the target block number from the sub-database to be queried by means of a key-value pair query;
    根据磁盘读取的方式,获取所述目标区块号对应的区块,作为目标区块;According to the method of disk reading, the block corresponding to the target block number is obtained as the target block;
    遍历所述目标区块,获取所述交易哈希查询请求对应的交易信息。Traverse the target block to obtain transaction information corresponding to the transaction hash query request.
  8. 如权利要求4所述的区块链索引的存储方法,其特征在于,所述区块链索引存储方法还包括:The storage method of the blockchain index according to claim 4, wherein the storage method of the blockchain index further comprises:
    若接收到交易哈希查询请求,则对所述交易哈希查询请求进行解析,得到目标时间戳信息;If a transaction hash query request is received, the transaction hash query request is parsed to obtain target timestamp information;
    基于所述目标时间戳信息,确定待查询的子数据库;Determine the sub-database to be queried based on the target timestamp information;
    通过键值对查询的方式,从所述待查询的子数据库中,获取目标区块号;Obtain the target block number from the sub-database to be queried by means of a key-value pair query;
    根据磁盘读取的方式,获取所述目标区块号对应的区块,作为目标区块;According to the method of disk reading, the block corresponding to the target block number is obtained as the target block;
    遍历所述目标区块,获取所述交易哈希查询请求对应的交易信息。Traverse the target block to obtain transaction information corresponding to the transaction hash query request.
  9. 一种区块链索引的存储装置,其特征在于,所述区块链索引的存储装置包括:A storage device for a blockchain index, characterized in that the storage device for the blockchain index comprises:
    构建模块,用于构建交易哈希索引,所述交易哈希索引包括版本信息、时间戳信息和交易哈希值;a building module for building a transaction hash index, the transaction hash index including version information, timestamp information and transaction hash value;
    匹配模块,用于基于所述时间戳信息,从交易索引存储数据库中获取与所述时间戳信息匹配的子数据库,作为目标数据库,其中,所述交易索引存储数据库包含至少两个子数据库,每个所述子数据库用于存储固定时间区间的交易哈希索引;The matching module is configured to obtain, based on the timestamp information, a sub-database matching the timestamp information from the transaction index storage database as a target database, wherein the transaction index storage database includes at least two sub-databases, each of which is a sub-database. The sub-database is used to store the transaction hash index of the fixed time interval;
    存储模块,用于将所述交易哈希索引作为Key,将所述交易哈希索引对应交易的区块号作为Value,并将所述Key和所述Value作为键值对,存储至所述目标数据库。A storage module, configured to use the transaction hash index as a key, use the block number of the transaction corresponding to the transaction hash index as a value, and store the key and the value as a key-value pair in the target database.
  10. 如权利要求9所述的区块链索引的存储装置,其特征在于,所述构建模块包括:The storage device for a blockchain index according to claim 9, wherein the building module comprises:
    哈希值计算单元,用于在区块链接收到交易信息时,根据所述交易信息,计算交易哈希值,并获取所述交易信息中包含的交易时间,生成时间戳信息;a hash value calculation unit, configured to calculate the transaction hash value according to the transaction information when the block link receives the transaction information, and obtain the transaction time included in the transaction information, and generate timestamp information;
    版本确定单元,用于基于所述时间戳信息,确定版本信息;a version determination unit, configured to determine version information based on the timestamp information;
    索引生成单元,用于根据所述版本信息、所述时间戳信息和所述交易哈希值,生成交易哈希索引。an index generating unit, configured to generate a transaction hash index according to the version information, the timestamp information and the transaction hash value.
  11. 如权利要求9所述的区块链索引的存储装置,其特征在于,所述匹配模块包括:The storage device for a blockchain index according to claim 9, wherein the matching module comprises:
    区间范围获取单元,用于获取所述子数据库对应的固定时间区间;an interval range obtaining unit, used to obtain a fixed time interval corresponding to the sub-database;
    目前区间确定单元,用于通过遍历匹配,确定所述时间戳信息所属的固定时间区间,作为目标时间区间;The current interval determination unit is used to determine the fixed time interval to which the timestamp information belongs by traversing and matching, as the target time interval;
    目标数据库确定单元,用于将所述目标时间区间对应的子数据库,作为所述目标数据库。The target database determination unit is configured to use the sub-database corresponding to the target time interval as the target database.
  12. 一种计算机设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机可读指令,其特征在于,所述处理器执行所述计算机可读指令时实现如下区块链索引的存储方法:A computer device, comprising a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, wherein the processor implements the following when executing the computer-readable instructions Storage method of blockchain index:
    构建交易哈希索引,所述交易哈希索引包括版本信息、时间戳信息和交易哈希值;constructing a transaction hash index, where the transaction hash index includes version information, timestamp information and transaction hash value;
    基于所述时间戳信息,从交易索引存储数据库中获取与所述时间戳信息匹配的子数据库,作为目标数据库,其中,所述交易索引存储数据库包含至少两个子数据库,每个所述子数据库用于存储固定时间区间的交易哈希索引;Based on the timestamp information, a sub-database matching the timestamp information is obtained from the transaction index storage database as a target database, wherein the transaction index storage database includes at least two sub-databases, and each sub-database uses A transaction hash index for storing fixed time intervals;
    将所述交易哈希索引作为Key,将所述交易哈希索引对应交易的区块号作为Value,并将所述Key和所述Value作为键值对,存储至所述目标数据库。The transaction hash index is used as the Key, the block number of the transaction corresponding to the transaction hash index is used as the Value, and the Key and the Value are used as a key-value pair, and are stored in the target database.
  13. 如权利要求12所述的计算机设备,其特征在于,所述构建交易哈希索引包括:The computer device of claim 12, wherein the constructing the transaction hash index comprises:
    在区块链接收到交易信息时,根据所述交易信息,计算交易哈希值,并获取所述交易信息中包含的交易时间,生成时间戳信息;When the block link receives the transaction information, according to the transaction information, calculate the transaction hash value, and obtain the transaction time included in the transaction information, and generate timestamp information;
    基于所述时间戳信息,确定版本信息;determining version information based on the timestamp information;
    根据所述版本信息、所述时间戳信息和所述交易哈希值,生成交易哈希索引。A transaction hash index is generated according to the version information, the timestamp information and the transaction hash value.
  14. 如权利要求12所述的计算机设备,其特征在于,所述基于所述时间戳信息,从交易索引存储数据库中获取与所述时间戳信息匹配的子数据库,作为目标数据库包括:The computer device according to claim 12, wherein, based on the time stamp information, the sub-database that matches the time stamp information is obtained from the transaction index storage database, and the target database comprises:
    获取所述子数据库对应的固定时间区间;obtaining a fixed time interval corresponding to the sub-database;
    通过遍历匹配,确定所述时间戳信息所属的固定时间区间,作为目标时间区间;Determine the fixed time interval to which the timestamp information belongs by traversing the matching, as the target time interval;
    将所述目标时间区间对应的子数据库,作为所述目标数据库。The sub-database corresponding to the target time interval is used as the target database.
  15. 如权利要求12所述的计算机设备,其特征在于,所述子数据库预设存储上限,所述将所述Key和所述Value作为键值对,存储至所述目标数据库包括:The computer device according to claim 12, wherein the sub-database presets a storage upper limit, and storing the Key and the Value as a key-value pair in the target database comprises:
    判断所述目标数据库中存储数据是否达到所述预设存储上限,得到判断结果;Judging whether the data stored in the target database reaches the preset storage upper limit, and obtaining a judgment result;
    若所述判断结果为所述目标数据库中存储数据达到所述预设存储上限,则新建与所述目标数据库的固定时间区间相同的数据库,并将所述键值对存储至新建数据库。If the judgment result is that the data stored in the target database reaches the preset storage upper limit, a new database with the same fixed time interval as the target database is newly created, and the key-value pair is stored in the newly created database.
  16. 如权利要求12所述的计算机设备,其特征在于,所述处理器执行所述计算机可读指令时还实现如下区块链索引的存储方法:The computer device according to claim 12, wherein when the processor executes the computer-readable instructions, the processor further implements the following storage method of the blockchain index:
    若接收到交易哈希查询请求,则对所述交易哈希查询请求进行解析,得到目标时间戳信息;If a transaction hash query request is received, the transaction hash query request is parsed to obtain target timestamp information;
    基于所述目标时间戳信息,确定待查询的子数据库;Determine the sub-database to be queried based on the target timestamp information;
    通过键值对查询的方式,从所述待查询的子数据库中,获取目标区块号;Obtain the target block number from the sub-database to be queried by means of a key-value pair query;
    根据磁盘读取的方式,获取所述目标区块号对应的区块,作为目标区块;According to the method of disk reading, the block corresponding to the target block number is obtained as the target block;
    遍历所述目标区块,获取所述交易哈希查询请求对应的交易信息。Traverse the target block to obtain transaction information corresponding to the transaction hash query request.
  17. 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机可读指令,其特征在于,所述计算机可读指令被处理器执行时实现如下区块链索引的存储方法:A computer-readable storage medium storing computer-readable instructions, characterized in that, when the computer-readable instructions are executed by a processor, the following storage method for a blockchain index is implemented:
    构建交易哈希索引,所述交易哈希索引包括版本信息、时间戳信息和交易哈希值;constructing a transaction hash index, where the transaction hash index includes version information, timestamp information and transaction hash value;
    基于所述时间戳信息,从交易索引存储数据库中获取与所述时间戳信息匹配的子数据库,作为目标数据库,其中,所述交易索引存储数据库包含至少两个子数据库,每个所述子数据库用于存储固定时间区间的交易哈希索引;Based on the timestamp information, a sub-database matching the timestamp information is obtained from the transaction index storage database as a target database, wherein the transaction index storage database includes at least two sub-databases, and each sub-database uses A transaction hash index for storing fixed time intervals;
    将所述交易哈希索引作为Key,将所述交易哈希索引对应交易的区块号作为Value,并将所述Key和所述Value作为键值对,存储至所述目标数据库。The transaction hash index is used as the Key, the block number of the transaction corresponding to the transaction hash index is used as the Value, and the Key and the Value are used as a key-value pair, and are stored in the target database.
  18. 如权利要求17所述的计算机可读存储介质,其特征在于,所述构建交易哈希索引包括:The computer-readable storage medium of claim 17, wherein the constructing the transaction hash index comprises:
    在区块链接收到交易信息时,根据所述交易信息,计算交易哈希值,并获取所述交易信息中包含的交易时间,生成时间戳信息;When the block link receives the transaction information, according to the transaction information, calculate the transaction hash value, and obtain the transaction time included in the transaction information, and generate timestamp information;
    基于所述时间戳信息,确定版本信息;determining version information based on the timestamp information;
    根据所述版本信息、所述时间戳信息和所述交易哈希值,生成交易哈希索引。A transaction hash index is generated according to the version information, the timestamp information and the transaction hash value.
  19. 如权利要求17所述的计算机可读存储介质,其特征在于,所述基于所述时间戳信息,从交易索引存储数据库中获取与所述时间戳信息匹配的子数据库,作为目标数据库包括: The computer-readable storage medium according to claim 17, wherein, based on the time stamp information, the sub-database that matches the time stamp information is obtained from the transaction index storage database, and the target database comprises:
    获取所述子数据库对应的固定时间区间;obtaining a fixed time interval corresponding to the sub-database;
    通过遍历匹配,确定所述时间戳信息所属的固定时间区间,作为目标时间区间;Determine the fixed time interval to which the timestamp information belongs by traversing the matching, as the target time interval;
    将所述目标时间区间对应的子数据库,作为所述目标数据库。The sub-database corresponding to the target time interval is used as the target database.
  20. 如权利要求17所述的计算机可读存储介质,其特征在于,所述子数据库预设存储上限,所述将所述Key和所述Value作为键值对,存储至所述目标数据库包括:The computer-readable storage medium according to claim 17, wherein the sub-database presets a storage upper limit, and storing the Key and the Value as a key-value pair to the target database comprises:
    判断所述目标数据库中存储数据是否达到所述预设存储上限,得到判断结果;Judging whether the data stored in the target database reaches the preset storage upper limit, and obtaining a judgment result;
    若所述判断结果为所述目标数据库中存储数据达到所述预设存储上限,则新建与所述目标数据库的固定时间区间相同的数据库,并将所述键值对存储至新建数据库。If the judgment result is that the data stored in the target database reaches the preset storage upper limit, a new database with the same fixed time interval as the target database is newly created, and the key-value pair is stored in the newly created database.
      
PCT/CN2021/141698 2020-12-31 2021-12-27 Block chain index storage method and apparatus, computer device and medium WO2022143540A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011640211.3 2020-12-31
CN202011640211.3A CN112765271B (en) 2020-12-31 2020-12-31 Block chain transaction index storage method and device, computer equipment and medium

Publications (1)

Publication Number Publication Date
WO2022143540A1 true WO2022143540A1 (en) 2022-07-07

Family

ID=75698400

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/141698 WO2022143540A1 (en) 2020-12-31 2021-12-27 Block chain index storage method and apparatus, computer device and medium

Country Status (2)

Country Link
CN (1) CN112765271B (en)
WO (1) WO2022143540A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115793992A (en) * 2023-02-07 2023-03-14 天翼云科技有限公司 Data storage method and device, electronic equipment and readable storage medium
CN116842223A (en) * 2023-08-29 2023-10-03 天津鑫宝龙电梯集团有限公司 Working condition data management method, device, equipment and medium
CN117271529A (en) * 2023-11-20 2023-12-22 阿里云计算有限公司 Index processing method, device and storage medium

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112765271B (en) * 2020-12-31 2023-02-07 杭州趣链科技有限公司 Block chain transaction index storage method and device, computer equipment and medium
CN113485949B (en) * 2021-05-28 2023-06-20 浙江毫微米科技有限公司 Data processing method, chip and computer readable storage medium
CN113343292A (en) * 2021-05-28 2021-09-03 网易(杭州)网络有限公司 Transaction number processing method and device, storage medium and computer equipment
CN113282662B (en) * 2021-06-03 2023-11-03 广东辰宜信息科技有限公司 Block information processing method, device, equipment and medium
CN113139019B (en) * 2021-06-18 2022-03-25 智己汽车科技有限公司 Method and device for recording mileage data of vehicle on block chain
CN113836142A (en) * 2021-09-24 2021-12-24 中国农业银行股份有限公司 Data processing method and related equipment
CN113886399A (en) * 2021-10-25 2022-01-04 支付宝(杭州)信息技术有限公司 Index database updating method and device and index database-based retrieval method and device
CN114860730A (en) * 2022-05-17 2022-08-05 北京新五好农业科技有限公司 Land data storage method, system and storage medium based on block chain
CN115099817B (en) * 2022-06-17 2023-03-24 北京中科深智科技有限公司 Efficient block chain transaction verification and query method and system
CN115622774B (en) * 2022-08-08 2024-01-12 付舒丛 Electronic commerce transaction system based on improved particle swarm optimization and supporting data encryption transmission of vector machine

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109189782A (en) * 2018-08-02 2019-01-11 哈尔滨工程大学 A kind of indexing means in block chain commodity transaction inquiry
CN110263014A (en) * 2019-05-15 2019-09-20 广州致链科技有限公司 Block chain storage system and method towards timing type data
CN111949672A (en) * 2020-07-30 2020-11-17 杭州电子科技大学 Block chain storage method for supporting incremental update of Internet-of-things data
CN112765271A (en) * 2020-12-31 2021-05-07 杭州趣链科技有限公司 Block chain transaction index storage method and device, computer equipment and medium

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107273556A (en) * 2017-08-23 2017-10-20 上海点融信息科技有限责任公司 Block chain data index method and equipment
CN110083604B (en) * 2019-04-17 2021-10-08 上海脆皮网络科技有限公司 Data right confirming method and device
CN110689349B (en) * 2019-10-08 2023-07-11 深圳前海微众银行股份有限公司 Transaction hash value storage and searching method and device in blockchain
CN111639080B (en) * 2020-06-01 2021-07-27 腾讯科技(深圳)有限公司 Data processing method and device, node equipment and storage medium
CN111708825B (en) * 2020-06-11 2021-08-24 腾讯科技(深圳)有限公司 Data processing method, device and equipment based on block chain and readable storage medium
CN112148734B (en) * 2020-09-22 2022-07-12 国网浙江省电力有限公司 Transaction data processing method, device, equipment and storage medium based on block chain

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109189782A (en) * 2018-08-02 2019-01-11 哈尔滨工程大学 A kind of indexing means in block chain commodity transaction inquiry
CN110263014A (en) * 2019-05-15 2019-09-20 广州致链科技有限公司 Block chain storage system and method towards timing type data
CN111949672A (en) * 2020-07-30 2020-11-17 杭州电子科技大学 Block chain storage method for supporting incremental update of Internet-of-things data
CN112765271A (en) * 2020-12-31 2021-05-07 杭州趣链科技有限公司 Block chain transaction index storage method and device, computer equipment and medium

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115793992A (en) * 2023-02-07 2023-03-14 天翼云科技有限公司 Data storage method and device, electronic equipment and readable storage medium
CN116842223A (en) * 2023-08-29 2023-10-03 天津鑫宝龙电梯集团有限公司 Working condition data management method, device, equipment and medium
CN116842223B (en) * 2023-08-29 2023-11-10 天津鑫宝龙电梯集团有限公司 Working condition data management method, device, equipment and medium
CN117271529A (en) * 2023-11-20 2023-12-22 阿里云计算有限公司 Index processing method, device and storage medium
CN117271529B (en) * 2023-11-20 2024-03-29 阿里云计算有限公司 Index processing method, device and storage medium

Also Published As

Publication number Publication date
CN112765271A (en) 2021-05-07
CN112765271B (en) 2023-02-07

Similar Documents

Publication Publication Date Title
WO2022143540A1 (en) Block chain index storage method and apparatus, computer device and medium
US9251201B2 (en) Compatibly extending offload token size
WO2022116425A1 (en) Method and system for data lineage analysis, computer device, and storage medium
WO2021103403A1 (en) Blockchain transaction information management method and device, computer device and storage medium
CN107016027A (en) The method and apparatus for realizing business information fast search
US20090327295A1 (en) Maintenance of exo-file system metadata on removable storage device
CN110795499A (en) Cluster data synchronization method, device and equipment based on big data and storage medium
WO2021057164A1 (en) Query method and device for blockchain ledger, and apparatus
WO2020233045A1 (en) Plug-in update method and device, server and computer readable storage medium
KR20210008486A (en) Secure dataset management
US10366081B2 (en) Declarative partitioning for data collection queries
CN115470156A (en) RDMA-based memory use method, system, electronic device and storage medium
CN114780519A (en) DBC file generation method, device, equipment and medium based on CAN communication
CN112765270B (en) Block chain data processing method and device, computer equipment and medium
CN112667636B (en) Index establishing method, device and storage medium
CN103970844A (en) Big data write-in method and device, big data read method and device and big data processing system
CN109783321A (en) Monitoring data management method, device, terminal device
US20220083507A1 (en) Trust chain for official data and documents
WO2023217086A1 (en) Resource file updating method and apparatus, and device and readable storage medium
WO2017177752A1 (en) File storage method and device
CN116842012A (en) Method, device, equipment and storage medium for storing Redis cluster in fragments
WO2024021417A1 (en) Data account creation method and apparatus
US10146791B2 (en) Open file rebalance
WO2020024392A1 (en) Node processing method and apparatus, storage medium and electronic device
CN110297842B (en) Data comparison method, device, terminal and storage medium

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

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

Country of ref document: EP

Kind code of ref document: A1