CN112597153B - Block chain-based data storage method, device and storage medium - Google Patents

Block chain-based data storage method, device and storage medium Download PDF

Info

Publication number
CN112597153B
CN112597153B CN202011429154.4A CN202011429154A CN112597153B CN 112597153 B CN112597153 B CN 112597153B CN 202011429154 A CN202011429154 A CN 202011429154A CN 112597153 B CN112597153 B CN 112597153B
Authority
CN
China
Prior art keywords
data
database
blockchain
association
types
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN202011429154.4A
Other languages
Chinese (zh)
Other versions
CN112597153A (en
Inventor
邱炜伟
李伟
黄方蕾
张珂杰
叶晨宇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Qulian Technology Co Ltd
Original Assignee
Hangzhou Qulian Technology Co Ltd
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 Hangzhou Qulian Technology Co Ltd filed Critical Hangzhou Qulian Technology Co Ltd
Priority to CN202011429154.4A priority Critical patent/CN112597153B/en
Publication of CN112597153A publication Critical patent/CN112597153A/en
Application granted granted Critical
Publication of CN112597153B publication Critical patent/CN112597153B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof
    • 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
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/64Protecting data integrity, e.g. using checksums, certificates or signatures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The application is applicable to the technical field of blockchain, and provides a data storage method, a device and a storage medium based on blockchain, wherein the method comprises the following steps: when an association instruction of multiple data types is received, associating each data type with a corresponding database, wherein the multiple data types comprise contract data, account data and index data; identifying a target data type of the blockchain data; and storing the blockchain data into a database associated with the target data type according to the identified target data type. According to the embodiment of the application, the data quantity of the data of different types is different according to application scenes, the data of different data types are associated with the corresponding databases through the association instruction, and different database configurations can be adopted for the data of different data quantities according to actual application scenes, so that the storage efficiency is improved, the data is stored into the associated databases according to the data types, the data of different types can be stored separately, and the storage efficiency is further improved.

Description

Block chain-based data storage method, device and storage medium
Technical Field
The application belongs to the technical field of blockchains, and particularly relates to a blockchain-based data storage method, a blockchain-based data storage device and a storage medium.
Background
The blockchain technology has been widely focused on the successful application of the blockchain system such as bitcoin and ethernet due to the characteristics of decentralization, tamper resistance, data sharing and the like.
Related data of a blockchain system is usually stored in a single database, and the storage capacity of the single database is limited, so that a bottleneck of data storage is easily caused, and the storage efficiency of the data is low.
Disclosure of Invention
The embodiment of the application provides a data storage method, device and storage medium based on a blockchain, and aims to solve the problem of low storage efficiency of existing blockchain data.
In a first aspect, an embodiment of the present application provides a data storage method based on a blockchain, including:
when an association instruction of multiple data types is received, associating each data type with a corresponding database, wherein the multiple data types comprise contract data, account data and index data;
identifying a target data type of the blockchain data;
and storing the blockchain data into a database associated with the target data type according to the identified target data type.
In one embodiment, the database comprises a single database, a clustered database, and a distributed database.
In one embodiment, the storing the blockchain data into a database associated with the target data type includes:
writing the blockchain data into a pre-write log;
writing the blockchain data into a temporary database;
storing the blockchain data successfully identified in the temporary database into a persistent database, wherein the persistent database is a database associated with the target data type;
and rewriting the blockchain data with failed consensus in the temporary database according to the blockchain data stored in the pre-written log.
In one embodiment, storing blockchain data in the temporary database that is successful in the consensus into the persistent database includes:
if the persistent database is a distributed database, the block chain data successfully identified in the temporary database is stored into the persistent database in a parallel writing mode.
In one embodiment, if the persistent database is a distributed database, storing the blockchain data successfully identified in the temporary database into the persistent database by parallel writing includes:
if the persistent database is a distributed database, traversing the area identifier in the distributed environment where each piece of data successfully identified in the temporary database is located, and grouping the data according to the area identifier to obtain N groups of data; the temporary database includes a plurality of regions;
and storing the N groups of data into the persistent database in a parallel writing mode.
In one embodiment, after receiving the association instruction of multiple data types, associating each data type with a corresponding database, the method includes:
when receiving configuration information for creating a database, creating a corresponding database entity according to the configuration information.
In one embodiment, the association instruction includes a database identifier corresponding to each data type association;
when receiving the association instruction of multiple data types, associating each data type with a corresponding database, including:
when an association instruction of N data types is received, associating a database corresponding to the database identifier according to the database identifier in the association instruction.
In one embodiment, the association instructions include application scenario features;
when receiving the association instruction of multiple data types, associating each data type with a corresponding database, including:
when an association instruction of N data types is received, an association rule pre-associated with the application scene feature is obtained;
and associating each data type with a corresponding database according to the association rule.
In a second aspect, embodiments of the present application provide a blockchain-based data storage device, comprising:
the association module is used for associating each data type with a corresponding database when receiving association instructions of multiple data types, wherein the multiple data types comprise contract data, account data and index data;
the identification module is used for identifying the target data type of the blockchain data;
and the storage module is used for storing the blockchain data into a database associated with the target data type according to the identified target data type.
In a third aspect, an embodiment of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of the blockchain-based data storage method described above when the processor executes the computer program.
In a fourth aspect, embodiments of the present application provide a computer readable storage medium storing a computer program which, when executed by a processor, implements the steps of the blockchain-based data storage method described above.
In a fifth aspect, embodiments of the present application provide a computer program product that, when run on an electronic device, causes the electronic device to perform the steps of the blockchain-based data storage method described above.
Compared with the prior art, the embodiment of the application has the beneficial effects that: when receiving an association instruction of multiple data types, the embodiment of the application associates each data type with a corresponding database, wherein the multiple data types comprise contract data, account data and index data; identifying a target data type of the blockchain data; and storing the blockchain data into a database associated with the target data type according to the identified target data type. According to the embodiment of the application, the data quantity of the data of different types is different according to application scenes, the data of different data types are associated with the corresponding databases through the association instruction, and different database configurations can be adopted for the data of different data quantities according to actual application scenes, so that the storage efficiency is improved, the data is stored into the associated databases according to the data types, the data of different types can be stored separately, and the storage efficiency is further improved.
It will be appreciated that the advantages of the second to fifth aspects may be found in the relevant description of the first aspect, and are not described here again.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following description will briefly introduce the drawings that are needed in the embodiments or the description of the prior art, it is obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a method for blockchain-based data storage according to an embodiment of the present application;
FIG. 2 is a schematic diagram of a database association result provided in an embodiment of the present application;
FIG. 3 is a flow chart of a method for blockchain-based data storage provided in another embodiment of the present application;
FIG. 4 is a schematic diagram of storing data in a distributed database application scenario according to an embodiment of the present application;
FIG. 5 is a schematic diagram of a block chain based data storage device according to one embodiment of the present application;
fig. 6 is a schematic structural diagram of a terminal device according to an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system configurations, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
It should be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It should also be understood that the term "and/or" as used in this specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
As used in this specification and the appended claims, the term "if" may be interpreted as "when..once" or "in response to a determination" or "in response to detection" depending on the context. Similarly, the phrase "if a determination" or "if a [ described condition or event ] is detected" may be interpreted in the context of meaning "upon determination" or "in response to determination" or "upon detection of a [ described condition or event ]" or "in response to detection of a [ described condition or event ]".
In addition, in the description of the present application and the appended claims, the terms "first," "second," "third," and the like are used merely to distinguish between descriptions and are not to be construed as indicating or implying relative importance.
Reference in the specification to "one embodiment" or "some embodiments" or the like means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," and the like in the specification are not necessarily all referring to the same embodiment, but mean "one or more but not all embodiments" unless expressly specified otherwise. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless expressly specified otherwise.
The data storage method based on the block chain is applied to terminal equipment, and the terminal equipment can be a block chain node. The blockchain is a distributed network system, has the characteristic of a consensus mechanism of the blockchain, namely, the blockchain can efficiently achieve consensus on the effectiveness of the blockchain data in a decentralized system with highly dispersed decision weights, and is a decentralized system, so that the blockchain is a high-reliability decentralized network system. Each node in the blockchain may be a server, a tablet, a wearable device, an in-vehicle device, an Augmented Reality (AR)/Virtual Reality (VR) device, a notebook, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (personal digital assistant, PDA), a cell phone, or other various terminal devices capable of data processing, without limitation. The terminal device may be a blockchain node.
In order to illustrate the technical solutions described in the present application, the following examples are provided.
Referring to fig. 1, a data storage method based on a blockchain according to an embodiment of the present application includes:
step S101, when an association instruction of multiple data types is received, associating each data type with a corresponding database, wherein the multiple data types comprise contract data, account data and index data.
Specifically, the data in the blockchain includes contract data, account data, index data, and other types of data, for example, the contract data may be data that needs to be saved for executing related contracts, the account data may be some account data that is used for saving account information of the user, and the index data may be understood as data that is stored for conducting transaction index data and block index. These types of data are currently stored in a single database, which can easily create bottlenecks in data storage performance when there is excessive data. Contract data, account data and index data can be stored separately in different databases, but also because different application scenarios require different data types, such as in scenarios where contracts are operated very frequently (contract data is very bulky) and the number of accounts is very small, i.e., different types of data are stored separately using a single database, the bottleneck still exists in a single database of contract data. Or in the case of blockchain certification, the index database is huge, while the account database and the contract database are relatively small, and the bottleneck is still in a single database of index data. Therefore, when the association instruction of multiple data types is received, each data type is associated with a corresponding database. The data of different types of the blockchain can be stored separately, so that the storage engine type can be flexibly configured.
In one embodiment, the database comprises a single database, a clustered database, and a distributed database.
Specifically, the user is provided in advance with a variety of selectable database types, candidates including, but not limited to: a single database, a clustered database, and a distributed database; the single database may be a single level db database; the cluster database may be a multi-level db database (multi-level db), which may be a database for storing a plurality of level dbs with a plurality of disks; the distributed database can be a distributed database TiKV, and a user can select the database according to the actual scene through the configuration file.
In one embodiment, after receiving the association instruction of multiple data types, associating each data type with a corresponding database, the method includes: when receiving configuration information for creating a database, creating a corresponding database entity according to the configuration information.
Specifically, after each data type is associated with a corresponding database, a database entity may be created according to pre-stored default configuration information, or a database entity may be created according to configuration information sent or input by a user.
In a specific application, the database is a level db, a user can set a default size of each SSTable in the level db database, etc., the database is a multi-level db, the user can set a path on which each level db is located, etc., the database is a distributed database TiKV, and the user can set a configuration of a network address, a port, etc. of the PD in the TiKV database.
In an actual application scenario, for example, according to different blockchain data types, the blockchain data is divided into three types of contract data, account data and index data, and the contract data is stored in a separate storage mode, a database stored by the contract data is called a StateDB, a database stored by the account data is called an AccountDB, and a database stored by the index data is called an index db; providing configuration items to be selected for each type of database in advance, such as 'LevelDB', 'MultiLevelDB', 'TiKV'; respectively selecting StateDB, accountDB databases to be associated with the IndexDB in databases of configuration items to be selected according to association instructions of users, and correspondingly providing specific configuration items in specific databases, wherein the specific configuration items comprise default size of each SSTable in the LevelDB, paths of each database in the MultiLevelDB, network addresses and ports of PDs in TiKV and other configuration information; and finally, creating a corresponding database entity for StateDB, accountDB, indexDB according to the type of the database selected by the user and the specific configuration information thereof. If the contract is frequently operated and the account number is small, and the block chain system needs to stably operate for a long time, a distributed TiKV database can be configured for the StateDB, a multi-level DB database can be configured for the IndexDB, a single-level DB database can be configured for the Account DB, and a database association result diagram is shown in FIG. 2.
In one embodiment, the association instruction includes a database identifier corresponding to each data type association; when receiving the association instruction of multiple data types, associating each data type with a corresponding database, including: when an association instruction of N data types is received, associating a database corresponding to the database identifier according to the database identifier in the association instruction.
In one embodiment, the association instructions include application scenario features; when receiving the association instruction of multiple data types, associating each data type with a corresponding database, including: when an association instruction of N data types is received, an association rule pre-associated with the application scene feature is obtained; and associating each data type with a corresponding database according to the association rule.
Specifically, the user can directly associate different data types with corresponding databases through association instructions, or the user does not know the data requirement of the application scene, can send or input the characteristics of the application scene, associates the association rules corresponding to the characteristics of the application scene in advance, and automatically selects the associated databases for contract data, account data and index data according to the characteristics of the application scene sent by the user. The pre-association rule of the application scene is characterized by 'blockchain certification',: the index data is associated with the distributed TiKV database, the contract data is associated with the multi-level DB database, the account data is associated with the single-level DB database, and then the index data can be automatically associated with the distributed TiKV database according to association rules, the contract data is associated with the multi-level DB database, and the account is associated with the single-level DB database.
Step S102, a target data type of the blockchain data is identified.
Specifically, in the process of processing the blockchain data, the processing of the blockchain data may be a process of backing up transaction data in the blockchain or processing data such as newly built data blocks. The data type of the block chain data in the process is identified, and the identified data type is called a target data type.
And step S103, storing the blockchain data into a database associated with the target data type according to the identified target data type.
Specifically, the blockchain data is stored in a database associated with the target data type according to the identified target data type. If the identified target data type is contract data, storing the contract data into a stateDB database, wherein the identified target data type is account data, storing the account data into an Account DB database, and storing the index data into an IndexDB database, wherein the identified target data type is index data.
In one embodiment, as shown in fig. 3, the storing the blockchain data into a database associated with the target data type includes steps S1031 to S1034:
step S1031, writing the blockchain data into a pre-write log.
Specifically, the blockchain data is written in batches (Batch) by taking a block as a unit, and when the block is written, a pre-written log (WAL) is written first, and the pre-written log is a data structure for quick recovery, but the query service cannot be provided, and the method is mainly used when the temporary database is lost or is in error (such as downtime occurs, the data in the temporary database is lost, and the pre-written log is required to be recovered at the moment).
Step S1032, writing the blockchain data into a temporary database.
Specifically, the temporary database may be an in-memory database, and then the blockchain data is written into the in-memory database in batches (Batch).
Step S1033, storing the blockchain data successfully identified in the temporary database into a persistent database, wherein the persistent database is a database associated with the target data type.
Specifically, the data in the temporary database and the pre-written log are identified by the block chain identification mechanism, so that when the block chain data after the block chain identification mechanism identification is detected to be successfully identified, the block chain data successfully identified in the temporary database can be stored in the persistent database.
In one embodiment, whether it is a pre-written log or an in-memory database, the data therein has not been validated by the consensus module, and thus there is a potential for rollback. Once the consensus is confirmed, the databases in the corresponding memory databases can be asynchronously written into the bottom persistent database, and related data in the corresponding pre-written log is deleted after the writing is completed.
Step S1034, rewriting the block chain data with failed consensus in the temporary database according to the block chain data stored in the pre-written log.
In one embodiment, when it is detected that the blockchain data after the failure of the identification of the passing blockchain data is the blockchain data with the identification mechanism of the blockchain, the blockchain data needs to be rolled back, and rolling back (Rollback) refers to the action of restoring the program or the data to the last correct state. The temporary database is emptied during the rollback process and the data that should not be rolled back is rewritten to the temporary database via the pre-written log. The temporary database corresponding to the block chain data with failed consensus is emptied, and then the data which should not be rolled back is rewritten into the temporary database through the pre-written log, and the data which should not be rolled back can be understood as abnormal data such as errors in the block chain data with failed consensus.
In one embodiment, storing blockchain data in the temporary database that is successful in the consensus into the persistent database includes: if the persistent database is a distributed database, the block chain data successfully identified in the temporary database is stored into the persistent database in a parallel writing mode.
In one embodiment, if the persistent database is a distributed database, storing the blockchain data successfully identified in the temporary database into the persistent database by parallel writing includes: if the persistent database is a distributed database, traversing the area identifier in the distributed environment where each piece of data successfully identified in the temporary database is located, and grouping the data according to the area identifier to obtain N groups of data; the temporary database includes a plurality of regions (regions); and storing the N groups of data into the persistent database in a parallel writing mode.
In one embodiment, the distributed database is to store the data in the original centralized database to a plurality of data storage nodes connected through a network in a scattered manner, and store the data in the distributed database in a mode of writing the data into the plurality of storage nodes in parallel according to the identification of each data storage node.
In the application, the user can flexibly configure the database through the method. If the persistent database is configured as a distributed database TiKV, since the data storage of the TiKV is performed according to partitions, each Region (Region) contains a certain amount of ordered data, the regions may be distributed on different machines, and before the data is written, the Region where the data to be written is located needs to be determined by an additional network communication. When the data in the memory database is required to be written through the consensus confirmation, the data in the memory database is traversed in sequence, the Region where each piece of data is located is determined, the data are grouped according to the Region ID, the groups are written into the distributed database in parallel after the grouping is finished, and the data in different groups are written into the distributed database in parallel.
In a specific application scenario, as shown in fig. 4, a schematic diagram of data stored in a distributed database in a TiKV scenario is shown.
In the embodiment of the invention, as the data volume of the data of different types is different according to application scenes, the data of different data types are associated with the corresponding databases through the association instruction, and different database configurations can be adopted for the data of different data volumes according to actual application scenes, so that the storage efficiency is improved, the data of different types are stored in the associated databases according to the data types, and the storage efficiency is further improved.
The embodiment of the application also provides a data storage device based on the block chain, which is used for executing the steps in the embodiment of the data storage method based on the block chain. As shown in fig. 5, a blockchain-based data storage device 500 provided in an embodiment of the present application includes:
the association module 501 is configured to associate each data type with a corresponding database when receiving an association instruction of multiple data types, where the multiple data types include contract data, account data, and index data;
an identification module 502 for identifying a target data type of the blockchain data;
a storage module 503, configured to store the blockchain data into a database associated with the target data type according to the identified target data type.
In one embodiment, the database comprises a single database, a clustered database, and a distributed database.
In one embodiment, the storage module 503 specifically includes:
the first writing unit is used for writing the blockchain data into a pre-write log;
a second writing unit for writing the blockchain data into a temporary database;
the storage unit is used for storing the blockchain data successfully identified in the temporary database into a persistent database, wherein the persistent database is a database associated with the target data type;
and the rewriting unit is used for rewriting the blockchain data with failed consensus in the temporary database according to the blockchain data stored in the pre-written log.
In one embodiment, the storage unit is specifically configured to:
if the persistent database is a distributed database, the block chain data successfully identified in the temporary database is stored into the persistent database in a parallel writing mode.
In one embodiment, the storage unit specifically includes:
a grouping subunit, configured to traverse an area identifier in a distributed environment where each piece of data in the temporary database is successfully identified if the persistent database is a distributed database, and group the data according to the area identifier to obtain N groups of data; the temporary database includes a plurality of regions;
and the writing subunit is used for storing the N groups of data into the persistent database in a parallel writing mode.
In one embodiment, the data storage device 500 further comprises:
and the configuration module is used for creating a corresponding database entity according to the configuration information when receiving the configuration information for creating the database.
In one embodiment, the association instruction includes a database identifier corresponding to each data type association; the association module 501 is specifically configured to:
when an association instruction of N data types is received, associating a database corresponding to the database identifier according to the database identifier in the association instruction.
In one embodiment, the association instructions include application scenario features; the association module 501 is specifically configured to:
when an association instruction of N data types is received, an association rule pre-associated with the application scene feature is obtained; and associating each data type with a corresponding database according to the association rule.
According to the embodiment of the application, the data quantity of the data of different types is different according to application scenes, the data of different data types are associated with the corresponding databases through the association instruction, and different database configurations can be adopted for the data of different data quantities according to actual application scenes, so that the storage efficiency is improved, the data is stored into the associated databases according to the data types, the data of different types can be stored separately, and the storage efficiency is further improved.
As shown in fig. 6, an embodiment of the present invention further provides a terminal device 600 including: a processor 601, a memory 602, and a computer program 603 stored in the memory 602 and executable on the processor 601, such as a blockchain based data storage program. The processor 601, when executing the computer program 603, performs the steps of the various blockchain-based data storage method embodiments described above. The processor 601, when executing the computer program 603, performs the functions of the modules of the apparatus embodiments described above, such as the functions of the modules 501 to 503 shown in fig. 5.
Illustratively, the computer program 603 may be partitioned into one or more modules that are stored in the memory 602 and executed by the processor 601 to perform the present invention. The one or more modules may be a series of computer program instruction segments capable of performing specific functions for describing the execution of the computer program 603 in the terminal device 600. For example, the computer program 603 may be divided into an association module, an identification module, and a storage module, where specific functions of each module are described in the foregoing embodiments, and are not described herein again.
The terminal device 600 may be a server, tablet, wearable device, in-vehicle device, augmented reality (augmented reality, AR)/Virtual Reality (VR) device, notebook, ultra-mobile personal computer, UMPC, netbook, personal digital assistant (personal digital assistant, PDA), cell phone, or other computing device. The terminal device may include, but is not limited to, a processor 601, a memory 602. It will be appreciated by those skilled in the art that fig. 5 is merely an example of a terminal device 600 and is not limiting of the terminal device 600, and may include more or fewer components than shown, or may combine certain components, or different components, e.g., the terminal device may further include an input-output device, a network access device, a bus, etc.
The processor 601 may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field-programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 602 may be an internal storage unit of the terminal device 600, for example, a hard disk or a memory of the terminal device 600. The memory 602 may also be an external storage device of the terminal device 600, for example, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card) or the like, which are provided on the terminal device 600. Further, the memory 602 may also include both an internal storage unit and an external storage device of the terminal device 600. The memory 602 is used for storing the computer program and other programs and data required by the terminal device. The memory 602 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions. The functional units and modules in the embodiment may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit, where the integrated units may be implemented in a form of hardware or a form of a software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working process of the units and modules in the above system may refer to the corresponding process in the foregoing method embodiment, which is not described herein again.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and in part, not described or illustrated in any particular embodiment, reference is made to the related descriptions of other embodiments.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus/terminal device and method may be implemented in other manners. For example, the apparatus/terminal device embodiments described above are merely illustrative, e.g., the division of the modules or units is merely a logical function division, and there may be additional divisions in actual implementation, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection via interfaces, devices or units, which may be in electrical, mechanical or other forms.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated modules, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the present invention may implement all or part of the flow of the method of the above embodiment, or may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, and when the computer program is executed by a processor, the computer program may implement the steps of each of the method embodiments described above. Wherein the computer program comprises computer program code which may be in source code form, object code form, executable file or some intermediate form etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), an electrical carrier signal, a telecommunications signal, a software distribution medium, and so forth. It should be noted that the computer readable medium contains content that can be appropriately scaled according to the requirements of jurisdictions in which such content is subject to legislation and patent practice, such as in certain jurisdictions in which such content is subject to legislation and patent practice, the computer readable medium does not include electrical carrier signals and telecommunication signals.
The above embodiments are only for illustrating the technical solution of the present invention, and not for limiting the same; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention, and are intended to be included in the scope of the present invention.

