Blockchain-based data processing method, device, equipment, and computer program
By distributing blockchain data across multiple database instances based on a storage instance mapping table and sharding policy, the method enhances storage capacity and performance in blockchain systems, overcoming limitations of single-disk storage.
Patent Information
- Application Number
- JP2023573451
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2022-11-07
- Filing Date
- 2023-08-09
- Publication Date
- 2025-08-13
- Estimated Expiration
- 2043-08-09
AI Technical Summary
Traditional blockchain systems face limitations in storage capacity and performance due to reliance on a single hard disk, which cannot meet the demands of high-frequency transaction scenarios.
Implement a data processing method that utilizes a storage instance mapping table to distribute blockchain data across multiple database instances, matching data types to specific database instances based on a sharding policy, thereby expanding storage capacity and improving read/write performance.
The method effectively doubles storage capacity and read/write performance by allocating multiple database instances, allowing for efficient storage and management of different data types across various instances, addressing storage pressure and capacity limitations.
Smart Images

Figure 0007722778000003 
Figure 0007722778000004 
Figure 0007722778000005
Abstract
Description
[Technical Field]
[0001] This application claims priority to a Chinese patent application filed on November 7, 2022, bearing application number 202211383918.X and entitled "Blockchain-based data processing method, device, equipment and medium," the entire contents of which are incorporated herein by reference.
[0002] The present application relates to the technical field of blockchain, and in particular to a data processing method, device, equipment, and medium using blockchain. [Background technology]
[0003] In traditional blockchain systems, database instances are used to store blockchain data. Blockchain nodes and database instances are both located on the same device and are in a corresponding relationship. The database instances only use one hard disk. Generally, data from blockchain nodes is stored on a standalone local hard disk. When the scale of blockchain data is small, this standalone storage method can meet the storage needs within a short period of time. However, when blockchain is applied to high-frequency transaction scenarios, the storage capacity of blockchain nodes is limited by the capacity of a single hard disk, and the storage performance is also limited by the read / write speed of a single hard disk, making it difficult to meet the storage needs. Summary of the Invention [Problem to be solved by the invention]
[0004] The embodiments of the present application provide a method, device, equipment and medium for processing data using blockchain, and the technical solutions include the following: [Means for solving the problem]
[0005] One aspect of an embodiment of the present application provides a data processing method using a blockchain, Obtaining a storage instance mapping table based on the database configuration information of the blockchain node, the storage instance mapping table including data mapping relationships of N database instances, the data mapping relationships indicating data types of the database instances, where N is a positive integer greater than 1; When acquiring the blockchain data to be stored, determining M candidate database instances from the N database instances, where the data types of the candidate database instances match the blockchain data, and M is a positive integer less than or equal to N; and storing the blockchain data in a first database instance among the M candidate database instances based on a data sharding policy in the database placement information.
[0006] One aspect of an embodiment of the present application provides a data processing device using a blockchain, A mapping table acquisition module for acquiring a storage instance mapping table according to the database configuration information of the blockchain node, the storage instance mapping table including data mapping relationships of N database instances, the data mapping relationships indicating data types of the database instances, N being a positive integer greater than 1; When acquiring blockchain data to be stored, a data type matching module determines M candidate database instances from the N database instances, where the data types of the candidate database instances match the blockchain data, and M is a positive integer less than or equal to N; and a data storage module that stores the blockchain data in a first database instance among the M candidate database instances based on a data sharding policy in the database placement information.
[0007] One aspect of an embodiment of the present application provides a computer device, including a processor, a memory, and a network interface; The processor, memory, and network interface are coupled together, the network interface provides a data communication function, the memory stores a computer program, and the processor invokes the computer program to cause the computer device to perform the blockchain-based data processing method provided by the embodiments of the present application.
[0008] One aspect of an embodiment of the present application provides a computer-readable storage medium having a computer program stored therein, the computer program being read and executed by a processor, causing a computer device having the processor to perform a blockchain-based data processing method provided by an embodiment of the present application.
[0009] One aspect of an embodiment of the present application provides a computer program product, the computer program product including a computer program, the computer program being stored in a computer-readable storage medium, a processor of a computer device reading the computer program from the computer-readable storage medium, and the processor executing the computer program, thereby causing the computer device to perform a blockchain-based data processing method provided by an embodiment of the present application. [Effects of the Invention]
[0010] In an embodiment of the present application, a blockchain node obtains a storage instance mapping table based on the database configuration information of the blockchain node. The storage instance mapping table includes data mapping relationships for N database instances, each indicating the data type of a database instance, where N is a positive integer greater than 1. In an embodiment of the present application, the blockchain node corresponds to multiple database instances, and these multiple database instances are closely related to data types. When the blockchain node obtains blockchain data to be stored, it determines M candidate database instances whose data types match the blockchain data from the N database instances included in the storage instance mapping table, and then stores the blockchain data in a first database instance of the M candidate database instances based on the data sharding policy in the database configuration information, where M is a positive integer less than or equal to N. In this way, the storage method provided by the embodiments of the present application can allocate multiple database instances to one blockchain node according to traffic needs, greatly expanding the storage capacity. Subsequently, when the blockchain data is stored in the corresponding database instances in a sharded and classified manner based on the data type of the blockchain data, blockchain data of different data types can be stored in different database instances, greatly relieving storage pressure and realizing the diversion effect. Based on the above, when using the storage method of the embodiments of the present application, the storage capacity and read / write performance of the blockchain node can be doubled, effectively improving the node storage capacity of the blockchain node and meeting the storage needs. [Brief explanation of the drawings]
[0011] [Figure 1] FIG. 1 is a structural schematic diagram of a blockchain node system provided by an embodiment of the present application. [Figure 2]FIG. 1 is a schematic diagram of a storage expansion for a single disk provided by an embodiment of the present application. [Figure 3] FIG. 1 is a schematic diagram of a storage expansion for multi-disks provided by an embodiment of the present application; [Figure 4] FIG. 1 is a schematic diagram of a distributed classification and database partitioning storage expansion system provided by an embodiment of the present application. [Figure 5] 1 is a schematic diagram of a data storage scenario provided by an embodiment of the present application; [Figure 6] FIG. 1 is a schematic flow diagram of a data processing method using a blockchain provided by an embodiment of the present application. [Figure 7] FIG. 10 is a schematic diagram of the acquisition flow of a storage instance mapping table provided by an embodiment of the present application; [Figure 8] 1 is a schematic diagram of the structure of the database division and classification storage of data provided by an embodiment of the present application. [Figure 9] FIG. 1 is a schematic diagram of a storage scenario for blockchain data provided by an embodiment of the present application. [Figure 10] FIG. 1 is a schematic flow diagram of a data processing method using a blockchain provided by an embodiment of the present application. [Figure 11] 1 is a schematic diagram of an access flow of data to be processed provided by an embodiment of the present application; [Figure 12] FIG. 1 is a structural schematic diagram of a data processing device based on a blockchain provided by an embodiment of the present application. [Figure 13] 1 is a schematic diagram of a computer device provided by an embodiment of the present application; DETAILED DESCRIPTION OF THE INVENTION
[0012] The following clearly and completely describes the technical solutions in the embodiments of this application, combined with the drawings in the embodiments of this application, and it is obvious that the described embodiments are not all of the embodiments, but only some of the embodiments of this application. Based on the embodiments of this application, on the premise that a person skilled in the art does not make any inventive efforts, all other embodiments obtained fall within the scope of protection of this application.
[0013] Please refer to Figure 1, which is a structural schematic diagram of a blockchain node system provided by an embodiment of the present application. As shown in Figure 1, the blockchain node system in the embodiment of the present application is a distributed system formed by connecting multiple blockchain nodes in the form of network communication. The blockchain network corresponding to this blockchain system is a peer-to-peer network (abbreviated as P2P network), that is, a distributed application architecture that allocates tasks and workloads among users, and is a networking or network form formed by a peer-to-peer computing model at the application layer.
[0014] 1 includes multiple blockchain nodes, including node 10a, node 10b, node 10c, ..., node 10n. A blockchain node in the blockchain system is any type of computer device that accesses the blockchain network, for example, the computer device is a terminal device that accesses the blockchain network or a server that accesses the blockchain network, and the specific type of the blockchain node is not limited here.
[0015] Optionally, the server accessing the blockchain network is an independent physical server, or a server cluster consisting of multiple physical servers, or a distributed system, or a cloud server providing cloud computing services. Terminal devices accessing the blockchain network include smart terminals such as smartphones, tablet computers, laptops, desktop computers, smart speakers, smart watches, in-vehicle terminals, and smart TVs. In embodiments of the present application, the application client executed by the terminal device is an independent client, or an embedded sub-client integrated into another client (e.g., a social client, an education client, a media client, etc.), and is not limited thereto.
[0016] The blockchain network in Figure 1 includes multiple participants, such as blockchain nodes that need to store all ledger data (e.g., consensus nodes or all-level nodes) and blockchain nodes that store only a portion of the ledger data (e.g., light nodes). Light nodes store only a portion of the blockchain database, i.e., block header data and transaction data related to their own node, rather than the complete transaction data. To address large-scale storage and high-performance scenarios, the present application proposes a classification / database partitioning / sharding storage method for blockchain nodes that need to store all ledger data.
[0017] The databases of any one blockchain node in a blockchain network include a main database and an archive database. The main database is a database used by the blockchain node and includes a database located locally on the blockchain node (e.g., the local database 110 of node 10a in FIG. 1) and a database located in a remote storage having a network connection relationship with the blockchain node (e.g., the remote database 120 of node 10a in FIG. 1). The archive database is an independent database that performs batch processing on blockchain data, and the batch processing includes batch transfer and batch deletion.
[0018] Optionally, each blockchain node includes a blockchain ledger module, a database service component, and other blockchain modules. The blockchain ledger module provides functions such as storing, querying, modifying, and deleting ledger data, and transmits record data of operations on the ledger data to other nodes in the blockchain system. After the other nodes verify the validity, the record data is stored in a temporary block as an authentication response to the validity of the ledger data, and further transmits a confirmation to the node initiating the operation. The database service component provides database services to the remote database of the blockchain node, for example, storing or accessing blockchain data in the remote database based on the database service. The database service component is also referred to as a database service SDK (Software Development Kit).
[0019] Optionally, other blockchain modules include processing modules such as object management, foundation services, smart contracting, and operation detection. Here, the object management module manages the identity information of all blockchain participants, including public and private key generation and maintenance (account management), private key management, and maintenance of the correspondence between object actual identities and blockchain addresses (authority management). If authorized, it monitors, manages, and audits the transaction status of actual identities and provides risk management rule configuration (risk management audit). The foundation service module is deployed in all blockchain node devices and verifies the validity of traffic data requests, reaches consensus on the validity request, and then records it in memory. For a new traffic data request, the foundation service first performs adaptive analysis and decryption authentication processing on the interface (interface adaptation), then uses the consensus algorithm to encrypt the traffic information (consensus management), and after encryption, transmits it completely and consistently to the shared ledger (network communication) for recording and storage. The smart token module handles the registration and issuance of tokens, triggering and executing them. The development object defines the token logic in a programming language and publishes it to the blockchain (toggle registration). Based on the token logic, it executes it by calling the private key or other events to trigger it, completing the token logic and providing the functions of upgrading and deregistering the token. The operation detection module mainly handles the configuration, configuration modification, token setup, cloud adaptation during the product launch process, and real-time status visualization output during product execution, such as alarms, network status detection, and node device health status detection.
[0020] Optionally, to meet traffic storage needs, the blockchain node in the embodiment of the present application is configured with one or more hard disks, each of which is configured with multiple database instances. For ease of understanding, please refer to FIG. 2, which is a schematic diagram of storage expansion for a single disk provided by the embodiment of the present application. As shown in FIG. 2, the blockchain node in the embodiment of the present application is a blockchain node in which a single hard disk is configured on the host (i.e., the main body excluding input / output devices), and the blockchain node is any one of the blockchain nodes in the blockchain network of FIG. 1 above, for example, the blockchain node is node 10a. The blockchain node is configured with one hard disk, for example, hard disk A in FIG. 2.
[0021] If the read / write speed of a single database instance cannot meet the traffic read / write needs of a blockchain node and the read / write speed of the database instance does not reach the upper limit of the read / write performance of the hard disk, in order to fully utilize the read / write resources of the hard disk, an embodiment of the present application allocates multiple database instances to a single hard disk based on the storage performance of the hard disk A, here including three database instances D1, D2 and D3 as examples. The storage performance of hard disk A is jointly determined by the storage capacity and read / write performance of hard disk A.
[0022] Further, please refer to Figure 3, which is a schematic diagram of storage expansion for multiple disks provided by an embodiment of the present application. As shown in Figure 3, the blockchain node in the embodiment of the present application is a blockchain node in which multiple hard disks are arranged on a host, and this blockchain node is any one of the blockchain nodes in the blockchain network of Figure 1 above, for example, this blockchain node is node 10a. Since there may be differences in the storage performance of different hard disks, the number of instances of database instances arranged on each hard disk varies depending on the storage performance of the hard disk itself.
[0023] As shown in Figure 3, the multiple hard disks deployed in the blockchain node include two, for example, hard disk A and hard disk B, where hard disk B has higher storage performance than hard disk A. Based on this, if the storage expansion solution of Figure 2 above still cannot meet the traffic needs of the blockchain node, the embodiment of the present application deploys more database instances and distributes them across different hard disks to achieve the distribution effect, thereby doubling the storage capacity and read / write performance.
[0024] For example, in an embodiment of the present application, multiple database instances are arranged on hard disk A based on the storage performance of hard disk A, including three database instances, for example, database instance D1, database instance D2, and database instance D3. Similarly, in an embodiment of the present application, multiple database instances are arranged on hard disk B based on the storage performance of hard disk B, including four database instances, for example, database instance D4, database instance D5, database instance D6, and database instance D7.
[0025] Further, please refer to FIG. 4, which is a schematic diagram of the storage expansion of distributed classification and database partitioning provided by an embodiment of the present application. As shown in FIG. 4, the blockchain node in the embodiment of the present application is any one of the blockchain nodes in the blockchain network of FIG. 1 above, for example, node 10a. If the storage performance of a single machine of the blockchain node is insufficient to meet the traffic needs, the embodiment of the present application performs distributed storage expansion, that is, storage using a database proxy. Optionally, the database proxy is located on the same computer device as the blockchain node or on a computer device different from the blockchain node, where the location of the database proxy is not limited.
[0026] In a remote database associated with the blockchain node, an embodiment of the present application arranges a corresponding host cluster for each data type based on X data types of the blockchain data received by the blockchain node, where X is a positive integer. In this embodiment, N database instances are arranged in the remote database associated with the blockchain node, and the remote database includes host clusters corresponding to the X data types, one data type corresponding to one host cluster, and each host cluster includes multiple database host nodes.
[0027] As shown in Figure 4, the data types in the embodiment of the present application include three examples: a first data type, a second data type, and a third data type. The first data type is a data type corresponding to frequently accessed small data, and includes, for example, a block header data type and a status data type. The block header data type is the data type to which the block header data belongs, and the status data type is the data type to which the status data belongs. The status data includes the risk status of an enterprise object, the document status of an electronic document, the asset status of a traffic object, etc. The host cluster corresponding to the first data type is host cluster 1 in Figure 4, and the host cluster 1 includes multiple hosts, for example, host J. 11 , Host J 12 , …, and host J 1N Each host in the host cluster 1 is equipped with multiple hard disks. For example, host J 11 Two hard disks, hard disk A and hard disk B, are arranged in the database, and multiple database instances are arranged on each hard disk.
[0028] The second data type is a data type of blockchain data that requires independent storage, such as a transaction data type, which is the data type to which transaction data belongs. Note that transaction data corresponds to sales, and in some cases, transaction sales do not need to be stored for a long time, so storing them in an independent database instance contributes to subsequent data archiving or periodic deletion. The host cluster corresponding to the second data type is host cluster 2 in FIG. 4, and the host cluster 2 includes multiple hosts, such as host J. 21 , Host J 22 , …, and host J 2N Each host in the host cluster 2 is equipped with multiple hard disks. For example, host J 21Two hard disks, hard disk C and hard disk D, are arranged in the database, and multiple database instances are arranged on each hard disk.
[0029] The third data type is another data type corresponding to the blockchain data that requires independent storage, such as the contrast data type, which is the data type to which the contrast data belongs. The contrast data is actual traffic data, and by storing it independently in multiple database instances, the amount of data in a single database is reduced, effectively improving the database read / write performance and further enhancing the storage performance of the blockchain node. The host cluster corresponding to the third data type is host cluster 3 in Figure 4, which includes multiple hosts, such as host J. 31 , Host J 32 , …, and host J 3N Each host in the host cluster 3 is equipped with multiple hard disks. For example, host J 21 Two hard disks, hard disk E and hard disk F, are arranged in the database server 100, and multiple database instances are arranged on each hard disk.
[0030] For ease of understanding, please refer to Figure 5, which is a schematic diagram of a data storage scenario provided by an embodiment of the present application. As shown in Figure 5, the blockchain node in the embodiment of the present application is a blockchain node in the blockchain network that needs to store full ledger data, for example, the blockchain node is any one of the blockchain nodes in the blockchain network of Figure 1 above, such as node 10a.
[0031] In this embodiment, the blockchain data to be stored is divided into X data types, where X is a positive integer, and the number of data types in the embodiment is three, including data type 21, data type 22, and data type 23.
[0032] When a blockchain node is started, the blockchain node obtains a storage instance mapping table according to the database configuration information of the blockchain node. If the blockchain node is started for the first time, the storage instance mapping table is generated according to the database configuration information. If the blockchain node is not started for the first time, the generated storage instance mapping table is directly loaded according to the database configuration information.
[0033] The storage instance mapping table includes data mapping relationships of N database instances, where one data mapping relationship indicates the data type of one database instance, and N is a positive integer greater than 1. Optionally, the N database instances are arranged according to the traffic needs of the blockchain node, that is, all are arranged in the local database of the blockchain node (for example, the arrangement method of Figure 2 above), or all are arranged in the remote database of the blockchain node (for example, the arrangement method of Figure 4 above), or all are arranged in the local database and the remote database, here not limited.
[0034] Further, please refer to Table 1, which is a storage instance mapping table provided in an embodiment of the present application. The storage instance mapping table in Table 1 includes data mapping relationships of N database instances. For example, if N is equal to 6, the N database instances include database instance D1, database instance D2, database instance D3, database instance D4, database instance D5, and database instance D6. In an embodiment of the present application, database instances of different data types may be located on the same hard disk or on different hard disks. For example, database instances corresponding to data types 21, 22, and 23 are configured to be located on the same hard disk (e.g., hard disk A in FIG. 2). Preferably, database instances corresponding to data types 21 and 22 are both located on the same hard disk (e.g., hard disk A in FIG. 3), and database instances corresponding to data type 23 are both located on a different hard disk (e.g., hard disk B in FIG. 3). As shown in Table 1, [Table 1] Note that the data mapping relationship of database instance D1 indicates that the data type of database instance D1 is data type 21, the data mapping relationship of database instance D2 indicates that the data type of database instance D2 is data type 22, the data mapping relationship of database instance D3 indicates that the data type of database instance D3 is data type 22, the data mapping relationship of database instance D4 indicates that the data type of database instance D4 is data type 23, the data mapping relationship of database instance D5 indicates that the data type of database instance D5 is data type 23, and the data mapping relationship of database instance D6 indicates that the data type of database instance D6 is data type 23.
[0035] In the embodiments of the present application, since the data volume and access frequency of different data types of blockchain data are different, the storage capacity occupied by different data types of blockchain data is also different, and the number of instances of database instances allocated to different data types is also different.
[0036] Here, when acquiring blockchain data to be stored, the blockchain node determines M candidate database instances from the N database instances included in the storage instance mapping table of Table 1 above, where the data types of the candidate database instances match the blockchain data, and M is a positive integer less than or equal to N. As shown in Figure 5, when the blockchain node acquires blockchain data Q to be stored, it can determine the data type of the blockchain data Q. If the data type of the blockchain data Q belongs to data type 22, in the storage instance mapping table of Table 1 above, the blockchain node determines that both database instances corresponding to data type 22 (for example, database instance D2 and database instance D3) are database instances that match the blockchain data Q.
[0037] Furthermore, the blockchain node determines the database instance (i.e., the first database instance, for example, database instance D3) that needs to store the blockchain data Q based on the data sharding policy in the database placement information, and stores it in database instance D3.
[0038] In this way, one blockchain node can allocate N database instances according to traffic needs, thereby improving the storage capacity of the blockchain node, and any one data type of blockchain data can be stored in the corresponding database instance according to the embodiment in which blockchain data Q is stored in the first database instance, that is, blockchain data of different data types can be stored in different database instances, greatly relieving storage pressure and realizing the effect of diversion. This not only solves the problem of insufficient data read / write performance of blockchain nodes, but also solves the problem of limited standalone storage space, and further provides the possibility of implementing blockchain in large-scale data storage scenarios through fine-grained contrast storage management based on data types and data sharding policies.
[0039] For an implementation example in which a blockchain node in a blockchain network in which N database instances are arranged performs classification, database division, and sharding storage on the blockchain data to be stored, please refer to the examples in Figures 6 to 11 below.
[0040] Further, please refer to Figure 6, which is a flow diagram of a data processing method using blockchain provided by an embodiment of the present application. As shown in Figure 6, the method is executed by a computer device, and the computer device is a blockchain node in a blockchain network, and the blockchain node is a blockchain node in the blockchain network that needs to store full ledger data, for example, any one of the blockchain nodes in the blockchain network of Figure 1 above, for example, the blockchain node is node 10a. The method includes at least the following steps 601 to 603.
[0041] Step 601: The blockchain node obtains a storage instance mapping table based on the database configuration information of the blockchain node, the storage instance mapping table includes data mapping relationships of N database instances, the data mapping relationships indicate the data types of the database instances, and N is a positive integer greater than 1.
[0042] The storage instance mapping table includes data mapping relationships of N database instances, where one data mapping relationship indicates the data type of one database instance, and N is a positive integer greater than 1. Optionally, a traffic object (e.g., a user) performs a start-up operation on a blockchain node, and when the blockchain node responds to the start-up operation, the storage instance mapping table of the blockchain node is obtained based on the database configuration information of the blockchain node. The start-up operation is a trigger operation that starts the blockchain node, and the trigger operation includes, but is not limited to, a contact operation such as a click or a long press, or a non-contact operation such as a voice or a gesture.
[0043] Optionally, when the startup operation indicates that the blockchain node is started for the first time, the blockchain node performs an initialization process, that is, reads the database configuration information of the blockchain node, and builds N database instances according to the database configuration information and the database type of the main database of the blockchain node. After the initialization is successful, the blockchain node establishes a mapping relationship between each database instance and the data type of the hard disk to which each database instance belongs, and generates a storage instance mapping table according to the established mapping relationship.
[0044] The database configuration information is information about the database of a blockchain node that is configured by a configuration object (e.g., a configuration user of the blockchain node) for the blockchain node based on traffic storage needs. For example, the database configuration information includes a database storage path, the number of instances to be configured on the hard disk of the blockchain node, and a data sharding policy. The data storage path includes multiple storage paths configured by the configuration object for blockchain data of different data types. The number of instances is determined based on the storage performance of the hard disk configured for the blockchain node, and the data sharding policy is a calculation method, such as consistent hashing, that the blockchain node uses to store blockchain data.
[0045] For example, if the configuration object determines that the data types of the blockchain data include X data types (X is a positive integer), in order to improve the node performance of the blockchain node, the configuration object will configure a different database instance for each data type, and store each type of blockchain data in a different database instance. Of course, the same type of data can be stored in multiple database instances, and the hard disks corresponding to the database instances can be configured in the local database of the blockchain node or in the remote database of the blockchain node, and this is not limited thereto.
[0046] Optionally, the local database and remote database of the blockchain node are both configured with one or more hard disks, and the database storage path in the database configuration information of the embodiment of the present application indicates a set of hard disks for X data types, that is, includes a storage path corresponding to each type of data type.
[0047] For example, the X data types include at least one of a first data type, a second data type, or a third data type. The first data type includes at least one of a block header data type or a state data type, the second data type includes a transaction data type, and the third data type includes a contrast data type. Because the read and write frequency of the blockchain data of the first data type is high and the data volume is small, when deploying a database instance for the first data type, the deployment object selects a machine (i.e., a hard disk) with a small storage volume and weak storage performance, thereby meeting traffic needs and greatly reducing costs. The storage performance of the hard disk of the first data type is lower than that of the hard disk of the second data type and lower than that of the hard disk of the third data type.
[0048] Further, please refer to Table 2, which is a pseudocode schematic table for database configuration information provided in the embodiment of the present application. For ease of description, the hard disk sets for X data types configured in the blockchain node in the embodiment of the present application include, for example, four hard disks A (e.g., data1), B (e.g., data2), D (e.g., data4) configured in the local database, and C (e.g., data3) configured in the remote database.
[0049] The computer device corresponding to the remote database is indicated in the data format of endpoint:port, as shown in Table 2. [Table 2] As shown in Table 2, if the storage performance of hard disk A of the local database is lower than that of the other hard disks, when the first data type is a block header data type, the storage path corresponding to the first data type in the database configuration information is the " / data1 / blockHeader" directory. When the second data type is a transaction data type, the storage paths corresponding to the second data type in the database configuration information include the " / data1 / transaction" and " / data2 / transaction" directories in the local database and the " / data3 / transaction" directory in the remote database, which means that the configuration object configures three storage locations for the transaction data type. When the third data type is a contract data type, the storage path corresponding to the third data type in the database configuration information is the " / data4 / contract" directory in the local database. When multiple database instances are configured in the same directory, the root directories of the database instances are each the target prefix + instance number. For example, if multiple database instances are placed on hard disk A, the storage paths corresponding to the transaction data type are " / data1 / transaction / 1, / data1 / transaction / 2, / data1 / transaction / 3".
[0050] For ease of understanding, please refer to Figure 7, which is a schematic diagram of the acquisition flow of the storage instance mapping table provided by the embodiment of the present application. As shown in Figure 7, the blockchain node in the embodiment of the present application is any one of the blockchain nodes in the blockchain network of Figure 1 above, for example, node 10a.
[0051] If the startup operation performed on the blockchain node indicates that the blockchain node is started for the first time, the blockchain node executes step 701 to start the blockchain node, and then executes step 702 to load database configuration information. Furthermore, the blockchain node obtains the database type of the main database of the blockchain node, and determines whether to automatically execute steps 703 to 704 to build a database instance based on the smart contrast on the blockchain, or to manually build a database instance based on the configuration object of the blockchain node.
[0052] The database type of the primary data includes a first type (for example, a type that automatically constructs a database instance based on smart contrast) and a second type (for example, a type that manually constructs an artificial database instance).
[0053] If the database type of the blockchain node belongs to a first type, the blockchain node obtains a smart contract from the blockchain to which the blockchain node belongs, and the smart contract constructs a database instance. The smart contract is a computerized protocol that can execute contract clauses and is realized by code placed on a shared ledger. When certain conditions are met, the code is executed, and the code completes an automated transaction based on actual traffic needs. Furthermore, based on the smart contract, the blockchain node constructs a database instance for each hard disk in the hard disk set, thereby obtaining N database instances. Optionally, for each hard disk in the hard disk set, the blockchain node determines the number of instances for each hard disk based on the database configuration information.
[0054] Furthermore, the blockchain node performs step 703 to determine whether the hard disk to be constructed is located in the local database. Optionally, if the hard disk is located in the local database of the main database, the blockchain node performs step 704 to construct a database instance for the hard disk that matches the number of instances based on smart correlation. Optionally, if the hard disk is located in the remote database of the main database, the blockchain node performs step 704 to construct a database instance for the hard disk that matches the number of instances based on smart correlation, and the database service component provides a remote database service. That is, the blockchain node jumps to step 707 to step 709 to invoke the database service component and construct a database instance for the number of instances based on the remote database service provided by the database service component. When the construction is complete, the database service component receives and responds to the database instance.
[0055] Optionally, when the database type of the blockchain node belongs to a second type, the blockchain node displays prompt information about the database configuration information, so that the configuration object performs a trigger operation according to the prompt information. The prompt information may be information corresponding to a type such as picture, video, audio, or text, and the information type of the prompt information is not limited thereto. In response to the trigger operation on the prompt information, the blockchain node respectively constructs a database instance for each hard disk in the hard disk set, thereby obtaining N database instances.
[0056] When both a local database and a remote database are constructed, the blockchain node executes step 705 to establish a mapping relationship between each database instance and the data type of the hard disk to which each database instance belongs, and generates a storage instance mapping table based on the established mapping relationship. Thereafter, the blockchain node executes step 706 to provide data services (e.g., data access services) to the blockchain node.
[0057] For ease of understanding, please refer to Figure 8, which is a structural diagram of the database partitioning and classification storage of data provided by the embodiment of the present application. As shown in Figure 8, the blockchain node in the embodiment of the present application is a blockchain node in which multiple hard disks are arranged in the host, and the blockchain node is any one of the blockchain nodes in the blockchain network of Figure 1 above, for example, node 10a.
[0058] 8 responds to the startup operation, the blockchain node loads database configuration information. The storage path information in the database configuration information indicates hard disk sets for three data types (e.g., block header data type, transaction data type, and contrast data type), and the hard disk sets include hard disk A and hard disk B that are locally allocated based on traffic needs.
[0059] A blockchain node constructs a database instance for the master database based on the database type (e.g., the first type) and database configuration information of the master database. The storage path of the database configuration information indicates the number of instances of different data types on each hard disk. For example, the number of instances of the block header data type on hard disk A (i.e., the first number of instances) is 1, the number of instances of the transaction data type on hard disk A (i.e., the second number of instances) is 2, and the number of instances of the contrast data type on hard disk B (i.e., the third number of instances) is 3.
[0060] Taking hard disk A as an example, the blockchain node determines the number of instances of hard disk A to be the sum of the first instance number and the second instance number (i.e., 3) based on the database configuration information. In this case, the blockchain node builds three database instances for hard disk A, namely, database instance D1, database instance D2, and database instance D3, based on smart contrast.
[0061] Similarly, taking hard disk B as an example, the blockchain node determines the number of instances of hard disk B to be the third instance number (i.e., 3) based on the database configuration information. In this case, the blockchain node builds three database instances, namely, database instance D4, database instance D5, and database instance D6, for hard disk B based on smart contrast.
[0062] Furthermore, the blockchain node establishes a mapping relationship between each of the six database instances and the data type of the hard disk to which it belongs, and generates the storage instance mapping table shown in Table 1 above based on the established mapping relationship. Optionally, the storage method of the storage instance mapping table is key-value storage, i.e., Key-Value storage, abbreviated as KV storage. That is, the blockchain node determines the Key as the data type and the Value as the database instance.
[0063] It should be noted that the storage instance mapping table in the embodiments of the present application may be an independent mapping table containing the X data types in Table 1 above, or may be a mapping table consisting of X storage instance sub-mapping tables, and is not limited thereto. For example, if the storage expansion method of a blockchain node is the storage expansion method of Figure 4 above, the blockchain node will construct a storage instance sub-mapping table for each data type, thereby enabling the database proxy to quickly determine the host cluster to be accessed from the X host clusters, thereby improving access efficiency.
[0064] Step 602: When obtaining the blockchain data to be stored, the blockchain node determines M candidate database instances from the N database instances, where the data types of the candidate database instances match the blockchain data, and M is a positive integer less than or equal to N.
[0065] Optionally, when obtaining the blockchain data to be stored, the blockchain node determines data information of the blockchain data, and determines a data type of the blockchain data according to the data information of the blockchain data. Furthermore, the blockchain node searches a data type that matches the data type of the blockchain data in the storage instance mapping table, and determines a database instance corresponding to the searched data type as a candidate database instance, thereby obtaining M candidate database instances.
[0066] Optionally, the database configuration information includes a data volume threshold and an access frequency threshold that are configured based on traffic needs. If the data information indicates that the data volume of the blockchain has not reached the data volume threshold and the data access frequency of the blockchain data has reached the access frequency threshold, the blockchain data is considered to be frequently accessed small data, and in this case, the blockchain node determines the data type of the blockchain data to be a first data type. Optionally, if the data information indicates that the blockchain data belongs to transaction data, the blockchain node determines the data type of the blockchain data to be a second data type, for example, the transaction data includes asset transfer transaction data or electronic document turnover transaction data. Optionally, if the data information indicates that the blockchain data belongs to contrast data, the blockchain node determines the data type of the blockchain data to be a third data type. Of course, the X data types in the embodiments of the present application may further include other data types, which will not be described here.
[0067] As shown in Figure 5, when the blockchain node obtains the blockchain data Q to be stored, it determines the data type of the blockchain data Q. If the data type of the blockchain data Q belongs to data type 22, the blockchain node determines the database instances corresponding to data type 22 (for example, database instance D2 and database instance D3) from the storage instance mapping table in Table 1 above as two candidate database instances that match the blockchain data Q.
[0068] Step 603: The blockchain node stores the blockchain data in a first database instance among the M candidate database instances based on the data sharding policy in the database placement information.
[0069] Optionally, the blockchain node generates a hash ring associated with the data type of the blockchain data in the hash value space according to the storage direction based on the data sharding policy in the database placement information. Further, the blockchain node performs a hash calculation on first key information (e.g., input information such as an address or a directory) of each candidate database instance among the M candidate database instances to obtain first location information of each candidate database instance on the hash ring. Similarly, the blockchain node further performs a hash calculation on second key information (e.g., a data hash value) of the blockchain data to obtain second location information on the hash ring of the blockchain data. Further, the blockchain node searches for first location information having a location relationship closest to the second location information along the storage direction in the hash ring, determines the database instance corresponding to the searched first location information as the first database instance, and further stores the blockchain data in the first database instance.
[0070] The embodiments of the present application relate to X data types, and if the blockchain data of the X data types is partitioned and stored in a database, the embodiments of the present application relate to X sets of database instances, and one set of database instances corresponds to one hash ring, that is, the embodiments of the present application relate to X hash rings. If the data types include a block header data type, a transaction data type, and a contrast data type, the embodiments of the present application relate to three hash rings, and the three hash rings respectively correspond to the database mapping relationships of the three data types.
[0071] For ease of understanding, please refer to FIG. 9, which is a schematic diagram of a storage scenario for blockchain data provided by an embodiment of the present application. As shown in FIG. 9, the hash ring in the embodiment of the present application is a hash ring corresponding to the data type of the blockchain data to be stored, and the hash ring is generated for the hash value space according to the storage direction (e.g., clockwise direction) based on the data sharding policy (e.g., consistent hashing) in the database allocation information. The hash value space is a number space ranging from 0 to (2 to 32)-1.
[0072] Optionally, the candidate database instances determined by the blockchain node from the storage instance mapping table include, for example, four database instances D1, D2, D3, and D4 in Figure 9. The blockchain node performs a hash calculation on the first key information of each of the four database instances to obtain first position information of each database instance on the hash ring.
[0073] The blockchain data that the blockchain node acquires and stores is the blockchain data Q in Figure 9. 61 , Blockchain Data Q 62, Blockchain Data Q 63 , Blockchain Data Q 64 , Blockchain Data Q 65 and Blockchain Data Q 66 For example, for a database instance D1, the blockchain node obtains directory information and device information (e.g., a device identifier) of the database instance D1 to determine first key information of the database instance D1. Furthermore, the blockchain node performs a hash calculation on the first key information of the database instance D1 according to a consistent hashing method to obtain a hash value of the database instance D1, maps the hash value of the database instance D1 to a hash ring, and obtains first position information of the database instance D1 on the hash ring.
[0074] Furthermore, the blockchain node performs a hash calculation on the second key information of the blockchain data to obtain second location information on the hash ring of the blockchain data. For example, 61 In response to this, the blockchain node 61 Based on the data type of the blockchain data Q 61 Furthermore, the blockchain node determines the second key information of the blockchain data Q according to the consistent hashing method. 61 The second key information is hashed to generate the blockchain data Q 61 The hash value of the blockchain data Q is obtained. 61 The hash value of the blockchain data Q is mapped to the hash ring. 61 Obtain the second location information on the hash ring.
[0075] The blockchain data Q 61 If the data type of is a block header data type, the blockchain node61 The block header hash value of the corresponding blockchain data Q 61 Optionally, the blockchain data Q 61 If the data type of is a transaction data type, the blockchain node 61 The transaction hash value of the blockchain data Q 61 Optionally, the blockchain data Q 61 If the data type of is a contrast data type, the blockchain node 61 The contrast hash value of the blockchain data Q 61 This is the second key information.
[0076] Furthermore, the blockchain node searches for first location information that has the closest location relationship to the second location information along the storage direction in the hash ring based on the second location information of the blockchain data, determines the database instance corresponding to the searched first location information as the first database instance, and stores the blockchain data in the first database instance.
[0077] For example, Blockchain Data Q 61 The blockchain node then stores the blockchain data Q 61 Based on the second location information, the first location information having the closest location relationship to the second location information is searched for along the clockwise storage direction in the hash ring, the database instance corresponding to the searched first location information (e.g., database instance D1 in Figure 9) is determined to be the first database instance, and the blockchain data is further stored in the first database instance.
[0078] By analogy, the blockchain node in question is the blockchain data Q 61 Referring to the storage method of blockchain data Q 62is stored in the database instance D1, and the blockchain data Q 63 is stored in the database instance D2, and the blockchain data Q 64 , Blockchain Data Q 65 and Blockchain Data Q 66 is stored in the database instance D3, and the blockchain data Q 67 is stored in database instance D4.
[0079] In this way, the storage method provided by the embodiments of the present application can allocate multiple database instances to one blockchain node according to traffic needs, greatly expanding the storage capacity. Subsequently, when the blockchain data is sharded and classified and stored into corresponding database instances based on the data type of the blockchain data, blockchain data of different data types can be stored in different database instances, greatly relieving storage pressure and realizing the diversion effect. Based on the above, when the storage method of the embodiments of the present application is used, the storage capacity and read / write performance of the blockchain node can be doubled, effectively improving the node storage capacity of the blockchain node and meeting the storage needs.
[0080] Further, please refer to Figure 10, which is a flow diagram of a data processing method using blockchain provided by an embodiment of the present application. As shown in Figure 10, the method is executed by a computer device, and the computer device is a blockchain node in a blockchain network, and the blockchain node is a blockchain node in the blockchain network that stores full ledger data, for example, any one of the blockchain nodes in the blockchain network of Figure 1 above, for example, node 10a. The method includes at least the following steps 1001 to 1006.
[0081] Step 1001: The blockchain node obtains a storage instance mapping table according to the database configuration information of the blockchain node.
[0082] The storage instance mapping table includes data mapping relationships of N database instances, where one data mapping relationship indicates the data type of one database instance, and N is a positive integer greater than 1. Optionally, a traffic object (e.g., a user) performs a startup operation on a blockchain node, and when the blockchain node responds to the startup operation, the storage instance mapping table of the blockchain node is obtained based on the database configuration information of the blockchain node. The startup operation is a trigger operation for starting the blockchain node, and the trigger operation may include, but is not limited to, a contact operation such as a click or a long press, or a non-contact operation such as a voice or a gesture.
[0083] Step 1002: When the blockchain node obtains the blockchain data to be stored, it determines M candidate database instances from the N database instances in the storage instance mapping table, and the data types of the candidate database instances match the blockchain data.
[0084] Here, M is a positive integer less than or equal to N. Optionally, when acquiring blockchain data to be stored, the blockchain node determines data information of the blockchain data, and determines a data type of the blockchain data based on the data information of the blockchain data. Furthermore, the blockchain node searches a data type that matches the data type of the blockchain data in the storage instance mapping table, and determines a database instance corresponding to the searched data type as a candidate database instance, thereby obtaining M candidate database instances.
[0085] Step 1003: The blockchain node stores the blockchain data in a first database instance among the M candidate database instances based on the data sharding policy in the database placement information.
[0086] Optionally, the blockchain node generates a hash ring associated with the data type of the blockchain data in the hash value space according to the storage direction based on the data sharding policy in the database placement information. Further, the blockchain node performs a hash calculation on first key information (e.g., input information such as an address or a directory) of each candidate database instance among the M candidate database instances to obtain first location information of each database instance on the hash ring. Similarly, the blockchain node performs a hash calculation on second key information (e.g., a data hash value) of the blockchain data to obtain second location information on the hash ring of the blockchain data. Further, the blockchain node searches for first location information having a location relationship closest to the second location information along the storage direction in the hash ring, determines the database instance corresponding to the searched first location information as the first database instance, and stores the blockchain data in the first database instance.
[0087] For an embodiment of steps 1001 to 1003, the description of steps 601 to 603 in the embodiment of FIG. 6 may be referred to, and no further explanation will be given here.
[0088] Optionally, the blockchain data comprises the data to be processed.
[0089] Step 1004: The blockchain node generates a data access command in response to the traffic data request for the data to be processed, and the data access command is used to access the data to be processed.
[0090] The traffic data request may be generated from the blockchain node based on the data type of the data to be processed, or may be sent from another computer device having a network connection relationship with the blockchain node (e.g., another blockchain node in the blockchain network, or a terminal device corresponding to the traffic object), where the origin of the traffic data request is not limited.
[0091] If the traffic data request is sent from another computer device that has a network connection relationship with the blockchain node, in order to effectively improve the security of data transmission, the computer device obtains the node public key of the blockchain node and performs encryption processing on data information such as the data type of the data to be processed to obtain data encryption information, and then generates a traffic data request to be sent to the blockchain node based on the data encryption information. When receiving the traffic data request, the blockchain node first performs a legitimacy check on the computer device (for example, whether the computer device belongs to the unauthorized list), and if it is determined that the computer device is legitimate, it decrypts the data encryption information based on the node private key of the blockchain node to obtain data information such as the data type of the data to be processed, and then generates a data access command to access the data to be processed based on this data information.
[0092] Step 1005: The blockchain node determines a second database instance from the N database instances in the storage instance mapping table, and accesses the data to be processed from the second database instance based on the data access command and the data sharding policy in the database placement information, and the data type of the second database instance matches the data to be processed.
[0093] Optionally, the blockchain node refers to an embodiment corresponding to step 602 above to determine a second database instance from the N database instances included in the storage instance mapping table, and further determines, according to the storage method of Figure 9 above, the traffic database instance to which the data to be processed belongs from the second database instance based on the data sharding policy in the database placement information, and accesses the data to be processed from the traffic database instance.
[0094] Optionally, the N database instances are all located in a remote database associated with the blockchain node, the remote database including host clusters corresponding to X data types, where X is a positive integer and each data type corresponds to one host cluster. Then, when the blockchain node accesses the data to be processed, it determines a target host cluster from the X host clusters, and the data type of the target host cluster matches the data to be processed. Optionally, the traffic data request is accompanied by a data type of the data to be processed, and matching the data type of the target host cluster with the data to be processed means that the data type of the target host cluster matches the data type of the data to be processed. The blockchain node determines the database instance to be located in the target host cluster as a second database instance. Furthermore, the blockchain node determines a traffic database instance to which the data to be processed belongs from the second database instance based on the data sharding policy in the database placement information, and forwards the data access command to a database proxy having a network connection relationship with the blockchain node. The database proxy then sends the data access command to a database host node where the traffic database instance is located. In this case, the blockchain node receives the data to be processed back from the database host node by the database proxy.
[0095] For example, if the storage expansion method of a blockchain node is the storage expansion method of Figure 4 above, when the blockchain node accesses the data to be processed, it determines host cluster 1 from three host clusters, the data type of host cluster 1 matches the data type of the data to be processed, and then determines the database instance to be placed in host cluster 1 as the second database instance. Furthermore, based on the data sharding policy in the database placement information, the blockchain node determines the traffic database instance (e.g., hard disk A in Figure 4) to which the data to be processed belongs from the second database instance according to the method of Figure 9 above.
[0096] In this case, the blockchain node calls the database service component, which may be located in the same device as the blockchain node or in a separate device different from the blockchain node, but is not limited thereto. When the database service component is located in a separate device different from the blockchain node, in the embodiment of the present application, the device is referred to as a database proxy having a network connection relationship with the blockchain node. The blockchain node forwards the data access command to the database proxy in FIG. 4, and the database proxy forwards the data access command to the database host node (e.g., host J) where the traffic database instance is located. 11 In this case, the blockchain node receives the data to be processed, which is returned from the database host node by the database proxy.
[0097] For ease of understanding, please refer to Figure 11, which is a schematic diagram of the access flow of data to be processed provided by an embodiment of the present application. As shown in Figure 11, the blockchain node in the embodiment of the present application is a blockchain node in the blockchain network that needs to store full ledger data, for example, any one of the blockchain nodes in the blockchain network of Figure 1 above, for example, node 10a.
[0098] When a traffic data request is received, the blockchain node performs step 1101 to obtain a storage instance mapping table, and further performs step 1102 to determine a second database instance based on the data type of the data to be processed attached to the traffic data request.
[0099] As shown in Figure 8 above, if the data type of the acquired data to be processed is a contrast data type, the blockchain node acquires the storage instance mapping table and determines a second database instance from the N database instances in the storage instance mapping table, and the data type of the second database instance matches the data to be processed, for example, the second database instance is database instance D4, database instance D5 and database instance D6 in Figure 8.
[0100] Furthermore, the blockchain node executes steps 1103 to 1104 to determine the location information on the hash ring of the data to be processed based on the data sharding policy, and further searches for first location information having the closest location relationship to the location information of the data to be processed according to the storage direction of the hash ring, and determines the database instance corresponding to the searched first location information as the traffic database instance.
[0101] In this case, the blockchain node executes step 1105 to determine whether the traffic database instance is located in the local database. If the traffic database instance is located in the local database, the blockchain node executes step 1106 to access the data to be processed in the local database, and then executes step 1107, thereby completing the access flow. For example, if the traffic database instance is database instance D3 in Figure 3 above, the blockchain node accesses the data to be processed on hard disk A of the local database.
[0102] Optionally, if the traffic database instance is located in a remote database rather than a local database, the blockchain node jumps and executes steps 1108 to 1111 to invoke the database service component to establish a connection between the blockchain node and the remote database, and then accesses the data to be processed in the remote database and returns the data to be processed to the database service component, which returns the data to be processed to the blockchain node, and executes step 1107 to end the access flow.
[0103] Step 1006: The blockchain node performs the data operation indicated by the traffic data request on the data to be processed.
[0104] Optionally, the traffic data request includes a data archive request, a data change request, a new data addition request, a data query request, and a data deletion request. If the data archive request indicates that the data type of the data to be processed is transaction data, the blockchain node performs an archiving process on the data to be processed. Optionally, if the traffic data request is a data archive request, the blockchain node acquires data information of the data to be processed and data archive conditions for the data to be processed. The data archive conditions include an archive parameter threshold, and the archive parameter threshold includes at least one of an archive time range (e.g., a time range N years ago) or an archive frequency threshold (e.g., 50 times). If the data information indicates that the transaction timestamp of the data to be processed belongs to the archive time range or the access frequency of the data to be processed is less than the archive frequency threshold, the blockchain node determines that the data to be processed meets the data archive condition. In this case, the blockchain node transfers the data to be processed from the database to which the data to be processed belongs to an archive database.
[0105] Thus, the embodiments of the present application are applicable to scenarios where large amounts of data are stored in a blockchain system, resulting in high chain performance requirements, including scenarios where performance pressure exists due to high transaction frequency and scenarios where storage space pressure exists due to a large number of transactions. By combining the data characteristics of blockchain, different types of blockchain data are stored in different database instances, thereby solving the problem of storage capacity bottlenecks. For example, in the embodiments of the present application, inactive data such as historical transactions is stored in an archive database. Archive databases are relatively low-performance, low-cost devices, and data archiving or periodic deletion can be performed on the data to save storage space and expenses. As a result, the main database of the blockchain in the embodiments of the present application only needs to retain the latest data, which reduces the amount of database data, speeds up data reads and writes, and improves data access performance. This storage expansion method not only solves the problem of insufficient data read and write performance of blockchain nodes, but also solves the problem of limited standalone storage space. Furthermore, detailed contrast storage management based on data types and data sharding policies provides the possibility of implementing blockchain in large-data storage scenarios.
[0106] Further, please refer to FIG. 12, which is a structural schematic diagram of a blockchain-based data processing device provided by an embodiment of the present application. As shown in FIG. 12, the blockchain-based data processing device 1 is a computer program (including program code) executed on a computer device. For example, the blockchain-based data processing device 1 is application software, and the blockchain-based data processing device performs corresponding steps of the method provided by the embodiment of the present application. As shown in FIG. 12, the blockchain-based data processing device is executed in a blockchain node in a blockchain network that needs to store full ledger data, for example, any one of the blockchain nodes in the blockchain network shown in FIG. 1 above. For example, the blockchain node is node 10a. The blockchain-based data processing device includes a mapping table acquisition module 121, a data type matching module 122, a data storage module 123, an access command generation module 124, a data access module 125, and an operation execution module 126. The mapping table acquisition module 121 acquires a storage instance mapping table based on the database configuration information of the blockchain node, and the storage instance mapping table includes data mapping relationships of N database instances, where the data mapping relationships indicate the data types of the database instances, and N is a positive integer greater than 1.
[0107] Optionally, the mapping table obtaining module 121 includes: a configuration information loading unit 1211 , an instance obtaining unit 1212 and a mapping table generating unit 1213 . The configuration information loading unit 1211 is configured to load database configuration information in response to a startup operation on the blockchain node when the startup operation indicates that the blockchain node is started for the first time; The instance obtaining unit 1212 constructs N database instances according to the database configuration information and the database type of the main database of the blockchain node.
[0108] Optionally, the storage path information in the database location information indicates a hard disk set associated with X data types, where X is a positive integer; The instance acquiring unit 1212 includes a database type acquiring subunit 12121 , a smart contrast acquiring subunit 12122 , a first construction subunit 12123 , a prompt information display subunit 12124 and a second construction subunit 12125 .
[0109] The database type acquisition subunit 12121 acquires the database type of the main database of the blockchain node; The smart contrast acquisition subunit 12122 acquires a smart contrast from the blockchain to which the blockchain node belongs when the database type belongs to a first type, and the smart contrast is used to construct a database instance; The first construction sub-unit 12123 constructs a database instance for each hard disk in the hard disk set based on smart contrast respectively to obtain N database instances.
[0110] The first building subunit 12123 further comprises: For each hard disk in the hard disk set, determine a number of instances of the hard disk based on the database placement information; When the hard disk is allocated to the local database in the main database, construct a database instance corresponding to the number of instances on the hard disk based on smart contrast; When the hard disk is arranged in the remote database in the main database, the database service component is called to build a database instance that matches the instance number on the hard disk based on smart contrast, and the database service component is for providing the remote database service.
[0111] The prompt information display subunit 12124 displays prompt information associated with the database configuration information when the database type belongs to a second type; The second construction subunit 12125 constructs a database instance for each hard disk in the hard disk set in response to a trigger operation on the prompt information, respectively, to obtain N database instances.
[0112] Regarding the implementation of the database type acquisition subunit 12121, smart contrast acquisition subunit 12122, first construction subunit 12123, prompt information display subunit 12124 and second construction subunit 12125, reference may be made to the description of the database instance construction in the embodiment of Figure 6 above, and no further details will be given here.
[0113] The X data types include at least one of a first data type, a second data type, or a third data type, the first data type includes a block header data type, the second data type includes a transaction data type, and the third data type includes a contrast data type, and the storage performance of a hard disk for the first data type is lower than the storage performance of a hard disk for the second data type, and the storage performance of a hard disk for the first data type is lower than the storage performance of a hard disk for the third data type.
[0114] The mapping table generating unit 1213 establishes a mapping relationship between each database instance and the data type of the hard disk to which each database instance belongs, and generates a storage instance mapping table according to the mapping relationship.
[0115] Regarding the implementation of the configuration information loading unit 1211, the instance obtaining unit 1212 and the mapping table generating unit 1213, it is sufficient to refer to the description of step 601 in the embodiment of FIG. 6 above, and no further explanation will be given here.
[0116] When the data type matching module 122 obtains the blockchain data to be stored, it determines M candidate database instances from the N database instances, and the data types of the candidate database instances match the blockchain data, where M is a positive integer less than or equal to N.
[0117] The data type matching module 122 includes a data information determining unit 1221 , a data type determining unit 1222 and a data type matching unit 1223 .
[0118] The data information determination unit 1221 determines the data information of the block chain data when the block chain data to be stored is obtained; The data type determination unit 1222 determines the data type of the blockchain data based on the data information of the blockchain data.
[0119] The database placement information includes a data volume threshold and an access frequency threshold. The data type determining unit 1222 includes a first determining subunit 12221, a second determining subunit 12222 and a third determining subunit 12223.
[0120] The first determining subunit 12221 determines the first data type as the data type of the blockchain data when the data information indicates that the data amount of the blockchain data has not reached the data amount threshold and the data access frequency of the blockchain data has reached the access frequency threshold; The second determining subunit 12222 determines the second data type as the data type of the blockchain data when the data information indicates that the blockchain data belongs to transaction data; The third determination subunit 12223 determines the third data type as the data type of the blockchain data when the data information indicates that the blockchain data belongs to the contrast data.
[0121] Regarding the implementation of the first determining subunit 12221, the second determining subunit 12222 and the third determining subunit 12223, reference can be made to the description of the data type in the embodiment of FIG. 6 above, and no further description is given here.
[0122] The data type matching unit 1223 searches the storage instance mapping table for a data type that matches the data type of the blockchain data, and determines the database instance corresponding to the searched data type as the candidate database instance.
[0123] Regarding the implementation of the data information determining unit 1221, the data type determining unit 1222 and the data type matching unit 1223, please refer to the description of step 601 in the embodiment corresponding to FIG. 6 above, and no further description will be given here.
[0124] The data storage module 123 stores the blockchain data in a first database instance among the M candidate database instances based on the data sharding policy in the database placement information.
[0125] The data storage module 123 includes: a hash ring generating unit 1231 that generates hash rings associated with data types of the blockchain data for a hash value space according to a storage direction based on a data sharding policy; a first hash calculation unit 1232 that performs hash calculation on first key information of each candidate database instance among the M candidate database instances to obtain first position information of each candidate database instance on the hash ring; a second hash calculation unit 1233 that performs a hash calculation on second key information of the blockchain data to obtain second position information on the hash ring of the blockchain data; a target instance determination unit 1234 that searches for first location information having a closest location relationship with the second location information along the storage direction in the hash ring based on the second location information, and determines a database instance corresponding to the searched first location information as the first database instance; and a data storage unit 1235 that stores the blockchain data in a first database instance.
[0126] Regarding the implementation of the hash ring generation unit 1231, the first hash calculation unit 1232, the second hash calculation unit 1233, the target instance determination unit 1234, and the data storage unit 1235, it is sufficient to refer to the description of step 603 in the embodiment of Figure 6 above, and no further explanation will be given here.
[0127] In addition, blockchain data includes data to be processed, the access command generation module 124 generates a data access command in response to a traffic data request for the data to be processed, the data access command being for accessing the data to be processed; The data access module 125 determines a second database instance from the N database instances, and accesses the data to be processed from the second database instance based on the data access command and the data sharding policy, where the data type of the second database instance matches the data to be processed.
[0128] The N database instances are located in a remote database associated with the blockchain node, and the remote database includes host clusters corresponding to X data types, where X is a positive integer, and one data type corresponds to one host cluster; The data access module 125 includes a search instance determining unit 1251 , a traffic instance determining unit 1252 , an access command forwarding unit 1253 and a data receiving unit 1254 .
[0129] The search target instance determination unit 1251 determines a target host cluster from the X host clusters, and determines a database instance to be located in the target host cluster as a second database instance, where the data type of the target host cluster matches the data to be processed; The traffic instance determination unit 1252 determines, based on the data sharding policy, from the second database instance, a traffic database instance to which the data to be processed belongs; The access command forwarding unit 1253 forwards the data access command to a database proxy that has a network connection relationship with the blockchain node, so that the database proxy sends the data access command to a database host node where the traffic database instance is located; The data receiving unit 1254 receives data to be processed that is returned by the database proxy from the database host node.
[0130] Regarding the implementation of the instance determination unit 1251, traffic instance determination unit 1252, access command forwarding unit 1253 and data receiving unit 1254 to be searched, it is sufficient to refer to the description of step 1005 in the embodiment corresponding to Figure 121 above, and no further details will be given here.
[0131] The operation execution module 126 performs the data operations indicated by the traffic data request on the data to be processed.
[0132] The traffic data request includes a data archive request, and the data archive request is for performing an archive process on the data to be processed when the data type of the data to be processed indicates that the data to be processed is transaction data; The operation execution module 126 includes an archive condition acquisition unit 1261 and a data transfer unit 1262 .
[0133] The archiving condition obtaining unit 1261 obtains data information of the data to be processed and data archiving conditions for the data to be processed, the data archiving conditions including an archiving parameter threshold, and the archiving parameter threshold including at least one of an archiving time range or an archiving frequency threshold; If the data information indicates that the transaction timestamp of the data to be processed belongs to the archive time range or the access frequency of the data to be processed is less than the archive frequency threshold, the data transfer unit 1262 determines that the data to be processed meets the data archiving conditions, and transfers the data to be processed from the database to which the data to be processed belongs to the archive database.
[0134] Regarding the implementation of the archive condition acquisition unit 1261 and the data transfer unit 1262, the description of step 1006 in the embodiment corresponding to FIG. 121 above may be referred to, and no further explanation will be given here.
[0135] Regarding the implementation of the mapping table acquisition module 121, the data type matching module 122, the data storage module 123, the access command generation module 124, the data access module 125, and the operation execution module 126, please refer to the description of steps 1001 to 1006 in the embodiment of Fig. 10 above, and no further explanation will be given here. In addition, no further explanation will be given regarding the beneficial effects of the same method.
[0136] Further, please refer to FIG. 13, which is a schematic diagram of a computer device provided by an embodiment of the present application. As shown in FIG. 13, the computer device 1300 is a blockchain node in a blockchain network that needs to store full ledger data, for example, any one of the blockchain nodes in the blockchain network shown in FIG. 1 above, for example, node 10a. The computer device 1300 includes at least one processor 1301, such as a CPU, at least one network interface 1304, a user interface 1303, memory 1305, and at least one communication bus 1302. The communication bus 1302 realizes communication between these components. The user interface 1303 includes a display and a keyboard, and the network interface 1304 optionally includes a standard wired interface or a wireless interface (e.g., a Wi-Fi interface). The memory 1305 may be a high-speed RAM memory or a non-volatile memory, for example, at least one magnetic disk memory. The memory 1305 may optionally be at least one storage device remote from the processor 1301. As shown in Figure 13, the memory 1305 as a computer storage medium includes an operating system, a network communication module, a user interface module, and a device control application program.
[0137] In the computer device 1300 of FIG. 13, the network interface 1304 mainly performs network communication, the user interface 1303 mainly provides an input interface for the user, and the processor 1301 invokes the device control application program stored in the memory 1305 to Obtaining a storage instance mapping table according to the database configuration information of the blockchain node, the storage instance mapping table including data mapping relationships of N database instances, where the data mapping relationships indicate data types of the database instances, and N is a positive integer greater than 1; When acquiring the blockchain data to be stored, determining M candidate database instances from the N database instances, where the data types of the candidate database instances match the blockchain data, and M is a positive integer less than or equal to N; Storing the blockchain data in a first database instance among the M candidate database instances based on the data sharding policy in the database placement information.
[0138] Here, the computer device 1300 described in the embodiment of the present application may implement the data processing method using the blockchain described in the above embodiments of Figures 6 and 13, or the data processing device using the blockchain described in the above embodiment of Figure 12, and no further details are provided here. Also, no further details are provided regarding the beneficial effects of the same method.
[0139] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program, the computer program including program instructions, which, when executed by a processor, realize the blockchain-based data processing method provided by the steps of Figures 6 and 10. Please refer to the implementation forms provided by the steps of Figures 6 and 10, and no further details will be provided here.
[0140] The computer-readable storage medium may be a data transmission device provided by any one of the above embodiments, or may be an internal storage unit of a computer device, such as a hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as an external hard disk, a smart media card (SMC), a secure digital (SD) card, or a flash memory card arranged in the computer device. Furthermore, the computer-readable storage medium may include both an internal storage unit of the computer device and an external storage device. The computer-readable storage medium stores the computer program and other programs and data required by the computer device. The computer-readable storage medium may also temporarily store data that has been output or is to be output.
[0141] The embodiments of the present application further provide a computer program product, which includes a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, causing the computer device to perform the blockchain-based data processing method or device described in each of the above embodiments, without further elaboration. The beneficial effects of the same method are also not described in detail.
[0142] The above is merely a preferred embodiment of the present application, and cannot limit the scope of the claims of the present application. Therefore, any equivalent modifications according to the claims of the present application belong to the scope of the present application. [Explanation of symbols]
[0143] 1 Data Processing Device 10 nodes 110 Local Database 120 Remote Databases 121 Mapping Table Acquisition Module 122 Data Type Matching Module 123 Data Storage Module 124 Access command generation module 125 Data Access Module 126 Operation Execution Module 1211 Placement Information Load Unit 1212 Instance Acquisition Unit 1213 Mapping Table Generation Unit 1221 Data Information Decision Unit 1222 Data Type Determination Unit 1223 Data Type Matching Unit 1231 Hash Ring Generation Unit 1232 First Hash Calculation Unit 1233 Second Hash Calculation Unit 1234 Target Instance Determination Unit 1235 Data Storage Unit 1251 Instance Determination Unit 1252 Traffic Instance Determination Unit 1253 Access Command Transfer Unit 1254 Data Receiving Unit 1261 Archive Condition Acquisition Unit 1262 Data Transfer Unit 1300 Computer Equipment 1301 processor 1302 Communication Bus 1303 User Interface 1304 Network Interface 1305 memory 12121 Database Type Acquisition Subunit 12122 Smart Contrast Acquisition Subunit 12123 First construction subunit 12124 Prompt Information Display Subunit 12125 Second Construction Subunit 12221 First Determination Subunit 12222 Second Determining Subunit 12223 Third Determination Subunit
Claims
1. A data processing method using a blockchain, executed by a blockchain node, comprising: Obtaining a storage instance mapping table based on the database configuration information of the blockchain node, the storage instance mapping table including data mapping relationships of N database instances, the data mapping relationships indicating data types mapped to the database instances, different data types being mapped to different database instances, and N being a positive integer greater than 1; When acquiring the blockchain data to be stored, determining M candidate database instances from the N database instances, where the data types of the candidate database instances match the blockchain data, and M is a positive integer less than or equal to N; storing the blockchain data in a first database instance among the M candidate database instances based on a data sharding policy in the database placement information.
2. The step of obtaining a storage instance mapping table based on the database configuration information of the blockchain node includes: In response to a startup operation on the blockchain node, if the startup operation indicates that the blockchain node is being started for the first time, loading database configuration information of the blockchain node; Constructing the N database instances based on the database configuration information and the database type of the primary database of the blockchain node; Establishing a mapping relationship between each database instance and the data type of the hard disk to which each database instance belongs; and generating the storage instance mapping table based on the mapping relationship.
3. The database location information includes storage path information, the storage path information indicating hard disk sets associated with X data types, where X is a positive integer; The step of constructing the N database instances based on the database configuration information and the database type of the primary database of the blockchain node includes: Obtaining a database type of the primary database of the blockchain node; If the database type belongs to a first type, obtaining a smart contract from the blockchain to which the blockchain node belongs, and the smart contract constructs a database instance; 3. The method of claim 2, further comprising: constructing a database instance for each hard disk in the set of hard disks based on the smart contrast to obtain the N database instances.
4. 4. The method of claim 3, wherein the X data types include at least one of a first data type, a second data type, or a third data type, the first data type includes a block header data type, the second data type includes a transaction data type, and the third data type includes a contrast data type, and wherein storage performance of hard disks of the first data type is lower than storage performance of hard disks of the second data type, and storage performance of hard disks of the first data type is lower than storage performance of hard disks of the third data type.
5. said step of constructing a database instance for each hard disk in said set of hard disks based on said smart contrast, for each hard disk in the hard disk set, determining a number of instances of the hard disk based on the database placement information; If the hard disk is located in a local database in the main database, constructing a database instance for the hard disk that matches the number of instances based on the smart contrast; 4. The method of claim 3, further comprising: if the hard disk is located in a remote database in the main database, calling a database service component to build a database instance on the hard disk that matches the number of instances based on the smart contrast, the database service component being for providing remote database services.
6. The method comprises: If the database type belongs to a second type, displaying prompt information associated with the database configuration information; 4. The method of claim 3, further comprising the step of: in response to a trigger operation on the prompt information, constructing a database instance for each hard disk in the hard disk set, respectively, to obtain the N database instances.
7. When the blockchain data to be stored is obtained, the step of determining M candidate database instances from the N database instances includes: If the block chain data is obtained, determining data information of the block chain data; determining a data type of the blockchain data based on data information of the blockchain data; The method of claim 1, further comprising: searching the storage instance mapping table for a data type that matches the data type of the blockchain data; and determining the database instance corresponding to the searched data type as the candidate database instance.
8. the database allocation information includes a data volume threshold and an access frequency threshold; The step of determining a data type of the blockchain data based on data information of the blockchain data includes: When the data information indicates that the data amount of the blockchain data has not reached the data amount threshold and the data access frequency of the blockchain data has reached the access frequency threshold, determining a first data type as the data type of the blockchain data; If the data information indicates that the block chain data belongs to transaction data, determining a second data type as a data type of the block chain data; The method of claim 7, further comprising: if the data information indicates that the block chain data belongs to contrast data, determining a third data type as the data type of the block chain data.
9. The step of storing the blockchain data in a first database instance among the M candidate database instances based on a data sharding policy in the database placement information includes: generating hash rings associated with data types of the blockchain data for a hash value space according to a storage direction based on the data sharding policy; performing a hash calculation on first key information of each candidate database instance to obtain first position information of each candidate database instance on the hash ring; performing a hash calculation on second key information of the blockchain data to obtain second location information of the blockchain data on the hash ring; searching the hash ring for first location information having a location relationship closest to the second location information along the storage direction, and determining the database instance corresponding to the searched first location information as the first database instance; and storing the blockchain data in the first database instance.
10. The blockchain data includes data to be processed, and the method includes: generating a data access command in response to a traffic data request for the data to be processed, the data access command being a command for accessing the data to be processed; determining a second database instance from the N database instances, and accessing the data to be processed from the second database instance based on the data access command and the data sharding policy, wherein a data type of the second database instance matches the data to be processed; 2. The method of claim 1, further comprising: performing a data operation on the data to be processed as indicated by the traffic data request.
11. The N database instances are located in a remote database associated with the blockchain node, the remote database including host clusters corresponding to X data types, where X is a positive integer, and one data type corresponds to one host cluster; determining a second database instance from the N database instances, and accessing the data to be processed from the second database instance based on the data access command and the data sharding policy, determining a target host cluster from the X host clusters, and determining a database instance to be placed on the target host cluster as the second database instance, wherein a data type of the target host cluster matches the data to be processed; determining a traffic database instance to which the data to be processed belongs from the second database instance based on the data sharding policy; forwarding the data access command to a database proxy having a network connection relationship with the blockchain node, so that the database proxy sends the data access command to a database host node on which the traffic database instance is located; and receiving the data to be processed returned by the database proxy from the database host node.
12. The traffic data request includes a data archive request, and when the data to be processed is transaction data, the data archive request performs an archive process on the data to be processed, The step of executing a data operation indicated by the traffic data request on the data to be processed includes: acquiring data information of the data to be processed and data archiving conditions for the data to be processed, the data archiving conditions including an archiving parameter threshold, and the archiving parameter threshold including at least one of an archiving time range or an archiving frequency threshold; 11. The method of claim 10, further comprising: if the data information indicates that a transaction timestamp of the data to be processed falls within the archive time range or that an access frequency of the data to be processed is less than the archive frequency threshold, determining that the data to be processed satisfies the data archive condition, and transferring the data to be processed from a database to which the data to be processed belongs to an archive database.
13. A blockchain-based data processing device that is located in a blockchain node, A mapping table acquisition module that acquires a storage instance mapping table based on the database configuration information of the blockchain node, the storage instance mapping table including data mapping relationships of N database instances, the data mapping relationships indicating data types mapped to the database instances, different data types being mapped to different database instances, and N being a positive integer greater than 1; A data type matching module that, when acquiring blockchain data to be stored, determines M candidate database instances from the N database instances, where the data types of the candidate database instances match the blockchain data, and M is a positive integer less than or equal to N; a data storage module that stores the blockchain data in a first database instance among the M candidate database instances based on a data sharding policy in the database placement information.
14. A computer device comprising a processor, a memory, and a network interface; A computer device in which the processor, the memory, and the network interface are connected, the network interface provides a data communication function, the memory stores a computer program, and the processor calls the computer program to cause the computer device to execute the method of any one of claims 1 to 12.
15. A computer program stored in a computer-readable storage medium, the computer program being loaded and executed by a processor, causing a computer device having the processor to perform the method of any one of claims 1 to 12.
Citation Information
Patent Citations
Block chain block transaction data storage method, device and system and storage medium
CN114255128A
Network distributed duplication exclusion file storage system
JP2018190227A
Database engine for amorphous data sets
US20200159712A1