WO2018161760A1 - Blockchain data storage system and method - Google Patents

Blockchain data storage system and method Download PDF

Info

Publication number
WO2018161760A1
WO2018161760A1 PCT/CN2018/075496 CN2018075496W WO2018161760A1 WO 2018161760 A1 WO2018161760 A1 WO 2018161760A1 CN 2018075496 W CN2018075496 W CN 2018075496W WO 2018161760 A1 WO2018161760 A1 WO 2018161760A1
Authority
WO
WIPO (PCT)
Prior art keywords
database
blockchain data
memory
disk
disk database
Prior art date
Application number
PCT/CN2018/075496
Other languages
French (fr)
Chinese (zh)
Other versions
WO2018161760A8 (en
Inventor
刘雄文
陆陈一帆
黄宇翔
段宣斌
Original Assignee
深圳壹账通智能科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳壹账通智能科技有限公司 filed Critical 深圳壹账通智能科技有限公司
Priority to SG11201907619VA priority Critical patent/SG11201907619VA/en
Publication of WO2018161760A1 publication Critical patent/WO2018161760A1/en
Publication of WO2018161760A8 publication Critical patent/WO2018161760A8/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/061Improving I/O performance
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/064Management of blocks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • G06F3/0674Disk device
    • G06F3/0676Magnetic disk device
    • 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
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/08Payment architectures
    • G06Q20/10Payment architectures specially adapted for electronic funds transfer [EFT] systems; specially adapted for home banking systems
    • G06Q20/102Bill distribution or payments

Definitions

  • the present application relates to the field of Internet technologies, and in particular, to a blockchain data storage system and method.
  • a blockchain is generally understood to be a distributed ledger, which is essentially a distributed computing and storage system.
  • the blockchain has multiple nodes. Different nodes reach a consensus through certain calculation rules, and the consensus execution result is stored in the database in the form of a block.
  • the multiple blocks form a blockchain. Due to the different calculation speeds of different nodes, data inconsistency between nodes may occur, and the data corresponding to the nodes needs to be read in the database for synchronization.
  • the transaction execution result stored in the database and the data corresponding to the node may be collectively referred to as blockchain data. Since the block read/write frequency of the blockchain data is very high, the blockchain data increases as the transaction volume increases. If the blockchain data is read and written with low efficiency, it will affect the performance of the blockchain. Therefore, how to effectively improve the reading and writing efficiency of blockchain data has become a technical problem that needs to be solved.
  • a blockchain data storage system and method is provided.
  • a blockchain data storage system including an in-memory database and a disk database, wherein:
  • the in-memory database and the disk database respectively receive blockchain data written by the blockchain node, and store the blockchain data;
  • the node When the node reads the blockchain data, the node first reads from the in-memory database, and if the reading fails, reads the blockchain data from the disk database, and synchronizes the read blockchain data. To the in-memory database.
  • a method for storing blockchain data comprising:
  • the reading is performed from the in-memory database. If the reading fails, the blockchain data is read from the disk database, and the read blockchain data is synchronized to the memory. database.
  • a blockchain data storage device comprising:
  • An acquisition module configured to acquire blockchain data
  • a storage module configured to separately write the blockchain data into an in-memory database and a disk database for storage;
  • An access module configured to read from the in-memory database when reading blockchain data, and read blockchain data from the disk database if the read fails, and read the blockchain data
  • the blockchain data is synchronized to the in-memory database.
  • a blockchain node comprising a memory and one or more processors, the memory storing computer readable instructions, the computer readable instructions being executed by the processor to cause the one or more processes Perform the following steps:
  • the reading is performed from the in-memory database. If the reading fails, the blockchain data is read from the disk database, and the read blockchain data is synchronized to the memory. database.
  • FIG. 2 is a schematic diagram of a connection of a blockchain data storage system in accordance with one or more embodiments
  • FIG. 3 is a flow diagram of a blockchain data storage method in accordance with one or more embodiments.
  • FIG. 4 is a block diagram of a blockchain node in accordance with one or more embodiments.
  • FIG. 5 is a block diagram of a blockchain data storage device in accordance with one or more embodiments.
  • a blockchain data storage system including an in-memory database and a disk database, wherein:
  • the in-memory database and the disk database respectively receive the blockchain data written by the blockchain node, and store the blockchain data.
  • the node When the node reads the blockchain data, the node first reads from the in-memory database. If the read fails, the blockchain data is read from the disk database, and the read blockchain data is synchronized to the memory. database.
  • Blockchain data includes transaction execution results and transaction logs.
  • the node of the blockchain stores the transaction execution result and the transaction log after calculating the transaction execution result.
  • the traditional way is that the node stores the transaction execution result and transaction log in the disk database, but there is a delay in writing to the disk database. If it is a high frequency write to the disk database, it will affect the performance of the blockchain.
  • the database corresponding to the node of the blockchain includes an in-memory database and a disk database.
  • the nodes may be authorized terminals or authorized servers.
  • the database corresponding to the node may be a database that is separately deployed for each node.
  • the node writes the blockchain data to the in-memory database through the in-memory database interface layer, and the in-memory database stores the blockchain data written by the node.
  • the node writes the blockchain data to the disk database through the disk database interface, data routing, sub-database sub-tab middleware, etc., and the disk database stores the blockchain data written by the node. Since the write speed of the in-memory database is much higher than the write speed of the disk database, storing the blockchain data in the in-memory database can effectively improve the storage efficiency. Blockchain data is not frequently affected by blockchain performance when it is written to the in-memory database at high frequency. However, the capacity of the in-memory database is relatively limited, and the disk database is required to provide permanent storage for the blockchain data.
  • the node When a node needs to read blockchain data in the database, the node first reads from the in-memory database.
  • the read speed of the in-memory database is higher than the read speed of the disk database, so the node can read the blockchain data from the in-memory database to effectively improve the reading efficiency. If the read fails, the node reads from the disk database, and after the read is successful, the blockchain data read is synchronized to the in-memory database, so that the next time it can be directly read in the in-memory database, so as to improve the reading. speed. If the required blockchain data is still not read in the disk database, a message that the read failed is returned to the node.
  • the node writes the blockchain data to the in-memory database and the disk database for storage.
  • the node first reads from the in-memory database. If the read fails, it reads from the disk database and synchronizes the read blockchain data to the in-memory database. Due to the high read and write performance of the in-memory database, the storage of blockchain data can be effectively improved. Due to the limited capacity of the in-memory database, the block database data of the node can be permanently stored through the disk database. When the node fails to read the blockchain data in the in-memory database, it can read through the disk database. And the blockchain data read is synchronized to the in-memory database, so that it can be read directly in the in-memory database next time, which effectively improves the reading speed.
  • the system further includes a first memory mapping file.
  • the node acquires the first memory mapping file, and writes the blockchain data into the first memory mapping file; After the in-memory database is restored, the node writes the blockchain data to the in-memory database through the first memory mapping file.
  • the in-memory database has a corresponding first memory mapping file.
  • the node obtains the first memory mapping file corresponding to the in-memory database, and writes the blockchain data into the first memory mapping file.
  • the blockchain data is cached by the first memory map file. Therefore, when a storage failure occurs in the in-memory database, the efficiency of blockchain data storage can be effectively prevented.
  • the first memory mapped file is pre-mapped in memory. After the in-memory database is restored, the node writes the blockchain data stored in the first memory map file to the in-memory database. This ensures that the cached data can be stored to the in-memory database accurately and effectively, preventing data loss.
  • the node After the in-memory database is restored, the node deletes the blockchain data stored in the first memory mapping file into the in-memory database, and can also delete the blockchain data cached in the first memory mapping file, thereby effectively improving the first The utilization of memory mapped files.
  • the system further includes a second memory mapping file.
  • the node acquires the second memory mapping file, and writes the blockchain data to the second memory mapping file; After the database is restored, the node writes the blockchain data to the disk database through the second memory mapping file.
  • the disk database has a corresponding second memory mapping file.
  • the node acquires a second memory mapping file corresponding to the disk database, and writes the blockchain data to the second memory mapping file.
  • the blockchain data is cached by the second memory mapped file. Therefore, when a storage failure occurs in the disk database, the efficiency of blockchain data storage can be effectively prevented.
  • the second memory map file is memory mapped in advance. After the disk database is restored, the node writes the blockchain data stored in the second memory map file to the disk database. This ensures that the cached data can be stored to the disk database accurately and effectively, preventing data loss.
  • the node After the disk database is restored, the node deletes the blockchain data stored in the second memory mapping file into the disk database, and can also delete the blockchain data cached in the second memory mapping file, thereby effectively improving the second.
  • the disk database includes a primary disk database and a secondary disk database; the blockchain data is written to the primary disk database for storage, and the primary disk database maintains blockchain data synchronization with the secondary disk database; when the node reads the block When chaining data, the blockchain data is read from the disk database.
  • the disk database can provide permanent storage for the blockchain data.
  • the disk database is divided into a primary disk database and a secondary disk database.
  • the main disk database is used to receive the blockchain data written by the node to store the blockchain data, and can also be used for the node to read the blockchain data.
  • the blockchain data is read from the disk database for the node.
  • When a node reads data from a disk database it can read from the disk database. If the read fails from the disk database, it can be read in the primary disk database.
  • the connection between the node and the in-memory database and the disk database is as shown in FIG. 2.
  • the node connects to the in-memory database through the database interface layer and the in-memory database interface layer, thereby performing read and write operations on the in-memory database.
  • the node connects to multiple primary disk databases through the database interface layer, the disk database interface layer, the data routing, the sub-database sub-table middleware, and the primary database connection pool.
  • the node connects to the multiple slave disk databases through the database interface layer, the disk database interface layer, the data routing, the sub-database partitioning middleware, and the database connection pool.
  • the primary disk database can be divided into multiple primary disk databases by sub-database sub-table middleware. Specifically, the primary disk database can be divided into multiple primary disk databases according to the type of blockchain data. Therefore, the blockchain data can be separately stored to different primary disk databases according to the type of the blockchain data, so that the classification and storage of the blockchain data can be realized.
  • the primary disk database can be divided into multiple primary disk databases according to the type of blockchain data.
  • the primary disk database is synchronized with the secondary database through database logs.
  • the blockchain data in the primary disk database can be classified and stored, so the hierarchical storage is also implemented from the blockchain data in the disk database.
  • the node reads the blockchain data
  • the corresponding blockchain data can be obtained from the disk database according to the type of the blockchain data, thereby effectively improving the reading speed.
  • the node after the node is restarted, the node first reads the blockchain data from the disk database, and loads the read blockchain data into the in-memory database, and the disk database and the in-memory database are performed according to a preset frequency. Synchronize.
  • the node of the blockchain after the node of the blockchain is powered off, the blockchain data in the in-memory database is lost or invalid.
  • the node After the node is restarted, the node first reads the blockchain data from the disk database and loads the read blockchain data into the in-memory database. After the node is started, the disk database and the in-memory database corresponding to the node are synchronized according to the preset frequency, so as to ensure that the node can read from the in-memory database when reading the data, thereby effectively improving the reading speed.
  • a blockchain data storage method is provided.
  • the method is applied to a node of a blockchain as an example, and includes the following steps:
  • Step 302 Obtain blockchain data.
  • step 304 the blockchain data is separately written into the in-memory database and the disk database for storage.
  • Step 306 when reading the blockchain data, first reading from the in-memory database, if the reading fails, reading the blockchain data from the disk database, and synchronizing the read blockchain data to Memory Database.
  • the node When a node needs to read blockchain data in the database, the node first reads from the in-memory database.
  • the read speed of the in-memory database is higher than the read speed of the disk database, so the node can read the blockchain data from the in-memory database to effectively improve the reading efficiency. If the read fails, the node reads from the disk database, and after the read is successful, the blockchain data read is synchronized to the in-memory database, so that the next time it can be directly read in the in-memory database, so as to improve the reading. speed. If the required blockchain data is still not read in the disk database, a message that the read failed is returned to the node.
  • steps in the flowchart of FIG. 3 are sequentially displayed as indicated by the arrows, these steps are not necessarily performed in the order indicated by the arrows. Except as explicitly stated herein, the execution of these steps is not strictly limited, and the steps may be performed in other orders. Moreover, at least some of the steps in FIG. 3 may include a plurality of sub-steps or stages, which are not necessarily performed at the same time, but may be performed at different times, and the execution of these sub-steps or stages The order is also not necessarily sequential, but may be performed alternately or alternately with other steps or at least a portion of the sub-steps or stages of the other steps.
  • the in-memory database has a corresponding first memory mapping file.
  • the method further includes: when the blockchain data fails to be written into the in-memory database, acquiring the first memory mapping file, and writing the blockchain data to the first memory.
  • the mapping file after the in-memory database is restored, the blockchain data is written to the in-memory database through the first memory mapping file.
  • the disk database has a corresponding second memory mapping file
  • the method further includes: when the blockchain data fails to be written to the disk database, acquiring the second memory mapping file, and writing the blockchain data to the second memory. Mapping file; after the disk database is restored, the blockchain data is written to the disk database through the second memory mapping file.
  • the disk database has a corresponding second memory mapping file.
  • the node acquires a second memory mapping file corresponding to the disk database, and writes the blockchain data to the second memory mapping file.
  • the blockchain data is cached by the second memory mapped file. Therefore, when a storage failure occurs in the disk database, the efficiency of blockchain data storage can be effectively prevented.
  • the second memory map file is memory mapped in advance. After the disk database is restored, the node writes the blockchain data stored in the second memory map file to the disk database. This ensures that the cached data can be stored to the disk database accurately and effectively, preventing data loss.
  • the disk database includes a primary disk database and a secondary disk database; and the method further includes: writing the blockchain data to the primary disk database for storage; the primary disk database and the secondary disk database maintain blockchain data synchronization; When the blockchain data is fetched, the blockchain data is read from the disk database.
  • the blockchain node can be a terminal or a server. Taking the blockchain node as the terminal as an example, the block diagram of its internal structure can be as shown in FIG. 4.
  • the terminal includes a processor connected through a system bus, an internal memory, a non-volatile storage medium, and a network interface.
  • the non-volatile storage medium of the terminal stores an operating system and computer readable instructions.
  • the non-volatile storage medium can be a non-transitory computer readable storage medium.
  • the processor of the terminal is used to provide computation and control capabilities and is configured to perform a blockchain data storage method.
  • the internal memory of the terminal provides an environment for the operation of computer readable instructions in a non-volatile storage medium.
  • the network interface of the terminal is used to communicate with an external client terminal through a network connection, such as receiving a transaction request uploaded by the client terminal, sending an event message stream to the client terminal, and the like.
  • a network connection such as receiving a transaction request uploaded by the client terminal, sending an event message stream to the client terminal, and the like.
  • FIG. 4 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the terminal to which the solution of the present application is applied.
  • the terminal may include a ratio. More or fewer components are shown in the figures, or some components are combined, or have different component arrangements.
  • a blockchain data storage device including: an obtaining module 502, a storage module 504, and an access module 506, wherein:
  • the obtaining module 502 is configured to acquire blockchain data.
  • the storage module 504 is configured to store the blockchain data into the in-memory database and the disk database for storage.
  • the access module 506 is configured to first read from the in-memory database when reading the blockchain data, and if the reading fails, read the blockchain data from the disk database, and the blockchain to be read is read. Data is synchronized to the in-memory database.
  • the in-memory database has a corresponding first memory mapping file; the storage module 504 is further configured to: when the blockchain data fails to be written into the in-memory database, acquire the first memory mapping file, and write the blockchain data into the first A memory mapped file; after the in-memory database is restored, the blockchain data is written to the in-memory database through the first memory mapped file.
  • the disk database has a corresponding second memory mapping file
  • the storage module 504 is further configured to: when the blockchain data is written to the disk database fails, acquire the second memory mapping file, and write the blockchain data into the first The second memory mapping file; after the disk database is restored, the blockchain data is written to the disk database through the second memory mapping file.
  • the disk database includes a primary disk database and a secondary disk database; the storage module 504 is further configured to write the blockchain data to the primary disk database for storage; and the primary disk database maintains blockchain data synchronization with the secondary disk database; The access module 506 is also operative to read blockchain data from the disk database when the blockchain data is read.
  • a blockchain node comprising a memory and one or more processors having stored therein computer readable instructions that, when executed by the processor, cause one or more processes
  • the steps of the various method embodiments described above can be performed in real time while the device is executing.
  • one or more non-volatile storage media having computer readable instructions stored by one or more processors are provided, such that when executed by one or more processors The steps of the various method embodiments described above are performed in real time.
  • Non-volatile memory can include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
  • Volatile memory can include random access memory (RAM) or external cache memory.
  • RAM is available in a variety of formats, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronization chain.
  • SRAM static RAM
  • DRAM dynamic RAM
  • SDRAM synchronous DRAM
  • DDRSDRAM double data rate SDRAM
  • ESDRAM enhanced SDRAM
  • Synchlink DRAM SLDRAM
  • Memory Bus Radbus
  • RDRAM Direct RAM
  • DRAM Direct Memory Bus Dynamic RAM
  • RDRAM Memory Bus Dynamic RAM

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Accounting & Taxation (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Finance (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Strategic Management (AREA)
  • General Business, Economics & Management (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Techniques For Improving Reliability Of Storages (AREA)

Abstract

A blockchain data storage system, comprising: a memory database and a magnetic disk database, wherein: said memory database and said magnetic disk database respectively receive blockchain data written by a blockchain node, and store said blockchain data; when a node reads blockchain data, the node first reads from the memory database, and if said reading fails, the node will then read blockchain data from within said magnetic disk database, and synchronize the blockchain data that has been read to the memory database.

Description

区块链数据存储***和方法Blockchain data storage system and method
本申请要求于2017年3月9日提交中国专利局,申请号为2017101392691,申请名称为“区块链数据存储***和方法”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。The present application claims the priority of the Chinese Patent Application entitled "Block Chain Data Storage System and Method" by the Chinese Patent Office, filed on March 9, 2017, the entire disclosure of which is hereby incorporated by reference. in.
技术领域Technical field
本申请涉及互联网技术领域,特别是涉及一种区块链数据存储***和方法。The present application relates to the field of Internet technologies, and in particular, to a blockchain data storage system and method.
背景技术Background technique
区块链一般被理解为一个分布式的账本,它实质上也是一个分布式计算和存储***。区块链有多个节点,不同的节点通过一定的计算规则达成共识,并且将共识后的交易执行结果以区块的形式存储至数据库中,多个区块组成了区块链。由于不同节点的计算速度不同,会出现节点之间数据不一致的情形,需要在数据库中读取节点对应的数据进行同步操作。存储在数据库中的交易执行结果和节点对应的数据可以统称为区块链数据。由于区块链数据的读写频率非常高,区块链数据随着交易量的增加而增多。如果区块链数据的读写效率较低,会对区块链的性能造成影响。因此如何有效提高区块链数据的读写效率成为目前需要解决的一个技术问题。A blockchain is generally understood to be a distributed ledger, which is essentially a distributed computing and storage system. The blockchain has multiple nodes. Different nodes reach a consensus through certain calculation rules, and the consensus execution result is stored in the database in the form of a block. The multiple blocks form a blockchain. Due to the different calculation speeds of different nodes, data inconsistency between nodes may occur, and the data corresponding to the nodes needs to be read in the database for synchronization. The transaction execution result stored in the database and the data corresponding to the node may be collectively referred to as blockchain data. Since the block read/write frequency of the blockchain data is very high, the blockchain data increases as the transaction volume increases. If the blockchain data is read and written with low efficiency, it will affect the performance of the blockchain. Therefore, how to effectively improve the reading and writing efficiency of blockchain data has become a technical problem that needs to be solved.
发明内容Summary of the invention
根据本申请公开的各种实施例,提供一种区块链数据存储***和方法。In accordance with various embodiments disclosed herein, a blockchain data storage system and method is provided.
一种区块链数据存储***,包括内存数据库和磁盘数据库,其中:A blockchain data storage system, including an in-memory database and a disk database, wherein:
所述内存数据库和所述磁盘数据库分别接收区块链节点写入的区块链数据,并对所述区块链数据进行存储;及The in-memory database and the disk database respectively receive blockchain data written by the blockchain node, and store the blockchain data; and
当节点读取区块链数据时,节点先从内存数据库中进行读取,若读取失 败,则从所述磁盘数据库中读取区块链数据,并且将读取到的区块链数据同步至内存数据库。When the node reads the blockchain data, the node first reads from the in-memory database, and if the reading fails, reads the blockchain data from the disk database, and synchronizes the read blockchain data. To the in-memory database.
一种区块链数据的存储方法,包括:A method for storing blockchain data, comprising:
获取区块链数据;Obtaining blockchain data;
将所述区块链数据分别写入内存数据库和磁盘数据库进行存储;及Writing the blockchain data to an in-memory database and a disk database for storage; and
当读取区块链数据时,先从内存数据库中进行读取,若读取失败,则从所述磁盘数据库中读取区块链数据,并且将读取到的区块链数据同步至内存数据库。When the blockchain data is read, the reading is performed from the in-memory database. If the reading fails, the blockchain data is read from the disk database, and the read blockchain data is synchronized to the memory. database.
一种区块链数据存储装置,包括:A blockchain data storage device comprising:
获取模块,用于获取区块链数据;An acquisition module, configured to acquire blockchain data;
存储模块,用于将所述区块链数据分别写入内存数据库和磁盘数据库进行存储;a storage module, configured to separately write the blockchain data into an in-memory database and a disk database for storage;
访问模块,用于当读取区块链数据时,先从所述内存数据库中进行读取,若读取失败,则从所述磁盘数据库中读取区块链数据,并且将读取到的区块链数据同步至所述内存数据库。An access module, configured to read from the in-memory database when reading blockchain data, and read blockchain data from the disk database if the read fails, and read the blockchain data The blockchain data is synchronized to the in-memory database.
一种区块链节点,包括存储器和一个或多个处理器,所述存储器中储存有计算机可读指令,所述计算机可读指令被所述处理器执行时,使得所述一个或多个处理器执行以下步骤:A blockchain node comprising a memory and one or more processors, the memory storing computer readable instructions, the computer readable instructions being executed by the processor to cause the one or more processes Perform the following steps:
获取区块链数据;Obtaining blockchain data;
将所述区块链数据分别写入内存数据库和磁盘数据库进行存储;及Writing the blockchain data to an in-memory database and a disk database for storage; and
当读取区块链数据时,先从内存数据库中进行读取,若读取失败,则从所述磁盘数据库中读取区块链数据,并且将读取到的区块链数据同步至内存数据库。When the blockchain data is read, the reading is performed from the in-memory database. If the reading fails, the blockchain data is read from the disk database, and the read blockchain data is synchronized to the memory. database.
一个或多个存储有计算机可读指令的非易失性计算机可读存储介质,计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行以下步骤:One or more non-transitory computer readable storage mediums storing computer readable instructions, when executed by one or more processors, cause one or more processors to perform the steps of:
获取区块链数据;Obtaining blockchain data;
将所述区块链数据分别写入内存数据库和磁盘数据库进行存储;及Writing the blockchain data to an in-memory database and a disk database for storage; and
当读取区块链数据时,先从内存数据库中进行读取,若读取失败,则从所述磁盘数据库中读取区块链数据,并且将读取到的区块链数据同步至内存数据库。When the blockchain data is read, the reading is performed from the in-memory database. If the reading fails, the blockchain data is read from the disk database, and the read blockchain data is synchronized to the memory. database.
本申请的一个或多个实施例的细节在下面的附图和描述中提出。本申请的其它特征和优点将从说明书、附图以及权利要求书变得明显。Details of one or more embodiments of the present application are set forth in the accompanying drawings and description below. Other features and advantages of the present invention will be apparent from the description, drawings and claims.
附图说明DRAWINGS
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其它的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings to be used in the embodiments will be briefly described below. Obviously, the drawings in the following description are only some embodiments of the present application, Those skilled in the art can also obtain other drawings based on these drawings without any creative work.
图1为根据一个或多个实施例中区块链数据存储***的框图;1 is a block diagram of a blockchain data storage system in accordance with one or more embodiments;
图2为根据一个或多个实施例中区块链数据存储***的连接示意图;2 is a schematic diagram of a connection of a blockchain data storage system in accordance with one or more embodiments;
图3为根据一个或多个实施例中区块链数据存储方法的流程图;3 is a flow diagram of a blockchain data storage method in accordance with one or more embodiments;
图4为根据一个或多个实施例中区块链节点的框图;4 is a block diagram of a blockchain node in accordance with one or more embodiments;
图5为根据一个或多个实施例中区块链数据存储装置的框图。FIG. 5 is a block diagram of a blockchain data storage device in accordance with one or more embodiments.
具体实施方式detailed description
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。In order to make the objects, technical solutions, and advantages of the present application more comprehensible, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It is understood that the specific embodiments described herein are merely illustrative of the application and are not intended to be limiting.
在一个实施例中,如图1所示,提供了一种区块链数据存储***,包括内存数据库和磁盘数据库,其中:In one embodiment, as shown in FIG. 1, a blockchain data storage system is provided, including an in-memory database and a disk database, wherein:
内存数据库和磁盘数据库分别接收区块链节点写入的区块链数据,并对区块链数据进行存储.The in-memory database and the disk database respectively receive the blockchain data written by the blockchain node, and store the blockchain data.
当节点读取区块链数据时,节点先从内存数据库中进行读取,若读取失 败,则从磁盘数据库中读取区块链数据,并且将读取到的区块链数据同步至内存数据库。When the node reads the blockchain data, the node first reads from the in-memory database. If the read fails, the blockchain data is read from the disk database, and the read blockchain data is synchronized to the memory. database.
区块链数据包括交易执行结果和交易日志。区块链的节点在计算得到交易执行结果后,对交易执行结果和交易日志进行存储。传统的方式是节点将交易执行结果和交易日志存入磁盘数据库,但是由于写入磁盘数据库会有延时,如果是高频率的写入磁盘数据库,会对区块链的性能造成影响。Blockchain data includes transaction execution results and transaction logs. The node of the blockchain stores the transaction execution result and the transaction log after calculating the transaction execution result. The traditional way is that the node stores the transaction execution result and transaction log in the disk database, but there is a delay in writing to the disk database. If it is a high frequency write to the disk database, it will affect the performance of the blockchain.
本实施例中,区块链的节点对应的数据库包括内存数据库和磁盘数据库。区块链的节点可以有多个,节点可以是被授权的终端也可以是被授权的服务器。节点对应的数据库可以是针对每个节点分别部署的数据库。In this embodiment, the database corresponding to the node of the blockchain includes an in-memory database and a disk database. There may be multiple nodes in the blockchain, and the nodes may be authorized terminals or authorized servers. The database corresponding to the node may be a database that is separately deployed for each node.
节点通过内存数据库接口层将区块链数据写入至内存数据库,内存数据库对节点写入的区块链数据进行存储。节点通过磁盘数据库接口、数据路由、分库分表中间件等将区块链数据写入至磁盘数据库,磁盘数据库对节点写入的区块链数据进行存储。由于内存数据库的写入速度远远高于磁盘数据库的写入速度,将区块链数据存入内存数据库能够有效提高存储效率。区块链数据被高频率的写入内存数据库时也不会对区块链性能造成影响。但是内存数据库的容量是相对有限的,还需要磁盘数据库对区块链数据提供永久性存储。The node writes the blockchain data to the in-memory database through the in-memory database interface layer, and the in-memory database stores the blockchain data written by the node. The node writes the blockchain data to the disk database through the disk database interface, data routing, sub-database sub-tab middleware, etc., and the disk database stores the blockchain data written by the node. Since the write speed of the in-memory database is much higher than the write speed of the disk database, storing the blockchain data in the in-memory database can effectively improve the storage efficiency. Blockchain data is not frequently affected by blockchain performance when it is written to the in-memory database at high frequency. However, the capacity of the in-memory database is relatively limited, and the disk database is required to provide permanent storage for the blockchain data.
当节点需要在数据库中读取区块链数据时,节点首先从内存数据库中进行读取。内存数据库的读取速度高于磁盘数据库的读取速度,因此节点从内存数据库中读取区块链数据能够有效提高读取效率。如果读取失败,则节点从磁盘数据库中读取,读取成功后将读取到的区块链数据同步至内存数据库,以便于下次能够直接在内存数据库中进行读取,以便提高读取速度。如果在磁盘数据库中仍然未能读取到所需的区块链数据,则向节点返回读取失败的消息。When a node needs to read blockchain data in the database, the node first reads from the in-memory database. The read speed of the in-memory database is higher than the read speed of the disk database, so the node can read the blockchain data from the in-memory database to effectively improve the reading efficiency. If the read fails, the node reads from the disk database, and after the read is successful, the blockchain data read is synchronized to the in-memory database, so that the next time it can be directly read in the in-memory database, so as to improve the reading. speed. If the required blockchain data is still not read in the disk database, a message that the read failed is returned to the node.
本实施例中,节点将区块链数据分别写入内存数据库和磁盘数据库进行存储。当读取区块链数据时,节点先从内存数据库中进行读取,若读取失败,则从磁盘数据库中读取,并且将读取到的区块链数据同步至内存数据库。由于内存数据库的读写性能较高,能够有效提高区块链数据的存储。由于内存 数据库的容量有限,通过磁盘数据库可以对节点的区块链数据提供永久存储。当节点在内存数据库中读取区块链数据失败时,能够通过磁盘数据库进行读取。并且读取到的区块链数据同步至内存数据库,便于下次直接在内存数据库中进行读取,有效提高了读取速度。In this embodiment, the node writes the blockchain data to the in-memory database and the disk database for storage. When the blockchain data is read, the node first reads from the in-memory database. If the read fails, it reads from the disk database and synchronizes the read blockchain data to the in-memory database. Due to the high read and write performance of the in-memory database, the storage of blockchain data can be effectively improved. Due to the limited capacity of the in-memory database, the block database data of the node can be permanently stored through the disk database. When the node fails to read the blockchain data in the in-memory database, it can read through the disk database. And the blockchain data read is synchronized to the in-memory database, so that it can be read directly in the in-memory database next time, which effectively improves the reading speed.
在一个实施例中,该***还包括第一内存映射文件,当区块链数据写入内存数据库失败时,节点获取第一内存映射文件,将区块链数据写入第一内存映射文件;在内存数据库恢复后,节点通过第一内存映射文件将区块链数据写入内存数据库。In an embodiment, the system further includes a first memory mapping file. When the blockchain data fails to be written into the in-memory database, the node acquires the first memory mapping file, and writes the blockchain data into the first memory mapping file; After the in-memory database is restored, the node writes the blockchain data to the in-memory database through the first memory mapping file.
当节点将区块链数据写入内存数据库时,存在写入失败的可能性。虽然这种写入失败的可能性较低,但是写入失败的情形一旦出现,则会对区块链数据的高频存储造成影响。When a node writes blockchain data to an in-memory database, there is a possibility of write failure. Although this write failure is less likely, once a write failure occurs, it will affect the high frequency storage of the blockchain data.
本实施例中,内存数据库具有对应的第一内存映射文件。当区块链数据写入内存数据库失败时,节点获取与内存数据库对应的第一内存映射文件,将区块链数据写入第一内存映射文件。通过第一内存映射文件对区块链数据进行缓存。因此在内存数据库出现存储故障时,能够有效防止区块链数据存储效率下降。第一内存映射文件预先进行了内存映射。在内存数据库恢复之后,节点将第一内存映射文件中存储的区块链数据写入到内存数据库中。从而可以确保缓存的数据能够被准确无误的存储至内存数据库,有效防止数据丢失。In this embodiment, the in-memory database has a corresponding first memory mapping file. When the blockchain data fails to be written into the in-memory database, the node obtains the first memory mapping file corresponding to the in-memory database, and writes the blockchain data into the first memory mapping file. The blockchain data is cached by the first memory map file. Therefore, when a storage failure occurs in the in-memory database, the efficiency of blockchain data storage can be effectively prevented. The first memory mapped file is pre-mapped in memory. After the in-memory database is restored, the node writes the blockchain data stored in the first memory map file to the in-memory database. This ensures that the cached data can be stored to the in-memory database accurately and effectively, preventing data loss.
在内存数据库恢复之后,节点将第一内存映射文件中存储的区块链数据写入内存数据库之后,还可以将第一内存映射文件中缓存的区块链数据进行删除,从而能够有效提高第一内存映射文件的利用率。After the in-memory database is restored, the node deletes the blockchain data stored in the first memory mapping file into the in-memory database, and can also delete the blockchain data cached in the first memory mapping file, thereby effectively improving the first The utilization of memory mapped files.
在一个实施例中,***还包括第二内存映射文件,当区块链数据写入磁盘数据库失败时,节点获取第二内存映射文件,将区块链数据写入第二内存映射文件;在磁盘数据库恢复后,节点通过第二内存映射文件将区块链数据写入磁盘数据库。In an embodiment, the system further includes a second memory mapping file. When the blockchain data fails to be written to the disk database, the node acquires the second memory mapping file, and writes the blockchain data to the second memory mapping file; After the database is restored, the node writes the blockchain data to the disk database through the second memory mapping file.
当节点将区块链数据写入磁盘数据库时,存在写入失败的可能性。虽然 这种写入失败的可能性较低,但是写入失败的情形一旦出现,则会对区块链数据的存储造成影响。When a node writes blockchain data to a disk database, there is a possibility of write failure. Although this type of write failure is less likely, once a write failure occurs, it affects the storage of blockchain data.
本实施例中,磁盘数据库具有对应的第二内存映射文件。当区块链数据写入磁盘数据库失败时,节点获取与磁盘数据库对应的第二内存映射文件,将区块链数据写入第二内存映射文件。通过第二内存映射文件对区块链数据进行缓存。因此在磁盘数据库出现存储故障时,能够有效防止区块链数据存储效率下降。第二内存映射文件预先进行了内存映射。在磁盘数据库恢复之后,节点将第二内存映射文件中存储的区块链数据写入到磁盘数据库中。从而可以确保缓存的数据能够被准确无误的存储至磁盘数据库,有效防止数据丢失。In this embodiment, the disk database has a corresponding second memory mapping file. When the blockchain data fails to be written to the disk database, the node acquires a second memory mapping file corresponding to the disk database, and writes the blockchain data to the second memory mapping file. The blockchain data is cached by the second memory mapped file. Therefore, when a storage failure occurs in the disk database, the efficiency of blockchain data storage can be effectively prevented. The second memory map file is memory mapped in advance. After the disk database is restored, the node writes the blockchain data stored in the second memory map file to the disk database. This ensures that the cached data can be stored to the disk database accurately and effectively, preventing data loss.
在磁盘数据库恢复之后,节点将第二内存映射文件中存储的区块链数据写入磁盘数据库之后,还可以将第二内存映射文件中缓存的区块链数据进行删除,从而能够有效提高第二内存映射文件的利用率。After the disk database is restored, the node deletes the blockchain data stored in the second memory mapping file into the disk database, and can also delete the blockchain data cached in the second memory mapping file, thereby effectively improving the second. The utilization of memory mapped files.
在一个实施例中,磁盘数据库包括主磁盘数据库和从磁盘数据库;将区块链数据写入主磁盘数据库进行存储,主磁盘数据库与从磁盘数据库保持区块链数据同步;当节点读取区块链数据时,在从磁盘数据库中读取区块链数据。In one embodiment, the disk database includes a primary disk database and a secondary disk database; the blockchain data is written to the primary disk database for storage, and the primary disk database maintains blockchain data synchronization with the secondary disk database; when the node reads the block When chaining data, the blockchain data is read from the disk database.
磁盘数据库可以对区块链数据提供永久存储,为了有效提高磁盘数据库的读写性能,将磁盘数据库分为主磁盘数据库和从磁盘数据库。主磁盘数据库用于接收节点写入的区块链数据对区块链数据进行存储,还可以用于节点读取区块链数据。从磁盘数据库用于节点读取区块链数据。当节点在磁盘数据库中读取数据时,可以在从磁盘数据库中进行读取。若在从磁盘数据库中读取失败,则可以在主磁盘数据库中进行读取。通过将主磁盘数据库和从磁盘数据库的读写功能分离,能够有效提高磁盘数据库的存储效率。The disk database can provide permanent storage for the blockchain data. In order to effectively improve the read and write performance of the disk database, the disk database is divided into a primary disk database and a secondary disk database. The main disk database is used to receive the blockchain data written by the node to store the blockchain data, and can also be used for the node to read the blockchain data. The blockchain data is read from the disk database for the node. When a node reads data from a disk database, it can read from the disk database. If the read fails from the disk database, it can be read in the primary disk database. By separating the primary disk database from the read and write functions of the disk database, the storage efficiency of the disk database can be effectively improved.
进一步的,主磁盘数据库包括多个,从磁盘数据库包括多个。节点通过磁盘数据库接口层、数据路由、分库分表中间件和主数据库连接池对多个主磁盘数据库进行读写操作。节点通过磁盘数据库接口层、数据路由、分库分 表中间件和从数据库连接池对多个主磁盘数据库进行读操作。Further, the primary disk database includes a plurality of, and the plurality of disks from the disk database. The node reads and writes to multiple primary disk databases through the disk database interface layer, data routing, sub-database sub-assembly middleware, and primary database connection pool. The node reads multiple primary disk databases through the disk database interface layer, data routing, sub-database partitioning middleware, and from the database connection pool.
在其中一个实施例中,节点与内存数据库和磁盘数据库的连接示意图如图2所示。其中,节点通过数据库接口层和内存数据库接口层与内存数据库进行连接,从而对内存数据库进行读写操作。节点通过数据库接口层、磁盘数据库接口层、数据路由、分库分表中间件、主数据库连接池与多个主磁盘数据库进行连接。节点通过数据库接口层、磁盘数据库接口层、数据路由、分库分表中间件、从数据库连接池与多个从磁盘数据库进行连接。In one of the embodiments, the connection between the node and the in-memory database and the disk database is as shown in FIG. 2. The node connects to the in-memory database through the database interface layer and the in-memory database interface layer, thereby performing read and write operations on the in-memory database. The node connects to multiple primary disk databases through the database interface layer, the disk database interface layer, the data routing, the sub-database sub-table middleware, and the primary database connection pool. The node connects to the multiple slave disk databases through the database interface layer, the disk database interface layer, the data routing, the sub-database partitioning middleware, and the database connection pool.
通过分库分表中间件可以将主磁盘数据库分为多个主磁盘数据库。具体的,可以根据区块链数据的类型将主磁盘数据库分为多个主磁盘数据库。由此可以根据区块链数据的类型将区块链数据分别存储至不同的主磁盘数据库,从而可以实现对区块链数据的分类存储。The primary disk database can be divided into multiple primary disk databases by sub-database sub-table middleware. Specifically, the primary disk database can be divided into multiple primary disk databases according to the type of blockchain data. Therefore, the blockchain data can be separately stored to different primary disk databases according to the type of the blockchain data, so that the classification and storage of the blockchain data can be realized.
通过分库分表中间件可以将从磁盘数据库分为多个从磁盘数据库。具体的,可以根据区块链数据的类型将主磁盘数据库分为多个主磁盘数据库。主磁盘数据库与从磁盘数据库之间通过数据库日志保持同步。主磁盘数据库中的区块链数据可以进行分类存储,因此从磁盘数据库中的区块链数据也实现了分类存储。当节点读取区块链数据时,可以根据区块链数据的类型在从磁盘数据库中获取对应的区块链数据,从而能够有效提高读取速度。You can divide a disk database into multiple slave disk databases by sub-database partitioning middleware. Specifically, the primary disk database can be divided into multiple primary disk databases according to the type of blockchain data. The primary disk database is synchronized with the secondary database through database logs. The blockchain data in the primary disk database can be classified and stored, so the hierarchical storage is also implemented from the blockchain data in the disk database. When the node reads the blockchain data, the corresponding blockchain data can be obtained from the disk database according to the type of the blockchain data, thereby effectively improving the reading speed.
在一个实施例中,在节点重启之后,节点先从磁盘数据库中读取区块链数据,并将读取到的区块链数据加载至内存数据库中,磁盘数据库与内存数据库按照预设频率进行同步。In one embodiment, after the node is restarted, the node first reads the blockchain data from the disk database, and loads the read blockchain data into the in-memory database, and the disk database and the in-memory database are performed according to a preset frequency. Synchronize.
本实施例中,区块链的节点断电之后,会造成内存数据库中的区块链数据丢失或无效。在节点在重启之后,节点会首先从磁盘数据库中读取区块链数据,并且将读取到的区块链数据加载至内存数据库中。在节点启动之后,节点对应的磁盘数据库和内存数据库会按照预设频率进行同步,以此确保节点在读取数据时可以先从内存数据库中进行读取,有效提高读取速度。In this embodiment, after the node of the blockchain is powered off, the blockchain data in the in-memory database is lost or invalid. After the node is restarted, the node first reads the blockchain data from the disk database and loads the read blockchain data into the in-memory database. After the node is started, the disk database and the in-memory database corresponding to the node are synchronized according to the preset frequency, so as to ensure that the node can read from the in-memory database when reading the data, thereby effectively improving the reading speed.
在一个实施例中,如图3所示,提供了一种区块链数据存储方法,以该方法应用于区块链的节点为例进行说明,包括以下步骤:In an embodiment, as shown in FIG. 3, a blockchain data storage method is provided. The method is applied to a node of a blockchain as an example, and includes the following steps:
步骤302,获取区块链数据。Step 302: Obtain blockchain data.
步骤304,将区块链数据分别写入内存数据库和磁盘数据库进行存储。In step 304, the blockchain data is separately written into the in-memory database and the disk database for storage.
步骤306,当读取区块链数据时,先从内存数据库中进行读取,若读取失败,则从磁盘数据库中读取区块链数据,并且将读取到的区块链数据同步至内存数据库。 Step 306, when reading the blockchain data, first reading from the in-memory database, if the reading fails, reading the blockchain data from the disk database, and synchronizing the read blockchain data to Memory Database.
本实施例中,节点获取区块链数据,包括交易执行结果和交易日志。区块链的节点对应的数据库包括磁盘数据库和内存数据库。节点通过内存数据库接口层将区块链数据写入至内存数据库,内存数据库对节点写入的区块链数据进行存储。节点通过磁盘数据库接口、数据路由、分库分表中间件等将区块链数据写入至磁盘数据库,磁盘数据库对节点写入的区块链数据进行存储。由于内存数据库的写入速度远远高于磁盘数据库的写入速度,将区块链数据存入内存数据库能够有效提高存储效率。区块链数据被高频率的写入内存数据库时也不会对区块链性能造成影响。但是内存数据库的容量是相对有限的,还需要磁盘数据库对区块链数据提供永久性存储。In this embodiment, the node acquires blockchain data, including a transaction execution result and a transaction log. The database corresponding to the nodes of the blockchain includes a disk database and an in-memory database. The node writes the blockchain data to the in-memory database through the in-memory database interface layer, and the in-memory database stores the blockchain data written by the node. The node writes the blockchain data to the disk database through the disk database interface, data routing, sub-database sub-tab middleware, etc., and the disk database stores the blockchain data written by the node. Since the write speed of the in-memory database is much higher than the write speed of the disk database, storing the blockchain data in the in-memory database can effectively improve the storage efficiency. Blockchain data is not frequently affected by blockchain performance when it is written to the in-memory database at high frequency. However, the capacity of the in-memory database is relatively limited, and the disk database is required to provide permanent storage for the blockchain data.
当节点需要在数据库中读取区块链数据时,节点首先从内存数据库中进行读取。内存数据库的读取速度高于磁盘数据库的读取速度,因此节点从内存数据库中读取区块链数据能够有效提高读取效率。如果读取失败,则节点从磁盘数据库中读取,读取成功后将读取到的区块链数据同步至内存数据库,以便于下次能够直接在内存数据库中进行读取,以便提高读取速度。如果在磁盘数据库中仍然未能读取到所需的区块链数据,则向节点返回读取失败的消息。When a node needs to read blockchain data in the database, the node first reads from the in-memory database. The read speed of the in-memory database is higher than the read speed of the disk database, so the node can read the blockchain data from the in-memory database to effectively improve the reading efficiency. If the read fails, the node reads from the disk database, and after the read is successful, the blockchain data read is synchronized to the in-memory database, so that the next time it can be directly read in the in-memory database, so as to improve the reading. speed. If the required blockchain data is still not read in the disk database, a message that the read failed is returned to the node.
本实施例中,由于内存数据库的读写性能较高,节点将区块链数据分别写入内存数据库能够有效提高区块链数据的存储。由于内存数据库的容量有限,通过磁盘数据库可以对节点的区块链数据提供永久存储。当节点在内存数据库中读取区块链数据失败时,能够通过磁盘数据库进行读取。并且读取到的区块链数据同步至内存数据库,便于下次直接在内存数据库中进行读取,有效提高了读取速度。In this embodiment, because the read/write performance of the in-memory database is high, the node can separately write the blockchain data into the in-memory database to effectively improve the storage of the blockchain data. Due to the limited capacity of the in-memory database, the block database data of the node can be permanently stored through the disk database. When the node fails to read the blockchain data in the in-memory database, it can read through the disk database. And the blockchain data read is synchronized to the in-memory database, so that it can be read directly in the in-memory database next time, which effectively improves the reading speed.
应该理解的是,虽然图3的流程图中的各个步骤按照箭头的指示依次显示,但是这些步骤并不是必然按照箭头指示的顺序依次执行。除非本文中有明确的说明,这些步骤的执行并没有严格的顺序限制,这些步骤可以以其它的顺序执行。而且,图3中的至少一部分步骤可以包括多个子步骤或者多个阶段,这些子步骤或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,这些子步骤或者阶段的执行顺序也不必然是依次进行,而是可以与其它步骤或者其它步骤的子步骤或者阶段的至少一部分轮流或者交替地执行。It should be understood that although the various steps in the flowchart of FIG. 3 are sequentially displayed as indicated by the arrows, these steps are not necessarily performed in the order indicated by the arrows. Except as explicitly stated herein, the execution of these steps is not strictly limited, and the steps may be performed in other orders. Moreover, at least some of the steps in FIG. 3 may include a plurality of sub-steps or stages, which are not necessarily performed at the same time, but may be performed at different times, and the execution of these sub-steps or stages The order is also not necessarily sequential, but may be performed alternately or alternately with other steps or at least a portion of the sub-steps or stages of the other steps.
在一个实施例中,内存数据库具有对应的第一内存映射文件;方法还包括:当区块链数据写入内存数据库失败时,获取第一内存映射文件,将区块链数据写入第一内存映射文件;在内存数据库恢复后,通过第一内存映射文件将区块链数据写入内存数据库。In an embodiment, the in-memory database has a corresponding first memory mapping file. The method further includes: when the blockchain data fails to be written into the in-memory database, acquiring the first memory mapping file, and writing the blockchain data to the first memory. The mapping file; after the in-memory database is restored, the blockchain data is written to the in-memory database through the first memory mapping file.
本实施例中,内存数据库具有对应的第一内存映射文件。当区块链数据写入内存数据库失败时,节点获取与内存数据库对应的第一内存映射文件,将区块链数据写入第一内存映射文件。通过第一内存映射文件对区块链数据进行缓存。因此在内存数据库出现存储故障时,能够有效防止区块链数据存储效率下降。第一内存映射文件预先进行了内存映射。在内存数据库恢复之后,节点将第一内存映射文件中存储的区块链数据写入到内存数据库中。从而可以确保缓存的数据能够被准确无误的存储至内存数据库,有效防止数据丢失。In this embodiment, the in-memory database has a corresponding first memory mapping file. When the blockchain data fails to be written into the in-memory database, the node obtains the first memory mapping file corresponding to the in-memory database, and writes the blockchain data into the first memory mapping file. The blockchain data is cached by the first memory map file. Therefore, when a storage failure occurs in the in-memory database, the efficiency of blockchain data storage can be effectively prevented. The first memory mapped file is pre-mapped in memory. After the in-memory database is restored, the node writes the blockchain data stored in the first memory map file to the in-memory database. This ensures that the cached data can be stored to the in-memory database accurately and effectively, preventing data loss.
在一个实施例中,磁盘数据库具有对应的第二内存映射文件,方法还包括:当区块链数据写入磁盘数据库失败时,获取第二内存映射文件,将区块链数据写入第二内存映射文件;在磁盘数据库恢复后,通过第二内存映射文件将区块链数据写入磁盘数据库。In an embodiment, the disk database has a corresponding second memory mapping file, and the method further includes: when the blockchain data fails to be written to the disk database, acquiring the second memory mapping file, and writing the blockchain data to the second memory. Mapping file; after the disk database is restored, the blockchain data is written to the disk database through the second memory mapping file.
本实施例中,磁盘数据库具有对应的第二内存映射文件。当区块链数据写入磁盘数据库失败时,节点获取与磁盘数据库对应的第二内存映射文件,将区块链数据写入第二内存映射文件。通过第二内存映射文件对区块链数据 进行缓存。因此在磁盘数据库出现存储故障时,能够有效防止区块链数据存储效率下降。第二内存映射文件预先进行了内存映射。在磁盘数据库恢复之后,节点将第二内存映射文件中存储的区块链数据写入到磁盘数据库中。从而可以确保缓存的数据能够被准确无误的存储至磁盘数据库,有效防止数据丢失。In this embodiment, the disk database has a corresponding second memory mapping file. When the blockchain data fails to be written to the disk database, the node acquires a second memory mapping file corresponding to the disk database, and writes the blockchain data to the second memory mapping file. The blockchain data is cached by the second memory mapped file. Therefore, when a storage failure occurs in the disk database, the efficiency of blockchain data storage can be effectively prevented. The second memory map file is memory mapped in advance. After the disk database is restored, the node writes the blockchain data stored in the second memory map file to the disk database. This ensures that the cached data can be stored to the disk database accurately and effectively, preventing data loss.
在一个实施例中,磁盘数据库包括主磁盘数据库和从磁盘数据库;方法还包括:将区块链数据写入主磁盘数据库进行存储;主磁盘数据库与从磁盘数据库保持区块链数据同步;当读取区块链数据时,从从磁盘数据库中读取区块链数据。In one embodiment, the disk database includes a primary disk database and a secondary disk database; and the method further includes: writing the blockchain data to the primary disk database for storage; the primary disk database and the secondary disk database maintain blockchain data synchronization; When the blockchain data is fetched, the blockchain data is read from the disk database.
本实施例中,为了有效提高磁盘数据库的读写性能,将磁盘数据库分为主磁盘数据库和从磁盘数据库。主磁盘数据库用于接收节点写入的区块链数据对区块链数据进行存储,还可以用于节点读取区块链数据。从磁盘数据库用于节点读取区块链数据。当节点在磁盘数据库中读取数据时,可以在从磁盘数据库中进行读取。若在从磁盘数据库中读取失败,则可以在主磁盘数据库中进行读取。通过将主磁盘数据库和从磁盘数据库的读写功能分离,能够有效提高磁盘数据库的存储效率。In this embodiment, in order to effectively improve the read and write performance of the disk database, the disk database is divided into a primary disk database and a secondary disk database. The main disk database is used to receive the blockchain data written by the node to store the blockchain data, and can also be used for the node to read the blockchain data. The blockchain data is read from the disk database for the node. When a node reads data from a disk database, it can read from the disk database. If the read fails from the disk database, it can be read in the primary disk database. By separating the primary disk database from the read and write functions of the disk database, the storage efficiency of the disk database can be effectively improved.
在一个实施例中,区块链节点可以为终端,也可以为服务器。以区块链节点为终端为例,其内部结构的框图可以如图4所示。终端包括通过***总线连接的处理器、内存储器、非易失性存储介质和网络接口。其中,该终端的非易失性存储介质中存储有操作***和计算机可读指令。非易失性存储介质可以是一种非易失性计算机可读存储介质。终端的处理器用于提供计算和控制能力,被配置为执行一种区块链数据存储方法。终端的内存储器为非易失性存储介质中的计算机可读指令的运行提供环境。该计算机可读指令被处理器执行时,可以实现一种区块链数据存储方法。终端的网络接口用于据以与外部的客户终端通过网络连接通信,比如接收客户终端上传的交易请求,向客户终端发送事件消息流等。本领域技术人员可以理解,图4中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用 于其上的终端的限定,具体地终端可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。In one embodiment, the blockchain node can be a terminal or a server. Taking the blockchain node as the terminal as an example, the block diagram of its internal structure can be as shown in FIG. 4. The terminal includes a processor connected through a system bus, an internal memory, a non-volatile storage medium, and a network interface. The non-volatile storage medium of the terminal stores an operating system and computer readable instructions. The non-volatile storage medium can be a non-transitory computer readable storage medium. The processor of the terminal is used to provide computation and control capabilities and is configured to perform a blockchain data storage method. The internal memory of the terminal provides an environment for the operation of computer readable instructions in a non-volatile storage medium. When the computer readable instructions are executed by the processor, a blockchain data storage method can be implemented. The network interface of the terminal is used to communicate with an external client terminal through a network connection, such as receiving a transaction request uploaded by the client terminal, sending an event message stream to the client terminal, and the like. A person skilled in the art can understand that the structure shown in FIG. 4 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the terminal to which the solution of the present application is applied. Specifically, the terminal may include a ratio. More or fewer components are shown in the figures, or some components are combined, or have different component arrangements.
在一个实施例中,如图5所示,提供了一种区块链数据存储装置,包括:获取模块502、存储模块504和访问模块506,其中:In one embodiment, as shown in FIG. 5, a blockchain data storage device is provided, including: an obtaining module 502, a storage module 504, and an access module 506, wherein:
获取模块502,用于获取区块链数据。The obtaining module 502 is configured to acquire blockchain data.
存储模块504,用于将区块链数据分别写入内存数据库和磁盘数据库进行存储。The storage module 504 is configured to store the blockchain data into the in-memory database and the disk database for storage.
访问模块506,用于当读取区块链数据时,先从内存数据库中进行读取,若读取失败,则从磁盘数据库中读取区块链数据,并且将读取到的区块链数据同步至内存数据库。The access module 506 is configured to first read from the in-memory database when reading the blockchain data, and if the reading fails, read the blockchain data from the disk database, and the blockchain to be read is read. Data is synchronized to the in-memory database.
在一个实施例中,内存数据库具有对应的第一内存映射文件;存储模块504还用于当区块链数据写入内存数据库失败时,获取第一内存映射文件,将区块链数据写入第一内存映射文件;在内存数据库恢复后,通过第一内存映射文件将区块链数据写入内存数据库。In an embodiment, the in-memory database has a corresponding first memory mapping file; the storage module 504 is further configured to: when the blockchain data fails to be written into the in-memory database, acquire the first memory mapping file, and write the blockchain data into the first A memory mapped file; after the in-memory database is restored, the blockchain data is written to the in-memory database through the first memory mapped file.
在一个实施例中,磁盘数据库具有对应的第二内存映射文件,存储模块504还用于当区块链数据写入磁盘数据库失败时,获取第二内存映射文件,将区块链数据写入第二内存映射文件;在磁盘数据库恢复后,通过第二内存映射文件将区块链数据写入磁盘数据库。In one embodiment, the disk database has a corresponding second memory mapping file, and the storage module 504 is further configured to: when the blockchain data is written to the disk database fails, acquire the second memory mapping file, and write the blockchain data into the first The second memory mapping file; after the disk database is restored, the blockchain data is written to the disk database through the second memory mapping file.
在一个实施例中,磁盘数据库包括主磁盘数据库和从磁盘数据库;存储模块504还用于将区块链数据写入主磁盘数据库进行存储;主磁盘数据库与从磁盘数据库保持区块链数据同步;访问模块506还用于当读取区块链数据时,从从磁盘数据库中读取区块链数据。In one embodiment, the disk database includes a primary disk database and a secondary disk database; the storage module 504 is further configured to write the blockchain data to the primary disk database for storage; and the primary disk database maintains blockchain data synchronization with the secondary disk database; The access module 506 is also operative to read blockchain data from the disk database when the blockchain data is read.
在一个实施例中,提供了一种区块链节点,包括存储器和一个或多个处理器,存储器中储存有计算机可读指令,计算机可读指令被处理器执行时,使得一个或多个处理器执行时可以实时上述各个方法实施例的步骤。In one embodiment, a blockchain node is provided, comprising a memory and one or more processors having stored therein computer readable instructions that, when executed by the processor, cause one or more processes The steps of the various method embodiments described above can be performed in real time while the device is executing.
在一个实施例中,提供了一个或多个存储有计算机可读指令的非易失性存储介质,计算机可读指令被一个或多个处理器执行时,使得一个或多个处 理器执行时可以实时上述各个方法实施例的步骤。In one embodiment, one or more non-volatile storage media having computer readable instructions stored by one or more processors are provided, such that when executed by one or more processors The steps of the various method embodiments described above are performed in real time.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机可读指令来指令相关的硬件来完成,所述的计算机可读指令可存储于一非易失性计算机可读取存储介质中,该计算机可读指令在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。One of ordinary skill in the art can understand that all or part of the process of implementing the above embodiments can be completed by computer readable instructions, which can be stored in a non-volatile computer. The readable storage medium, which when executed, may include the flow of an embodiment of the methods as described above. Any reference to a memory, storage, database or other medium used in the various embodiments provided herein may include non-volatile and/or volatile memory. Non-volatile memory can include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of formats, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronization chain. Synchlink DRAM (SLDRAM), Memory Bus (Rambus) Direct RAM (RDRAM), Direct Memory Bus Dynamic RAM (DRDRAM), and Memory Bus Dynamic RAM (RDRAM).
以上实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。The technical features of the above embodiments may be arbitrarily combined. For the sake of brevity of description, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, It is considered to be the range described in this specification.
以上实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。The above embodiments are merely illustrative of several embodiments of the present application, and the description thereof is more specific and detailed, but is not to be construed as limiting the scope of the invention. It should be noted that a number of variations and modifications may be made by those skilled in the art without departing from the spirit and scope of the present application. Therefore, the scope of the invention should be determined by the appended claims.

Claims (20)

  1. 一种区块链数据存储***,其特征在于,所述***包括内存数据库和磁盘数据库,其中:A blockchain data storage system, characterized in that the system comprises an in-memory database and a disk database, wherein:
    所述内存数据库和所述磁盘数据库分别接收区块链节点写入的区块链数据,并对所述区块链数据进行存储;及The in-memory database and the disk database respectively receive blockchain data written by the blockchain node, and store the blockchain data; and
    当节点读取区块链数据时,节点先从内存数据库中进行读取,若读取失败,则从所述磁盘数据库中读取区块链数据,并且将读取到的区块链数据同步至内存数据库。When the node reads the blockchain data, the node first reads from the in-memory database, and if the reading fails, reads the blockchain data from the disk database, and synchronizes the read blockchain data. To the in-memory database.
  2. 根据权利要求1所述的***,其特征在于,所述***还包括第一内存映射文件,当区块链数据写入内存数据库失败时,节点获取所述第一内存映射文件,将所述区块链数据写入第一内存映射文件;及在所述内存数据库恢复后,节点通过所述第一内存映射文件将所述区块链数据写入内存数据库。The system according to claim 1, wherein the system further comprises a first memory mapping file, and when the blockchain data fails to be written into the in-memory database, the node acquires the first memory mapping file, and the area is The blockchain data is written to the first memory mapped file; and after the in-memory database is restored, the node writes the blockchain data to the in-memory database through the first memory mapped file.
  3. 根据权利要求1所述的***,其特征在于,所述***还包括第二内存映射文件,当区块链数据写入磁盘数据库失败时,节点获取所述第二内存映射文件,将所述区块链数据写入第二内存映射文件;及在所述磁盘数据库恢复后,节点通过所述第二内存映射文件将所述区块链数据写入磁盘数据库。The system according to claim 1, wherein the system further comprises a second memory mapping file, and when the blockchain data fails to be written to the disk database, the node acquires the second memory mapping file, and the area is The blockchain data is written to the second memory mapped file; and after the disk database is restored, the node writes the blockchain data to the disk database through the second memory mapped file.
  4. 根据权利要求1所述的***,其特征在于,所述磁盘数据库包括主磁盘数据库和从磁盘数据库;将所述区块链数据写入主磁盘数据库进行存储,所述主磁盘数据库与所述从磁盘数据库保持区块链数据同步;及当节点读取区块链数据时,在所述从磁盘数据库中读取区块链数据。The system according to claim 1, wherein said disk database comprises a primary disk database and a secondary disk database; said blockchain data is written to a primary disk database for storage, said primary disk database and said slave database The disk database maintains blockchain data synchronization; and when the node reads the blockchain data, the blockchain data is read from the slave disk database.
  5. 根据权利要求4所述的***,其特征在于,所述主磁盘数据库包括多个,所述节点通过磁盘数据库接口层、数据路由、分库分表中间件和主数据库连接池对多个主磁盘数据库进行读写操作。The system according to claim 4, wherein said primary disk database comprises a plurality of said primary disks through said disk database interface layer, data routing, sub-database sub-table middleware and primary database connection pool The database is read and written.
  6. 根据权利要求4或5所述的***,其特征在于,所述从磁盘数据库包括多个,所述节点通过磁盘数据库接口层、数据路由、分库分表中间件和从数据库连接池对多个主磁盘数据库进行读操作。The system according to claim 4 or 5, wherein the slave disk database comprises a plurality of nodes, and the nodes are connected to each other through a disk database interface layer, a data route, a library partition table middleware, and a slave database connection pool. The primary disk database is read.
  7. 根据权利要求1所述的***,其特征在于,在节点重启之后,节点先 从所述磁盘数据库中读取区块链数据,并将读取到的区块链数据加载至内存数据库中,及所述磁盘数据库与所述内存数据库按照预设频率进行同步。The system according to claim 1, wherein after the node is restarted, the node first reads the blockchain data from the disk database, and loads the read blockchain data into the in-memory database, and The disk database and the in-memory database are synchronized according to a preset frequency.
  8. 一种区块链数据存储方法,包括:A blockchain data storage method includes:
    获取区块链数据;Obtaining blockchain data;
    将所述区块链数据分别写入内存数据库和磁盘数据库进行存储;及Writing the blockchain data to an in-memory database and a disk database for storage; and
    当读取区块链数据时,先从内存数据库中进行读取,若读取失败,则从所述磁盘数据库中读取区块链数据,并且将读取到的区块链数据同步至内存数据库。When the blockchain data is read, the reading is performed from the in-memory database. If the reading fails, the blockchain data is read from the disk database, and the read blockchain data is synchronized to the memory. database.
  9. 根据权利要求8所述的方法,其特征在于,所述内存数据库具有对应的第一内存映射文件;所述方法还包括:The method according to claim 8, wherein the in-memory database has a corresponding first memory mapping file; the method further comprises:
    当区块链数据写入内存数据库失败时,获取所述第一内存映射文件,将所述区块链数据写入第一内存映射文件;及When the blockchain data fails to be written into the in-memory database, acquiring the first memory mapping file, and writing the blockchain data into the first memory mapping file; and
    在所述内存数据库恢复后,通过所述第一内存映射文件将所述区块链数据写入内存数据库。After the in-memory database is restored, the blockchain data is written into the in-memory database by the first memory mapping file.
  10. 根据权利要求8所述的方法,其特征在于,所述磁盘数据库具有对应的第二内存映射文件,所述方法还包括:The method of claim 8, wherein the disk database has a corresponding second memory mapping file, the method further comprising:
    当区块链数据写入磁盘数据库失败时,获取所述第二内存映射文件,将所述区块链数据写入第二内存映射文件;及When the blockchain data is written to the disk database, the second memory mapping file is obtained, and the blockchain data is written into the second memory mapping file;
    在所述磁盘数据库恢复后,通过所述第二内存映射文件将所述区块链数据写入磁盘数据库。After the disk database is restored, the blockchain data is written to the disk database by the second memory mapping file.
  11. 根据权利要求8-10任一项所述的方法,其特征在于,磁盘数据库包括主磁盘数据库和从磁盘数据库;所述方法还包括:The method according to any one of claims 8 to 10, wherein the disk database comprises a primary disk database and a secondary disk database; and the method further comprises:
    将区块链数据写入主磁盘数据库进行存储;所述主磁盘数据库与所述从磁盘数据库保持区块链数据同步;及Writing blockchain data to a primary disk database for storage; the primary disk database is synchronized with the slave disk database to maintain blockchain data; and
    当读取区块链数据时,在所述从磁盘数据库中读取区块链数据。When the blockchain data is read, the blockchain data is read in the slave disk database.
  12. 一种区块链数据存储装置,包括:A blockchain data storage device comprising:
    获取模块,用于获取区块链数据;An acquisition module, configured to acquire blockchain data;
    存储模块,用于将所述区块链数据分别写入内存数据库和磁盘数据库进行存储;a storage module, configured to separately write the blockchain data into an in-memory database and a disk database for storage;
    访问模块,用于当读取区块链数据时,先从所述内存数据库中进行读取,若读取失败,则从所述磁盘数据库中读取区块链数据,并且将读取到的区块链数据同步至所述内存数据库。An access module, configured to read from the in-memory database when reading blockchain data, and read blockchain data from the disk database if the read fails, and read the blockchain data The blockchain data is synchronized to the in-memory database.
  13. 一种区块链节点,包括存储器和一个或多个处理器,所述存储器中储存有计算机可读指令,所述计算机可读指令被所述处理器执行时,使得所述一个或多个处理器执行以下步骤:A blockchain node comprising a memory and one or more processors, the memory storing computer readable instructions, the computer readable instructions being executed by the processor to cause the one or more processes Perform the following steps:
    获取区块链数据;Obtaining blockchain data;
    将所述区块链数据分别写入内存数据库和磁盘数据库进行存储;及Writing the blockchain data to an in-memory database and a disk database for storage; and
    当读取区块链数据时,先从内存数据库中进行读取,若读取失败,则从所述磁盘数据库中读取区块链数据,并且将读取到的区块链数据同步至内存数据库。When the blockchain data is read, the reading is performed from the in-memory database. If the reading fails, the blockchain data is read from the disk database, and the read blockchain data is synchronized to the memory. database.
  14. 根据权利要求13所述的区块链节点,其特征在于,所述内存数据库具有对应的第一内存映射文件;所述计算机可读指令被所述处理器执行时,使得所述一个或多个处理器还执行以下步骤:The blockchain node of claim 13 wherein said in-memory database has a corresponding first memory mapped file; said computer readable instructions being executed by said processor such that said one or more The processor also performs the following steps:
    当区块链数据写入内存数据库失败时,获取所述第一内存映射文件,将所述区块链数据写入第一内存映射文件;及When the blockchain data fails to be written into the in-memory database, acquiring the first memory mapping file, and writing the blockchain data into the first memory mapping file; and
    在所述内存数据库恢复后,通过所述第一内存映射文件将所述区块链数据写入内存数据库。After the in-memory database is restored, the blockchain data is written into the in-memory database by the first memory mapping file.
  15. 根据权利要求13所述的区块链节点,其特征在于,所述磁盘数据库具有对应的第二内存映射文件;所述计算机可读指令被所述处理器执行时,使得所述一个或多个处理器还执行以下步骤:The blockchain node of claim 13 wherein said disk database has a corresponding second memory mapped file; said computer readable instructions being executed by said processor to cause said one or more The processor also performs the following steps:
    当区块链数据写入磁盘数据库失败时,获取所述第二内存映射文件,将所述区块链数据写入第二内存映射文件;及When the blockchain data is written to the disk database, the second memory mapping file is obtained, and the blockchain data is written into the second memory mapping file;
    在所述磁盘数据库恢复后,通过所述第二内存映射文件将所述区块链数 据写入磁盘数据库。After the disk database is restored, the blockchain data is written to the disk database by the second memory mapped file.
  16. 根据权利要求13-15任一项所述的区块链节点,其特征在于,磁盘数据库包括主磁盘数据库和从磁盘数据库;所述计算机可读指令被所述处理器执行时,使得所述一个或多个处理器还执行以下步骤:A blockchain node according to any of claims 13-15, wherein the disk database comprises a primary disk database and a secondary disk database; said computer readable instructions being executed by said processor such that said one Or multiple processors perform the following steps:
    将区块链数据写入主磁盘数据库进行存储;所述主磁盘数据库与所述从磁盘数据库保持区块链数据同步;及Writing blockchain data to a primary disk database for storage; the primary disk database is synchronized with the slave disk database to maintain blockchain data; and
    当读取区块链数据时,在所述从磁盘数据库中读取区块链数据。When the blockchain data is read, the blockchain data is read in the slave disk database.
  17. 一个或多个存储有计算机可读指令的非易失性计算机可读存储介质,计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行以下步骤:One or more non-transitory computer readable storage mediums storing computer readable instructions, when executed by one or more processors, cause one or more processors to perform the steps of:
    获取区块链数据;Obtaining blockchain data;
    将所述区块链数据分别写入内存数据库和磁盘数据库进行存储;及Writing the blockchain data to an in-memory database and a disk database for storage; and
    当读取区块链数据时,先从内存数据库中进行读取,若读取失败,则从所述磁盘数据库中读取区块链数据,并且将读取到的区块链数据同步至内存数据库。When the blockchain data is read, the reading is performed from the in-memory database. If the reading fails, the blockchain data is read from the disk database, and the read blockchain data is synchronized to the memory. database.
  18. 根据权利要求17所述的存储介质,其特征在于,所述内存数据库具有对应的第一内存映射文件;计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器还执行以下步骤:The storage medium of claim 17 wherein said in-memory database has a corresponding first memory mapped file; when said computer readable instructions are executed by one or more processors, causing one or more processors to also execute The following steps:
    当区块链数据写入内存数据库失败时,获取所述第一内存映射文件,将所述区块链数据写入第一内存映射文件;及When the blockchain data fails to be written into the in-memory database, acquiring the first memory mapping file, and writing the blockchain data into the first memory mapping file; and
    在所述内存数据库恢复后,通过所述第一内存映射文件将所述区块链数据写入内存数据库。After the in-memory database is restored, the blockchain data is written into the in-memory database by the first memory mapping file.
  19. 根据权利要求17所述的存储介质,其特征在于,所述磁盘数据库具有对应的第二内存映射文件,计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器还执行以下步骤:The storage medium of claim 17 wherein said disk database has a corresponding second memory mapped file, the computer readable instructions being executed by one or more processors such that one or more processors further execute The following steps:
    当区块链数据写入磁盘数据库失败时,获取所述第二内存映射文件,将所述区块链数据写入第二内存映射文件;及When the blockchain data is written to the disk database, the second memory mapping file is obtained, and the blockchain data is written into the second memory mapping file;
    在所述磁盘数据库恢复后,通过所述第二内存映射文件将所述区块链数据写入磁盘数据库。After the disk database is restored, the blockchain data is written to the disk database by the second memory mapping file.
  20. 根据权利要求17-19任一项所述的存储介质,其特征在于,磁盘数据库包括主磁盘数据库和从磁盘数据库;计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器还执行以下步骤:A storage medium according to any one of claims 17 to 19, wherein the disk database comprises a primary disk database and a secondary disk database; and when the computer readable instructions are executed by one or more processors, causing one or more processes The device also performs the following steps:
    将区块链数据写入主磁盘数据库进行存储;所述主磁盘数据库与所述从磁盘数据库保持区块链数据同步;及Writing blockchain data to a primary disk database for storage; the primary disk database is synchronized with the slave disk database to maintain blockchain data; and
    当读取区块链数据时,在所述从磁盘数据库中读取区块链数据。When the blockchain data is read, the blockchain data is read in the slave disk database.
PCT/CN2018/075496 2017-03-09 2018-02-06 Blockchain data storage system and method WO2018161760A1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
SG11201907619VA SG11201907619VA (en) 2017-03-09 2018-02-06 Blockchain data storage system and method

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710139269.1 2017-03-09
CN201710139269.1A CN107704196B (en) 2017-03-09 2017-03-09 Block chain data storage system and method

Publications (2)

Publication Number Publication Date
WO2018161760A1 true WO2018161760A1 (en) 2018-09-13
WO2018161760A8 WO2018161760A8 (en) 2019-08-29

Family

ID=61169547

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/075496 WO2018161760A1 (en) 2017-03-09 2018-02-06 Blockchain data storage system and method

Country Status (3)

Country Link
CN (1) CN107704196B (en)
SG (1) SG11201907619VA (en)
WO (1) WO2018161760A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110275892A (en) * 2019-05-22 2019-09-24 深圳壹账通智能科技有限公司 Data managing method, device, equipment and storage medium towards block chain

Families Citing this family (35)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108537642A (en) * 2018-04-20 2018-09-14 郑勇 A kind of on-line off-line universe credit cycle service system based on block platform chain
CN111897498A (en) * 2018-07-27 2020-11-06 创新先进技术有限公司 Multi-level storage method and device for block chain data
CN109114726B (en) * 2018-08-17 2020-07-10 广东奥维信息科技有限公司 Machine room with temperature control function and carrying block chain technology
CN108897145A (en) * 2018-08-17 2018-11-27 深圳市贝优通新能源技术开发有限公司 A kind of intelligent glasses with defrosting function based on block chain technology
CN109031698A (en) * 2018-08-17 2018-12-18 深圳市雷凌广通技术研发有限公司 A kind of dust-proof shading eyeglasses based on block chain technology
CN109189163A (en) * 2018-08-17 2019-01-11 深圳市贝优通新能源技术开发有限公司 A kind of server with anti-static function based on block chain technology
CN109240438B (en) * 2018-08-17 2020-12-22 安徽宝葫芦信息科技集团股份有限公司 Computer with dustproof function based on block chain technology
CN109145189A (en) * 2018-08-22 2019-01-04 杭州微链区块链科技有限公司 A kind of data deposit and search system and its method based on block chain
CN109741162A (en) * 2018-09-03 2019-05-10 上海奥若拉信息科技集团有限公司 The storage of personal collage-credit data, processing, sharing method and system based on block chain
CN109325011A (en) * 2018-09-03 2019-02-12 上海奥若拉信息科技集团有限公司 Data storage, processing, sharing method and system based on block chain
CN109033916B (en) * 2018-09-06 2020-11-13 江西驴充充充电技术有限公司 Code scanner based on block chain technology
CN108898039A (en) * 2018-09-06 2018-11-27 深圳市晓控通信科技有限公司 A kind of shatter-resistant based on block chain technology and energy-efficient barcode scanning gun
CN109138774B (en) * 2018-09-19 2021-01-05 浙江佳洋门业有限公司 Security door based on block chain technology
CN109360302A (en) * 2018-09-19 2019-02-19 深圳市贝优通新能源技术开发有限公司 A kind of smart lock based on block chain technology
CN109246341A (en) * 2018-09-19 2019-01-18 深圳市安思科电子科技有限公司 A kind of camera convenient for handling based on block chain technology
CN109184356A (en) * 2018-09-19 2019-01-11 深圳市奈士迪技术研发有限公司 A kind of safe type intelligent lock based on block chain technology
CN109120824A (en) * 2018-09-19 2019-01-01 深圳市晓控通信科技有限公司 A kind of camera with dust reduction capability based on block chain technology
CN109068040A (en) * 2018-09-19 2018-12-21 深圳市奈士迪技术研发有限公司 A kind of camera being easily installed based on block chain technology
CN109326312A (en) * 2018-09-19 2019-02-12 深圳市奈士迪技术研发有限公司 A kind of safety-type shared intelligent hard disc based on block chain technology
CN109255875A (en) * 2018-09-19 2019-01-22 深圳市奈士迪技术研发有限公司 A kind of smart lock that the safety coefficient based on block chain technology is high
CN109403735A (en) * 2018-10-12 2019-03-01 深圳市中科智诚科技有限公司 A kind of safe and reliable intelligent door lock based on block chain technology
CN109347502B (en) * 2018-10-12 2020-11-10 江西驴充充充电技术有限公司 Durable security protection communication device based on block chain technology
CN109302584A (en) * 2018-10-12 2019-02-01 深圳市乐业科技有限公司 A kind of security monitoring device that the coverage based on block chain technology is wide
CN109068045A (en) * 2018-10-12 2018-12-21 深圳市贝优通新能源技术开发有限公司 A kind of monitoring device with light regulatory function based on block chain technology
CN109582735A (en) * 2018-10-26 2019-04-05 黄淮学院 A kind of block chain blocks of knowledge storage system
CN111159142B (en) * 2018-11-07 2023-07-14 马上消费金融股份有限公司 Data processing method and device
CN109558453B (en) * 2018-11-27 2021-01-26 深圳市链联科技有限公司 Block chain data network storage and relocation method
CN109739843A (en) * 2018-12-26 2019-05-10 篱笆墙网络科技有限公司 Block chain data read-write method, system, equipment and storage medium
CN110209742B (en) * 2019-06-17 2021-07-27 国家计算机网络与信息安全管理中心 Block chain based storage system and method classified according to data importance
CN110442579B (en) * 2019-08-02 2022-06-28 杭州复杂美科技有限公司 State tree data storage method, synchronization method and equipment and storage medium
CN111147718A (en) * 2019-12-24 2020-05-12 深圳市安思科电子科技有限公司 Monitoring device convenient to accomodate based on block chain technique
CN111291022B (en) * 2020-02-10 2024-01-05 刘翱天 Data storage system based on block chain
CN111309783A (en) * 2020-02-10 2020-06-19 刘翱天 Cochain data reading system
CN111432011B (en) * 2020-03-30 2023-02-17 百度国际科技(深圳)有限公司 Block chain network communication method and equipment
CN115098045B (en) * 2022-08-23 2022-11-25 成都止观互娱科技有限公司 Data storage system and network data reading and writing method

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102222107A (en) * 2011-06-28 2011-10-19 中国联合网络通信集团有限公司 Data access system and method
US20120209891A1 (en) * 2009-11-18 2012-08-16 Hitachi, Ltd. Database management method, database management system and database management program
CN102945251A (en) * 2012-10-12 2013-02-27 浪潮电子信息产业股份有限公司 Method for optimizing performance of disk database by memory database technology
CN106372115A (en) * 2016-08-23 2017-02-01 成都乾威科技有限公司 Data reading/writing method and system, and database system

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8433684B2 (en) * 2010-03-30 2013-04-30 Sybase, Inc. Managing data backup of an in-memory database in a database management system
CN102521389A (en) * 2011-12-23 2012-06-27 天津神舟通用数据技术有限公司 Postgresql database cluster system mixedly using solid state drives and hard disk drive and optimizing method thereof
CN102868552B (en) * 2012-08-21 2015-11-18 广东电网公司电力科学研究院 Data transmission method for uplink

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120209891A1 (en) * 2009-11-18 2012-08-16 Hitachi, Ltd. Database management method, database management system and database management program
CN102222107A (en) * 2011-06-28 2011-10-19 中国联合网络通信集团有限公司 Data access system and method
CN102945251A (en) * 2012-10-12 2013-02-27 浪潮电子信息产业股份有限公司 Method for optimizing performance of disk database by memory database technology
CN106372115A (en) * 2016-08-23 2017-02-01 成都乾威科技有限公司 Data reading/writing method and system, and database system

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110275892A (en) * 2019-05-22 2019-09-24 深圳壹账通智能科技有限公司 Data managing method, device, equipment and storage medium towards block chain
CN110275892B (en) * 2019-05-22 2022-08-19 深圳壹账通智能科技有限公司 Block chain-oriented data management method, device, equipment and storage medium

Also Published As

Publication number Publication date
SG11201907619VA (en) 2019-09-27
WO2018161760A8 (en) 2019-08-29
CN107704196A (en) 2018-02-16
CN107704196B (en) 2020-03-27

Similar Documents

Publication Publication Date Title
WO2018161760A1 (en) Blockchain data storage system and method
US10831720B2 (en) Cloud storage distributed file system
US20190146946A1 (en) Method and device for archiving block data of blockchain and method and device for querying the same
US10817498B2 (en) Distributed transactions in cloud storage with hierarchical namespace
US20190370362A1 (en) Multi-protocol cloud storage for big data and analytics
CN106815218B (en) Database access method and device and database system
CN106547859B (en) Data file storage method and device under multi-tenant data storage system
US9547706B2 (en) Using colocation hints to facilitate accessing a distributed data storage system
US9405643B2 (en) Multi-level lookup architecture to facilitate failure recovery
CN103595797B (en) Caching method for distributed storage system
CN111324665B (en) Log playback method and device
CN107153644B (en) Data synchronization method and device
CN107391033B (en) Data migration method and device, computing equipment and computer storage medium
US10152493B1 (en) Dynamic ephemeral point-in-time snapshots for consistent reads to HDFS clients
WO2017084520A1 (en) Method and apparatus for synchronizing data files in a cloud environment
CN103501319A (en) Low-delay distributed storage system for small files
WO2023077971A1 (en) Transaction processing method and apparatus, and computing device and storage medium
CN112559529B (en) Data storage method, device, computer equipment and storage medium
CN116204575A (en) Method, device, equipment and computer storage medium for importing data into database
US9767139B1 (en) End-to-end data integrity in parallel storage systems
WO2017028721A1 (en) Data update method and device in distributed file system
CN109542860B (en) Service data management method based on HDFS and terminal equipment
CN115328931A (en) Database cluster data verification method and device, storage medium and electronic equipment
JP2022078972A (en) Change data capture log history, or method of tracking cdc log history, and computer program (tracking change data capture log history)
CN113656496A (en) Data processing method and system

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

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 22/01/2020)

122 Ep: pct application non-entry in european phase

Ref document number: 18764580

Country of ref document: EP

Kind code of ref document: A1