Claims (8)

1. A blockchain-based data storage method, applied to a blockchain node, comprising:
when an association instruction of multiple data types is received, associating each data type with a corresponding database, wherein the multiple data types comprise contract data, account data and index data; the contract data is data which is required to be saved for executing related contracts, the account data is account data for saving user account information, and the index data is data stored for carrying out transaction index data and block index; the database comprises a single database, a cluster database and a distributed database;
identifying a target data type of the blockchain data;
storing the blockchain data in a database associated with the target data type according to the identified target data type, including: writing the blockchain data into a pre-write log; writing the blockchain data into a temporary database; storing the blockchain data successfully identified in the temporary database into a persistent database, wherein the persistent database is a database associated with the target data type; and rewriting the blockchain data with failed consensus in the temporary database according to the blockchain data stored in the pre-written log.
2. The data storage method of claim 1, wherein storing the blockchain data in the temporary database for which the consensus is successful in the persistent database comprises:
if the persistent database is a distributed database, the block chain data successfully identified in the temporary database is stored into the persistent database in a parallel writing mode.
3. The data storage method according to claim 2, wherein if the persistent database is a distributed database, storing the blockchain data successfully identified in the temporary database into the persistent database by parallel writing includes:
if the persistent database is a distributed database, traversing the area identifier in the distributed environment where each piece of data successfully identified in the temporary database is located, and grouping the data according to the area identifier to obtain N groups of data; the temporary database includes a plurality of regions;
and storing the N groups of data into the persistent database in a parallel writing mode.
4. The data storage method according to claim 1, wherein upon receiving the association instruction of the plurality of data types, associating each data type with the corresponding database comprises:
when receiving configuration information for creating a database, creating a corresponding database entity according to the configuration information.
5. The data storage method of claim 1, wherein the association instructions include database identifications corresponding to each data type association;
when receiving the association instruction of multiple data types, associating each data type with a corresponding database, including:
when an association instruction of N data types is received, associating a database corresponding to the database identifier according to the database identifier in the association instruction.
6. The data storage method of claim 1, wherein the association instructions comprise application scenario features;
when receiving the association instruction of multiple data types, associating each data type with a corresponding database, including:
when an association instruction of N data types is received, an association rule pre-associated with the application scene feature is obtained;
and associating each data type with a corresponding database according to the association rule.
7. A blockchain-based data storage device, for use with a blockchain node, comprising:
the association module is used for associating each data type with a corresponding database when receiving association instructions of multiple data types, wherein the multiple data types comprise contract data, account data and index data; the contract data is data which is required to be saved for executing related contracts, the account data is account data for saving user account information, and the index data is data stored for carrying out transaction index data and block index; the database comprises a single database, a cluster database and a distributed database;
the identification module is used for identifying the target data type of the blockchain data;
the storage module is used for storing the blockchain data into a database associated with the target data type according to the identified target data type;
the storage module specifically comprises:
the first writing unit is used for writing the blockchain data into a pre-write log;
a second writing unit for writing the blockchain data into a temporary database;
the storage unit is used for storing the blockchain data successfully identified in the temporary database into a persistent database, wherein the persistent database is a database associated with the target data type;
and the rewriting unit is used for rewriting the blockchain data with failed consensus in the temporary database according to the blockchain data stored in the pre-written log.
8. A computer readable storage medium storing a computer program, characterized in that the computer program when executed by a processor implements the method according to any one of claims 1 to 6.
CN202011429154.4A 2020-12-09 2020-12-09 Block chain-based data storage method, device and storage medium Active CN112597153B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011429154.4A CN112597153B (en) 2020-12-09 2020-12-09 Block chain-based data storage method, device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011429154.4A CN112597153B (en) 2020-12-09 2020-12-09 Block chain-based data storage method, device and storage medium

