[0040] The principles and features of the present invention will be described below with reference to the accompanying drawings. The examples cited are only used to explain the present invention, and are not used to limit the scope of the present invention.
[0041] Such as figure 1 As shown, figure 1 It is a schematic diagram of the system architecture of the first embodiment of the blockchain data processing system of the present invention.
[0042] have to be aware of is, figure 1 Only two database groups 20 are shown in, which does not mean that the number of database groups 20 is limited to two. The present invention does not limit the number of database groups 20. In addition, the proxy server group 22 may include multiple proxy servers. (Not shown in the figure).
[0043] In this embodiment, the blockchain data processing system includes a blockchain transaction processing auxiliary system and a smart contract 10. The blockchain transaction processing auxiliary system includes a plurality of database groups 20 and a control center 30, each of the databases The group 20 is in communication connection with the smart contract 10, and the smart contract 10 is also in communication connection with the control center 30, wherein:
[0044] Each of the database groups 20 respectively includes a cluster load balancer (LVS) communicating with the smart contract 10, a proxy server (DbProxy) group 22 communicating with the cluster load balancer 21, and the proxy server group 22 22. The first standby database 24 (slave) and the primary database load balancer 23 (HaProxy) that communicate with each other, the master database 25 (Master) that communicates with the primary database load balancer 23, and the second database that communicates with the primary database 25. The second standby database 26, the first standby database 24 of one database group 20 communicates with the second standby database 26 of another database group 20; where:
[0045] The control center 30 is configured to issue user group fragmentation rules to the smart contract 10;
[0046] The smart contract 10 is used to initiate a data transaction request with the preset identification information of the transaction party on a node on the blockchain, according to the user group fragmentation rule issued in advance by the control center 30, Determine the database group 20 corresponding to the preset identification information of the transaction party and the database under the database group 20 corresponding to the data transaction request, and pass the data transaction request through the determined proxy server group 22 of the database group 20 Send to the determined database for data reading or writing.
[0047] The aforementioned smart contract 10 contains a data operation entry API (Application Programming Interface).
[0048] The preset identification information of the transaction party may be user identification information (for example, user account name), and the smart contract 10 may call the data operation portal API to pass the data transaction request through the determined proxy server of the database group 20 The group 22 is sent to the determined database for data reading or writing.
[0049] According to the user group sharding rules issued by the control center 30, the smart contract 10 of this embodiment sends the transaction request to the database via the proxy server group 22 of the database group 20 for data read and write operations, which solves the existing blockchain The read operation and/or write operation of the system transaction data at each node is overly dependent on the participation of the smart contract 10, which improves transaction processing efficiency.
[0050] Preferably, in this embodiment, the user group fragmentation rule includes:
[0051] Predetermine the mapping relationship between each database group 20 and the preset identification information of each transaction party;
[0052] For example, each database group 20 may correspond to a different set of preset identification information of transaction parties, and each set of preset identification information of transaction parties includes one or more preset identification information of transaction parties.
[0053] Determine the database group 20 corresponding to the preset identification information of the transaction party of the data transaction request according to the predetermined mapping relationship between each database group 20 and the preset identification information of each transaction party;
[0054] According to the predetermined mapping relationship between the data transaction request type and the database, the database corresponding to the data transaction request is determined.
[0055] For example, the database corresponding to the data read operation request may be the first standby database 24; the database corresponding to the data write operation request may be the main database 25.
[0056] Preferably, in this embodiment, the control center 30 is also used for:
[0057] When an abnormality occurs in a database group 20, the database group 20 is taken offline from the data transaction request service queue, and the database group 20 in another database group 20 communicating with the first standby database 24 in the database group 20 The second backup database 26 is adjusted to the main database 25 and responds to the data transaction request corresponding to the database group 20 on its behalf;
[0058] The foregoing determination of an abnormality in a database group 20 may specifically be: if a database group 20 cannot complete a normal data read operation and/or write operation, it is determined that the database group 20 is abnormal.
[0059] When the database group 20 returns to normal, the data in the second standby database 26 in another database group 20 is synchronized to the first standby database 24, the second standby database 26, and the main database in the database group 20 25. Add the database group 20 to the data transaction request service queue and go online.
[0060] The control center 30 of this embodiment can dynamically adjust the main database 25 among the database groups 20. When an abnormality occurs in one database group 20, the second backup database 26 in the other database group 20 can be adjusted as the main database. For the database 25, when the abnormal database group 20 returns to normal, the database group 20 is reactivated, so that when an abnormality occurs in the database group, the service can be automatically and quickly restored.
[0061] Preferably, in this embodiment, the main database load balancer 23 is also used for:
[0062] When the main database 25 of a database group 20 is abnormal, the original second backup database 26 of the database group 20 is switched to the main database 25 of the database group 20, and the data transaction request corresponding to the main database 25 is replaced. Respond
[0063] When the primary database 25 returns to normal, use the primary database 25 as the new secondary standby database 26, switch to the standby database of the original secondary standby database 26, and synchronize the data of the original secondary standby database 26 to the new secondary standby database. Database 26.
[0064] The main database load balancer 23 of this embodiment can dynamically adjust the main database 25 in a database group 20, so that when the main database 25 is abnormal, the service can be automatically and quickly restored.
[0065] Preferably, in this embodiment, the aforementioned blockchain transaction processing auxiliary system is also used for:
[0066] The transaction request sent by the smart contract 10 is received, and the transaction processing is performed according to the received transaction request, and the transaction processing result is written into the storage block in the blockchain storage layer in an asynchronous manner.
[0067] Preferably, in this embodiment, the aforementioned blockchain transaction processing auxiliary system is also used for:
[0068] Regularly sort all transaction processing results to be stored in the chain in the order of generation time;
[0069] When the number of transaction processing results to be stored in the chain is less than or equal to the first threshold number, the transaction processing results to be stored in the chain are written into the storage block in the blockchain storage layer according to the sort order;
[0070] When the number of transaction processing results to be stored in the chain is greater than the first threshold number, the transaction processing results of the first threshold number to be stored in the chain are written in the blockchain storage layer according to the sort order. The storage block caches the remaining transaction processing results to be stored in the chain.
[0071] Preferably, in this embodiment, the aforementioned blockchain transaction processing auxiliary system is also used for:
[0072] When a transaction processing result is generated, the transaction processing result is added to a pre-generated in-chain storage result queue. The in-chain storage result queue is used to cache all transaction processing results to be stored in the chain. The in-chain storage result queue is All transaction processing results to be stored in the chain are sorted in the order of generation time;
[0073] Regularly start the in-chain storage operation for the transaction processing results to be stored in the in-chain storage result queue in the in-chain storage result queue, and after the in-chain storage operation is started, determine all the transaction processing in the in-chain storage result queue to be stored in the in-chain storage Whether the number of results is less than the first threshold number;
[0074] When the number of transaction processing results to be stored in the chain is less than or equal to the first threshold number, the transaction processing results to be stored in the chain are written into the storage block in the blockchain storage layer according to the sort order;
[0075] When the number of transaction processing results to be stored in the chain is greater than the first threshold number, the transaction processing results of the first threshold number to be stored in the chain are written in the blockchain storage layer according to the sort order. The storage block continues to cache the remaining transaction processing results to be stored in the chain.
[0076] The invention also provides a block chain transaction processing auxiliary system.
[0077] Such as figure 2 As shown, figure 2 It is a schematic diagram of the system architecture of the first embodiment of the blockchain transaction processing auxiliary system of the present invention.
[0078] have to be aware of is, figure 2 Only two database groups 20 are shown in, which does not mean that the number of database groups 20 is limited to two. The present invention does not limit the number of database groups 20. In addition, the proxy server group 22 may include multiple proxy servers. (Not shown in the figure).
[0079] In this embodiment, the blockchain transaction processing auxiliary system includes a plurality of database groups 20 and a control center 30, among which:
[0080] Each of the database groups 20 respectively includes a cluster load balancer 21 (LVS) communicating with the smart contract 10, a proxy server (DbProxy) group 22 communicating with the cluster load balancer 21, and the proxy server group 22 The first standby database 24 (slave) and the primary database load balancer 23 (HaProxy) that the group 22 communicates with, the master database 25 (Master) that communicates with the primary database load balancer 23, and the primary database 25 (Master) that communicates with the primary database 25 The second standby database 26, the first standby database 24 of one database group 20 communicates with the second standby database 26 of another database group 20;
[0081] The control center 30 is configured to issue user group sharding rules to the smart contract 10, so that the smart contract 10 initiates a data transaction with preset identification information of the transaction party on a node on the blockchain After the request, according to the user group fragmentation rule issued by the control center 30 in advance, the database group 20 corresponding to the preset identification information of the transaction party and the database under the database group 20 corresponding to the data transaction request are determined , And send the data transaction request to the determined database via the determined proxy server group 22 of the database group 20 to perform a data read operation or write operation.
[0082] The aforementioned smart contract 10 contains a data operation entry API (Application Programming Interface).
[0083] The preset identification information of the transaction party may be user identification information (for example, user account name), and the smart contract 10 may call the data operation portal API to pass the data transaction request through the determined proxy server of the database group 20 The group 22 is sent to the determined database for data reading or writing.
[0084] According to the user group sharding rules issued by the control center 30, the smart contract 10 of this embodiment sends the transaction request to the database via the proxy server group 22 of the database group 20 for data read and write operations, which solves the existing blockchain The read operation and/or write operation of the system transaction data at each node is excessively dependent on the participation of the smart contract 10, which improves the transaction processing efficiency.
[0085] Preferably, in this embodiment, the user group fragmentation rule includes:
[0086] Predetermine the mapping relationship between each database group 20 and the preset identification information of each transaction party;
[0087] For example, each database group 20 may correspond to a different set of preset identification information of transaction parties, and each set of preset identification information of transaction parties includes one or more preset identification information of transaction parties.
[0088] Determine the database group 20 corresponding to the preset identification information of the transaction party of the data transaction request according to the predetermined mapping relationship between each database group 20 and the preset identification information of each transaction party;
[0089] According to the predetermined mapping relationship between the data transaction request type and the database, the database corresponding to the data transaction request is determined.
[0090] For example, the database corresponding to the data read operation request may be the first standby database 24; the database corresponding to the data write operation request may be the main database 25.
[0091] Preferably, in this embodiment, the control center 30 is also used for:
[0092] When an abnormality occurs in a database group 20, the database group 20 is taken offline from the data transaction request service queue, and the database group 20 in another database group 20 communicating with the first standby database 24 in the database group 20 The second backup database 26 is adjusted to the main database 25 and responds to the data transaction request corresponding to the database group 20 on its behalf;
[0093] The foregoing determination of an abnormality in a database group 20 may specifically be: if a database group 20 cannot complete a normal data read operation and/or write operation, it is determined that the database group 20 is abnormal.
[0094] When the database group 20 returns to normal, the data in the second standby database 26 in another database group 20 is synchronized to the first standby database 24, the second standby database 26, and the main database in the database group 20 25. Add the database group 20 to the data transaction request service queue and go online.
[0095] The control center 30 of this embodiment can dynamically adjust the main database 25 among the database groups 20. When an abnormality occurs in one database group 20, the second backup database 26 in the other database group 20 can be adjusted as the main database. For the database 25, when the abnormal database group 20 returns to normal, the database group 20 is reactivated, so that when an abnormality occurs in the database group, the service can be automatically and quickly restored.
[0096] Preferably, in this embodiment, the main database load balancer 23 is also used for:
[0097] When the main database 25 of a database group 20 is abnormal, the original second backup database 26 of the database group 20 is switched to the main database 25 of the database group 20, and the data transaction request corresponding to the main database 25 is replaced. Respond
[0098] When the primary database 25 returns to normal, use the primary database 25 as the new secondary standby database 26, switch to the standby database of the original secondary standby database 26, and synchronize the data of the original secondary standby database 26 to the new secondary standby database. Database 26.
[0099] The main database load balancer 23 of this embodiment can dynamically adjust the main database 25 in a database group 20, so that when the main database 25 is abnormal, the service can be automatically and quickly restored.
[0100] The invention also provides a block chain data processing method.
[0101] Such as image 3 As shown, image 3 It is a schematic flowchart of the first embodiment of the blockchain data processing method of the present invention.
[0102] In this embodiment, the method is applicable to a blockchain data processing system, which is characterized in that the blockchain data processing system includes multiple database groups, smart contracts communicating with each of the database groups, and The control center of smart contract communication, where:
[0103] Each of the database groups respectively includes a cluster load balancer 21 communicating with a smart contract, a proxy server group communicating with the cluster load balancer 21, a first standby database and a master server communicating with the proxy server group. A database load balancer, a primary database that communicates with the primary database load balancer, and a second standby database that communicates with the primary database, the first standby database of one database group and the second standby database of another database group Database communication; the blockchain data processing method includes:
[0104] Step S10: After the smart contract initiates a data transaction request with the preset identification information of the transaction party on a node on the blockchain, it is determined according to the user group sharding rule issued in advance by the control center The database group corresponding to the preset identification information of the transaction party and the database under the database group corresponding to the data transaction request;
[0105] The above-mentioned smart contract contains the data operation entry API (Application Programming Interface).
[0106] The above-mentioned preset identification information of the transaction party may be user identification information (for example, user account name), and the above-mentioned smart contract may call the data operation portal API to pass the data transaction request through the determined proxy server group of the database group Send to the determined database for data reading or writing.
[0107] Step S20: The smart contract sends the data transaction request to the determined database via the determined proxy server group of the database group to perform a data read operation or write operation.
[0108] According to the user group sharding rules issued by the control center, the smart contract of this embodiment sends transaction requests to the database through the proxy server group of the database group for data read and write operations, which solves the problem of the existing blockchain system transaction data The read operation and/or write operation of each node is excessively dependent on the participation of the smart contract, which improves the efficiency of transaction processing.
[0109] Preferably, in this embodiment, the user group fragmentation rule includes:
[0110] Predetermining the mapping relationship between each of the database groups and the preset identification information of each of the transaction parties;
[0111] For example, each database group may correspond to a different set of preset identification information of transaction parties, and each set of preset identification information of transaction parties includes one or more preset identification information of transaction parties.
[0112] Determine the database group corresponding to the preset identification information of the transaction party requested by the data transaction according to the predetermined mapping relationship between each of the database groups and each of the transaction party preset identification information;
[0113] According to the predetermined mapping relationship between the data transaction request type and the database, the database corresponding to the data transaction request is determined.
[0114] For example, the database corresponding to the data read operation request may be the first standby database; the database corresponding to the data write operation request may be the primary database.
[0115] Preferably, in this embodiment, the blockchain data processing method further includes:
[0116] When an abnormality occurs in a database group, the control center takes the database group offline from the data transaction request service queue, and will communicate with the first standby database in the database group to the second database group in another database group. The second standby database is adjusted to the main database, and responds to the data transaction request corresponding to the database group on its behalf;
[0117] The foregoing determination of an abnormality in a database group can be specifically: if a database group cannot complete a normal data read operation and/or write operation, it is determined that the database group is abnormal.
[0118] When the database group returns to normal, the control center synchronizes the data in the second standby database in another database group to the first standby database, the second standby database, and the main database in the database group, and Add the database group to the data transaction request service queue and go online.
[0119] The control center of this embodiment can dynamically adjust the main database among database groups. When an abnormality occurs in one database group, the second standby database in another database group can be adjusted as the main database. When the database group returns to normal, the database group is re-enabled, so that when an abnormality occurs in the database group, services can be automatically and quickly restored.
[0120] Preferably, in this embodiment, the blockchain data processing method further includes:
[0121] When an abnormality occurs in the primary database of a database group, the primary database load balancer switches the original secondary database of the database group to the primary database of the database group, and acts as a data transaction request corresponding to the primary database. Respond
[0122] When the primary database returns to normal, the primary database load balancer uses the primary database as the new secondary standby database, switches to the standby database of the original secondary standby database, and synchronizes the data of the original secondary standby database to the new secondary database. Second standby database.
[0123] The main database load balancer of this embodiment can implement dynamic adjustment of the main database in a database group, so that when the main database is abnormal, the service can be automatically and quickly restored.
[0124] The above descriptions are only the preferred embodiments of the present invention and do not limit the scope of the present invention. Any equivalent structural transformations or direct/indirect applications made by using the contents of the description and drawings of the present invention under the inventive concept of the present invention Other related technical fields are included in the scope of patent protection of the present invention.