WO2024098862A1 - 一种基于区块链的数据处理方法、装置、设备及介质 - Google Patents

一种基于区块链的数据处理方法、装置、设备及介质 Download PDF

Info

Publication number
WO2024098862A1
WO2024098862A1 PCT/CN2023/112029 CN2023112029W WO2024098862A1 WO 2024098862 A1 WO2024098862 A1 WO 2024098862A1 CN 2023112029 W CN2023112029 W CN 2023112029W WO 2024098862 A1 WO2024098862 A1 WO 2024098862A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
database
blockchain
instance
type
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Ceased
Application number
PCT/CN2023/112029
Other languages
English (en)
French (fr)
Inventor
刘区城
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to EP23786169.5A priority Critical patent/EP4390720A4/en
Priority to JP2023573451A priority patent/JP7722778B2/ja
Priority to US18/527,704 priority patent/US20240152505A1/en
Publication of WO2024098862A1 publication Critical patent/WO2024098862A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • G06F16/278Data partitioning, e.g. horizontal or vertical partitioning
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/906Clustering; Classification
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files

Definitions

  • the present application relates to the field of blockchain technology, and in particular to a blockchain-based data processing method, device, equipment and medium.
  • database instances are used to store blockchain data.
  • Blockchain nodes and database instances are deployed on the same device, and there is a one-to-one correspondence between blockchain nodes and database instances.
  • the database instance uses only one hard disk, and the data of blockchain nodes is usually stored on the local hard disk of a single machine. When the scale of blockchain data is relatively small, this single-machine storage method can still meet storage needs in the short term.
  • the storage capacity of blockchain nodes will be limited by the capacity of a single hard disk, and the storage performance will also be subject to the read and write speed of a single hard disk, which makes it difficult to meet storage needs.
  • the embodiments of the present application provide a blockchain-based data processing method, device, equipment and medium, and the technical solution includes the following contents.
  • an embodiment of the present application provides a data processing method based on blockchain, including:
  • a storage instance mapping table is obtained; the storage instance mapping table includes data mapping relationships of N database instances; the data mapping relationship indicates the data type of the database instance; N is a positive integer greater than 1;
  • M candidate database instances are determined from the N database instances, and the data types of the candidate database instances match the blockchain data; M is a positive integer less than or equal to N;
  • the blockchain data is stored in a first database instance among the M candidate database instances.
  • an embodiment of the present application provides a data processing device based on blockchain, including:
  • a mapping table acquisition module used to acquire 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 relationship indicates the data type of the database instance; N is a positive integer greater than 1;
  • a data type matching module for determining M candidate database instances from the N database instances when the blockchain data to be stored is acquired, the data type of the candidate database instances matching the blockchain data; M is a positive integer less than or equal to N;
  • a data storage module is used to store the blockchain data in a first database instance among the M candidate database instances based on the data sharding strategy in the database configuration information.
  • an embodiment of the present application provides a computer device, including: a processor, a memory, and a network interface;
  • the processor is connected to the memory and the network interface, wherein the network interface is used to provide a data communication function, the memory is used to store a computer program, and the processor is used to call the computer program so that the computer device executes the blockchain-based data processing method provided in the embodiment of the present application.
  • the present invention provides a computer-readable storage medium that stores a computer program product.
  • a computer program is suitable for being loaded and executed by a processor so that a computer device having the processor executes the blockchain-based data processing method provided in an embodiment of the present application.
  • an embodiment of the present application provides 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, so that the computer device executes the blockchain-based data processing method provided in the 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 of N database instances; a data mapping relationship indicates the data type of a database instance; and N is a positive integer greater than 1.
  • the blockchain node in the embodiment of the present application corresponds to multiple database instances, and these multiple database instances are closely related to the data type.
  • the blockchain node When the blockchain node obtains the 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 the first database instance among the M candidate database instances based on the data sharding strategy in the database configuration information, where M is a positive integer less than or equal to N. It can be seen that the storage method provided by the embodiment of the present application can deploy multiple database instances on a blockchain node according to business needs, greatly expanding the storage capacity.
  • blockchain data of different data types can be stored in different database instances respectively, which greatly alleviates the storage pressure and achieves the diversion effect.
  • the storage capacity and read-write performance of the blockchain node can be increased exponentially, thereby effectively improving the node storage capacity of the blockchain node and meeting the storage requirements.
  • FIG1 is a schematic diagram of the structure of a blockchain node system provided in an embodiment of the present application.
  • FIG2 is a schematic diagram of a storage expansion for a single disk provided in an embodiment of the present application.
  • FIG3 is a schematic diagram of a storage expansion for multiple disks provided in an embodiment of the present application.
  • FIG4 is a schematic diagram of storage expansion of a distributed classification sub-library provided in an embodiment of the present application.
  • FIG5 is a schematic diagram of a scenario for data storage provided in an embodiment of the present application.
  • FIG6 is a flowchart of a data processing method based on blockchain provided in an embodiment of the present application.
  • FIG. 7 is a schematic diagram of a process for obtaining a storage instance mapping table provided in an embodiment of the present application.
  • FIG8 is a schematic diagram of a structure of a data sub-library classification storage provided by an embodiment of the present application.
  • FIG9 is a schematic diagram of a scenario for storing blockchain data provided by an embodiment of the present application.
  • FIG10 is a flowchart of a data processing method based on blockchain provided in an embodiment of the present application.
  • FIG11 is a schematic diagram of a process for accessing data to be processed provided by an embodiment of the present application.
  • FIG12 is a schematic diagram of the structure of a blockchain-based data processing device provided in an embodiment of the present application.
  • FIG. 13 is a schematic diagram of a computer device provided in an embodiment of the present application.
  • FIG 1 is a schematic diagram of the structure of a blockchain node system provided in an embodiment of the present application.
  • the blockchain node system in the embodiment of the present application is a distributed system formed by connecting multiple blockchain nodes through network communication.
  • the blockchain network corresponding to the blockchain system is a peer-to-peer network (Peer to peer networking, referred to as P2P network), that is, a distributed application architecture that distributes tasks and workloads among users, and is a networking or network form formed by a peer-to-peer computing model at the application layer.
  • P2P network peer to peer networking
  • the blockchain system shown in FIG1 includes multiple blockchain nodes, including node 10a, node Point 10b, node 10c, ..., node 10n.
  • the blockchain node in the blockchain system is any form of computer device connected to the blockchain network, for example, the computer device is a terminal device connected to the blockchain network, or a server connected to the blockchain network.
  • the specific form of the blockchain node is not limited here.
  • the server connected to the blockchain network is an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.
  • the terminal devices connected to the blockchain network include: smart phones, tablet computers, laptops, desktop computers, smart speakers, smart watches, car terminals, smart TVs and other smart terminals.
  • the application client running on the terminal device in the embodiment of the present application is an independent client, or an embedded sub-client integrated in a client (for example, a social client, an educational client, and a multimedia client, etc.), which is not limited here.
  • the blockchain network shown in FIG1 includes more than one participant, for example, a blockchain node that needs to store the full amount of ledger data (for example, a consensus node or a full node) and a blockchain node that stores part of the ledger data (for example, a light node).
  • the light node is used to store part of the blockchain database, that is, to store the block header data and the transaction data associated with its own node, but not the complete transaction data.
  • the embodiment of the present application proposes a storage method of classification/sub-library/sharding for such blockchain nodes that need to store the full amount of ledger data.
  • the database of any blockchain node in the blockchain network includes a main database and an archive database.
  • the main database refers to the database currently used by the blockchain node, and the main database includes a database deployed locally on the blockchain node (for example, the local database 110 of the node 10a shown in Figure 1) and a database deployed in a remote storage that has a network connection relationship with the blockchain node (for example, the remote database 120 of the node 10a shown in Figure 1).
  • the archive database refers to an independent database used for batch processing of blockchain data, and batch processing includes batch transfer or batch deletion, etc.
  • each blockchain node includes a blockchain ledger module, a database service component, and other blockchain modules.
  • the blockchain ledger module is used to provide functions such as storage, query, modification, and deletion of account data, and send the record data of the operation on the account data to other nodes in the blockchain system. After other nodes verify the validity, as a response to acknowledging the validity of the account data, the record data is stored in a temporary block, and a confirmation can also be sent to the node that initiated the operation.
  • the database service component is used to provide database services to the remote database of the blockchain node, for example, based on the database service, the blockchain data is stored or accessed in the remote database.
  • the database service component is also called the database service SDK (Software Development Kit).
  • other blockchain modules include object management, basic services, smart contracts, and operational detection processing modules.
  • object management module is responsible for the identity information management of all blockchain participants, including maintaining public and private key generation (account management), key management, and maintaining the correspondence between the object's real identity and blockchain address (authority management), etc., and, with authorization, supervises and audits the transaction of the real identity and provides risk control rule configuration (risk control audit);
  • basic service module is deployed on all blockchain node devices to verify the validity of business data requests, and records the valid requests to the storage after consensus is reached.
  • the basic service For a new business data request, the basic service first performs interface adaptation analysis and authentication processing (interface adaptation), and then encrypts the business information through the consensus algorithm ( Consensus management), after encryption, it is completely and consistently transmitted to the shared ledger (network communication), and recorded and stored; the smart contract module is responsible for the registration and issuance of contracts, as well as contract triggering and contract execution.
  • the development object defines the contract logic through a certain programming language and publishes it to the blockchain (contract registration). According to the logic of the contract terms, the key or other events are called to trigger the execution to complete the contract logic.
  • the operation detection module is mainly responsible for the deployment, configuration modification, contract setting, cloud adaptation and real-time status visualization output of the product during the product release process, such as: alarm, network status detection, node equipment health status detection, etc.
  • the blockchain node in the embodiment of the present application deploys one or more hard disks, and each hard disk deploys multiple database instances.
  • Figure 2 is a schematic diagram of storage expansion for a single disk provided by an embodiment of the present application.
  • the blockchain node in the embodiment of the present application is a blockchain node with a single hard disk deployed in the host (i.e., the main body part other than the input and output devices), and the blockchain node is any one of the blockchain nodes in the blockchain network shown in Figure 1 above, for example, the blockchain node is node 10a.
  • the blockchain node can deploy a hard disk, for example, hard disk A shown in Figure 2.
  • the embodiment of the present application deploys multiple database instances in a single hard disk based on the storage performance of hard disk A.
  • three are taken as an example, including database instance D 1 , database instance D 2 , and database instance D 3 .
  • the storage performance of hard disk A is jointly determined by the storage capacity and read/write performance of hard disk A.
  • Figure 3 is a schematic diagram of storage expansion for multiple disks provided in an embodiment of the present application.
  • the blockchain node in the embodiment of the present application is a blockchain node with multiple hard disks deployed in the host, and the blockchain node is any blockchain node in the blockchain network shown in Figure 1 above, for example, the blockchain node is node 10a. Since the storage performance of different hard disks may vary, the number of instances of the database instance deployed by each hard disk will vary according to the storage performance of the hard disk itself.
  • the multiple hard disks deployed by the blockchain node take two as an example, including hard disk A and hard disk B, and the storage performance of hard disk B is higher than that of hard disk A.
  • the embodiment of the present application can deploy more database instances and distribute them on different hard disks, thereby achieving a diversion effect, so that the storage capacity and read and write performance can be doubled.
  • the embodiment of the present application deploys multiple database instances in hard disk A based on the storage performance of hard disk A, taking 3 as an example, including database instance D 1 , database instance D 2 and database instance D 3 .
  • the embodiment of the present application also deploys multiple database instances in hard disk B based on the storage performance of hard disk B, taking 4 as an example, including database instance D 4 , database instance D 5 , database instance D 6 and database instance D 7 .
  • Figure 4 is a schematic diagram of storage expansion of a distributed classification sub-library provided in an embodiment of the present application.
  • the blockchain node in the embodiment of the present application is any blockchain node in the blockchain network shown in Figure 1 above, for example, the blockchain node is node 10a.
  • the embodiment of the present application performs distributed storage expansion, that is, storage is performed through a database proxy.
  • the database proxy is deployed on the same computer device as the blockchain node, or on a different computer device from the blockchain node, and the deployment method of the database proxy will not be limited here.
  • the embodiment of the present application deploys a corresponding host cluster for each data type according to the X data types of blockchain data received by the blockchain node.
  • X is a positive integer.
  • N database instances are deployed 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 corresponds to one host cluster, and each host cluster includes multiple database host nodes.
  • the data types in the embodiment of the present application are taken as three examples, including a first data type, a second data type, and a third data type.
  • the first data type refers to the data type corresponding to the frequently accessed small amount of data.
  • the first data type includes a block header data type and a status data type, etc.
  • the block header data type refers to the data type to which the block header data belongs
  • the status data type refers to the data type to which the status data belongs.
  • the status data includes the risk status of the enterprise object, the bill status of the electronic bill, the asset status of the business object, etc.
  • the host cluster corresponding to the first data type is the host cluster 1 shown in FIG4 , and the host cluster 1 includes multiple hosts, for example, including host J 11 , host J 12 , ..., and host J 1N . Among them, each host in the host cluster 1 is deployed with multiple hard disks. For example, host J 11 deploys two hard disks, hard disk A and hard disk B, and each hard disk is deployed with multiple database instances.
  • the second data type refers to a data type of blockchain data that needs to be stored independently.
  • the second data type includes a transaction data type
  • the transaction data type refers to the data type to which the transaction data belongs.
  • transaction data is equivalent to running water. In some scenarios, transaction running water does not need to be saved for too long, so it needs to be stored in an independent database instance, which is conducive to subsequent data archiving or regular deletion.
  • the host cluster corresponding to the second data type is the host cluster 2 shown in Figure 4, and the host cluster 2 includes multiple hosts, for example, including host J 21 , host J 22 , ..., and host J 2N .
  • each host in the host cluster 2 is deployed with multiple hard disks. For example, host J 21 deploys two hard disks, hard disk C and hard disk D, and each hard disk is deployed with multiple database instances.
  • the third data type refers to another data type corresponding to blockchain data that needs to be stored independently.
  • the third data type includes a contract data type, which refers to the data type to which contract data belongs.
  • contract data refers to real business data. Storing it independently in multiple database instances can reduce the amount of data in a single database. This can effectively improve the read and write performance of the database, thereby improving the storage performance of the blockchain node.
  • the host cluster corresponding to the third data type is the host cluster 3 shown in Figure 4, and the host cluster 3 includes multiple hosts, for example, including host J 31 , host J 32 , ..., and host J 3N . Among them, each host in the host cluster 3 is deployed with multiple hard disks, for example, host J 21 deploys two hard disks, hard disk E and hard disk F, and each hard disk is deployed with multiple database instances.
  • the blockchain node in the embodiment of the present application is a blockchain node in the blockchain network that needs to store the full amount of ledger data
  • the blockchain node is any blockchain node in the blockchain network shown in Figure 1 above, for example, the blockchain node is node 10a.
  • the embodiment of the present application divides the blockchain data to be stored into X data types, so as to store the blockchain data in different libraries according to the data types and improve the node storage performance.
  • X is a positive integer.
  • the number of data types in the embodiment of the present application is 3 as an example, including data type 21, data type 22 and data type 23.
  • the blockchain node When starting a blockchain node, the blockchain node obtains a storage instance mapping table based on the database configuration information of the blockchain node. If the blockchain node is a node started for the first time, the blockchain node generates a storage instance mapping table based on the database configuration information. If the blockchain node is not a node started for the first time, the blockchain node directly loads the generated storage instance mapping table based on the database configuration information.
  • 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.
  • the N database instances are deployed according to the business needs of the blockchain node, that is, they are all deployed in the local database of the blockchain node (for example, the deployment method shown in FIG. 2 above), or they are all deployed in the remote database of the blockchain node (for example, the deployment method shown in FIG. 4 above), or they are deployed in both the local database and the remote database, which will not be limited here.
  • Table 1 is a storage instance mapping table provided in an embodiment of the present application.
  • the storage instance mapping table shown in Table 1 includes data mapping relationships of N database instances. Taking N equal to 6 as an example, the N database instances include database instance D 1 , database instance D 2 , database instance D 3 , database instance D 4 , database instance D 5 and database instance D 6.
  • database instances of different data types can be deployed in the same hard disk or in different hard disks. For example, database instances corresponding to data types 21, 22 and 23 can be deployed in the same hard disk (for example, hard disk A shown in Figure 2).
  • database instances corresponding to data types 21 and 22 can be deployed in the same hard disk (for example, hard disk A shown in Figure 3), and database instances corresponding to data type 23 can be deployed in another hard disk (for example, hard disk B shown in Figure 3).
  • Table 1 shows that
  • the blockchain node needs to determine M candidate database instances from the N database instances included in the storage instance mapping table shown in Table 1 above, and the data type of the candidate database instance matches the blockchain data, and M is a positive integer less than or equal to N.
  • the blockchain node obtains the blockchain data Q to be stored, the data type of the blockchain data Q can be determined. 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 D 2 and database instance D 3 ) from the storage embodiment mapping table shown in Table 1 above as database instances that match the blockchain data Q.
  • the blockchain node determines the database instance (i.e., the first database instance, for example, database instance D 3 ) required to store the blockchain data Q based on the data sharding strategy in the database configuration information, and stores it in the database instance D 3 .
  • a blockchain node deploys N database instances according to business needs, which means that the storage capacity of the blockchain node can be improved, and for any data type of blockchain data, it can be stored in the corresponding database instance according to the implementation method of storing blockchain data Q in the first database instance, that is, blockchain data of different data types can be stored in different database instances respectively, which greatly alleviates the storage pressure and achieves the diversion effect.
  • This not only solves the problem of insufficient data reading and writing performance of blockchain nodes, but also solves the problem of limited storage space of a single machine. It even provides the possibility for blockchain to land in large data storage scenarios through refined contract storage management according to data types and data sharding strategies.
  • Figure 6 is a flowchart of a data processing method based on blockchain provided by an embodiment of the present application.
  • the method is executed by a computer device, which 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.
  • the blockchain node is any blockchain node in the blockchain network shown in Figure 1 above, for example, the blockchain node is node 10a.
  • the method may at least include the following steps 601-603:
  • 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 relationship indicates the data type of the database instance, and N is a positive integer greater than 1.
  • the storage instance mapping table includes data mapping relationships of N database instances; one data mapping relationship indicates the data type of a database instance; and N is a positive integer greater than 1.
  • a business object e.g., a user
  • performs a startup operation on a blockchain node and then 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 refers to a trigger operation for starting a blockchain node, which includes contact operations such as clicks and long presses, or non-contact operations such as voice and gestures, which will not be limited here.
  • the blockchain node needs to be initialized, that is, the database configuration information of the blockchain node is loaded, and N database instances are created based on the database configuration information and the database type of the main database of the blockchain node.
  • 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 based on the established mapping relationship.
  • the database configuration information refers to the information associated with the database of the blockchain node configured by the configuration object (e.g., the configuration user of the blockchain node) for the blockchain node based on the business storage requirements.
  • the database configuration information includes the database storage path, the number of instances configured by the hard disk of the blockchain node, and the data sharding strategy.
  • 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 deployed by the blockchain node; the data sharding strategy refers to the calculation method used by the blockchain node when storing blockchain data, for example, the consistent hashing algorithm.
  • the configuration object determines that the data type of blockchain data includes X data types (X is a positive integer)
  • the configuration object configures a different database instance for each data type to Blockchain-like data is stored in different database instances.
  • the same type of data can also be stored in multiple database instances, and the hard disk corresponding to the database instance can be deployed in the local database of the blockchain node or in the remote database of the blockchain node, which will not be limited here.
  • both the local database and the remote database of the blockchain node can deploy one or more hard disks.
  • the database storage path in the database configuration information in the embodiment of the present application indicates a set of hard disks associated with X data types, that is, including storage paths corresponding to each type of data.
  • the X data types here include at least one of the first data type, the second data type, or the third data type.
  • the first data type includes at least one of the block header data type or the state data type; the second data type includes the transaction data type; and the third data type includes the contract data type.
  • the configuration object selects a machine (i.e., a hard disk) with relatively small storage capacity and slightly weaker storage performance, so as to save costs to a great extent while meeting business needs.
  • the storage performance of the hard disk of the first data type is lower than the storage performance of the hard disk of the second data type, and also lower than the storage performance of the hard disk of the third data type.
  • Table 2 is a pseudo code schematic table associated with database configuration information provided in an embodiment of the present application.
  • the hard disk set associated with X data types deployed by the blockchain node in the embodiment of the present application is taken as 4 as an example, including hard disk A (e.g., data1), hard disk B (e.g., data2) and hard disk D (e.g., data4) deployed in the local database, and hard disk C (e.g., data3) deployed in the remote database.
  • the computer device corresponding to the remote database can be represented by the data format of endpoint:port. As shown in Table 2:
  • the storage performance of hard disk A in the local database is lower than that of other hard disks.
  • the storage path corresponding to the first data type in the database configuration information is the "/data1/blockHeader" directory.
  • the storage path corresponding to the second data type in the database configuration information includes the "/data1/transaction, /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.
  • the third data type is the contract data type
  • the storage path corresponding to the third data type in the database configuration information includes the "/data4/contract" directory in the local database.
  • the root directories of the database instances are the target prefix plus the instance serial number. For example, if multiple database instances are deployed in hard disk A, the storage path corresponding to the transaction data type is "/data1/transaction/1, /data1/transaction/2, /data1/transaction/3".
  • Figure 7 is a schematic diagram of a process for obtaining a storage instance mapping table provided in an embodiment of the present application.
  • the blockchain node in the embodiment of the present application is any blockchain node in the blockchain network shown in Figure 1 above, for example, the blockchain node is node 10a.
  • the blockchain node executes step 701 to start the blockchain node, and then executes step 702 to load the database configuration information. Further, the blockchain node can obtain the database type of the main database of the blockchain node, so as to decide whether to automatically execute steps 703-704 according to the smart contract on the blockchain to create a database instance, or to manually create a database instance according to the configuration object of the blockchain node.
  • the database types of master data include a first type (for example, a type that can automatically create a database instance based on a smart contract) and a second type (for example, a type that requires manual creation of a database instance).
  • a first type for example, a type that can automatically create a database instance based on a smart contract
  • a second type for example, a type that requires manual creation of a database instance
  • the blockchain node obtains a smart contract from the blockchain to which the blockchain node belongs, and the smart contract is used to create a database instance.
  • a smart contract refers to a computerized protocol that can execute contract terms and is implemented through code deployed on a shared ledger. The code is used to execute when certain conditions are met, and the code completes automated transactions according to actual business needs.
  • the blockchain node creates a database instance for each hard disk in the hard disk set, and obtains N database instances.
  • the blockchain node determines the number of instances of each hard disk based on the database configuration information.
  • the blockchain node executes step 703 to determine whether the hard disk to be created is deployed in the local database.
  • the blockchain node executes step 704, and creates a database instance for the hard disk that matches the number of instances based on the smart contract.
  • the blockchain node calls the database service component, and creates a database instance for the hard disk that matches the number of instances based on the smart contract, and the database service component is used to provide remote database services.
  • the blockchain node jumps to execute steps 707-709, calls the database service component, and creates a database instance that matches the number of instances based on the remote database service provided by the database service component, and the database service component receives a database instance response when the creation is completed.
  • the blockchain node displays prompt information associated with the database configuration information, so that the configuration object performs a trigger operation based on the prompt information.
  • the prompt information may be information corresponding to types such as pictures, videos, audio, and text, and the information type of the prompt information is not limited here.
  • the blockchain node creates a database instance for each hard disk in the hard disk set, and obtains N database instances.
  • 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 then generates a storage instance mapping table based on the established mapping relationship, so as to subsequently execute step 706 to provide data services (e.g., data access services, etc.) for the blockchain node.
  • data services e.g., data access services, etc.
  • Figure 8 is a structural diagram of a data sub-library classification storage provided by an embodiment of the present application.
  • the blockchain node of the embodiment of the present application is a blockchain node with multiple hard disks deployed in the host, and the blockchain node is any blockchain node in the blockchain network shown in Figure 1 above, for example, the blockchain node is node 10a.
  • the blockchain node shown in Figure 8 loads the database configuration information.
  • the storage path information in the database configuration information indicates a hard disk set associated with three data types (e.g., block header data type, transaction data type, and contract data type), and the hard disk set includes hard disk A and hard disk B deployed locally according to business needs.
  • the blockchain node can create a database instance for the main database according to the database type (e.g., the first type) and database configuration information of the main database.
  • the storage path of the database configuration information indicates the number of instances of different data types in each hard disk. For example, the number of instances of the block header data type in hard disk A (i.e., the first instance number) is 1, the number of instances of the transaction data type in hard disk A (i.e., the second instance number) is 2, and the number of instances of the contract data type in hard disk B (i.e., the third instance number) is 3.
  • the blockchain node determines that the number of instances of hard disk A is the sum of the first number of instances and the second number of instances (i.e., 3) based on the database configuration information. At this time, the blockchain node creates 3 database instances for hard disk A based on the smart contract, including database instance D1 , database instance D2 , and database instance D3 .
  • the blockchain node determines that the instance number of hard disk B is the third instance number (i.e., 3) based on the database configuration information. At this time, the blockchain node creates 3 database instances for hard disk B based on the smart contract, including database instance D 4 , database instance D 5 , and database instance D 6 .
  • 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 then generates the storage instance mapping table shown in Table 1 based on the established mapping relationship.
  • the storage instance mapping table is stored in a key-value storage, i.e., Key-Value storage, referred to as KV storage. That is, the blockchain node determines the Key as the data type and the Value as the database instance.
  • the storage instance mapping table in the embodiment of the present application can be an independent mapping table including X data types as shown in Table 1 above, or it can be a mapping table composed of X storage instance sub-mapping tables, which will not be limited here.
  • the blockchain node establishes a storage instance sub-mapping table for each data type, so that the host cluster to be accessed can be quickly determined from the X host clusters through the database proxy later, thereby improving access efficiency.
  • Step 602 When the blockchain node obtains the blockchain data to be stored, it determines M candidate database instances from N database instances, where the data type of the candidate database instance matches the blockchain data, and M is a positive integer less than or equal to N.
  • the blockchain node determines the data information of the blockchain data, and then determines the data type of the blockchain data based on the data information of the blockchain data. Further, the blockchain node searches for a data type that matches the data type of the blockchain data from the storage instance mapping table, and determines the database instance corresponding to the found data type as a candidate database instance, thereby obtaining M candidate database instances.
  • the database configuration information includes a data volume threshold and an access frequency threshold configured according to business requirements.
  • the blockchain node determines the first data type as the data type of the blockchain data.
  • the blockchain node determines the second data type as the data type of the blockchain data, for example, the transaction data includes asset transfer transaction data or electronic bill circulation transaction.
  • the blockchain node determines the third data type as the data type of the blockchain data.
  • the X data types in the embodiment of the present application may also include other data types, which will not be exemplified one by one here.
  • the blockchain node 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 D 2 and database instance D 3 ) from the storage embodiment mapping table shown in Table 1 as two candidate database instances matching the blockchain data Q.
  • Step 603 The blockchain node stores the blockchain data in the first database instance among the M candidate database instances based on the data sharding strategy in the database configuration information.
  • the blockchain node generates a hash ring associated with the data type of the blockchain data based on the data sharding strategy in the database configuration information, and distributes the hash value space according to the storage direction.
  • the first key information e.g., input information such as address and directory
  • the blockchain node can also perform hash calculation on the second key information (e.g., data hash value) of the blockchain data to obtain the second position information of the blockchain data on the hash ring.
  • the blockchain node searches for the first position information that has the closest position relationship with the second position information along the storage direction on the hash ring, determines the database instance corresponding to the first position information found as the first database instance, and then stores the blockchain data in the first database instance.
  • the embodiment of the present application involves X data types
  • the embodiment of the present application involves X groups of database instances, and a group of database instances corresponds to a hash ring, that is, the embodiment of the present application involves X hash rings.
  • the data type includes a block header data type, a transaction data type, and a contract data type
  • the embodiment of the present application will involve three hash rings, and these three hash rings correspond to the database mapping relationship of these three data types respectively.
  • Figure 9 is a schematic diagram of a scenario for storing blockchain data provided by an embodiment of the present application.
  • 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 based on the data sharding strategy (e.g., consistent hashing algorithm) in the database configuration information, and the hash value space is generated according to the storage direction (e.g., clockwise).
  • the hash value space refers to a digital space from 0 to (2 ⁇ 32)-1.
  • the blockchain node determines four candidate database instances from the storage instance mapping table, including database instance D 1 , database instance D 2 , database instance D 3 and database instance D 4 shown in FIG9 .
  • the blockchain node performs hash calculation on the first key information of each of the four database instances to obtain the first position information of each database instance on the hash ring.
  • the blockchain data to be stored acquired by the blockchain node include blockchain data Q 61 , blockchain data Q 62 , blockchain data Q 63 , blockchain data Q 64 , blockchain data Q 65 and blockchain data Q 66 shown in FIG9 .
  • the blockchain node acquires directory information, device information (e.g., device identification, etc.) of the database instance D 1 as the first key information of the database instance D 1. Further, the blockchain node performs hash calculation on the first key information of the database instance D 1 according to the consistent hashing algorithm, thereby obtaining the hash value of the database instance D 1 , and mapping the hash value of the database instance D 1 on the hash ring to obtain the first position information of the database instance D 1 on the hash ring.
  • the blockchain node performs a hash calculation on the second key information of the blockchain data to obtain the second position information of the blockchain data on the hash ring.
  • the blockchain node needs to determine the second key information of the blockchain data Q 61 according to the data type of the blockchain data Q 61.
  • the blockchain node performs a hash calculation on the second key information of the blockchain data Q 61 according to the consistent hashing algorithm to obtain the hash value of the blockchain data Q 61 , maps the hash value of the blockchain data Q 61 on the hash ring, and obtains the second position information of the blockchain data Q 61 on the hash ring.
  • the blockchain node uses the block header hash value of the blockchain data Q 61 as the second key information of the blockchain data Q 61.
  • the blockchain node uses the transaction hash value of the blockchain data Q 61 as the second key information of the blockchain data Q 61.
  • the blockchain node uses the contract hash value of the blockchain data Q 61 as the second key information of the blockchain data Q 61 .
  • the blockchain node searches for the first location information having the closest position relationship with the second location information along the storage direction on the hash ring, determines the database instance corresponding to the found first location information as the first database instance, and stores the blockchain data in the first database instance.
  • the blockchain node searches for the first location information that has the closest position relationship with the second location information in a clockwise storage direction on the hash ring based on the second location information of the blockchain data Q 61 , and determines the database instance corresponding to the found first location information (for example, database instance D 1 shown in FIG. 9 ) as the first database instance, and then stores the blockchain data in the first database instance.
  • the database instance corresponding to the found first location information (for example, database instance D 1 shown in FIG. 9 ) as the first database instance, and then stores the blockchain data in the first database instance.
  • the blockchain node refers to the storage method of blockchain data Q 61 , stores blockchain data Q 62 to database instance D 1 , stores blockchain data Q 63 to database instance D 2 , stores blockchain data Q 64 , blockchain data Q 65 and blockchain data Q 66 to database instance D 3 , and stores blockchain data Q 67 to database instance D 4 .
  • the storage method provided by the embodiment of the present application can deploy multiple database instances on a blockchain node according to business needs, greatly expanding the storage capacity. Subsequently, when the blockchain data is sharded and classified and stored in the corresponding database instance according to the data type of the blockchain data, blockchain data of different data types can be stored in different database instances respectively, which greatly alleviates the storage pressure and achieves the diversion effect. This means that when the storage method of the embodiment of the present application is adopted, the storage capacity and read-write performance of the blockchain node can be increased exponentially, thereby effectively improving the node storage capacity of the blockchain node and meeting the storage requirements.
  • Figure 10 is a flowchart of a data processing method based on blockchain provided by an embodiment of the present application.
  • the method is executed by a computer device, which 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.
  • the blockchain node is any blockchain node in the blockchain network shown in Figure 1 above, for example, the blockchain node is node 10a.
  • the method may at least include the following steps 1001-1006:
  • Step 1001 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; one data mapping relationship indicates the data type of a database instance; and N is a positive integer greater than 1.
  • a business 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 refers to a trigger operation for starting a blockchain node, which includes contact operations such as clicks and long presses, or non-contact operations such as voice and gestures, which will not be limited here.
  • 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 type of the candidate database instances matches the blockchain data.
  • M is a positive integer less than or equal to N.
  • the blockchain node determines the data information of the blockchain data, and determines the data type of the blockchain data based on the data information of the blockchain data. Further, the blockchain node searches for a data type that matches the data type of the blockchain data from the storage instance mapping table, and determines the database instance corresponding to the found data type as a candidate database instance, thereby obtaining M candidate database instances.
  • Step 1003 The blockchain node stores the blockchain data in the first database instance among the M candidate database instances based on the data sharding strategy in the database configuration information.
  • the blockchain node generates a hash ring associated with the data type of the blockchain data according to the storage direction of the hash value space based on the data sharding strategy in the database configuration information. Further, the blockchain node performs a hash calculation on the first key information (e.g., input information such as address and directory) of each candidate database instance in the M candidate database instances to obtain the first position information of each database instance on the hash ring. Similarly, the blockchain node performs a hash calculation on the second key information of the blockchain data (e.g., data hash value) to obtain the second position information of the blockchain data on the hash ring.
  • the first key information e.g., input information such as address and directory
  • the blockchain node performs a hash calculation on the second key information of the blockchain data (e.g., data hash value) to obtain the second position information of the blockchain data on the hash ring.
  • the blockchain node searches for the first position information that has the closest position relationship with the second position information on the hash ring along the storage direction, determines the database instance corresponding to the found first position information as the first database instance, and stores the blockchain data in the first database instance.
  • step 1001 to step 1003 may refer to the description of step 601 to step 603 in the embodiment of FIG. 6 above, and will not be repeated here.
  • the blockchain data includes data to be processed.
  • Step 1004 The blockchain node generates a data access instruction in response to a business data request for the data to be processed, and the data access instruction is used to access the data to be processed.
  • the business data request is generated by the blockchain node based on the data type of the data to be processed, or it may be generated by other computer devices that have a network connection relationship with the blockchain node (for example, another blockchain node in the blockchain network). Or the terminal device corresponding to the business object), the source of the business data request will not be limited here.
  • the computer device obtains the node public key of the blockchain node, encrypts the data information such as the data type of the data to be processed, so as to obtain data encryption information, and then can generate a business data request for sending to the blockchain node based on the data encryption information.
  • the blockchain node receives the business data request, it first verifies the legitimacy of the computer device (for example, whether it belongs to the computer device on the illegal list).
  • the computer device When verifying the legitimacy of the computer device, it decrypts the data encryption information based on the node private key of the blockchain node, thereby obtaining data information such as the data type of the data to be processed, and then generates a data access instruction for accessing the data to be processed based on these data information.
  • 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 instruction and the data sharding strategy in the database configuration information.
  • the data type of the second database instance matches the data to be processed.
  • the blockchain node refers to the implementation method corresponding to the above step 602, determines the second database instance from the N database instances included in the storage instance mapping table, and then determines the business database instance to which the data to be processed belongs from the second database instance based on the data sharding strategy in the database configuration information according to the storage method shown in Figure 9 above, so as to access the data to be processed from the business database instance.
  • N database instances are all deployed in a remote database associated with a blockchain node; the remote database includes host clusters corresponding to X data types; X is a positive integer; one data type corresponds to one host cluster.
  • the blockchain node executes access to the data to be processed, it determines the target host cluster from the X host clusters, and the data type of the target host cluster matches the data to be processed.
  • the business data request carries the data type of the data to be processed, and the data type of the target host cluster matches the data to be processed, which 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 deployed in the target host cluster as the second database instance.
  • the blockchain node determines the business database instance to which the data to be processed belongs from the second database instance, and forwards the data access instruction to the database proxy having a network connection relationship with the blockchain node, so that the database proxy sends the data access instruction to the database host node where the business database instance is deployed. At this time, the blockchain node receives the data to be processed returned by the database host node through the database proxy.
  • the storage expansion mode of the blockchain node is the storage expansion mode shown in FIG4 above, then when the blockchain node executes access to the data to be processed, it can determine host cluster 1 from the three host clusters, the data type of host cluster 1 matches the data type of the data to be processed, and then determine the database instance deployed in host cluster 1 as the second database instance. Further, based on the data sharding strategy in the database configuration information, the blockchain node determines the business database instance (for example, hard disk A shown in FIG4) to which the data to be processed belongs from the second database instance according to the method shown in FIG9 above.
  • the business database instance for example, hard disk A shown in FIG4
  • the blockchain node calls the database service component, wherein the database service component can be deployed on the same device as the blockchain node, or can be deployed separately on another device different from the blockchain node, which will not be limited here. If the database service component is deployed separately on another device different from the blockchain node, the embodiment of the present application refers to this device as a database agent having a network connection relationship with the blockchain node.
  • the blockchain node forwards the data access instruction to the database agent shown in Figure 4, so that the database agent sends the data access instruction to the database host node deployed by the business database instance (for example, the database host node where the host J 11 is located).
  • the blockchain node can receive the data to be processed returned by the database host node through the database agent.
  • the blockchain node in the embodiment of the present application is a blockchain node in the blockchain network that needs to store the full amount of ledger data, for example, the blockchain node is any blockchain node in the blockchain network shown in Figure 1 above, for example, the blockchain node is node 10a.
  • the blockchain node executes step 1101 to obtain a storage instance mapping table, and then executes step 1102 to determine a second database instance according to the data type of the to-be-processed data carried by the business data request.
  • the blockchain node when the blockchain node obtains that the data type of the data to be processed is a contract data type, the blockchain node obtains the storage instance mapping table, and determines the second database instance among 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.
  • the second database instance is database instance D4 , database instance D5 , and database instance D6 shown in FIG8 .
  • step 1103-step 1104 determines the location information of the data to be processed on the hash ring based on the data sharding strategy, and then finds the first location information that has the closest location information to the location information of the data to be processed according to the storage direction of the hash ring, and then determines the database instance corresponding to the first location information found as the business database instance.
  • the blockchain node executes step 1105 to determine whether the business database instance is deployed in the local database. If the business database instance is deployed in the local database, the blockchain node executes step 1106 to access the data to be processed in the local database, and executes step 1107 to end the access process. For example, if the business database instance is the database instance D 3 shown in FIG. 3 above, the blockchain node accesses the data to be processed in hard disk A in the local database.
  • the blockchain node jumps to execute steps 1108-1111, calls the database service component, so that the database service component establishes 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, so that the database service component returns the data to be processed to the blockchain node, and then executes step 1107 to end the access process.
  • Step 1006 The blockchain node performs the data operation indicated by the business data request on the data to be processed.
  • the business data request includes a data archiving request, a data change request, a data addition request, a data query request, and a data deletion request, etc.
  • the data archiving request is used to archive 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 blockchain node obtains data information of the data to be processed and data archiving conditions for the data to be processed.
  • the data archiving conditions include an archiving parameter threshold; the archiving parameter threshold includes at least one of an archiving time range (for example, a time range N years ago from now) or an archiving frequency threshold (for example, 50 times).
  • the blockchain node determines that the data to be processed meets the data archiving conditions. At this time, the blockchain node transfers the data to be processed from the database to which the data to be processed belongs to the archiving database.
  • the embodiments of the present application are applied to scenarios where the blockchain system needs to store massive amounts of data and has high requirements for chain performance, including scenarios with performance pressure due to high transaction frequency and scenarios with storage space pressure due to large number of transactions.
  • different types of blockchain data are stored in different database instances respectively, thereby solving the storage capacity bottleneck problem.
  • the embodiments of the present application store inactive data such as historical transactions in an archive database.
  • the archive database is a device with poor performance and lower cost, which is conducive to archiving or regularly deleting data, thereby saving storage space and expenses.
  • 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 storage space of a single machine, and even through the refined contract storage management according to the data type and data sharding strategy, it also provides the possibility for the blockchain to land in the storage scenario of large amounts of data.
  • the blockchain-based data processing device 1 is a computer program (including program code) running in a computer device, for example, the blockchain-based data processing device 1 is an application software; the blockchain-based data processing device is used to execute the corresponding steps in the method provided in the embodiment of the present application.
  • the blockchain-based data processing device runs on a blockchain node in the blockchain network that needs to save the full amount of ledger data, for example, any blockchain node in the blockchain network shown in Figure 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 instruction generation module 124, a data access module 125, and an operation execution module 126.
  • the mapping table acquisition module 121 is used to acquire 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 relationship indicates the data type of the database instance; and N is a positive integer greater than 1.
  • the mapping table acquisition module 121 includes: a configuration information loading unit 1211 , an instance acquisition unit 1212 , and a mapping table generation unit 1213 .
  • the configuration information loading unit 1211 is used to load database configuration information in response to a startup operation for the blockchain node, when the startup operation indicates that the blockchain node is started for the first time;
  • the instance acquisition unit 1212 is used to create N database instances based on the database configuration information and the database type of the main database of the blockchain node.
  • the storage path information in the database configuration information indicates a set of hard disks associated with X data types; X is a positive integer;
  • the instance acquisition unit 1212 includes: a database type acquisition subunit 12121, a smart contract acquisition subunit 12122, a first creation subunit 12123, a prompt information display subunit 12124 and a second creation subunit 12125.
  • the database type acquisition subunit 12121 is used to obtain the database type of the main database of the blockchain node;
  • the smart contract acquisition subunit 12122 is used to acquire a smart contract from the blockchain to which the blockchain node belongs when the database type belongs to the first type, and the smart contract is used to create a database instance;
  • the first creation subunit 12123 is used to create a database instance for each hard disk in the hard disk set based on the smart contract, so as to obtain N database instances.
  • the first creation subunit 12123 is further used for:
  • the database service component is called to create a database instance that matches the number of instances for the hard disk based on the smart contract.
  • the database service component is used to provide remote database services.
  • the prompt information display subunit 12124 is used to display prompt information associated with the database configuration information when the database type belongs to the second type;
  • the second creation subunit 12125 is used to create a database instance for each hard disk in the hard disk set in response to a trigger operation on the prompt information, so as to obtain N database instances.
  • the implementation methods of the database type acquisition subunit 12121, the smart contract acquisition subunit 12122, the first creation subunit 12123, the prompt information display subunit 12124 and the second creation subunit 12125 can be referred to the description of creating a database instance in the embodiment of Figure 6 above, and will not be further elaborated here.
  • the X data types include at least one of the first data type, the second data type or the third data type; the first data type includes the block header data type; the second data type includes the transaction data type; the third data type includes the contract data type; the storage performance of the hard disk of the first data type is lower than the storage performance of the hard disk of the second data type, and the storage performance of the hard disk of the first data type is lower than the storage performance of the hard disk of the third data type.
  • the mapping table generating unit 1213 is used to establish a mapping relationship between each database instance and the data type of the hard disk to which each database instance belongs, and generate a storage instance mapping table based on the mapping relationship.
  • the implementation of the configuration information loading unit 1211, the instance obtaining unit 1212 and the mapping table generating unit 1213 may refer to the description of step 601 in the embodiment of FIG. 6 above, and will not be further described here.
  • the data type matching module 122 is used to determine M candidate database instances from N database instances when the blockchain data to be stored is obtained, and the data type of the candidate database instance matches the blockchain data; M is a positive integer less than or equal to N.
  • 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 .
  • the data information determining unit 1221 is used to determine the data information of the blockchain data when the blockchain data to be stored is obtained;
  • the data type determination unit 1222 is used to determine the data type of the blockchain data based on the data information of the blockchain data. type.
  • the database configuration information includes a data volume threshold and an access frequency threshold
  • the data type determination unit 1222 includes: a first determination subunit 12221 , a second determination subunit 12222 and a third determination subunit 12223 .
  • the first determination subunit 12221 is configured to determine the first data type as the data type of the blockchain data when 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 second determining subunit 12222 is used to determine 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 is used to determine the third data type as the data type of the blockchain data when the data information indicates that the blockchain data belongs to the contract data.
  • the implementation methods of the first determining subunit 12221, the second determining subunit 12222 and the third determining subunit 12223 can refer to the description of the data type in the embodiment of Figure 6 above, and will not be further described here.
  • the data type matching unit 1223 is used to search for a data type that matches the data type of the blockchain data from the storage instance mapping table, and determine the database instance corresponding to the found data type as a candidate database instance.
  • the implementation methods of the data information determination unit 1221, the data type determination unit 1222 and the data type matching unit 1223 can refer to the description of step 601 in the embodiment corresponding to Figure 6 above, and will not be further described here.
  • the data storage module 123 is used to store the blockchain data in the first database instance among the M candidate database instances based on the data sharding strategy in the database configuration information.
  • the data storage module 123 includes: a hash ring generation unit 1231 , a first hash calculation unit 1232 , a second hash calculation unit 1233 , a target instance determination unit 1234 and a data storage unit 1235 .
  • the hash ring generation unit 1231 is used to generate a hash ring associated with the data type of the blockchain data according to the storage direction of the hash value space based on the data sharding strategy;
  • the first hash calculation unit 1232 is used to perform hash calculation on the first key information of each candidate database instance in the M candidate database instances to obtain the first position information of each candidate database instance on the hash ring;
  • the second hash calculation unit 1233 is used to perform hash calculation on the second key information of the blockchain data to obtain second position information of the blockchain data on the hash ring;
  • the target instance determination unit 1234 is configured to search for the first location information having the closest location relationship with the second location information along the storage direction on the hash ring based on the second location information, and determine the database instance corresponding to the found first location information as the first database instance;
  • the data storage unit 1235 is used to store the blockchain data in the first database instance.
  • the implementation methods 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 can refer to the description of step 603 in the embodiment of Figure 6 above, and will not be further described here.
  • blockchain data includes data to be processed
  • the access instruction generation module 124 is used to generate a data access instruction in response to a business data request for the data to be processed, and the data access instruction is used to access the data to be processed;
  • the data access module 125 is used to determine a second database instance from N database instances, and access the data to be processed from the second database instance based on the data access instruction and the data sharding strategy, and the data type of the second database instance matches the data to be processed.
  • N database instances are deployed in a remote database associated with a blockchain node;
  • the remote database includes host clusters corresponding to X data types;
  • X is a positive integer;
  • one data type corresponds to one host cluster;
  • the data access module 125 includes: a to-be-searched instance determination unit 1251 , a service instance determination unit 1252 , an access instruction forwarding unit 1253 , and a data receiving unit 1254 .
  • the to-be-searched instance determining unit 1251 is used to determine a target host cluster from the X host clusters, determine the database instance deployed in the target host cluster as the second database instance, and the data type of the target host cluster is the same as the data to be processed. Match;
  • the business instance determination unit 1252 is used to determine the business database instance to which the data to be processed belongs from the second database instance based on the data sharding strategy;
  • the access instruction forwarding unit 1253 is used to forward the data access instruction to a database agent that has a network connection relationship with the blockchain node, so that the database agent sends the data access instruction to the database host node where the business database instance is deployed;
  • the data receiving unit 1254 is used to receive the to-be-processed data returned by the database host node through the database agent.
  • the implementation methods of the to-be-searched instance determination unit 1251, the business instance determination unit 1252, the access instruction forwarding unit 1253 and the data receiving unit 1254 can refer to the description of step 1005 in the embodiment corresponding to the above-mentioned Figure 121, and will not be further elaborated here.
  • the operation execution module 126 is used to execute the data operation indicated by the business data request on the data to be processed.
  • the business data request includes a data archiving request; the data archiving request is used to archive 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 archiving condition acquisition unit 1261 and a data transfer unit 1262 .
  • the filing condition acquisition unit 1261 is used to acquire data information of the data to be processed and data filing conditions for the data to be processed; the data filing conditions include filing parameter thresholds; the filing parameter thresholds include at least one of a filing time range or a filing frequency threshold;
  • the data transfer unit 1262 is used to determine that the data to be processed meets the data archiving conditions when the data information indicates that the transaction timestamp of the data to be processed belongs to the archiving time range, or the access frequency of the data to be processed is less than the archiving frequency threshold, and transfer the data to be processed from the database to which the data to be processed belongs to the archiving database.
  • the implementation method of the archiving condition acquisition unit 1261 and the data transfer unit 1262 can refer to the description of step 1006 in the embodiment corresponding to the above-mentioned Figure 121, and will not be further elaborated here.
  • mapping table acquisition module 121 the data type matching module 122, the data storage module 123, the access instruction generation module 124, the data access module 125 and the operation execution module 126 can refer to the description of steps 1001 to 1006 in the embodiment of FIG. 10 above, which will not be described in detail here. In addition, the description of the beneficial effects of adopting the same method will not be described in detail.
  • the computer device 1300 can be a blockchain node in the blockchain network that needs to save the full amount of ledger data, for example, any blockchain node in the blockchain network shown in Figure 1 above, for example, the blockchain node is node 10a.
  • the computer device 1300 may include: at least one processor 1301, for example, a CPU, at least one network interface 1304, a user interface 1303, a memory 1305, and at least one communication bus 1302. Among them, the communication bus 1302 is used to realize the connection and communication between these components.
  • the user interface 1303 may include a display screen (Display), a keyboard (Keyboard), and the network interface 1304 may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface).
  • the memory 1305 may be a high-speed RAM memory, or it may be a non-volatile memory (non-volatile memory), such as at least one disk memory.
  • the memory 1305 may also be optionally at least one storage device located away from the aforementioned processor 1301.
  • the memory 1305 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a device control application program.
  • the network interface 1304 is mainly used for network communication;
  • the user interface 1303 is mainly used for providing an input interface for the user; and
  • the processor 1301 can be used to call the device control application stored in the memory 1305 to achieve:
  • a storage instance mapping table is obtained; the storage instance mapping table includes data mapping relationships of N database instances; the data mapping relationship indicates the data type of the database instance; N is a positive integer greater than 1;
  • M candidate database instances are determined from the N database instances, and the data types of the candidate database instances match the blockchain data; M is a positive integer less than or equal to N;
  • the blockchain data is stored in the first database instance among the M candidate database instances.
  • the computer device 1300 described in the embodiment of the present application can execute the description of the data processing method based on blockchain in the embodiments of Figures 6 and 13 above, and can also execute the description of the data processing device based on blockchain in the embodiment of Figure 12 above, which will not be repeated here. In addition, the description of the beneficial effects of using the same method will not be repeated.
  • An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program.
  • the computer program includes program instructions.
  • the program instructions are executed by a processor, the blockchain-based data processing method provided in each step of FIG. 6 and FIG. 10 is implemented. Please refer to the implementation methods provided in each step of FIG. 6 and FIG. 10, which will not be repeated here.
  • the computer-readable storage medium may be a data transmission device or an internal storage unit of a computer device provided in any of the aforementioned embodiments, such as a hard disk or memory of a computer device.
  • the computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (smart media card, SMC), a secure digital (secure digital, SD) card, a flash card (flash card), etc. equipped on the computer device.
  • the computer-readable storage medium may also include both an internal storage unit of the computer device and an external storage device.
  • the computer-readable storage medium is used to store the computer program and other programs and data required by the computer device.
  • the computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.
  • the present application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium.
  • the processor of the computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device can execute the description of the data processing method or device based on blockchain in the above embodiments, which will not be repeated here.
  • the description of the beneficial effects of using the same method will not be repeated.