Publications (2)

Publication Number Publication Date
CN112597153A CN112597153A (en) 2021-04-02
CN112597153B true CN112597153B (en) 2023-07-25

Family

ID=75191173

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011429154.4A Active CN112597153B (en) 2020-12-09 2020-12-09 Block chain-based data storage method, device and storage medium

Country Status (1)

Country Link
CN (1) CN112597153B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022216204A1 (en) * 2021-04-06 2022-10-13 Rz Capital Holding Ab Method and apparatus for handling secure communication using blockchains in a communications network
CN113553452A (en) * 2021-06-16 2021-10-26 浙江科技学院 Spatial domain name processing method and device based on virtual reality
CN113392159A (en) * 2021-06-18 2021-09-14 湖南快乐阳光互动娱乐传媒有限公司 Data sharing method and device
CN113326165B (en) * 2021-08-04 2021-11-16 腾讯科技(深圳)有限公司 Data processing method and device based on block chain and computer readable storage medium
CN114780285A (en) * 2022-02-25 2022-07-22 蚂蚁区块链科技(上海)有限公司 Block chain data recovery method and device and electronic equipment
CN115617859A (en) * 2022-12-16 2023-01-17 安徽华云安科技有限公司 Data query method and device based on knowledge graph cluster

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6714935B1 (en) * 1998-09-21 2004-03-30 Microsoft Corporation Management of non-persistent data in a persistent database
CA3048741A1 (en) * 2017-03-28 2018-10-04 Alibaba Group Holding Limited Blockchain-based data storage and query method and device
CN109857724A (en) * 2019-02-12 2019-06-07 众安信息技术服务有限公司 The method and apparatus for supporting multitype database is realized based on block chain
CN110309163A (en) * 2019-06-28 2019-10-08 杭州复杂美科技有限公司 Block chain relation type database maintenance method and data query method
CN110309173A (en) * 2019-06-14 2019-10-08 深圳前海达闼云端智能科技有限公司 Contract data recording method and device, block chain node and storage medium
CN110457398A (en) * 2019-08-15 2019-11-15 广州蚁比特区块链科技有限公司 Block data storage method and device
WO2020088109A1 (en) * 2018-10-31 2020-05-07 阿里巴巴集团控股有限公司 Blockchain-based private transactions and usage method and apparatus therefor
CN112015806A (en) * 2019-05-30 2020-12-01 中国移动通信集团浙江有限公司 Method and device for storing data by block chain

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11139081B2 (en) * 2016-05-02 2021-10-05 Bao Tran Blockchain gene system
US10789222B2 (en) * 2019-06-28 2020-09-29 Alibaba Group Holding Limited Blockchain-based hierarchical data storage
CN111078723B (en) * 2019-11-29 2021-08-13 支付宝(杭州)信息技术有限公司 Data processing method and device for block chain browser
CN111274318B (en) * 2020-01-16 2023-04-25 杭州趣链科技有限公司 Block chain state data storage and rollback method, equipment and storage medium
CN111291119B (en) * 2020-01-21 2023-04-25 郑州阿帕斯数云信息科技有限公司 Data synchronization method and device

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6714935B1 (en) * 1998-09-21 2004-03-30 Microsoft Corporation Management of non-persistent data in a persistent database
CA3048741A1 (en) * 2017-03-28 2018-10-04 Alibaba Group Holding Limited Blockchain-based data storage and query method and device
WO2020088109A1 (en) * 2018-10-31 2020-05-07 阿里巴巴集团控股有限公司 Blockchain-based private transactions and usage method and apparatus therefor
CN109857724A (en) * 2019-02-12 2019-06-07 众安信息技术服务有限公司 The method and apparatus for supporting multitype database is realized based on block chain
CN112015806A (en) * 2019-05-30 2020-12-01 中国移动通信集团浙江有限公司 Method and device for storing data by block chain
CN110309173A (en) * 2019-06-14 2019-10-08 深圳前海达闼云端智能科技有限公司 Contract data recording method and device, block chain node and storage medium
CN110309163A (en) * 2019-06-28 2019-10-08 杭州复杂美科技有限公司 Block chain relation type database maintenance method and data query method
CN110457398A (en) * 2019-08-15 2019-11-15 广州蚁比特区块链科技有限公司 Block data storage method and device