Landscapes

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

Abstract

一种基于区块链的数据处理方法、装置、设备及介质,该方法由区块链节点执行,包括:基于区块链节点的数据库配置信息,获取存储实例映射表,存储实例映射表包括N个数据库实例的数据映射关系,数据映射关系指示数据库实例的数据类型,N为大于1的正整数(601);在获取到待存储的区块链数据的情况下,从N个数据库实例中,确定M个候选数据库实例,候选数据库实例的数据类型与区块链数据相匹配,M为小于或者等于N的正整数(602);基于数据库配置信息中的数据分片策略,将区块链数据存储至M个候选数据库实例中的第一数据库实例(603)。本申请能够提升区块链节点的存储能力,满足存储需求。

Description

一种基于区块链的数据处理方法、装置、设备及介质
本申请要求于2022年11月07日提交、申请号为202211383918.X、发明名称为“一种基于区块链的数据处理方法、装置、设备及介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及区块链技术领域,尤其涉及一种基于区块链的数据处理方法、装置、设备及介质。
背景技术
在传统区块链系统中,数据库实例用于存储区块链数据,区块链节点与数据库实例均部署在同一个设备上,且区块链节点与数据库实例为一一对应的关系,该数据库实例仅使用一个硬盘,区块链节点的数据通常是保存在单机的本地硬盘上,在区块链数据规模比较小时,这种单机存储方式短期来看还是可以满足存储需求,但是当区块链被应用在一些高频交易的场景时,区块链节点的存储能力将会受限于单个硬盘的容量,存储性能也受制于单个硬盘的读写速度,进而难以满足存储需求。
发明内容
本申请实施例提供一种基于区块链的数据处理方法、装置、设备及介质,所述技术方案包括如下内容。
本申请实施例一方面提供一种基于区块链的数据处理方法,包括:
基于区块链节点的数据库配置信息,获取存储实例映射表;所述存储实例映射表包括N个数据库实例的数据映射关系;所述数据映射关系指示所述数据库实例的数据类型;N为大于1的正整数;
在获取到待存储的区块链数据的情况下,从所述N个数据库实例中,确定M个候选数据库实例,所述候选数据库实例的数据类型与所述区块链数据相匹配;M为小于或者等于N的正整数;
基于所述数据库配置信息中的数据分片策略,将所述区块链数据存储至所述M个候选数据库实例中的第一数据库实例。
本申请实施例一方面提供一种基于区块链的数据处理装置,包括:
映射表获取模块,用于基于区块链节点的数据库配置信息,获取存储实例映射表;所述存储实例映射表包括N个数据库实例的数据映射关系;所述数据映射关系指示所述数据库实例的数据类型;N为大于1的正整数;
数据类型匹配模块,用于在获取到待存储的区块链数据的情况下,从所述N个数据库实例中,确定M个候选数据库实例,所述候选数据库实例的数据类型与所述区块链数据相匹配;M为小于或者等于N的正整数;
数据存储模块,用于基于数据库配置信息中的数据分片策略,将所述区块链数据存储至所述M个候选数据库实例中的第一数据库实例。
本申请实施例一方面提供了一种计算机设备,包括:处理器、存储器、网络接口;
处理器与存储器、网络接口相连,其中,网络接口用于提供数据通信功能,存储器用于存储计算机程序,处理器用于调用计算机程序,以使得计算机设备执行本申请实施例提供的基于区块链的数据处理方法。
本申请实施例一方面提供了一种计算机可读存储介质,计算机可读存储介质存储有计算 机程序,该计算机程序适于由处理器加载并执行,以使得具有该处理器的计算机设备执行本申请实施例提供的基于区块链的数据处理方法。
本申请实施例一方面提供了一种计算机程序产品,该计算机程序产品包括计算机程序,该计算机程序存储在计算机可读存储介质中;计算机设备的处理器从计算机可读存储介质读取该计算机程序,处理器执行该计算机程序,使得该计算机设备执行本申请实施例提供的基于区块链的数据处理方法。
在本申请实施例中,区块链节点基于区块链节点的数据库配置信息,获取存储实例映射表。其中,存储实例映射表包括N个数据库实例的数据映射关系;一个数据映射关系指示一个数据库实例的数据类型;N为大于1的正整数。本申请实施例中的区块链节点对应多个数据库实例,且这多个数据库实例与数据类型密切相关。当区块链节点获取到待存储的区块链数据时,从存储实例映射表所包括的N个数据库实例中,确定数据类型与区块链数据相匹配的M个候选数据库实例,进而基于数据库配置信息中的数据分片策略,将区块链数据存储至M个候选数据库实例中的第一数据库实例,其中,M为小于或者等于N的正整数。由此可见,本申请实施例提供的这种存储方式能够在一个区块链节点上按照业务需求部署多个数据库实例,极大程度地扩展存储容量,后续在根据区块链数据的数据类型,将区块链数据分片分类存储至对应的数据库实例时,能够将不同数据类型的区块链数据分别存储在不同的数据库实例上,极大程度地缓解了存储压力,从而实现分流效果,这意味着采用本申请实施例的存储方式时,区块链节点的存储容量及读写性能能够成倍增大,进而有效提升了区块链节点的节点存储能力,并满足存储需求。
附图说明
图1是本申请实施例提供的一种区块链节点系统的结构示意图;
图2是本申请实施例提供的一种针对单盘的存储扩展示意图;
图3是本申请实施例提供的一种针对多盘的存储扩展示意图;
图4是本申请实施例提供的一种分布式分类分库的存储扩展示意图;
图5是本申请实施例提供的一种进行数据存储的场景示意图;
图6是本申请实施例提供的一种基于区块链的数据处理方法的流程示意图;
图7是本申请实施例提供的一种用于获取存储实例映射表的流程示意图;
图8是本申请实施例提供的一种数据分库分类存储的结构示意图;
图9是本申请实施例提供的一种用于存储区块链数据的场景示意图;
图10是本申请实施例提供的一种基于区块链的数据处理方法的流程示意图;
图11是本申请实施例提供的一种用于访问待处理数据的流程示意图;
图12是本申请实施例提供的一种基于区块链的数据处理装置的结构示意图;
图13是本申请实施例提供的一种计算机设备的示意图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
请参见图1,图1是本申请实施例提供的一种区块链节点系统的结构示意图。如图1所示,本申请实施例中的区块链节点系统是由多个区块链节点通过网络通信的形式连接形成的分布式系统。该区块链系统对应的区块链网络是一种点对点的对等网络(Peer to peer networking,简称P2P网络),即是一种在用户之间分配任务和工作负载的分布式应用架构,是对等计算模型在应用层形成的一种组网或网络形式。
其中,图1所示的区块链系统中包括多个区块链节点,多个区块链节点包括节点10a、节 点10b、节点10c、…、节点10n。其中,该区块链系统中的区块链节点为接入该区块链网络中的任意形式的计算机设备,比如,该计算机设备为接入该区块链网络中的终端设备,或者为接入该区块链网络中的服务器,这里对区块链节点的具体形式不做限定。
可选地,接入到该区块链网络中的服务器是独立的物理服务器,或者是多个物理服务器构成的服务器集群或者分布式系统,或者是提供云计算服务的云服务器。接入到该区块链网络中的终端设备包括:智能手机、平板电脑、笔记本电脑、台式计算机、智能音箱、智能手表、车载终端、智能电视等智能终端。其中,本申请实施例中的终端设备运行的应用客户端为独立的客户端,或者为集成在某客户端(例如,社交客户端、教育客户端以及多媒体客户端等)中的嵌入式子客户端,在此不做限定。
在图1所示的区块链网络中包含比多个参与方,比如,需要保存全量账本数据的区块链节点(例如,共识节点或全量节点)以及保存部分账本数据的区块链节点(例如,轻节点)。其中,轻节点用于存储区块链数据库的一部分,即存储区块头数据和与自身节点相关联的交易数据,而不存储完整交易数据。为了应对海量存储、高性能的场景,本申请实施例针对需要存储全量账本数据的这类区块链节点,提出了一种分类/分库/分片的存储方式。
对于区块链网络中的任意一个区块链节点的数据库而言,均包括主数据库和归档数据库。其中,主数据库是指区块链节点当前正在使用的数据库,主数据库包括部署在区块链节点本地的数据库(例如,图1所示的节点10a的本地数据库110)和部署在与区块链节点具有网络连接关系的远程存储的数据库(例如,图1所示的节点10a的远程数据库120)。归档数据库是指用于对区块链数据进行批量处理的独立的数据库,批量处理包括批量转移或批量删除等。
可选地,每个区块链节点包括区块链账本模块、数据库服务组件以及其他区块链模块。其中,区块链账本模块用于提供账目数据的存储、查询、修改和删除等操作的功能,将对账目数据的操作的记录数据发送到区块链系统中的其他节点,其他节点验证有效后,作为承认账目数据有效的响应,将记录数据存入临时区块中,还能够向发起操作的节点发送确认。数据库服务组件用于对区块链节点的远程数据库提供数据库服务,例如,基于数据库服务在远程数据库中存储或访问区块链数据,数据库服务组件又称为数据库服务SDK(Software Development Kit,软件开发工具包)。
可选地,其他区块链模块包括对象管理、基础服务、智能合约以及运营检测等处理模块。应当理解,对象管理模块负责所有区块链参与者的身份信息管理,包括维护公私钥生成(账户管理)、密钥管理以及对象真实身份和区块链地址对应关系维护(权限管理)等,并且在授权的情况下,监管和审计真实身份的交易情况,提供风险控制的规则配置(风控审计);基础服务模块部署在所有区块链节点设备上,用来验证业务数据请求的有效性,并对有效请求完成共识后记录到存储上,对于一个新的业务数据请求,基础服务先对接口适配解析和鉴权处理(接口适配),然后通过共识算法将业务信息加密(共识管理),在加密之后完整一致的传输至共享账本上(网络通信),并进行记录存储;智能合约模块负责合约的注册发行以及合约触发和合约执行,开发对象通过某种编程语言定义合约逻辑,发布到区块链上(合约注册),根据合约条款的逻辑,调用密钥或者其它的事件触发执行,完成合约逻辑,同时还提供对合约升级注销的功能;运营检测模块主要负责产品发布过程中的部署、配置的修改、合约设置、云适配以及产品运行中的实时状态的可视化输出,例如:告警、检测网络情况、检测节点设备健康状态等。
可选地,为了满足业务存储需求,本申请实施例中的区块链节点部署一个或多个硬盘,且每个硬盘均部署多个数据库实例。为便于理解,进一步地,请参见图2,图2是本申请实施例提供的一种针对单盘的存储扩展示意图。如图2所示,本申请实施例中的区块链节点为在主机(即除去输入输出设备以外的主要机体部分)中部署有单个硬盘的区块链节点,该区块链节点为上述图1所示的区块链网络中的任意一个区块链节点,例如,该区块链节点为节点10a。其中,该区块链节点能够部署一个硬盘,例如,图2所示的硬盘A。
当单个数据库实例的读写速度满足不了区块链节点的业务读写需求时,且数据库实例的 读写速度还未达到硬盘读写性能的上限时,为了充分利用硬盘的读写资源,本申请实施例基于该硬盘A的存储性能,在单个硬盘中部署多个数据库实例,这里以3个为例,包括数据库实例D1、数据库实例D2以及数据库实例D3。其中,硬盘A的存储性能是由硬盘A的存储容量和读写性能所共同决定的。
进一步地,请参见图3,图3是本申请实施例提供的一种针对多盘的存储扩展示意图。如图3所示,本申请实施例中的区块链节点为在主机中部署有多个硬盘的区块链节点,该区块链节点为上述图1所示的区块链网络中的任意一个区块链节点,例如,该区块链节点为节点10a。由于不同硬盘的存储性能可能存在差异,因此每个硬盘所部署的数据库实例的实例数量将会根据硬盘自身的存储性能存在不同。
如图3所示,该区块链节点所部署的多个硬盘以2个为例,包括硬盘A和硬盘B,且硬盘B的存储性能高于硬盘A。基于此,在上述图2所示的存储扩展方案仍然满足不了区块链节点的业务需求时,本申请实施例能够部署更多的数据库实例,并使它们分布在不同的硬盘上,从而实现分流效果,使得存储容量和读写性能均能实现成倍增长。
比如,本申请实施例基于硬盘A的存储性能,在硬盘A中部署多个数据库实例,这里以3个为例,包括数据库实例D1、数据库实例D2以及数据库实例D3。同理,本申请实施例还基于硬盘B的存储性能,在硬盘B中部署多个数据库实例,这里以4个为例,包括数据库实例D4、数据库实例D5、数据库实例D6以及数据库实例D7
进一步地,请参见图4,图4是本申请实施例提供的一种分布式分类分库的存储扩展示意图。如图4所示,本申请实施例中的区块链节点为上述图1所示的区块链网络中的任意一个区块链节点,例如,该区块链节点为节点10a。在区块链节点的单个机器的存储性能难以满足业务需求时,本申请实施例进行分布式存储扩展,即通过数据库代理进行存储。可选地,数据库代理与区块链节点部署在同一个计算机设备上,或者与区块链节点部署在不同的计算机设备上,这里将不对数据库代理的部署方式进行限定。
在与该区块链节点相关联的远程数据库中,本申请实施例根据区块链节点所接收的区块链数据的X个数据类型,为每个数据类型分别部署对应的主机集群。X为正整数。在本申请实施例中,N个数据库实例均部署在与区块链节点相关联的远程数据库中,远程数据库包括与X个数据类型分别对应的主机集群,一个数据类型对应一个主机集群,且每个主机集群均包括多个数据库主机节点。
如图4所示,本申请实施例中的数据类型以3个为例,包括第一数据类型、第二数据类型和第三数据类型。其中,第一数据类型是指频繁被访问的小额数据对应的数据类型,例如,第一数据类型包括区块头数据类型和状态数据类型等,区块头数据类型是指区块头数据所属的数据类型,状态数据类型是指状态数据所属的数据类型。其中,状态数据包括企业对象的风险状态、电子票据的票据状态、业务对象的资产状态等。该第一数据类型对应的主机集群为图4所示的主机集群1,该主机集群1包括多个主机,比如,包括主机J11、主机J12、…、以及主机J1N。其中,主机集群1中的每个主机均部署多个硬盘,例如,主机J11部署硬盘A和硬盘B这两个硬盘,且每个硬盘均部署多个数据库实例。
第二数据类型是指一种需要独立存储的区块链数据的数据类型,例如,第二数据类型包括交易数据类型,交易数据类型是指交易数据所属的数据类型。其中,交易数据相当于流水,在某些场景下,交易流水并不需要保存过长时间,因此需要将其存储至独立的数据库实例中,有利于后续将数据归档或定期删除。该第二数据类型对应的主机集群为图4所示的主机集群2,该主机集群2包括多个主机,比如,包括主机J21、主机J22、…、以及主机J2N。其中,主机集群2中的每个主机均部署多个硬盘,例如,主机J21部署硬盘C和硬盘D这两个硬盘,且每个硬盘均部署多个数据库实例。
第三数据类型是指另一种需要独立存储的区块链数据对应的数据类型,例如,第三数据类型包括合约数据类型,合约数据类型是指合约数据所属的数据类型。其中,合约数据是指真实的业务数据,将其独立存储到多个数据库实例中,能够使得单个数据库的数据量变少, 这样能够有效提升数据库的读写性能,从而提升区块链节点的存储性能。该第三数据类型对应的主机集群为图4所示的主机集群3,该主机集群3包括多个主机,比如,包括主机J31、主机J32、…、以及主机J3N。其中,主机集群3中的每个主机均部署多个硬盘,例如,主机J21部署硬盘E和硬盘F这两个硬盘,且每个硬盘均部署多个数据库实例。
为便于理解,进一步地,请参见图5,图5是本申请实施例提供的一种数据存储的场景示意图。如图5所示,本申请实施例中的区块链节点为区块链网络中需要保存全量账本数据的区块链节点,例如,该区块链节点为上述图1所示的区块链网络中的任意一个区块链节点,例如,该区块链节点为节点10a。
应当理解,本申请实施例将需要存储的区块链数据分为X个数据类型,以便于将区块链数据按照数据类型分库存储,提升节点存储性能。其中,X为正整数。为便于阐述,本申请实施例中的数据类型的数量以3个为例,包括数据类型21、数据类型22以及数据类型23。
在启动区块链节点时,该区块链节点基于区块链节点的数据库配置信息,获取存储实例映射表。其中,在该区块链节点属于首次启动的节点的情况下,则该区块链节点基于数据库配置信息,生成存储实例映射表。在该区块链节点属于非首次启动的节点的情况下,则该区块链节点基于数据库配置信息,直接加载已生成的存储实例映射表。
存储实例映射表包括N个数据库实例的数据映射关系,一个数据映射关系指示一个数据库实例的数据类型,N为大于1的正整数。可选地,N个数据库实例按照区块链节点的业务需求进行部署,即均部署在区块链节点的本地数据库(例如,上述图2所示的部署方式),或者均部署在区块链节点的远程数据库(例如,上述图4所示的部署方式),或者在本地数据库和远程数据库中均有部署,这里将不对其进行限定。
进一步地,请参见表1,表1是本申请实施例提供的一种存储实例映射表。其中,表1所示的存储实例映射表中包括N个数据库实例的数据映射关系,以N等于6为例,则N个数据库实例包括数据库实例D1、数据库实例D2、数据库实例D3、数据库实例D4、数据库实例D5以及数据库实例D6。在本申请实施例中,不同数据类型的数据库实例可以部署在同一个硬盘中,也可以部署在不同硬盘中,比如,数据类型21、数据类型22以及数据类型23对应的数据库实例可以部署在同一个硬盘(例如,图2所示的硬盘A)中所创建的。可选的,数据类型21和数据类型22对应的数据库实例均可以部署在同一个硬盘(例如,图3所示的硬盘A),而数据类型23对应的数据库实例均可以部署在另一个硬盘(例如,图3所示的硬盘B)中。如表1所示:
表1
其中,数据库实例D1的数据映射关系指示数据库实例D1的数据类型为数据类型21;数据库实例D2的数据映射关系指示数据库实例D2的数据类型为数据类型22;数据库实例D3的数据映射关系指示数据库实例D3的数据类型为数据类型22;数据库实例D4的数据映射关系指示数据库实例D4的数据类型为数据类型23;数据库实例D5的数据映射关系指示数据库实例D5的数据类型为数据类型23;数据库实例D6的数据映射关系指示数据库实例D6的数据类型为数据类型23。
在本申请实施例中,由于不同数据类型的区块链数据的数据量、访问频次存在不同,因此,不同数据类型的区块链数据所占据的存储容量也会存在不同,进而导致为不同数据类型所部署的数据库实例的实例数量不同。
应当理解,在获取到待存储的区块链数据的情况下,则该区块链节点需要从上述表1所示的存储实例映射表所包括的N个数据库实例中,确定M个候选数据库实例,候选数据库实例的数据类型与区块链数据相匹配,M为小于或者等于N的正整数。如图5所示,当该区块链节点获取到需要存储的区块链数据Q时,可以确定区块链数据Q的数据类型。若该区块链数据Q的数据类型属于数据类型22,则该区块链节点从上述表1所示的存储实施例映射表中,将数据类型22对应的数据库实例(例如,数据库实例D2和数据库实例D3)均确定为与该区块链数据Q相匹配的数据库实例。
进一步地,该区块链节点基于数据库配置信息中的数据分片策略,确定该区块链数据Q所需存储的数据库实例(即第一数据库实例,例如,数据库实例D3),并将其存储至数据库实例D3中。
由此可见,一个区块链节点根据业务需求部署N个数据库实例,这意味着能够提升区块链节点的存储容量,且对于任意一种数据类型的区块链数据而言,均可以按照区块链数据Q存储至第一数据库实例的实施方式,存储至对应的数据库实例中,即不同数据类型的区块链数据可以分别存储至不同的数据库实例上,极大程度地缓解了存储压力,从而实现分流效果。这不仅解决了区块链节点的数据读写性能不足的问题,还解决了单机存储空间受限的问题,甚至通过按照数据类型和数据分片策略这种精细化的合约存储管理,也为区块链在大数据量的存储场景落地提供了可能。
其中,部署N个数据库实例的区块链网络中的区块链节点,对待存储的区块链数据进行分类分库分片存储的实现方式可以参见下述图6-图11的实施例。
进一步地,请参见图6,图6是本申请实施例提供的一种基于区块链的数据处理方法的流程示意图。如图6所示,该方法由计算机设备执行,该计算机设备为区块链网络中的区块链节点,该区块链节点为区块链网络中需要保存全量账本数据的区块链节点,例如,该区块链节点为上述图1所示的区块链网络中的任意一个区块链节点,例如,该区块链节点为节点10a。该方法至少可以包括以下步骤601-步骤603:
步骤601,区块链节点基于区块链节点的数据库配置信息,获取存储实例映射表,存储实例映射表包括N个数据库实例的数据映射关系,数据映射关系指示数据库实例的数据类型,N为大于1的正整数。
其中,存储实例映射表包括N个数据库实例的数据映射关系;一个数据映射关系指示一个数据库实例的数据类型;N为大于1的正整数。可选地,业务对象(例如,用户)针对区块链节点执行启动操作,进而在该区块链节点响应该启动操作时,基于该区块链节点的数据库配置信息,来获取该区块链节点的存储实例映射表。其中,启动操作是指用于启动区块链节点的触发操作,该触发操作包括点击、长按等接触性操作,或者包括语音、手势等非接触性操作,这里将不对其进行限定。
可选地,在启动操作指示首次启动区块链节点的情况下,该区块链节点需要进行初始化处理,即加载区块链节点的数据库配置信息,基于数据库配置信息以及区块链节点的主数据库的数据库类型,创建N个数据库实例。在初始化成功后,该区块链节点建立每个数据库实例与每个数据库实例所属硬盘的数据类型之间的映射关系,基于建立的映射关系,生成存储实例映射表。
其中,数据库配置信息是指配置对象(例如,区块链节点的配置用户)基于业务存储需求,为该区块链节点所配置的与区块链节点的数据库相关联的信息。比如,该数据库配置信息包括数据库存储路径、该区块链节点的硬盘所配置的实例数量以及数据分片策略等。其中,数据存储路径包括配置对象针对不同数据类型的区块链数据所配置的多条存储路径。实例数量是基于区块链节点所部署的硬盘的存储性能所确定的;数据分片策略是指区块链节点存储区块链数据时所采用的计算方式,例如,一致性哈希算法。
比如,在配置对象确定区块链数据的数据类型包括X个数据类型(X为正整数)时,为了提升区块链节点的节点性能,该配置对象为每个数据类型配置不同的数据库实例,以将各 类区块链数据存入到不同的数据库实例中。当然,同一类数据也可以存入多个数据库实例,且数据库实例对应的硬盘可以部署在区块链节点的本地数据库,也可以部署在区块链节点的远程数据库,这里将不对其进行限定。
可选地,区块链节点的本地数据库和远程数据库均可以部署一个或多个硬盘,本申请实施例中的数据库配置信息中的数据库存储路径指示与X个数据类型相关联的硬盘集合,即包括各类数据类型分别对应的存储路径。
比如,这里X个数据类型包括第一数据类型、第二数据类型或第三数据类型中的至少一项。第一数据类型包括区块头数据类型或状态数据类型中的至少一项;第二数据类型包括交易数据类型;第三数据类型包括合约数据类型。其中,由于第一数据类型的区块链数据的读写频率较高,且数据量较小,因此,配置对象在为第一数据类型配置数据库实例时,选用存储量相对较小,存储性能稍弱的机器(即硬盘),以在满足业务需求的同时极大程度的节约成本。第一数据类型的硬盘的存储性能低于第二数据类型的硬盘的存储性能,也低于第三数据类型的硬盘的存储性能。
进一步地,请参见表2,表2是本申请实施例提供的一种与数据库配置信息相关联的伪代码示意表。为便于阐述,本申请实施例中的区块链节点所部署的与X个数据类型相关联的硬盘集合以4个为例,包括本地数据库中所部署的硬盘A(例如,data1)、硬盘B(例如,data2)以及硬盘D(例如,data4),以及远程数据库所部署的硬盘C(例如,data3)。
其中,该远程数据库对应的计算机设备可以用端点:端口这一数据格式进行表示。如表2所示:
表2
如表2所示,在本地数据库的硬盘A的存储性能均低于其他硬盘的存储性能,则在第一 数据类型为区块头数据类型时,该数据库配置信息中第一数据类型对应的存储路径为“/data1/blockHeader”目录。在第二数据类型为交易数据类型时,该数据库配置信息中第二数据类型对应的存储路径包括本地数据库中的“/data1/transaction,/data2/transaction”目录和远程数据库中的“/data3/transaction”目录,这意味着配置对象为交易数据类型配置三个存储位置。在第三数据类型为合约数据类型时,该数据库配置信息中第三数据类型对应的存储路径包括本地数据库中的“/data4/contract”目录。当同一个目录中部署有多个数据库实例时,数据库实例的根目录分别为目标前缀加实例序号。比如,若硬盘A中部署有多个数据库实例时,这是交易数据类型对应的存储路径为“/data1/transaction/1,/data1/transaction/2,/data1/transaction/3”。
为便于理解,进一步地,请参见图7,图7是本申请实施例提供的一种用于获取存储实例映射表的流程示意图。如图7所示,本申请实施例中的区块链节点为上述图1所示的区块链网络中的任意一个区块链节点,例如,该区块链节点为节点10a。
在针对区块链节点所执行的启动操作指示首次启动区块链节点的情况下,则区块链节点在执行步骤701,启动区块链节点后,进而执行步骤702,以加载数据库配置信息。进一步地,该区块链节点可以获取区块链节点的主数据库的数据库类型,从而决定是根据区块链上的智能合约自动执行步骤703-步骤704,以创建数据库实例,还是根据区块链节点的配置对象手动创建数据库实例。
主数据的数据库类型包括第一类型(例如,可根据智能合约自动创建数据库实例的类型)和第二类型(例如,需人工手动创建数据库实例的类型)。
在区块链节点的数据库类型属于第一类型的情况下,则该区块链节点从区块链节点所属的区块链上,获取智能合约,智能合约用于创建数据库实例。其中,智能合约是指计算机化的协议,能够执行合约条款,通过部署在共享账本上的代码实现,代码用于在满足一定条件时而执行,根据实际的业务需求代码完成自动化的交易。进一步地,该区块链节点基于智能合约,分别为硬盘集合中的每个硬盘创建数据库实例,得到N个数据库实例。可选地,该区块链节点对于硬盘集合中的每个硬盘,基于数据库配置信息确定每个硬盘的实例数量。
进一步地,该区块链节点执行步骤703确定待创建硬盘是否部署在本地数据库。可选地,在硬盘部署在主数据库中的本地数据库的情况下,则该区块链节点执行步骤704,基于智能合约,为硬盘创建与实例数量相符合的数据库实例。可选地,在硬盘部署在主数据库中的远程数据库的情况下,则该区块链节点调用数据库服务组件,基于智能合约,为硬盘创建与实例数量相符合的数据库实例,数据库服务组件用于提供远程数据库服务。即该区块链节点跳转执行步骤707-步骤709,调用数据库服务组件,基于该数据库服务组件所提供的远程数据库服务,创建与实例数量相符合的数据库实例,且在创建完成时该数据库服务组件接收数据库实例响应。
可选地,在区块链节点的数据库类型属于第二类型的情况下,则区块链节点显示与数据库配置信息相关联的提示信息,以使配置对象基于提示信息执行触发操作。其中,提示信息可以为图片、视频、音频、文字等类型对应的信息,这里将不对提示信息的信息类型进行限定。区块链节点响应于针对提示信息的触发操作,分别为硬盘集合中的每个硬盘创建数据库实例,得到N个数据库实例。
在本地数据库与远程数据库均创建完成时,该区块链节点执行步骤705,建立每个数据库实例与每个数据库实例所属硬盘的数据类型之间的映射关系,进而基于建立的映射关系,生成存储实例映射表,以便后续执行步骤706,为区块链节点提供数据服务(例如,数据访问服务等)。
为便于理解,进一步地,请参见图8,图8是本申请实施例提供的一种数据分库分类存储的结构示意图。如图8所示,本申请实施例的区块链节点为在主机中部署有多个硬盘的区块链节点,该区块链节点为上述图1所示的区块链网络中的任意一个区块链节点,例如,该区块链节点为节点10a。
图8所示的区块链节点在响应启动操作后,加载数据库配置信息。其中,数据库配置信息中的存储路径信息指示与三个数据类型(例如,区块头数据类型、交易数据类型以及合约数据类型)相关联的硬盘集合,该硬盘集合包括根据业务需求部署在本地的硬盘A和硬盘B。
区块链节点可以根据主数据库的数据库类型(例如,第一类型)以及数据库配置信息,为主数据库创建数据库实例。其中,该数据库配置信息的存储路径指示每个硬盘中不同数据类型的实例数量。比如,在硬盘A中区块头数据类型的实例数量(即第一实例数量)为1,在硬盘A中交易数据类型的实例数据(即第二实例数量)为2,在硬盘B中合约数据类型的实例数量(即第三实例数量)为3。
以硬盘A为例,该区块链节点基于数据库配置信息,确定硬盘A的实例数量为第一实例数量和第二实例数量之和(即3),这时,该区块链节点基于智能合约,为硬盘A创建3个数据库实例,包括数据库实例D1、数据库实例D2以及数据库实例D3
同理,以硬盘B为例,该区块链节点基于数据库配置信息,确定硬盘B的实例数量为第三实例数量(即3),这时,该区块链节点基于智能合约,为硬盘B创建3个数据库实例,包括数据库实例D4、数据库实例D5以及数据库实例D6
进一步地,该区块链节点建立这6个数据库实例中的每个数据库实例与自身所属硬盘的数据类型之间的映射关系,进而基于建立的映射关系,生成上述表1所示的存储实例映射表。可选地,存储实例映射表的存储方式为键值存储,即Key-Value存储,简称KV存储。即该区块链节点将Key确定为数据类型,将Value确定为数据库实例。
其中,本申请实施例中的存储实例映射表可以为上述表1所示的包括X个数据类型的一个独立的映射表,也可以为由X个存储实例子映射表所组成的一个映射表,这里将不对其进行限定。比如,在区块链节点的存储扩展方式为上述图4所示的存储扩展方式时,该区块链节点分别为每个数据类型建立存储实例子映射表,以便于后续在通过数据库代理,从X个主机集群中能够快速确定需要访问的主机集群,从而提升访问效率。
步骤602,区块链节点在获取到待存储的区块链数据的情况下,从N个数据库实例中,确定M个候选数据库实例,候选数据库实例的数据类型与区块链数据相匹配,M为小于或者等于N的正整数。
可选地,在获取到待存储的区块链数据的情况下,该区块链节点确定区块链数据的数据信息,进而基于区块链数据的数据信息,确定区块链数据的数据类型。进一步地,该区块链节点从存储实例映射表中,查找与区块链数据的数据类型相匹配的数据类型,将查找到的数据类型对应的数据库实例确定为候选数据库实例,从而得到M个候选数据库实例。
可选地,数据库配置信息包括根据业务需求所配置的数据量阈值和访问频次阈值。在数据信息指示区块链的数据量未达到数据量阈值,且区块链数据的数据访问频次达到访问频次阈值的情况下,则认为该区块链数据属于被频繁访问的小额数据,此时,该区块链节点将第一数据类型确定为区块链数据的数据类型。可选地,在数据信息指示区块链数据属于交易数据的情况下,则该区块链节点将第二数据类型确定为区块链数据的数据类型,例如交易数据包括资产转移交易数据或电子票据流转交易等。可选地,在数据信息指示区块链数据属于合约数据的情况下,则该区块链节点将第三数据类型确定为区块链数据的数据类型。当然,本申请实施例中的X个数据类型还可以包括其他数据类型,这里将不再对其进行一一举例。
如图5所示,当该区块链节点获取到需要存储的区块链数据Q时,确定区块链数据Q的数据类型。若该区块链数据Q的数据类型属于数据类型22,则该区块链节点从上述表1所示的存储实施例映射表中,将数据类型22对应的数据库实例(例如,数据库实例D2和数据库实例D3)均确定为与该区块链数据Q相匹配的两个候选数据库实例。
步骤603,区块链节点基于数据库配置信息中的数据分片策略,将区块链数据存储至M个候选数据库实例中的第一数据库实例。
可选地,该区块链节点基于数据库配置信息中的数据分片策略,将哈希值空间按照存储方向,生成与区块链数据的数据类型相关联的哈希环。进一步地,该区块链节点对M个候选 数据库实例中的每个候选数据库实例的第一关键信息(例如,地址、目录等输入信息)进行哈希计算,得到每个候选数据库实例在哈希环上的第一位置信息,同理,该区块链节点还可以对区块链数据的第二关键信息(例如,数据哈希值)进行哈希计算,得到区块链数据在哈希环上的第二位置信息。进一步地,该区块链节点在哈希环上沿着存储方向,查找与第二位置信息具有最近位置关系的第一位置信息,将查找到的第一位置信息对应的数据库实例确定为第一数据库实例,进而将区块链数据存储至第一数据库实例。
其中,由于本申请实施例涉及X个数据类型,因此,在将这X个数据类型的区块链数据分库进行存储时,这意味着本申请实施例涉及X组数据库实例,且一组数据库实例对应一个哈希环,即本申请实施例涉及X个哈希环。在数据类型包括区块头数据类型、交易数据类型和合约数据类型时,本申请实施例将涉及三个哈希环,且这三个哈希环分别对应这三种数据类型的数据库映射关系。
为便于理解,进一步地,请参见图9,图9是本申请实施例提供的一种用于存储区块链数据的场景示意图。如图9所示,本申请实施例中的哈希环为待存储的区块链数据的数据类型对应的哈希环,该哈希环是基于数据库配置信息中的数据分片策略(例如,一致性哈希算法),将哈希值空间按照存储方向(例如,顺时针方向)所生成的。其中,哈希值空间是指一个从0到(2^32)-1的数字空间中。
可选地,该区块链节点从存储实例映射表中所确定的候选数据库实例以4个为例,包括图9所示的数据库实例D1、数据库实例D2、数据库实例D3以及数据库实例D4。该区块链节点对这4个数据库实例中的每个数据库实例的第一关键信息进行哈希计算,得到每个数据库实例在哈希环上的第一位置信息。
其中,该区块链节点所获取到的待存储的区块链数据包括图9所示的区块链数据Q61、区块链数据Q62、区块链数据Q63、区块链数据Q64、区块链数据Q65以及区块链数据Q66。比如,对于数据库实例D1而言,该区块链节点获取将该数据库实例D1的目录信息、设备信息(例如,设备标识等)等确定为该数据库实例D1的第一关键信息。进一步地,该区块链节点按照一致性哈希算法对数据库实例D1的第一关键信息进行哈希计算,从而得到数据库实例D1的哈希值,将该数据库实例D1的哈希值映射在哈希环上,得到该数据库实例D1在哈希环上的第一位置信息。
进一步地,该区块链节点对区块链数据的第二关键信息进行哈希计算,得到区块链数据在哈希环上的第二位置信息。比如,对于区块链数据Q61而言,该区块链节点需要根据该区块链数据Q61的数据类型,确定该区块链数据Q61的第二关键信息。进一步地,该区块链节点按照一致性哈希算法对区块链数据Q61的第二关键信息进行哈希计算,从而得到区块链数据Q61的哈希值,将该区块链数据Q61的哈希值映射在哈希环上,得到该区块链数据Q61在哈希环上的第二位置信息。
其中,在该区块链数据Q61的数据类型为区块头数据类型的情况下,则该区块链节点将区块链数据Q61的区块头哈希值作为该区块链数据Q61的第二关键信息。可选地,在该区块链数据Q61的数据类型为交易数据类型的情况下,则该区块链节点将区块链数据Q61的交易哈希值作为该区块链数据Q61的第二关键信息。可选地,在该区块链数据Q61的数据类型为合约数据类型的情况下,则该区块链节点将区块链数据Q61的合约哈希值作为该区块链数据Q61的第二关键信息。
进一步地,该区块链节点基于区块链数据的第二位置信息,在哈希环上沿着存储方向,查找与第二位置信息具有最近位置关系的第一位置信息,且将查找到的第一位置信息对应的数据库实例确定为第一数据库实例,将区块链数据存储至第一数据库实例。
比如,对于区块链数据Q61而言,该区块链节点基于区块链数据Q61的第二位置信息,在哈希环上沿着顺时针这一存储方向,查找与第二位置信息具有最近位置关系的第一位置信息,且将查找到的第一位置信息对应的数据库实例(例如,图9所示的数据库实例D1)确定为第一数据库实例,进而将区块链数据存储至第一数据库实例。
以此类推,该区块链节点参见区块链数据Q61的存储方式,将区块链数据Q62存储至数据库实例D1,将区块链数据Q63存储至数据库实例D2,将区块链数据Q64、区块链数据Q65以及区块链数据Q66存储至数据库实例D3,将区块链数据Q67存储至数据库实例D4
由此可见,本申请实施例提供的这种存储方式能够在一个区块链节点上按照业务需求部署多个数据库实例,极大程度地扩展存储容量,后续在根据区块链数据的数据类型,将区块链数据分片分类存储至对应的数据库实例时,能够将不同数据类型的区块链数据分别存储在不同的数据库实例上,极大程度地缓解了存储压力,从而实现分流效果,这意味着采用本申请实施例的存储方式时,区块链节点的存储容量及读写性能能够成倍增大,进而有效提升了区块链节点的节点存储能力,并满足存储需求。
进一步地,请参见图10,图10是本申请实施例提供的一种基于区块链的数据处理方法的流程示意图。如图10所示,该方法由计算机设备执行,该计算机设备为区块链网络中的区块链节点,该区块链节点为区块链网络中需要保存全量账本数据的区块链节点,例如,该区块链节点为上述图1所示的区块链网络中的任意一个区块链节点,例如,该区块链节点为节点10a。该方法至少可以包括以下步骤1001-步骤1006:
步骤1001,区块链节点基于区块链节点的数据库配置信息,获取存储实例映射表。
其中,存储实例映射表包括N个数据库实例的数据映射关系;一个数据映射关系指示一个数据库实例的数据类型;N为大于1的正整数。可选地,业务对象(例如,用户)针对区块链节点执行启动操作,在该区块链节点响应该启动操作时,基于区块链节点的数据库配置信息,来获取该区块链节点的存储实例映射表。其中,启动操作是指用于启动区块链节点的触发操作,该触发操作包括点击、长按等接触性操作,或者包括语音、手势等非接触性操作,这里将不对其进行限定。
步骤1002,区块链节点在获取到待存储的区块链数据的情况下,从存储实例映射表中的N个数据库实例中,确定M个候选数据库实例,候选数据库实例的数据类型与区块链数据相匹配。
其中,M为小于或者等于N的正整数。可选地,在获取到待存储的区块链数据的情况下,则该区块链节点确定区块链数据的数据信息,基于区块链数据的数据信息,确定区块链数据的数据类型。进一步地,该区块链节点从存储实例映射表中,查找与区块链数据的数据类型相匹配的数据类型,将查找到的数据类型所对应的数据库实例确定为候选数据库实例,从而得到M个候选数据库实例。
步骤1003,区块链节点基于数据库配置信息中的数据分片策略,将区块链数据存储至M个候选数据库实例中的第一数据库实例。
可选地,该区块链节点基于数据库配置信息中的数据分片策略,将哈希值空间按照存储方向,生成与区块链数据的数据类型相关联的哈希环。进一步地,该区块链节点对M个候选数据库实例中的每个候选数据库实例的第一关键信息(例如,地址、目录等输入信息)进行哈希计算,得到每个数据库实例在哈希环上的第一位置信息,同理,该区块链节点对区块链数据的第二关键信息(例如,数据哈希值)进行哈希计算,得到区块链数据在哈希环上的第二位置信息。进一步地,该区块链节点在哈希环上沿着存储方向,查找与第二位置信息具有最近位置关系的第一位置信息,将查找到的第一位置信息所对应的数据库实例确定为第一数据库实例,将区块链数据存储至第一数据库实例。
其中,该步骤1001-步骤1003的实施方式可参见上述图6的实施例中对步骤601-步骤603的描述,这里将不再赘述。
可选地,区块链数据包括待处理数据。
步骤1004,区块链节点响应于针对待处理数据的业务数据请求,生成数据访问指令,数据访问指令用于访问待处理数据。
其中,业务数据请求为该区块链节点基于待处理数据的数据类型所生成的,也可以为与该区块链节点具有网络连接关系的其他计算机设备(例如,区块链网络中的另一区块链节点 或业务对象对应的终端设备)所发送的,这里将不对业务数据请求的来源进行限定。
若该业务数据请求为与区块链节点具有网络连接关系的其他计算机设备所发送的,则为了有效提升数据传输时的安全性,该计算机设备获取区块链节点的节点公钥,对待处理数据的数据类型等数据信息进行加密处理,以得到数据加密信息,进而可以基于该数据加密信息生成用于发送至区块链节点的业务数据请求。该区块链节点在接收到该业务数据请求时,先对计算机设备进行合法性校验(例如,是否属于非法名单中的计算机设备),在校验计算机设备具备合法性时,基于区块链节点的节点私钥,对数据加密信息进行解密处理,从而获取待处理数据的数据类型等数据信息,进而基于这些数据信息生成用于访问待处理数据的数据访问指令。
步骤1005,区块链节点从存储实例映射表中的N个数据库实例中,确定第二数据库实例,基于数据访问指令以及数据库配置信息中的数据分片策略,从第二数据库实例中访问待处理数据,第二数据库实例的数据类型与待处理数据相匹配。
可选地,该区块链节点参见上述步骤602所对应的实施方式,从存储实例映射表所包括的N个数据库实例中,确定第二数据库实例,进而按照上述图9所示的存储方式,基于数据库配置信息中的数据分片策略,从第二数据库实例中确定待处理数据所属的业务数据库实例,以从该业务数据库实例中访问待处理数据。
可选地,N个数据库实例均部署在与区块链节点相关联的远程数据库;远程数据库包括与X个数据类型对应的主机集群;X为正整数;一个数据类型对应一个主机集群。那么,该区块链节点在执行访问待处理数据时,从X个主机集群中确定目标主机集群,目标主机集群的数据类型与待处理数据相匹配。可选地,业务数据请求携带待处理数据的数据类型,目标主机集群的数据类型与待处理数据相匹配是指目标主机集群的数据类型与待处理数据的数据类型相匹配。区块链节点将目标主机集群中所部署的数据库实例确定为第二数据库实例。进一步地,该区块链节点基于数据库配置信息中的数据分片策略,从第二数据库实例中确定待处理数据所属的业务数据库实例,将数据访问指令转发至与区块链节点具有网络连接关系的数据库代理,以使数据库代理将数据访问指令发送至业务数据库实例所部署的数据库主机节点。此时,该区块链节点接收数据库主机节点通过数据库代理所返回的待处理数据。
比如,若区块链节点的存储扩展方式为上述图4所示的存储扩展方式,则该区块链节点在执行访问待处理数据时,可以从3个主机集群中,确定主机集群1,主机集群1的数据类型与待处理数据的数据类型相匹配,进而将主机集群1中所部署的数据库实例确定为第二数据库实例。进一步地,该区块链节点基于数据库配置信息中的数据分片策略,从第二数据库实例中按照上述图9所示的方法,确定待处理数据所属的业务数据库实例(例如,图4所示的硬盘A)。
此时,该区块链节点调用数据库服务组件,其中,数据库服务组件可以与区块链节点部署在同一设备上,也可以单独部署在不同于区块链节的另一设备上,这里将不对其进行限定。若数据库服务组件单独部署在不同于区块链节点的另一设备上,本申请实施例将这一设备称之为与区块链节点具有网络连接关系的数据库代理。该区块链节点将数据访问指令转发至图4所示的数据库代理,以使数据库代理将数据访问指令发送至业务数据库实例所部署的数据库主机节点(例如,主机J11所在的数据库主机节点)。此时,该区块链节点可以接收数据库主机节点通过数据库代理所返回的待处理数据。
为便于理解,请参见图11,图11是本申请实施例提供的一种用于访问待处理数据的流程示意图。如图11所示,本申请实施例中的区块链节点为区块链网络中需要保存全量账本数据的区块链节点,例如,该区块链节点为上述图1所示的区块链网络中的任意一个区块链节点,例如,该区块链节点为节点10a。
在区块链节点获取到业务数据请求时,该区块链节点执行步骤1101,获取存储实例映射表,进而可以执行步骤1102,根据业务数据请求所携带的待处理数据的数据类型,确定第二数据库实例。
如上述图8所示,在区块链节点获取到待处理数据的数据类型为合约数据类型的情况下,该区块链节点获取存储实例映射表,在存储实例映射表中的N个数据库实例中,确定第二数据库实例,第二数据库实例的数据类型与待处数据相匹配,例如,第二数据库实例为图8所示的数据库实例D4、数据库实例D5以及数据库实例D6
进一步地,该区块链节点执行步骤1103-步骤1104,基于数据分片策略,确定待处理数据在哈希环上的位置信息,进而按照哈希环的存储方向,找到与待处理数据的位置信息具有最近位置信息的第一位置信息,进而将查找到的第一位置信息对应的数据库实例确定为业务数据库实例。
此时,该区块链节点执行步骤1105,确定该业务数据库实例是否部署在本地数据库。在该业务数据库实例部署在本地数据库的情况下,则该区块链节点执行步骤1106,在本地数据库中访问待处理数据,并执行步骤1107,以结束访问流程。例如,若业务数据库实例为上述图3所示的数据库实例D3,则该区块链节点在本地数据库中的硬盘A中访问该待处理数据。
可选地,在业务数据库实例未部署在本地数据库,而是部署在远程数据库的情况下,则该区块链节点跳转执行步骤1108-步骤1111,调用数据库服务组件,以使数据库服务组件建立区块链节点与远程数据库之间的连接,进而在远程数据库中访问待处理数据,并将待处理数据返回给数据库服务组件,以使数据库服务组件将待处理数据返回至区块链节点,进而执行步骤1107,以结束访问流程。
步骤1006,区块链节点对待处理数据执行业务数据请求指示的数据操作。
可选地,业务数据请求包括数据归档请求、数据更改请求、数据新增请求、数据查询请求以及数据删除请求等。其中,数据归档请求用于在待处理数据的数据类型指示待处理数据为交易数据时,对待处理数据进行归档处理。可选地,在业务数据请求为数据归档请求时,该区块链节点获取待处理数据的数据信息以及针对待处理数据的数据归档条件。其中,数据归档条件包括归档参数阈值;该归档参数阈值包括归档时间范围(例如,距离现在N年前的时间范围)或归档频次阈值(例如,50次)中的至少一项。在数据信息指示待处理数据的交易时间戳属于归档时间范围,或待处理数据的访问频次小于归档频次阈值的情况下,则该区块链节点确定待处理数据满足数据归档条件,此时,该区块链节点将待处理数据从待处理数据所属的数据库转移至归档数据库。
由此可见,本申请实施例应用于需要区块链系统存储海量数据且对链性能要求较高的场景,其中包括由于交易频率高带来的性能压力的场景、以及由于交易数量大而带来的存储空间压力的场景。通过结合区块链的数据特性,将不同类型的区块链数据分别存储至不同的数据库实例上,从而解决存储容量瓶颈问题。比如,本申请实施例将历史交易等不活跃的数据存储至归档数据库。归档数据库为性能较差成本更低的设备,有利于将数据进行归档或定期删除等处理,从而节省存储空间以及开支。这意味着本申请实施例中的区块链的主数据库仅需要保留最近数据,从而使得数据库的数据量级较小,从而提升数据读写速率,以便于提高数据访问性能。这种存储扩展方式不仅解决了区块链节点的数据读写性能不足的问题,还解决了单机存储空间受限的问题,甚至通过按照数据类型和数据分片策略这种精细化的合约存储管理,也为区块链在大数据量的存储场景落地提供了可能。
进一步地,请参见图12,图12是本申请实施例提供的一种基于区块链的数据处理装置的结构示意图。如图12所示,该基于区块链的数据处理装置1是运行于计算机设备中的一个计算机程序(包括程序代码),例如,该基于区块链的数据处理装置1为一个应用软件;该基于区块链的数据处理装置用于执行本申请实施例提供的方法中的相应步骤。如图12所示,该基于区块链的数据处理装置运行于区块链网络中需要保存全量账本数据的区块链节点,例如,上述图1所示的区块链网络中的任意一个区块链节点,例如,该区块链节点为节点10a。该基于区块链的数据处理装置包括:映射表获取模块121、数据类型匹配模块122、数据存储模块123、访问指令生成模块124、数据访问模块125以及操作执行模块126。
该映射表获取模块121,用于基于区块链节点的数据库配置信息,获取存储实例映射表; 存储实例映射表包括N个数据库实例的数据映射关系;数据映射关系指示数据库实例的数据类型;N为大于1的正整数。
可选地,该映射表获取模块121包括:配置信息加载单元1211、实例获取单元1212以及映射表生成单元1213。
该配置信息加载单元1211,用于响应于针对区块链节点的启动操作,在启动操作指示首次启动区块链节点的情况下,加载数据库配置信息;
该实例获取单元1212,用于基于数据库配置信息以及区块链节点的主数据库的数据库类型,创建N个数据库实例。
可选地,数据库配置信息中的存储路径信息指示与X个数据类型相关联的硬盘集合;X为正整数;
该实例获取单元1212包括:数据库类型获取子单元12121、智能合约获取子单元12122、第一创建子单元12123、提示信息显示子单元12124以及第二创建子单元12125。
该数据库类型获取子单元12121,用于获取区块链节点的主数据库的数据库类型;
该智能合约获取子单元12122,用于在数据库类型属于第一类型的情况下,则从区块链节点所属的区块链上,获取智能合约,智能合约用于创建数据库实例;
该第一创建子单元12123,用于基于智能合约,分别为硬盘集合中的每个硬盘创建数据库实例,得到N个数据库实例。
其中,该第一创建子单元12123还用于:
对于硬盘集合中的每个硬盘,基于数据库配置信息确定硬盘的实例数量;
在硬盘部署在主数据库中的本地数据库的情况下,基于智能合约,为硬盘创建与实例数量相符合的数据库实例;
在硬盘部署在主数据库中的远程数据库的情况下,调用数据库服务组件,基于智能合约,为硬盘创建与实例数量相符合的数据库实例,数据库服务组件用于提供远程数据库服务。
该提示信息显示子单元12124,用于在数据库类型属于第二类型的情况下,显示与数据库配置信息相关联的提示信息;
该第二创建子单元12125,用于响应于针对提示信息的触发操作,分别为硬盘集合中的每个硬盘创建数据库实例,得到N个数据库实例。
其中,该数据库类型获取子单元12121、智能合约获取子单元12122、第一创建子单元12123、提示信息显示子单元12124以及第二创建子单元12125的实现方式可以参见上述图6的实施例中对创建数据库实例的描述,这里将不再继续进行赘述。
其中,X个数据类型包括第一数据类型、第二数据类型或第三数据类型中的至少一项;第一数据类型包括区块头数据类型;第二数据类型包括交易数据类型;第三数据类型包括合约数据类型;第一数据类型的硬盘的存储性能低于第二数据类型的硬盘的存储性能,第一数据类型的硬盘的存储性能低于第三数据类型的硬盘的存储性能。
该映射表生成单元1213,用于建立每个数据库实例与每个数据库实例所属硬盘的数据类型之间的映射关系,基于映射关系,生成存储实例映射表。
其中,该配置信息加载单元1211、实例获取单元1212以及映射表生成单元1213的实现方式可以参见上述图6的实施例中对步骤601的描述,这里将不再继续进行赘述。
该数据类型匹配模块122,用于在获取到待存储的区块链数据的情况下,从N个数据库实例中,确定M个候选数据库实例,候选数据库实例的数据类型与区块链数据相匹配;M为小于或者等于N的正整数。
其中,该数据类型匹配模块122包括:数据信息确定单元1221、数据类型确定单元1222以及数据类型匹配单元1223。
该数据信息确定单元1221,用于在获取到待存储的区块链数据的情况下,确定区块链数据的数据信息;
该数据类型确定单元1222,用于基于区块链数据的数据信息,确定区块链数据的数据类 型。
其中,数据库配置信息包括数据量阈值和访问频次阈值;
该数据类型确定单元1222包括:第一确定子单元12221、第二确定子单元12222以及第三确定子单元12223。
该第一确定子单元12221,用于在数据信息指示区块链的数据量未达到数据量阈值,且区块链数据的数据访问频次达到访问频次阈值的情况下,将第一数据类型确定为区块链数据的数据类型;
该第二确定子单元12222,用于在数据信息指示区块链数据属于交易数据的情况下,将第二数据类型确定为区块链数据的数据类型;
该第三确定子单元12223,用于在数据信息指示区块链数据属于合约数据的情况下,将第三数据类型确定为区块链数据的数据类型。
其中,该第一确定子单元12221、第二确定子单元12222以及第三确定子单元12223的实现方式可以参见上述图6的实施例中对数据类型的描述,这里将不再继续进行赘述。
该数据类型匹配单元1223,用于从存储实例映射表中,查找与区块链数据的数据类型相匹配的数据类型,将查找到的数据类型对应的数据库实例确定为候选数据库实例。
其中,该数据信息确定单元1221,数据类型确定单元1222以及数据类型匹配单元1223的实现方式可以参见上述图6所对应实施例中对步骤601的描述,这里将不再继续进行赘述。
该数据存储模块123,用于基于数据库配置信息中的数据分片策略,将区块链数据存储至M个候选数据库实例中的第一数据库实例。
其中,数据存储模块123包括:哈希环生成单元1231、第一哈希计算单元1232、第二哈希计算单元1233、目标实例确定单元1234以及数据存储单元1235。
该哈希环生成单元1231,用于基于数据分片策略,将哈希值空间按照存储方向,生成与区块链数据的数据类型相关联的哈希环;
该第一哈希计算单元1232,用于对M个候选数据库实例中的每个候选数据库实例的第一关键信息进行哈希计算,得到每个候选数据库实例在哈希环上的第一位置信息;
该第二哈希计算单元1233,用于对区块链数据的第二关键信息进行哈希计算,得到区块链数据在哈希环上的第二位置信息;
该目标实例确定单元1234,用于基于第二位置信息,在哈希环上沿着存储方向,查找与第二位置信息具有最近位置关系的第一位置信息,将查找到的第一位置信息对应的数据库实例确定为第一数据库实例;
该数据存储单元1235,用于将区块链数据存储至第一数据库实例。
其中,该哈希环生成单元1231、第一哈希计算单元1232、第二哈希计算单元1233,目标实例确定单元1234以及数据存储单元1235的实现方式可以参见上述图6的实施例中对步骤603的描述,这里将不再继续进行赘述。
其中,区块链数据包括待处理数据;
该访问指令生成模块124,用于响应于针对待处理数据的业务数据请求,生成数据访问指令,数据访问指令用于访问待处理数据;
该数据访问模块125,用于从N个数据库实例中,确定第二数据库实例,基于数据访问指令以及数据分片策略,从第二数据库实例中访问待处理数据,第二数据库实例的数据类型与待处理数据相匹配。
其中,N个数据库实例部署在与区块链节点相关联的远程数据库;远程数据库包括与X个数据类型对应的主机集群;X为正整数;一个数据类型对应一个主机集群;
该数据访问模块125包括:待查找实例确定单元1251、业务实例确定单元1252、访问指令转发单元1253以及数据接收单元1254。
该待查找实例确定单元1251,用于从X个主机集群中,确定目标主机集群,将目标主机集群中所部署的数据库实例确定为第二数据库实例,目标主机集群的数据类型与待处理数据 相匹配;
该业务实例确定单元1252,用于基于数据分片策略,从第二数据库实例中确定待处理数据所属的业务数据库实例;
该访问指令转发单元1253,用于将数据访问指令转发至与区块链节点具有网络连接关系的数据库代理,以使数据库代理将数据访问指令发送至业务数据库实例所部署的数据库主机节点;
该数据接收单元1254,用于接收数据库主机节点通过数据库代理所返回的待处理数据。
其中,该待查找实例确定单元1251、业务实例确定单元1252、访问指令转发单元1253以及数据接收单元1254的实现方式可以参见上述图121所对应实施例中对步骤1005的描述,这里将不再继续进行赘述。
该操作执行模块126,用于对待处理数据执行业务数据请求指示的数据操作。
其中,业务数据请求包括数据归档请求;数据归档请求用于在待处理数据的数据类型指示待处理数据为交易数据时,对待处理数据进行归档处理;
该操作执行模块126包括:归档条件获取单元1261以及数据转移单元1262。
该归档条件获取单元1261,用于获取待处理数据的数据信息以及针对待处理数据的数据归档条件;数据归档条件包括归档参数阈值;归档参数阈值包括归档时间范围或归档频次阈值中的至少一项;
该数据转移单元1262,用于在数据信息指示待处理数据的交易时间戳属于归档时间范围,或待处理数据的访问频次小于归档频次阈值的情况下,确定待处理数据满足数据归档条件,将待处理数据从待处理数据所属的数据库转移至归档数据库。
其中,该归档条件获取单元1261以及数据转移单元1262的实现方式可以参见上述图121所对应实施例中对步骤1006的描述,这里将不再继续进行赘述。
其中,该映射表获取模块121、数据类型匹配模块122、数据存储模块123、访问指令生成模块124、数据访问模块125以及操作执行模块126的实现方式可以参见上述图10的实施例中对步骤1001-步骤1006的描述,这里将不再继续进行赘述。另外,对采用相同方法的有益效果描述,也不再进行赘述。
进一步地,请参见图13,图13是本申请实施例提供的一种计算机设备的示意图。如图13所示,该计算机设备1300可以为区块链网络中需要保存全量账本数据的区块链节点,例如,上述图1所示的区块链网络中的任意一个区块链节点,例如,该区块链节点为节点10a。该计算机设备1300可以包括:至少一个处理器1301,例如,CPU,至少一个网络接口1304,用户接口1303,存储器1305,至少一个通信总线1302。其中,通信总线1302用于实现这些组件之间的连接通信。其中,用户接口1303可以包括显示屏(Display)、键盘(Keyboard),网络接口1304可选地可以包括标准的有线接口、无线接口(如WI-FI接口)。存储器1305可以是高速RAM存储器,也可以是非不稳定的存储器(non-volatile memory),例如至少一个磁盘存储器。存储器1305可选地还可以是至少一个位于远离前述处理器1301的存储装置。如图13所示,作为一种计算机存储介质的存储器1305可以包括操作系统、网络通信模块、用户接口模块以及设备控制应用程序。
在图13所示的计算机设备1300中,网络接口1304主要用于进行网络通信;而用户接口1303主要用于为用户提供输入的接口;而处理器1301可以用于调用存储器1305中存储的设备控制应用程序,以实现:
基于区块链节点的数据库配置信息,获取存储实例映射表;存储实例映射表包括N个数据库实例的数据映射关系;数据映射关系指示数据库实例的数据类型;N为大于1的正整数;
在获取到待存储的区块链数据的情况下,从N个数据库实例中,确定M个候选数据库实例,候选数据库实例的数据类型与区块链数据相匹配;M为小于或者等于N的正整数;
基于数据库配置信息中的数据分片策略,将区块链数据存储至M个候选数据库实例中的第一数据库实例。
应当理解,本申请实施例中所描述的计算机设备1300可执行前文图6和图13的实施例中对该基于区块链的数据处理方法的描述,也可执行前文图12的实施例中对该基于区块链的数据处理装置的描述,在此不再赘述。另外,对采用相同方法的有益效果描述,也不再进行赘述。
本申请实施例还提供一种计算机可读存储介质,该计算机可读存储介质存储有计算机程序,该计算机程序包括程序指令,该程序指令被处理器执行时实现图6和图10中各个步骤所提供的基于区块链的数据处理方法,可参见图6以及图10各个步骤所提供的实现方式,在此不再赘述。
计算机可读存储介质可以是前述任一实施例提供的数据传输装置或者计算机设备的内部存储单元,例如计算机设备的硬盘或内存。该计算机可读存储介质也可以是该计算机设备的外部存储设备,例如该计算机设备上配备的插接式硬盘,智能存储卡(smart media card,SMC),安全数字(secure digital,SD)卡,闪存卡(flash card)等。进一步地,该计算机可读存储介质还可以既包括该计算机设备的内部存储单元也包括外部存储设备。该计算机可读存储介质用于存储该计算机程序以及该计算机设备所需的其他程序和数据。该计算机可读存储介质还可以用于暂时地存储已经输出或者将要输出的数据。
本申请实施例还提供了一种计算机程序产品,该计算机程序产品包括计算机程序,该计算机程序存储在计算机可读存储介质中。计算机设备的处理器从计算机可读存储介质读取该计算机程序,处理器执行该计算机程序,使得该计算机设备可执行前文各实施例中对基于区块链的数据处理方法或装置的描述,在此不再赘述。另外,对采用相同方法的有益效果描述,也不再进行赘述。
以上所揭露的仅为本申请的可选实施例而已,当然不能以此来限定本申请之权利范围,因此依本申请权利要求所作的等同变化,仍属本申请所涵盖的范围。

Claims (16)

  1. 一种基于区块链的数据处理方法,由区块链节点执行,包括:
    基于所述区块链节点的数据库配置信息,获取存储实例映射表,所述存储实例映射表包括N个数据库实例的数据映射关系,所述数据映射关系指示所述数据库实例的数据类型,N为大于1的正整数;
    在获取到待存储的区块链数据的情况下,从所述N个数据库实例中,确定M个候选数据库实例,所述候选数据库实例的数据类型与所述区块链数据相匹配,M为小于或者等于N的正整数;
    基于所述数据库配置信息中的数据分片策略,将所述区块链数据存储至所述M个候选数据库实例中的第一数据库实例。
  2. 根据权利要求1所述的方法,其中,所述基于所述区块链节点的数据库配置信息,获取存储实例映射表,包括:
    响应针对所述区块链节点的启动操作,在所述启动操作指示首次启动所述区块链节点的情况下,加载所述区块链节点的数据库配置信息;
    基于所述数据库配置信息以及所述区块链节点的主数据库的数据库类型,创建所述N个数据库实例;
    建立每个数据库实例与每个数据库实例所属硬盘的数据类型之间的映射关系;
    基于所述映射关系,生成所述存储实例映射表。
  3. 根据权利要求2所述的方法,其中,所述数据库配置信息包括存储路径信息,所述存储路径信息指示与X个数据类型相关联的硬盘集合;X为正整数;
    所述基于所述数据库配置信息以及所述区块链节点的主数据库的数据库类型,创建所述N个数据库实例,包括:
    获取所述区块链节点的主数据库的数据库类型;
    在所述数据库类型属于第一类型的情况下,从所述区块链节点所属的区块链上,获取智能合约,所述智能合约用于创建数据库实例;
    基于所述智能合约,分别为所述硬盘集合中的每个硬盘创建数据库实例,得到所述N个数据库实例。
  4. 根据权利要求3所述的方法,其中,所述X个数据类型包括第一数据类型、第二数据类型或第三数据类型中的至少一项;所述第一数据类型包括区块头数据类型;所述第二数据类型包括交易数据类型;所述第三数据类型包括合约数据类型;所述第一数据类型的硬盘的存储性能低于所述第二数据类型的硬盘的存储性能,所述第一数据类型的硬盘的存储性能低于所述第三数据类型的硬盘的存储性能。
  5. 根据权利要求3所述的方法,其中,所述基于所述智能合约,分别为所述硬盘集合中的每个硬盘创建数据库实例,包括:
    对于所述硬盘集合中的每个硬盘,基于所述数据库配置信息确定所述硬盘的实例数量;
    在所述硬盘部署在所述主数据库中的本地数据库的情况下,基于所述智能合约,为所述硬盘创建与所述实例数量相符合的数据库实例;
    在所述硬盘部署在所述主数据库中的远程数据库的情况下,调用数据库服务组件,基于所述智能合约,为所述硬盘创建与所述实例数量相符合的数据库实例,所述数据库服务组件用于提供远程数据库服务。
  6. 根据权利要求3所述的方法,其中,所述方法还包括:
    在所述数据库类型属于第二类型的情况下,显示与所述数据库配置信息相关联的提示信息;
    响应于针对所述提示信息的触发操作,分别为所述硬盘集合中的每个硬盘创建数据库实例,得到所述N个数据库实例。
  7. 根据权利要求1所述的方法,其中,所述在获取到待存储的区块链数据的情况下,从所述N个数据库实例中,确定M个候选数据库实例,包括:
    在获取到所述区块链数据的情况下,确定所述区块链数据的数据信息;
    基于所述区块链数据的数据信息,确定所述区块链数据的数据类型;
    从所述存储实例映射表中,查找与所述区块链数据的数据类型相匹配的数据类型,将查找到的数据类型对应的数据库实例确定为所述候选数据库实例。
  8. 根据权利要求7所述的方法,其中,所述数据库配置信息包括数据量阈值和访问频次阈值;
    所述基于所述区块链数据的数据信息,确定所述区块链数据的数据类型,包括:
    在所述数据信息指示所述区块链数据的数据量未达到所述数据量阈值,且所述区块链数据的数据访问频次达到所述访问频次阈值的情况下,将第一数据类型确定为所述区块链数据的数据类型;
    在所述数据信息指示所述区块链数据属于交易数据的情况下,将第二数据类型确定为所述区块链数据的数据类型;
    在所述数据信息指示所述区块链数据属于合约数据的情况下,将第三数据类型确定为所述区块链数据的数据类型。
  9. 根据权利要求1所述的方法,其中,所述基于所述数据库配置信息中的数据分片策略,将所述区块链数据存储至所述M个候选数据库实例中的第一数据库实例,包括:
    基于所述数据分片策略,将哈希值空间按照存储方向,生成与所述区块链数据的数据类型相关联的哈希环;
    分别对每个候选数据库实例的第一关键信息进行哈希计算,得到每个候选数据库实例在所述哈希环上的第一位置信息;
    对所述区块链数据的第二关键信息进行哈希计算,得到所述区块链数据在所述哈希环上的第二位置信息;
    在所述哈希环上沿着所述存储方向,查找与所述第二位置信息具有最近位置关系的第一位置信息,将查找到的第一位置信息对应的数据库实例确定为所述第一数据库实例;
    将所述区块链数据存储至所述第一数据库实例。
  10. 根据权利要求1所述的方法,其中,所述区块链数据包括待处理数据;所述方法还包括:
    响应于针对所述待处理数据的业务数据请求,生成数据访问指令,所述数据访问指令用于访问所述待处理数据;
    从所述N个数据库实例中,确定第二数据库实例,基于所述数据访问指令以及所述数据分片策略,从所述第二数据库实例中访问所述待处理数据,所述第二数据库实例的数据类型与所述待处理数据相匹配;
    对所述待处理数据执行所述业务数据请求指示的数据操作。
  11. 根据权利要求10所述的方法,其中,所述N个数据库实例部署在与所述区块链节点相关联的远程数据库;所述远程数据库包括与X个数据类型对应的主机集群;X为正整数;一个数据类型对应一个主机集群;
    所述从所述N个数据库实例中,确定第二数据库实例,基于所述数据访问指令以及所述数据分片策略,从所述第二数据库实例中访问所述待处理数据,包括:
    从X个主机集群中,确定目标主机集群,将所述目标主机集群中所部署的数据库实例确定为所述第二数据库实例,所述目标主机集群的数据类型与所述待处理数据相匹配;
    基于所述数据分片策略,从所述第二数据库实例中确定所述待处理数据所属的业务数据库实例;
    将所述数据访问指令转发至与所述区块链节点具有网络连接关系的数据库代理,以使所述数据库代理将所述数据访问指令发送至所述业务数据库实例所部署的数据库主机节点;
    接收所述数据库主机节点通过所述数据库代理所返回的所述待处理数据。
  12. 根据权利要求10所述的方法,其中,所述业务数据请求包括数据归档请求;所述数据归档请求用于在所述待处理数据为交易数据时,对所述待处理数据进行归档处理;
    所述对所述待处理数据执行所述业务数据请求指示的数据操作,包括:
    获取所述待处理数据的数据信息以及所述待处理数据的数据归档条件;所述数据归档条件包括归档参数阈值;所述归档参数阈值包括归档时间范围或归档频次阈值中的至少一项;
    在所述数据信息指示所述待处理数据的交易时间戳属于所述归档时间范围,或所述待处理数据的访问频次小于所述归档频次阈值的情况下,确定所述待处理数据满足所述数据归档条件,将所述待处理数据从所述待处理数据所属的数据库转移至归档数据库。
  13. 一种基于区块链的数据处理装置,配置于区块链节点中,包括:
    映射表获取模块,用于基于所述区块链节点的数据库配置信息,获取存储实例映射表;所述存储实例映射表包括N个数据库实例的数据映射关系;所述数据映射关系指示所述数据库实例的数据类型;N为大于1的正整数;
    数据类型匹配模块,用于在获取到待存储的区块链数据的情况下,从所述N个数据库实例中,确定M个候选数据库实例,所述候选数据库实例的数据类型与所述区块链数据相匹配;M为小于或者等于N的正整数;
    数据存储模块,用于基于所述数据库配置信息中的数据分片策略,将所述区块链数据存储至所述M个候选数据库实例中的第一数据库实例。
  14. 一种计算机设备,包括:处理器和存储器以及网络接口;
    所述处理器与所述存储器、所述网络接口相连,其中,所述网络接口用于提供数据通信功能,所述存储器用于存储计算机程序,所述处理器用于调用所述计算机程序,以使得所述计算机设备执行权利要求1至12任一项所述的方法。
  15. 一种计算机可读存储介质,所述计算机可读存储介质中存储有计算机程序,所述计算机程序适于由处理器加载并执行,以使得具有所述处理器的计算机设备执行权利要求1至12任一项所述的方法。
  16. 一种计算机程序产品,所述计算机程序产品包括计算机程序,所述计算机程序存储在计算机可读存储介质中,所述计算机程序适于由处理器读取并执行,以使得具有所述处理器的计算机设备执行权利要求1至12任一项所述的方法。
PCT/CN2023/112029 2022-11-07 2023-08-09 一种基于区块链的数据处理方法、装置、设备及介质 Ceased WO2024098862A1 (zh)

Priority Applications (3)

Application Number Priority Date Filing Date Title
EP23786169.5A EP4390720A4 (en) 2022-11-07 2023-08-09 METHOD AND DEVICE, DEVICE AND MEDIUM FOR BLOCKCHAIN-BASED DATA PROCESSING
JP2023573451A JP7722778B2 (ja) 2022-11-07 2023-08-09 ブロックチェーンによるデータ処理方法、装置、機器及びコンピュータプログラム
US18/527,704 US20240152505A1 (en) 2022-11-07 2023-12-04 Data processing method and apparatus based on blockchain, device, and medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211383918.X 2022-11-07
CN202211383918.XA CN118035345A (zh) 2022-11-07 2022-11-07 一种基于区块链的数据处理方法、装置、设备及介质

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US18/527,704 Continuation US20240152505A1 (en) 2022-11-07 2023-12-04 Data processing method and apparatus based on blockchain, device, and medium

Publications (1)

Publication Number Publication Date
WO2024098862A1 true WO2024098862A1 (zh) 2024-05-16

Family

ID=88413658

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/112029 Ceased WO2024098862A1 (zh) 2022-11-07 2023-08-09 一种基于区块链的数据处理方法、装置、设备及介质

Country Status (2)

Country Link
CN (1) CN118035345A (zh)
WO (1) WO2024098862A1 (zh)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110597912A (zh) * 2019-09-17 2019-12-20 深圳前海微众银行股份有限公司 一种区块存储方法及装置
CN113360501A (zh) * 2021-06-04 2021-09-07 永旗(北京)科技有限公司 一种基于区块链的分布式数据存储方法及系统
CN114255128A (zh) * 2021-12-22 2022-03-29 迅鳐成都科技有限公司 区块链区块交易数据存储方法、设备、系统及存储介质
CN115136566A (zh) * 2020-02-19 2022-09-30 区块链许可股份公司 分布式数据库

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110597912A (zh) * 2019-09-17 2019-12-20 深圳前海微众银行股份有限公司 一种区块存储方法及装置
CN115136566A (zh) * 2020-02-19 2022-09-30 区块链许可股份公司 分布式数据库
CN113360501A (zh) * 2021-06-04 2021-09-07 永旗(北京)科技有限公司 一种基于区块链的分布式数据存储方法及系统
CN114255128A (zh) * 2021-12-22 2022-03-29 迅鳐成都科技有限公司 区块链区块交易数据存储方法、设备、系统及存储介质

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP4390720A4

Also Published As

Publication number Publication date
CN118035345A (zh) 2024-05-14

Similar Documents

Publication Publication Date Title
JP7722778B2 (ja) ブロックチェーンによるデータ処理方法、装置、機器及びコンピュータプログラム
US11444783B2 (en) Methods and apparatuses for processing transactions based on blockchain integrated station
US11336660B2 (en) Methods and apparatuses for identifying replay transaction based on blockchain integrated station
US10262151B2 (en) User-agnostic backend storage for cloud-based applications
US11665234B2 (en) Methods and apparatuses for synchronizing data based on blockchain integrated station
WO2020207233A1 (zh) 一种区块链的权限控制方法及装置
WO2022121538A1 (zh) 基于区块链的数据同步方法、系统及相关设备
US11783339B2 (en) Methods and apparatuses for transferring transaction based on blockchain integrated station
CN111539829B (zh) 一种基于区块链一体机的待过滤交易识别方法及装置
CN103401902A (zh) 一种便携式云存储系统及方法
US9930063B2 (en) Random identifier generation for offline database
CN101335765A (zh) 基于移动缓存的存储服务中间件
CN110910110B (zh) 一种数据处理方法、装置及计算机存储介质
WO2022247316A1 (zh) 存储对象处理系统、请求处理方法、网关和存储介质
TWI812366B (zh) 一種資料共用方法、裝置、設備及存儲介質
EP4357950A1 (en) Device management method, system and apparatus
CN106155566A (zh) 用于存储数据的方法、装置及系统
CN111563083B (zh) 报表数据查询方法、装置及系统
CN109687970B (zh) 一种移动区块链全节点及其实现方法
WO2024098862A1 (zh) 一种基于区块链的数据处理方法、装置、设备及介质
WO2023207529A1 (zh) 数据处理方法、装置及设备、介质、产品
CN107395416A (zh) 一种数据发送方法及服务器集群
CN113495982B (zh) 交易节点管理方法、装置、计算机设备及存储介质
WO2025029420A1 (en) Network storage acceleration
HK40098481A (zh) 区块链网络的数据处理方法、装置、计算机设备和介质

Legal Events

Date Code Title Description
ENP Entry into the national phase

Ref document number: 2023786169

Country of ref document: EP

Effective date: 20231018

ENP Entry into the national phase

Ref document number: 2023573451

Country of ref document: JP

Kind code of ref document: A

WWE Wipo information: entry into national phase

Ref document number: 11202307759X

Country of ref document: SG

NENP Non-entry into the national phase

Ref country code: DE