Also Published As

Publication number Publication date
CN112597153A (en) 2021-04-02

Similar Documents

Publication Publication Date Title
CN112597153B (en) Block chain-based data storage method, device and storage medium
CN111352902A (en) Log processing method and device, terminal equipment and storage medium
CN106981024B (en) Transaction limit calculation processing system and processing method thereof
CN111913667B (en) OSD blocking detection method, system, terminal and storage medium based on Ceph
CN103164523A (en) Inspection method, device and system of data consistency inspection
CN110570311B (en) Block chain consensus method, device and equipment
CN110633977A (en) Payment exception processing method and device and terminal equipment
CN111611249A (en) Data management method, device, equipment and storage medium
CN113836184A (en) Service persistence method and device
CN111723159A (en) Data verification method and device based on block chain
CN111767270A (en) Data migration method, device, server and storage medium
CN110598993B (en) Data processing method and device
CN111291002B (en) File account checking method, device, computer equipment and storage medium
CN108920601A (en) A kind of data matching method and device
WO2024036829A1 (en) Data fusion method and apparatus, and device and storage medium
CN110827001A (en) Accounting event bookkeeping method, system, equipment and storage medium
CN111899018B (en) Order data processing method, device, server and storage medium
CN110399354B (en) Partition exchange method and device for database
CN113934566A (en) Exception handling method and device and electronic equipment
CN114006819A (en) Detection strategy generation and device, and data transmission method and device
CN111371818B (en) Data request verification method, device and equipment
CN111639057A (en) Log message processing method and device, computer equipment and storage medium
CN111158994A (en) Pressure testing performance testing method and device
CN111651123B (en) Processing method, device and equipment for concurrent IO (input/output) requests
CN115037799B (en) Current limiting method, device, equipment and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant