Block data processing method and related device

By selecting nodes with sufficient remaining storage space from the storage cluster in the blockchain network for block data archiving and querying, the blockchain data expansion problem is solved, reducing storage space requirements and improving storage and query efficiency.

CN119200951APending Publication Date: 2024-12-27TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310775062.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-06-27
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

The issue of expansion of blockchain data. The existing technology archives block data into a database, resulting in higher storage space for each blockchain node, making it difficult to expand storage.

Method used

By determining a storage node with sufficient remaining storage space from the storage cluster, storing the block data into the message queue of the node, archiving and querying the block data is realized, and the storage space requirements of the blockchain node and the storage node are reduced.

Benefits of technology

It effectively reduces the storage space requirements of blockchain nodes and storage nodes, improves the storage and query efficiency of block data, and realizes stable storage and load balancing of block data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119200951A_ABST
    Figure CN119200951A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a block data processing method and a related device, which can be applied to the fields of cloud technology, block chain and the like, and the method comprises the following steps: after obtaining a block data archiving request from a block chain node, determining a first storage node from a plurality of storage nodes included in a storage cluster, in the embodiment of the invention, the first storage node has the storage capability to store the to-be-archived block data included in the block data archiving request, so that the to-be-archived block data is stored in the first message queue corresponding to the first storage node, and the first storage node can acquire the to-be-archived block data from the first message queue and archive the to-be-archived block data. Therefore, the first storage node for storing the to-be-archived block data is determined based on the residual storage space of each storage node, so that the to-be-archived block data can be stably stored in the storage cluster, and different to-be-archived block data from different block chain nodes can be archived in different storage nodes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of blockchain technology, and in particular to a method for processing block data and related devices. Background Art

[0002] Block data records block metadata and transaction data, among which block metadata includes block header and other data. Transaction data refers to the data generated by each transaction on the blockchain, such as Zhang San transferred 50 yuan to Li Si. With the increase of blockchain data, and because block data is generally stored in the form of files, it is difficult to expand the storage of block data.

[0003] In related technologies, block data is directly archived into the database. Taking the first version of Changan Chain as an example, the block data of each blockchain node is transferred to its own database through the archiving operation. Although this method can solve the expansion problem of block data, each blockchain node requires more storage space. Summary of the invention

[0004] In order to solve the above technical problems, the present application provides a block data processing method and related devices for reducing the storage space of each blockchain node.

[0005] The embodiments of the present application disclose the following technical solutions:

[0006] On the one hand, an embodiment of the present application provides a method for processing block data, the method comprising: obtaining a block data archiving request from a blockchain node, the block data archiving request comprising block data to be archived;

[0007] Based on the block data archiving request, determine a first storage node from a plurality of storage nodes included in the storage cluster, wherein the remaining storage space of the first storage node is greater than or equal to the storage space required by the block data to be archived, and the remaining storage space is the remaining storage space of the storage node;

[0008] The block data to be archived is stored in a first message queue corresponding to the first storage node, so that the first storage node obtains and archives the block data to be archived from the first message queue.

[0009] On the other hand, an embodiment of the present application provides a method for processing block data, the method comprising:

[0010] Obtaining a data query request from a blockchain node, wherein the data query request includes a to-be-queried identifier, and the to-be-queried identifier is a to-be-queried block identifier or a to-be-queried transaction identifier;

[0011] If it is determined based on the data query request that the cache stores the data to be queried corresponding to the identifier to be queried, the data to be queried is sent to the blockchain node, and the cache stores data with a query frequency greater than a preset frequency threshold;

[0012] If it is determined based on the data query request that the cache does not store the data to be queried corresponding to the identifier to be queried, and the data to be queried is stored in the decompressed block, the data to be queried is loaded into the cache, and the data to be queried is sent to the blockchain node;

[0013] If it is determined based on the data query request that the data to be queried corresponding to the identifier to be queried is not stored in the cache, and the data to be queried is not stored in the decompressed block, the block corresponding to the identifier to be queried is decompressed from the uncompressed block, the data to be queried is loaded into the cache, and the data to be queried is sent to the blockchain node.

[0014] On the other hand, an embodiment of the present application provides a block data processing device, the device comprising: an acquisition unit, a determination unit and a storage unit;

[0015] The acquisition unit is used to acquire a block data archiving request from a blockchain node, wherein the block data archiving request includes block data to be archived;

[0016] The determining unit is configured to determine, based on the block data archiving request, a first storage node from a plurality of storage nodes included in the storage cluster, wherein the remaining storage space of the first storage node is greater than or equal to the storage space required by the block data to be archived, and the remaining storage space is the remaining storage space of the storage node;

[0017] The storage unit is used to store the block data to be archived in a first message queue corresponding to the first storage node, so that the first storage node obtains and archives the block data to be archived from the first message queue.

[0018] On the other hand, an embodiment of the present application provides a block data processing device, the device comprising: an acquisition unit, a sending unit, a loading unit and a decompression unit;

[0019] The acquisition unit is used to acquire a data query request from a blockchain node, wherein the data query request includes a to-be-queried identifier, and the to-be-queried identifier is a to-be-queried block identifier or a to-be-queried transaction identifier;

[0020] The sending unit is configured to send the to-be-queried data to the blockchain node if it is determined based on the data query request that the to-be-queried data corresponding to the to-be-queried identifier is stored in the cache, wherein the cache stores data with a query frequency greater than a preset frequency threshold;

[0021] The loading unit is configured to load the data to be queried into the cache and send the data to be queried to the blockchain node if it is determined based on the data query request that the data to be queried corresponding to the identifier to be queried is not stored in the cache and the data to be queried is stored in the decompressed block;

[0022] The decompression unit is used to decompress the block corresponding to the to-be-queried identifier from the uncompressed block, load the to-be-queried data into the cache, and send the to-be-queried data to the blockchain node if it is determined based on the data query request that the to-be-queried data corresponding to the to-be-queried identifier is not stored in the cache, and the to-be-queried data is not stored in the decompressed block.

[0023] On the other hand, an embodiment of the present application provides a computer device, the computer device comprising a processor and a memory:

[0024] The memory is used to store a computer program and transmit the computer program to the processor;

[0025] The processor is configured to execute the method described in the above aspects according to the instructions in the computer program.

[0026] On the other hand, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method described in the above aspects.

[0027] On the other hand, an embodiment of the present application provides a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method described in the above aspects.

[0028] It can be seen from the above technical solution that after obtaining the block data archiving request from the blockchain node, a storage node is determined from the multiple storage nodes included in the storage cluster as the first storage node, wherein the remaining storage space of the first storage node is greater than or equal to the storage space required for the block data to be archived, that is, the first storage node has the storage capacity to store the block data to be archived included in the block data archiving request, so the block data to be archived is stored in the first message queue corresponding to the first storage node, so that the first storage node can obtain the block data to be archived from the first message queue and archive the block data to be archived. Therefore, the storage cluster includes multiple storage nodes, and the first storage node for storing the block data to be archived is determined based on the remaining storage space of each storage node, which not only enables the block data to be archived to be stably stored in the storage cluster, but also enables different block data to be archived from different blockchain nodes to be archived in different storage nodes, that is, the storage node only stores the block data generated by the corresponding blockchain node, rather than storing the block data generated by all blockchain nodes on the blockchain, which not only reduces the storage space of the blockchain node, but also reduces the storage space of each storage node. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0030] Figure 1 An optional structural diagram of a distributed system provided in an embodiment of the present application applied to a blockchain system;

[0031] Figure 2 An optional schematic diagram of a block structure provided in an embodiment of the present application;

[0032] Figure 3 A schematic diagram of a block data processing system provided in an embodiment of the present application;

[0033] Figure 4 A flowchart of a method for processing block data provided in an embodiment of the present application;

[0034] Figure 5 A flowchart of a routing node storing data to be archived based on load balancing provided in an embodiment of the present application;

[0035] Figure 6 A schematic diagram of the internal structure of a routing node provided in an embodiment of the present application;

[0036] Figure 7 A schematic diagram of the internal structure of a storage node provided in an embodiment of the present application;

[0037] Figure 8A-B A schematic diagram of a block data archiving process provided in an embodiment of the present application;

[0038] Figure 9A-9C A schematic diagram of a block data query process provided in an embodiment of the present application;

[0039] Figure 10A-10C A schematic diagram of a transaction data query process provided in an embodiment of the present application;

[0040] Fig.11 A schematic diagram of the structure of a block data processing device provided in an embodiment of the present application;

[0041] Fig.12 A schematic diagram of the structure of a block data processing device provided in an embodiment of the present application;

[0042] Fig.13 A schematic diagram of the structure of a server provided in an embodiment of the present application;

[0043] Fig.14 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0044] The embodiments of the present application are described below in conjunction with the accompanying drawings.

[0045] Before explaining the block data processing method provided in the embodiment of the present application, the relevant content of the blockchain is first explained.

[0046] The system involved in the embodiments of the present application may be a distributed system formed by connecting a client and multiple nodes (any form of computing devices in an access network, such as a server and a user terminal) through network communication.

[0047] Take the distributed system as the blockchain system as an example, see Figure 1 , which is an optional structural diagram of the distributed system 100 provided in the embodiment of the present application applied to the blockchain system, which is formed by multiple nodes 200 (only one node is exemplarily indicated in the figure) and a client 300, and a peer-to-peer (P2P) network is formed between the nodes 200. The P2P protocol is an application layer protocol running on the Transmission Control Protocol (TCP) protocol. In a distributed system, any machine such as a server or a terminal can join and become a node, and the node includes a hardware layer, an intermediate layer, an operating system layer, and an application layer.

[0048] See also Figure 1 The functions of each node in the blockchain system shown include:

[0049] 1) Routing: a basic function of a node, used to support communication between nodes.

[0050] In addition to the routing function, the node can also have the following functions:

[0051] 2) Applications are deployed in the blockchain to implement specific businesses based on actual business needs, record data related to the implementation of functions to form record data, carry digital signatures in the record data to indicate the source of the task data, and send the record data to other nodes in the blockchain system for other nodes to add the record data to a temporary block when they successfully verify the source and integrity of the record data.

[0052] For example, the services implemented by the application include:

[0053] 2.1) Wallet, used to provide the function of conducting electronic currency transactions, including initiating transactions (i.e., sending the transaction record of the current transaction to other nodes in the blockchain system. After the other nodes successfully verify the transaction, as a response to acknowledge the validity of the transaction, the transaction record data is stored in the temporary block of the blockchain; of course, the wallet also supports querying the remaining electronic currency in the electronic currency address;

[0054] 2.2) Shared ledger, which is used to provide functions such as storage, query and modification of account data. The record data of the operation on the account data is sent 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.

[0055] 2.3) Smart contracts are computerized protocols that can execute the terms of a contract. They are implemented by deploying code on a shared ledger that is executed when certain conditions are met. The code is used to complete automated transactions based on actual business needs, such as querying the logistics status of the goods purchased by the buyer and transferring the buyer's electronic currency to the merchant's address after the buyer signs for the goods. Of course, smart contracts are not limited to executing contracts for transactions, but can also execute contracts for processing received information.

[0056] 3) Blockchain, including a series of blocks that are connected to each other in the order of their generation. Once a new block is added to the blockchain, it will not be removed. The block records the record data submitted by the nodes in the blockchain system.

[0057] See also Figure 2, this figure is an optional schematic diagram of the block structure (Block Structure) provided in the embodiment of the present application. Each block includes the hash value of the transaction record stored in this block (the hash value of this block) and the hash value of the previous block. Each block is connected by the hash value to form a blockchain. In addition, the block can also include information such as the timestamp when the block was generated. Blockchain (Block chain) is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains relevant information for verifying the validity of its information (anti-counterfeiting) and generating the next block.

[0058] Taking the shared ledger in the aforementioned application as an example, it includes block data and status data. The status data is generally the most recent storage state on the block, which can be expanded through the data layer. However, for block data, since block data is generally stored in the form of files, it is difficult to expand the storage capacity of block data.

[0059] For example, Hyperledger Fabric (an open source licensed blockchain framework) and the first version of Changan Chain directly archive block data into the database, that is, block data is no longer stored in the blockchain node, but transferred to their respective databases. Although the expansion problem of block data is solved, each blockchain node requires higher storage.

[0060] Based on this, an embodiment of the present application provides a method for processing block data. Based on the remaining storage space of each storage node included in the storage cluster, a first storage node for storing the block data to be archived is determined. Not only can the block data to be archived be stably stored in the storage cluster, but also different block data to be archived from different blockchain nodes can be archived in different storage nodes. That is, the storage node only stores the block data generated by the corresponding blockchain node, rather than storing the block data generated by all blockchain nodes on the blockchain. This not only reduces the storage space of the blockchain node, but also reduces the storage space of each storage node.

[0061] The processing method of block data provided in this application can be applied to computer devices with block data processing capabilities, such as terminal devices and servers. Among them, the terminal device can specifically be a desktop computer, a laptop computer, a mobile phone, a tablet computer, an Internet of Things device and a portable wearable device. The Internet of Things device can be a smart speaker, a smart TV, a smart air conditioner, a smart car device, etc. The smart car device can be a car navigation terminal and a car computer, etc. The portable wearable device can be a smart watch, a smart bracelet, a head-mounted device, etc., but it is not limited to this; the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server or server cluster that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), and big data and artificial intelligence platforms. Terminal devices and servers can be directly or indirectly connected through wired or wireless communication, and this application does not limit this.

[0062] In order to facilitate understanding of the block data processing method provided in the embodiment of the present application, the following takes the execution subject of the block data processing method as a server as an example to exemplarily introduce the application scenario of the block data processing method.

[0063] See also Figure 3 , which is a schematic diagram of a block data processing system provided in an embodiment of the present application. Figure 3 As shown, the block data processing system includes a blockchain node 310, a routing node 320 and a storage cluster 330. Each of them will be described below.

[0064] A blockchain node is a network node in a blockchain network. Each blockchain node has a complete copy of block data (block data can also be called a copy of the ledger) and has the ability to participate in blockchain network consensus and ledger maintenance. The blockchain network is a system of chained data based on blockchain technology that is jointly maintained by multiple participants on a distributed network through consensus rules. Figure 3 In the example, blockchain node 311, blockchain node 312, blockchain node 313 and blockchain node 314 can all be servers.

[0065] In order to reduce the storage space of each blockchain node on the blockchain, in the embodiment of the present application, the copy of the ledger of each blockchain node will be archived to the storage cluster, and the storage cluster includes multiple storage nodes. Figure 3 In the example, storage cluster 330 includes storage node 331 , storage node 332 , storage node 333 , and storage node 334 .

[0066] The routing node is used to archive the block data from the blockchain node to a storage node in the storage cluster to help the blockchain node reduce storage space. There can be multiple routing nodes. Figure 3 In the example, routing node 321, routing node 322 and routing node 323 are included. The routing node 321 is taken as an example to illustrate that server 311 archives block data to storage node 331 in the storage cluster.

[0067] The routing node 321 obtains the block data archiving request sent by the blockchain node 311, and the block data archiving request includes the block data to be archived. Since the storage cluster 330 includes multiple storage nodes, in order to ensure the stability of storage, the routing node 321 determines the storage node for storing the block data to be archived from the blockchain node 311 based on the remaining storage space of each storage node in the storage cluster 330, that is, the remaining storage space of each node.

[0068] exist Figure 3 In the example, the remaining storage space of the storage node 331 is larger than the storage space required for the block data to be archived, and the storage node 331 is used as the first storage node. The first storage node has the storage capacity to store the block data to be archived from the blockchain node 311, so the block data to be archived is stored in the first message queue 341 corresponding to the first storage node. Figure 3 In the figure, the first message queue 341 is located in the routing node 321, and the routing node 321 may also have a second message queue, etc. (not shown in the figure). The storage node 331 subscribes to the first message queue 341, and can obtain the block data to be archived from the first message queue 341 and archive the block data to be archived.

[0069] Therefore, the storage cluster includes multiple storage nodes, and the first storage node for storing the block data to be archived is determined based on the remaining storage space of each storage node. This not only allows the block data to be stably stored in the storage cluster, but also allows different block data to be archived from different blockchain nodes to be archived in different storage nodes, that is, the storage node only stores the block data generated by the corresponding blockchain node, rather than storing the block data generated by all blockchain nodes on the blockchain. This not only reduces the storage space of the blockchain node, but also reduces the storage space of each storage node.

[0070] The block data processing method provided in the embodiment of the present application can be executed by the server. However, in other embodiments of the present application, the terminal device can also have similar functions as the server, so as to execute the block data processing method provided in the embodiment of the present application, or the terminal device and the server can jointly execute the block data processing method provided in the embodiment of the present application, and this embodiment does not limit this.

[0071] The following is a detailed introduction to the block data processing method provided by the present application through a method embodiment.

[0072] See also Figure 4 , which is a flowchart of the block data processing method provided by the embodiment of the present application. For the convenience of description, the following embodiment is still introduced by taking the execution subject of the block data processing method as a server (or the execution subject of the routing node including the block data processing method as a server) as an example. Figure 4 As shown, the method for processing block data includes the following steps:

[0073] S401: Obtain a block data archiving request from a blockchain node.

[0074] As can be seen from the above, the blockchain network includes multiple blockchain nodes. In the related technology, in order to solve the expansion problem of block data, the block data is no longer transferred to the blockchain nodes, but transferred to their respective databases, but each blockchain node requires higher storage.

[0075] Based on this, the embodiment of the present application builds a storage cluster to centrally store the generated block data in the storage cluster, that is, the blockchain nodes no longer transfer the block data to their respective databases, but transfer the block data to the storage cluster through the routing nodes.

[0076] The routing node can execute the block data processing method provided in the embodiment of the present application. In actual application, when the blockchain node stores the block data, it no longer transfers it to its own database, but can send a block data archiving request to the routing node, and the block data archiving request includes the block data to be archived, so that the routing node can transfer the block data to be archived to the corresponding storage node. Among them, the block data to be archived is the block data for storage in the storage node.

[0077] S402: Based on the block data archiving request, determine a first storage node from a plurality of storage nodes included in the storage cluster.

[0078] After receiving a block data archiving request including block data to be archived, the routing node may transfer the block data to be archived to a storage cluster. The storage cluster includes a plurality of storage nodes, each of which may be used to store block data from a blockchain node. For the stability of block data storage, a first storage node for storing block data to be archived may be determined based on the remaining storage space of each storage node, i.e., the remaining storage space. The remaining storage space of the first storage node is greater than or equal to the storage space required for storing block data to be archived, so that the first storage node has the storage capacity to store block data to be archived, thereby avoiding the problem that the storage node cannot store block data to be archived due to insufficient memory.

[0079] As a possible implementation method, the storage nodes included in the storage cluster are servers for providing cloud services. Therefore, the storage cluster can provide cloud services, which can not only meet the requirements of a wide range of blockchain storage applications, but also reduce the hardware cost of users in building storage clusters.

[0080] The embodiment of the present application does not specifically limit the method for determining the auxiliary storage node. In the following, two methods will be used for illustration based on different types of blocks, which will not be repeated here.

[0081] In addition, in the related art, there is generally only one storage node, and it is difficult to achieve large-scale storage expansion with a single storage node, and the storage space is limited. Moreover, the read and write pressure of a single storage node is large, and the efficiency is low. The embodiment of the present application provides a storage cluster including multiple storage nodes, which is not only easy to achieve storage expansion, but also can disperse storage block data based on multiple storage nodes, reduce read and write pressure, and improve efficiency.

[0082] S403: Storing the block data to be archived in a first message queue corresponding to the first storage node, so that the first storage node obtains and archives the block data to be archived from the first message queue.

[0083] In order to improve the processing speed of block data by the routing node, the routing node may not need to directly store the block data to be archived in the first storage node, but may store the block data to be archived in the first message queue corresponding to the first storage node, so that the first storage node can obtain and archive the block data to be archived from the first message queue. Asynchronous processing can improve the utilization rate of the server, thereby improving the storage efficiency of block data on a macro level.

[0084] The first message queue is a message queue corresponding to the first storage node, or in other words, there is a corresponding relationship between the first message queue and the first storage node, for example, the first storage node subscribes to the first message queue. Therefore, the first storage node with storage capacity is first determined, and then the first message queue corresponding to the first storage node is determined, and the block data to be archived is stored in the first message queue, so that the block data to be archived can be stably stored in the first storage node.

[0085] The embodiments of the present application do not specifically limit the device where the message queue is located. The message queue can be independent of the routing node or can be located in the routing node. In addition, since a routing node can be responsible for one or more businesses, or receive block data to be archived from one or more blockchains, in order to further improve the reading speed of the data to be archived, one or more topics (Topic) can be created in the routing node based on the business type. Each topic is used to store data to be archived from the same type of business, which is equivalent to classifying the data to be archived. Each topic can be executed based on one or more message queues, thereby avoiding the storage node waiting for other types of business to be read when reading the data to be archived, shortening the waiting time of the storage node, and improving the archiving efficiency. It should be noted that, for the convenience of explanation, a message queue is allowed to process the data to be archived from a topic, that is, a message queue is allowed to process the data to be archived from the same business.

[0086] It can be seen from the above technical solution that after obtaining the block data archiving request from the blockchain node, a storage node is determined from the multiple storage nodes included in the storage cluster as the first storage node, wherein the remaining storage space of the first storage node is greater than or equal to the storage space required for the block data to be archived, that is, the first storage node has the storage capacity to store the block data to be archived included in the block data archiving request, so the block data to be archived is stored in the first message queue corresponding to the first storage node, so that the first storage node can obtain the block data to be archived from the first message queue and archive the block data to be archived. Therefore, the storage cluster includes multiple storage nodes, and the first storage node for storing the block data to be archived is determined based on the remaining storage space of each storage node, which not only enables the block data to be archived to be stably stored in the storage cluster, but also enables different block data to be archived from different blockchain nodes to be archived in different storage nodes, that is, the storage node only stores the block data generated by the corresponding blockchain node, rather than storing the block data generated by all blockchain nodes on the blockchain, which not only reduces the storage space of the blockchain node, but also reduces the storage space of each storage node.

[0087] The embodiment of the present application does not specifically limit the method of determining the auxiliary storage node. The following two methods are used for illustration based on different types of blocks.

[0088] Method 1: The block to be archived is the genesis block.

[0089] Based on the block data archiving request, the block height of the block to be archived identified by the block data to be archived is obtained. The block height is used to indicate the position of the block in the blockchain. Based on the block height, it can be determined whether the block to be archived is the first block on the blockchain, that is, whether the block to be archived is a genesis block. For example, if the block height is 0, the block to be archived is a genesis block. If it is determined based on the block height that the block to be archived is a genesis block, it means that the blockchain where the genesis block is located has not yet established a corresponding relationship with the storage node, and the storage node can be arbitrarily allocated to the blocks generated by the current blockchain.

[0090] In order to ensure load balancing, the remaining storage space corresponding to each storage node in the storage cluster can be obtained, and the storage node corresponding to the largest remaining storage space among the remaining storage spaces corresponding to multiple storage nodes can be determined as the first storage node, that is, the storage node with the largest remaining storage space in the storage cluster can be used as the first storage node. It should be noted that the remaining storage space of the first storage node is greater than or equal to the storage space required for the block data to be archived.

[0091] As a possible implementation, the storage status of each storage node, such as the remaining storage space of the storage node, can be recorded based on the storage node status table. For example, after a storage node stores a block to be archived, the remaining storage space of the storage node can be updated in the storage node status record table, so that the remaining storage space corresponding to each storage node can be obtained based on the storage node status table later.

[0092] Therefore, the genesis block of each blockchain will be assigned to the storage node with the largest remaining storage space for archiving. As time goes by, the genesis blocks identified by the block data to be archived from different blockchain nodes will be assigned to the storage node with the largest remaining storage space for archiving, thereby ensuring that the block data to be archived is evenly stored in the storage cluster, thereby ensuring the load balance of the storage cluster and the read and write capabilities of the storage cluster.

[0093] As a possible implementation method, after receiving the genesis block, the routing node also needs to store the genesis block in the first message queue corresponding to the first storage node. The following describes the method for determining the first message queue required for the genesis block.

[0094] Since routing nodes receive block data from multiple blockchains, and block data belonging to the same blockchain generally belongs to the same business, multiple message queues can be established so that one blockchain corresponds to one message queue, thereby sharding based on business. Different storage nodes can be responsible for different businesses, which is not only convenient for management, but also convenient for storage nodes to quickly obtain block data of the corresponding business from the message queue, and also convenient for query.

[0095] Based on this, after determining the corresponding first storage node for the genesis block, since the genesis block is the first block on the blockchain, or the corresponding business is stored in the first storage node for the first time, there is no message queue responsible for the corresponding business of the blockchain where the genesis block is located. Therefore, a new message queue can be created, that is, a new message queue, and the created new message queue is determined as the first message queue, that is, the message queue corresponding to the first storage node, so that the routing node can store the storage block data to be archived in the first message queue.

[0096] In addition, it is necessary to establish a correspondence between the new message queue serving as the first message queue and the first storage node, and update the correspondence between the message queue and the storage node, that is, to the correspondence between the message queue and the storage node, add the correspondence between the new message queue and the first storage node, so that the first message queue corresponding to the first storage node can be determined based on the correspondence between the message queue and the storage node.

[0097] Method 2: The block to be archived is not the genesis block.

[0098] Based on the block data archiving request, the block height of the block to be archived identified by the block data to be archived is obtained. Among them, the block height is used to indicate the position of the block in the blockchain. Based on the block height, it can be determined whether the block to be archived is the second block on the blockchain or a block after the second block, that is, the block to be archived is not a genesis block. For example, if the block height is greater than 0, the block to be archived is not a genesis block. If it is determined based on the block height that the block to be archived is not a genesis block, it means that the blockchain where the block to be archived is located has established a corresponding relationship with the storage node, and the block to be archived can be assigned to the storage node for archiving the block before the blockchain where it is located. For the convenience of explanation, the storage node is called a pending storage node, and the pending storage node is the storage node corresponding to the blockchain where the block to be archived is located.

[0099] As can be seen from the above, for the convenience of management, the block data corresponding to the blocks belonging to a blockchain will be stored in the same storage node for subsequent query. Therefore, based on the corresponding relationship between the message queue and the storage node described above, the message queue corresponding to the first storage node can be determined as the pending message queue.

[0100] In order to ensure load balancing, the remaining storage space of the pending storage node can be obtained. For example, the remaining storage space of the pending storage node can be obtained based on the storage node status table described above. Based on the size of the remaining storage space of the pending storage node, it is determined whether to use the pending storage node as the first storage node. Two cases are described below.

[0101] Case 1: If the remaining storage space of the pending storage node is greater than the preset storage threshold, it means that the remaining storage space of the pending storage node has not yet approached the storage critical value, and it has the ability to store the block data to be archived. At this time, the pending storage node can be directly used as the first storage node. The preset storage threshold can be determined based on the storage space required for the data to be archived, or it can be determined based on the storage capacity of the pending storage node, and this application does not make specific limitations on this.

[0102] In addition, since the pending storage node is still used as the first storage node, the message queue corresponding to the first storage node can be used as the first message queue based on the correspondence between the message queue and the storage node described above, and the block data to be archived can be stored in the first message queue.

[0103] Case 2: If the remaining storage space of the pending storage node is less than or equal to the preset storage threshold, it means that the remaining storage space of the pending storage node has approached the storage critical value, and it does not have the ability to store the block data to be archived. At this time, the remaining storage space of other storage nodes in the storage cluster (that is, storage nodes other than the pending storage node) can be obtained, and the storage node with the largest remaining storage space can be used as the first storage node.

[0104] It should be noted that since the block data to be archived is no longer archived to the storage node where the block before the blockchain is located, but the storage node corresponding to the largest remaining storage space among the remaining storage spaces corresponding to multiple storage nodes is used to determine the first storage node, at this time, it is necessary to create a new message queue and determine the new message queue as the first message queue so that the block data to be archived can be stored in the new message queue.

[0105] In addition, it is necessary to establish a corresponding relationship between the new message queue and the first storage node (i.e., the storage node with the largest remaining storage space in the current storage cluster) so that the subsequent block data of the blockchain can be stored in the first storage node instead of the pending storage node. At the same time, the data to be archived stored in the original message queue can be automatically deleted after being consumed by the pending storage node. Based on the corresponding relationship between the new message queue and the first storage node, the corresponding relationship between the message queue and the storage node is updated, that is, in the corresponding relationship between the message queue and the storage node, the corresponding relationship between the new message queue and the first storage node is added, so that the message queue corresponding to the storage node can be obtained based on the corresponding relationship between the message queue and the storage node.

[0106] Therefore, if the storage capacity of the pending storage node is sufficient, the block data to be archived can be stored in the pending storage node to ensure that the block data belonging to the same business can be stored in the same storage node. If the storage capacity of the pending storage node is insufficient, the storage node with the largest remaining storage space in the storage cluster is used as the first storage node, so that the first storage node can stably store the block data to be archived.

[0107] For the convenience of explanation, the following Figure 5 , an embodiment is used to illustrate that a routing node stores data to be archived in a first message queue based on the principle of load balancing.

[0108] See also Figure 5 , this figure is a flow chart of a routing node storing data to be archived based on load balancing provided in an embodiment of the present application.

[0109] S501: Start.

[0110] S502: Obtain a block data archiving request from a blockchain node.

[0111] S503: Based on the block data to be archived included in the block data archiving request, obtain the block height of the block to be archived identified by the block data to be archived.

[0112] S504: Determine whether the block height of the block to be archived is zero, if so, execute S505; if not, execute S510.

[0113] S505: Obtain remaining storage spaces corresponding to the plurality of storage nodes included in the storage cluster based on the storage node status table.

[0114] S506: Determine, among the remaining storage spaces corresponding to the plurality of storage nodes, a storage node corresponding to the largest remaining storage space as the first storage node.

[0115] S507: Create a new message queue, and determine the new message queue as the first message queue.

[0116] S508: Establish a correspondence between the new message queue and the first storage node, and based on the correspondence between the new message queue and the first storage node, update the correspondence between the message queue and the storage node.

[0117] S509: Store the block data to be archived in the first message queue, so that the first storage node obtains the block data to be archived from the first message queue, archives the block data to be archived, and executes S514.

[0118] S510: Obtain remaining storage space of the pending storage node based on the storage node status table.

[0119] S511: Determine whether the remaining storage space of the pending storage node is greater than a preset storage threshold, if so, execute S512, if not, execute S505.

[0120] S512: Determine the pending storage node as the first storage node.

[0121] S513: Based on the correspondence between the message queues and the storage nodes, the message queue corresponding to the first storage node is used as the first message queue, and S509 is executed.

[0122] It should be noted that, after determining that the remaining storage space of the pending storage node is less than or equal to the preset storage threshold, if a new message queue is created, the new message queue is determined as the first message queue. When the block data stored in the original message queue, that is, the message queue corresponding to the pending storage node is empty, the original message queue is deleted.

[0123] S514: End.

[0124] Therefore, after obtaining the block data to be archived, the routing node can allocate the block data to be archived based on the remaining storage space of multiple storage nodes included in the storage cluster. This can not only ensure load balancing, enable the storage cluster to give full play to its reading and writing speeds, and improve user experience, but also enable multiple blocks of the blockchain of the same business to be archived to the same storage node as much as possible for easy query.

[0125] As a possible implementation, after the block data to be archived is stored in the first message queue corresponding to the first storage node, the block identifier of the block to be archived identified by the block data to be archived, that is, the corresponding relationship between the block identifier to be archived and the first storage node, can be established, and based on the corresponding relationship between the block identifier to be archived and the first storage node, the corresponding relationship between the block identifier and the storage node is updated. Thus, as time goes by, the corresponding relationship between the block identifier and the storage node will store in which storage node the block identifier corresponding to each block is stored.

[0126] If a block data query request is obtained from a blockchain node, wherein the block data query request includes a block identifier to be queried, and the block identifier to be queried is the block identifier of the block to be queried of the block data identifier to be queried, the storage node corresponding to the block identifier to be queried can be obtained from the correspondence between the block identifier and the storage node, and the storage node corresponding to the block identifier to be queried can also be returned to the blockchain node, so that the blockchain node obtains the block data to be queried from the storage node corresponding to the identifier to be queried.

[0127] Thus, the correspondence between the block identifier of each block to be archived and the storage node where it is stored can be established, and the correspondence between the block identifier and the storage node can be obtained. After obtaining the block data query request, the storage node corresponding to the block identifier to be queried can be determined based on the correspondence between the block identifier and the storage node, and the block data to be queried can be obtained from the storage node corresponding to the block identifier to be queried, which is convenient and fast.

[0128] As a possible implementation method, the storage node corresponding to the block identifier to be queried can be quickly determined based on the block height. Specifically, according to the block identifier to be queried, the archived block height of the blockchain where the block to be queried is located is obtained, and the block height of the block to be queried is obtained. Among them, the archived block height is the block height of the archived block. Based on the archived block height of the blockchain where the block to be queried is located, the block height of the generated block on the blockchain can be determined.

[0129] If the block height of the block to be queried is greater than the archived block height of the blockchain where the block to be queried is located, it means that the block to be queried on the blockchain has not been generated or archived, or the block identifier of the block to be queried may be incorrect. At this time, there is no need to call the correspondence between the block identifier and the storage node for query, and the result of block query failure can be directly returned.

[0130] If the block height of the block to be queried is less than or equal to the archived block height of the blockchain where the block to be queried is located, it means that the block to be queried is stored in the storage node. Based on the correspondence between the block identifier and the storage node, the storage node corresponding to the block identifier to be queried can be determined.

[0131] Therefore, based on the block height of the block to be queried and the block height of the archived blocks on the blockchain where the block to be queried is located, it is quickly determined whether the block to be queried is stored in the corresponding storage node. This can avoid querying unarchived block data based on the correspondence between the block identifier and the storage node, thereby improving the query speed, reducing the user's waiting time, and improving the user experience.

[0132] In addition, in order to facilitate the acquisition of the block height of the blockchain where the block to be queried is located, the block height of the archived block of each blockchain can be recorded so that it can be directly obtained later. Specifically, the block height of the block to be archived is obtained, and based on the block height of the block to be archived, the archived block height of the blockchain where the block to be archived is located is updated. Therefore, every time a block is archived on the blockchain, the block height of the archived block of the blockchain is updated for subsequent direct acquisition without identifying the block height of the archived block of each blockchain, thereby improving the query speed and reducing the waiting time of users.

[0133] As a possible implementation method, not only can it be quickly determined whether the block to be queried is archived based on the block height, but it can also be determined whether the block to be archived has been archived based on the block height, thereby avoiding problems such as duplicate storage and data inconsistency. The following is a detailed description.

[0134] Obtain the block height of the block to be archived identified by the block data to be archived, and obtain the archived height of the blockchain where the block to be archived is located. It can be seen from the aforementioned storage method that the block height can uniquely identify the position of the block to be archived in the blockchain, so based on the block height, it can be determined whether the block to be archived is a newly generated block. If the block height of the block to be archived is greater than the archived height of the blockchain where the block to be archived is located, it means that the block to be archived is a newly generated block in the blockchain where it is located, and it can be archived, and the block data to be archived is stored in the first message queue corresponding to the first storage node. If the block height of the block to be archived is less than or equal to the archived block of the blockchain where the block to be archived is located, it means that the block to be archived is an already generated block and cannot be modified, and there is no need to archive it. At this time, the result of block archiving failure can be returned.

[0135] Therefore, based on the block height of the block to be archived and the block height of the archived blocks in the blockchain where the block to be archived is located, it can be quickly determined whether the block to be archived is a newly generated block of the blockchain. If it is a newly generated block, it can be archived. If it is not a newly generated block, it cannot be archived to ensure data consistency and that the block data cannot be tampered with at will.

[0136] As a possible implementation method, not only the block data to be archived can be stored, but also the transaction identifier included in the block data to be archived, that is, the identifier used to uniquely represent the transaction, so that each transaction can be queried separately later. Specifically, the target transaction identifier is extracted from the block data to be archived, and the target transaction identifier is the transaction identifier of at least one transaction included in the block data to be archived. The target transaction identifier and the block data to be archived are both stored in the first message queue, so that the first storage node pulls the target transaction identifier and the block data to be archived from the first message queue.

[0137] As a possible implementation manner, a correspondence between the target transaction identifier and the first storage node may be established, and based on the correspondence between the target transaction identifier and the first storage node, the correspondence between the transaction identifier and the storage node may be updated.

[0138] If a transaction data query request is obtained from a blockchain node, the query data transaction request includes a transaction identifier to be queried, that is, a transaction identifier of the transaction to be queried of the transaction data identifier to be queried. Based on the correspondence between the transaction identifier and the storage node, the storage node corresponding to the transaction identifier to be queried is determined, and the storage node corresponding to the transaction to be queried is returned to the blockchain node, so that the blockchain node can obtain the transaction data to be queried from the storage node corresponding to the transaction to be queried.

[0139] Thus, the correspondence between the transaction identifier of each transaction and the storage node where it is stored can be established, and the correspondence between the transaction identifier and the storage node can be obtained. After obtaining the transaction data query request, the storage node corresponding to the transaction identifier to be queried can be determined based on the correspondence between the transaction identifier and the storage node, and the transaction data to be queried can be obtained from the storage node corresponding to the transaction identifier to be queried, which is convenient and fast.

[0140] As a possible implementation method, it is possible to quickly determine whether the transaction to be queried exists based on a Bloom filter. Among them, a Bloom filter is a data structure that quickly checks whether an element belongs to a set by using multiple hash functions and bit arrays. Specifically, when an element is added to a set, the element is hashed multiple times and the corresponding bit is set to 1. When checking whether an element exists in a set, the element is also hashed multiple times and checked whether the corresponding bit is 1. If any bit is 0, the element is not in the set. However, due to the uncertainty of the hash function, the Bloom filter may misjudge that an element is in the set, but it will not misjudge that an element is not in the set. Based on this, the embodiment of the present application uses a Bloom filter to quickly determine whether the transaction identifier to be queried is stored in the storage cluster, which is fast and accurate.

[0141] In addition, for the convenience of management and fast calculation, one or more blockchains can correspond to one Bloom filter, rather than all blockchains corresponding to one Bloom filter, so that the Bloom filter is responsible for the calculation of less transaction data and improves the calculation speed. Specifically, the target transaction identifier is placed in the Bloom filter corresponding to the block to be archived identified by the block data to be archived. If the Bloom filter corresponding to the block to be archived determines that the transaction to be queried exists, it means that the transaction to be queried is archived in the storage cluster, then the storage node corresponding to the transaction identifier to be queried is determined based on the correspondence between the transaction identifier and the storage node. If the Bloom filter corresponding to the block to be archived determines that the transaction to be queried does not exist, it means that the transaction to be queried has not been archived in the storage cluster, and the result of transaction query failure is returned.

[0142] Therefore, based on the Bloom filter, it is possible to quickly determine that the transaction to be queried has not been archived in the storage cluster. There is no need to query which storage node the transaction to be queried is stored in based on the correspondence between the transaction identifier and the storage node, which improves the query speed, reduces the user's waiting time, and improves the user experience.

[0143] As a possible implementation, if the blockchain archiving request also includes permission information, the first storage node can be determined from the multiple storage nodes included in the storage cluster based on the permission information. The permission information is used to describe the permissions of the blockchain node. As a possible implementation, if the permission information identifies that the permission of the blockchain node is higher, the read and write speed of the first storage node is faster. For example, if the blockchain node is a senior user (very important person, VIP), the storage node where the disk with faster read and write speed in the storage cluster is located is used as the first storage node and allocated to the blockchain node for use.

[0144] Furthermore, based on the block data archiving request, the block height of the block to be archived identified by the block data to be archived is obtained; if the block to be archived is determined to be a genesis block based on the block height of the block to be archived, the remaining storage spaces corresponding to the multiple storage nodes are obtained; based on the multiple remaining storage spaces, the multiple storage nodes are sorted in order from large to small, and the storage nodes ranked in the top N and whose read and write speeds meet the authority are determined as the first storage nodes, so as to improve the user experience of users with higher authority while satisfying load balancing as much as possible.

[0145] In addition, if the authority verification of the blockchain node fails, it means that the blockchain node is not a trusted blockchain node, and the current process is terminated, such as the block data archiving process (corresponding to the block data archiving request), the block data query process (corresponding to the block data query request), the transaction data query process (corresponding to the transaction data query request), etc.

[0146] As a possible implementation method, it is also possible to verify whether the blockchain node is trustworthy based on digital certificates or signatures. Among them, a digital signature (also known as a public key digital signature) is a digital string that can only be generated by the sender of the information and cannot be forged by others. This digital string is also a valid proof of the authenticity of the information sent by the sender. Verifying the signature means that the receiver needs to confirm whether the ciphertext file he received is really sent by the sender. What needs to be confirmed is whether it has been tampered with in the middle (different from decryption). The signature verification is ultimately compared based on the message digest. Therefore, the blockchain node can digitally sign the block data to be archived before sending requests such as block data archiving requests to ensure that the block data to be archived has not been tampered with.

[0147] A digital certificate (or simply certificate) is an electronic file that uniquely identifies people and resources on the Internet. Certificates enable secure and confidential communication between two entities. There are many types of certificates, such as personal certificates (used by individuals) and server certificates (used to establish a secure session between a server and a client via Secure Sockets Layer [SSL] technology). Blockchain nodes can put their own digital certificates in block data archiving requests so that routing nodes can verify based on the digital certificates. If the digital certificate verification is successful, the block data archiving request will continue to be processed, otherwise, the current process will end.

[0148] In the related technology, the second version of Changan Chain sets up an archiving center, which adopts an independently deployed architecture design, and can store the entire blockchain's ledger (block data) in the same file in the same archiving center (because the ledgers stored in each blockchain node on the same blockchain are the same). However, the block data is only archived once, and the archiving center has only one node. The single node has a single point of downtime problem, and multi-copy disaster recovery processing is not implemented.

[0149] Based on this, when determining the first storage node, the embodiment of the present application will also determine the second storage node. The second storage node is a storage node different from the first storage node. The second storage node serves as a backup storage node for the first storage node to prevent problems with single archiving. After determining the second storage node, the number of blocks to be archived can be archived in the first storage node and the second storage node. Among them, the remaining storage space of the second storage node is greater than or equal to the storage space required for the block data to be archived. It should be noted that the second storage node can only serve as a backup storage node for the first storage node, or it can have its own corresponding blockchain, and the present application does not make specific limitations on this.

[0150] As a possible implementation, the routing node can store the block data to be archived in the message queue corresponding to the second storage node while storing the block data to be archived in the first message queue. Alternatively, the routing node stores the block data to be archived in the first message queue, and after the first storage node obtains the block data to be archived, it not only archives the block data to be archived, but also sends the block data to be archived to the second storage node for archiving.

[0151] Therefore, the second storage node is determined from the multiple storage nodes included in the storage cluster, and the second storage node is used as a backup storage node for the first storage node, that is, the second storage node can obtain and archive the block data to be archived. This avoids the problems existing in single archiving, and by storing the same block data in two storage nodes, after the first storage node goes down, operations such as archiving and querying can be performed based on the second storage node.

[0152] As a possible implementation method, when a blockchain node queries a block or transaction, if the blockchain node knows which storage node the block to be queried or the transaction to be queried is archived in, it can directly send a block data query request or a transaction data query request to the storage node. If the blockchain node does not know which storage node the block to be queried or the transaction to be queried is archived in, it can first send a block data query request or a transaction data query request to the routing node, and after obtaining which storage node the block to be queried or the transaction to be queried is archived in, send a block data query request or a transaction data query request to the corresponding storage node.

[0153] The storage node obtains a data query request from a blockchain node, where the data query request includes a to-be-queried identifier, where the to-be-queried identifier includes a to-be-queried block identifier or a to-be-queried transaction identifier. If the to-be-queried identifier is a to-be-queried block identifier, the data query request is a block data query request; if the to-be-queried identifier is a to-be-queried transaction identifier, the data query request is a transaction data query request.

[0154] As a possible implementation method, before determining whether the queried data corresponding to the queried identifier exists in the cache based on the data query request, the storage node can verify whether the blockchain node is trustworthy based on the digital certificate or signature mentioned above. When the blockchain node is trustworthy, the subsequent query process can continue. If the blockchain node is not trustworthy, the current query process is terminated.

[0155] As a possible implementation, before determining whether there is data to be queried corresponding to the identifier to be queried in the cache based on the data query request, if the identifier to be queried is a block identifier to be queried, it is possible to quickly determine whether the block height of the block to be queried is greater than the archived block height on the blockchain where it is located based on the block height. If so, continue the current query process. If not, return the result of block query failure. If the identifier to be queried is a transaction identifier to be queried, it is possible to quickly determine whether the transaction identifier to be queried is stored in the storage cluster based on the Bloom filter.

[0156] If it is determined based on the data query request that the cache stores the data to be queried corresponding to the to-be-queried identifier, the data to be queried is sent to the blockchain node to complete the query. The cache stores data with a query frequency greater than a preset frequency threshold. Data with a query frequency greater than the preset threshold can be called hot data. The hot data is stored in the cache for quick query.

[0157] If it is determined based on the data query request that the data to be queried corresponding to the to-be-queried identifier is not stored in the cache, and the data to be queried is stored in the decompressed block, the data to be queried is loaded into the cache and sent to the blockchain node.

[0158] If it is determined based on the data query request that the data to be queried corresponding to the identifier to be queried is not stored in the cache, and the data to be queried is not stored in the decompressed block, the uncompressed block corresponding to the identifier to be queried is decompressed, the data to be queried is loaded into the cache, and the data to be queried is sent to the blockchain node.

[0159] Therefore, hot data can be stored in the cache of the storage node to facilitate quick query, and non-hot data can be compressed and stored in compressed blocks to reduce storage space. If you want to use the block data in the compressed block, you can decompress the compressed block to obtain the decompressed block.

[0160] In order to facilitate further understanding of the technical solution provided in the embodiment of the present application, the block data processing method provided in the embodiment of the present application is taken as the execution subject of the server, and the block data processing method is introduced as a whole.

[0161] The internal structures of the routing node and storage node are described below.

[0162] See also Figure 6 , which is a schematic diagram of the internal structure of a routing node provided by an embodiment of the present application. The routing node 600 includes a network module 610, an authentication module 620, an application programming interface (API) module 630, a message queue 640, a storage module 650 and a node status table module 660. Each module is described below.

[0163] (1) Network module 610, used to communicate with nodes such as blockchain nodes and storage nodes, for example, to obtain block data archiving requests from blockchain nodes.

[0164] (2) Authentication module 620, used to verify the authority of the blockchain node, save digital certificates, etc. As a possible implementation, the authentication module 620 may also include a blockchain certificate submodule 621 and an authentication algorithm submodule 622.

[0165] The blockchain certificate submodule 621 is used to store the digital certificates of each blockchain node, such as the digital certificate of the blockchain node can be obtained when the blockchain node is registered. The authentication algorithm submodule 622 is used to verify the legitimacy of the digital certificate, user authority, etc., so as to verify whether the block data archiving request and other requests are from a trusted blockchain node.

[0166] (3) API module 630, used to provide an interface for users and blockchain nodes to call. As a possible implementation, API module 630 may also include a block query submodule 631, a transaction query submodule 632, and a block storage submodule 633.

[0167] The block query submodule 631 is used to query the storage node corresponding to the block to be queried. The transaction query submodule 632 is used to query the storage node corresponding to the transaction to be queried. The block storage submodule 633 is used to store the block data to be archived in the corresponding message queue so that the corresponding storage node can pull the block data to be archived from the message queue.

[0168] (4) Message queue 640 can be a Kafka Broker, which is used to temporarily store the block data to be archived. As a possible implementation, message queue 640 can include multiple topics, each topic corresponds to a message queue, or message queue 640 can include multiple sub-message queues, each topic is used to store a type of message, which is equivalent to classifying the messages. Figure 6 In the example, two topics are taken, each of which is used to store block data from a blockchain, such as Topic-1, which is used to store block data to be archived from blockchain 1, and Topic-2, which is used to store block data to be archived from blockchain 2.

[0169] Among them, Apache Kafka is a distributed data stream processing platform that can publish, subscribe, store and process data streams in real time. It is designed to process data streams from multiple sources and deliver them to multiple consumers. Kafka classifies messages according to topics when saving them. The sender of the message is called the producer, and the receiver of the message is called the consumer. The producer is responsible for sending messages to the broker, the broker is responsible for persisting the message to disk, and the consumer is responsible for subscribing and consuming messages from the broker.

[0170] (5) Storage module 650, used to cache the block data to be archived, and store corresponding relationships such as the corresponding relationship between block identifiers and storage nodes. As a possible implementation, storage module 650 may include an archived block height submodule 651, a Bloom filter 652, and a block transaction storage node mapping submodule 653.

[0171] Among them, the archived block height submodule 651 is used to store the block height of the archived blocks in each blockchain. The Bloom filter 652 is used to quickly verify whether each transaction identifier exists. The block transaction storage node mapping submodule 653 includes the corresponding relationship between the block identifier and the storage node and the corresponding relationship between the transaction identifier and the storage node.

[0172] (6) A node status table module 660 is used to store status information related to storage nodes. As a possible implementation, the node status table module 660 may include a node routing table 661 and a node storage status table 662 .

[0173] The node routing table 661 is used to store the routing information of the storage node, such as Internet Protocol (IP) address information, port information, etc. The node storage status table 662 is used to store the storage status of the storage node, such as the remaining storage space of the storage node.

[0174] See also Figure 7 , which is a schematic diagram of the internal structure of a storage node provided by an embodiment of the present application. The storage node 700 includes a network module 710, an authentication module 720, an API module 730, a consumption module 740 and a storage module 750. Each module is described below.

[0175] (1) Network module 710, used to communicate with nodes such as blockchain nodes and storage nodes, for example, to obtain block data query requests from blockchain nodes.

[0176] (2) Authentication module 720, used to verify the authority of the blockchain node, save digital certificates, etc. As a possible implementation, the authentication module 720 may also include a blockchain certificate submodule 721 and an authentication algorithm submodule 722.

[0177] The blockchain certificate submodule 721 is used to store the digital certificates of each blockchain node, such as obtaining the digital certificate of the blockchain node when the blockchain node is registered. The authentication algorithm submodule 722 is used to verify the legitimacy of the digital certificate, user authority, etc., so as to verify whether the block data archiving request and other requests are from a trusted blockchain node.

[0178] (3) API module 730, used to provide an interface for blockchain nodes to call. As a possible implementation, API module 730 may also include a block query submodule 731 and a transaction query submodule 732.

[0179] The block query submodule 731 is used to query the block to be queried so as to return the block data to the corresponding blockchain node. The transaction query submodule 732 is used to query the transaction to be queried so as to return the transaction data to the corresponding blockchain node.

[0180] (4) The consumption module 740 may be a Kafka Consumer, i.e., a Kafka consumer, which is used to receive and archive the block data to be archived from the consumption queue of the routing node. As a possible implementation, the consumption module 740 may include multiple consumers, and different consumers are used to consume the block data to be archived stored in different message queues. Figure 7 There are two consumers in it, Consumer-1 is used to consume the data of blockchain 1, and Consumer-2 is used to consume the data of blockchain 2.

[0181] (5) Storage module 750, used to store the block data to be archived. As a possible implementation, storage module 750 may include archived block height submodule 751, Bloom filter 752, block transaction cache submodule 753, decompressed block submodule 754 and compressed block submodule 755.

[0182] Among them, the archived block height submodule 751 is used to store the block height of the archived blocks in each blockchain. The Bloom filter 752 is used to quickly verify whether each transaction identifier exists. The block transaction cache submodule 753 is used to cache block data and transaction data whose query frequency is greater than a preset frequency threshold, that is, hot block data and hot transaction data. The decompressed block submodule 754 is used to store decompressed block data. The compressed block submodule 755 is used to store uncompressed block data.

[0183] The block data archiving process, block data query process and transaction data query process are explained below respectively.

[0184] See also Fig. 8A and Figure 8B , are schematic diagrams of a block data archiving process provided by an embodiment of the present application. Among them, Fig. 8A Node a in Figure 8B Node a in is connected.

[0185] S801: Start.

[0186] S802: The routing node obtains a block data archiving request from a blockchain node.

[0187] The block data archiving request includes a digital certificate, permission information, and the block data to be archived.

[0188] S803: The routing node determines whether the blockchain node is trustworthy based on the digital certificate. If so, execute S804; if not, execute S805.

[0189] S804: The routing node determines whether the blockchain node is trustworthy based on the permission information. If so, execute S806; if not, execute S805.

[0190] S805: The routing node returns the authentication failure result to the blockchain node.

[0191] S806: The routing node obtains the block height of the block to be archived identified by the block data to be archived, and the archived block height of the blockchain where the block to be archived is located.

[0192] S807: The routing node determines whether the block height of the block to be archived is greater than the archived block height of the blockchain where the block to be archived is located. If not, execute S808; if so, execute S809.

[0193] S808: The routing node returns the result of block archiving failure to the blockchain node.

[0194] S809: The routing node extracts the target transaction identifier from the block data to be archived.

[0195] S810: The routing node puts the target transaction identifier into the Bloom filter corresponding to the block to be archived identified by the block data to be archived.

[0196] S811: The routing node determines a first storage node from a plurality of storage nodes included in the storage cluster.

[0197] S812: The routing node stores the target transaction identifier and the block data to be archived in the first message queue.

[0198] S813: The routing node establishes a correspondence between the identifier of the block to be archived and the first storage node.

[0199] S814: The routing node updates the correspondence between the block identifier and the storage node based on the correspondence between the to-be-archived block identifier and the first storage node.

[0200] S815: The routing node establishes a corresponding relationship between the target transaction identifier and the first storage node.

[0201] S816: The routing node updates the correspondence between the transaction identifier and the storage node based on the correspondence between the target transaction identifier and the first storage node.

[0202] S817: The routing node updates the archived block height of the blockchain where the block to be archived is located based on the block height of the block to be archived.

[0203] S818: End.

[0204] See also Figure 9A-9C , are schematic diagrams of a block data query process provided by an embodiment of the present application. Among them, Fig.9A Node a in Fig. 9B Node a in the connection, Fig.9A Node b in Fig. 9B Node b in the connection, Fig. 9B The node c in Fig. 9C Node c in is connected.

[0205] S901: Start.

[0206] S902: The blockchain node determines whether the storage node where the block data to be queried is archived is clear. If not, execute S903; if so, execute S912.

[0207] S903: The blockchain node sends a block data query request to the routing node.

[0208] The block data query request includes a digital certificate, permission information, and a block identifier of the block data to be queried.

[0209] S904: The routing node determines whether the blockchain node is trustworthy based on the digital certificate. If so, execute S905; if not, execute S906.

[0210] S905: The routing node determines whether the blockchain node is trustworthy based on the permission information. If so, execute S907; if not, execute S906.

[0211] S906: The routing node returns the authentication failure result to the blockchain node.

[0212] S907: The routing node obtains the archived block height of the blockchain where the block to be queried is located according to the block identifier to be queried, and obtains the block height of the block to be queried.

[0213] S908: The routing node determines whether the block height of the block to be archived is greater than the archived block height of the blockchain where the block to be archived is located. If so, execute S909; if not, execute S910.

[0214] S909: The routing node returns the result of block query failure to the blockchain node.

[0215] S910: The routing node determines the storage node corresponding to the block identifier to be queried based on the correspondence between the block identifier and the storage node.

[0216] S911: The routing node returns the storage node corresponding to the block identifier to be queried to the blockchain node.

[0217] For the convenience of subsequent explanation, the storage node corresponding to the block identifier to be queried is referred to as the storage node, and the storage node where the block data to be queried is archived is referred to as the storage node.

[0218] S912: The blockchain node sends a block data query request to the storage node.

[0219] S913: The storage node determines whether the blockchain node is trustworthy based on the digital certificate. If so, execute S914; if not, execute S915.

[0220] S914: The storage node determines whether the blockchain node is trustworthy based on the permission information. If so, execute S916; if not, execute S915.

[0221] S915: The storage node returns the authentication failure result to the blockchain node.

[0222] S916: The storage node obtains the block height of the block to be queried and the block height of the archived block of the blockchain where the block to be queried is located based on the block identifier to be queried.

[0223] S917: The storage node determines whether the block height of the block to be queried is greater than the block height of the archived block. If so, execute S918; if not, execute S919.

[0224] S918: The storage node returns the result of block query failure to the blockchain node.

[0225] S919: The storage node determines whether the cache stores the block data to be queried corresponding to the block identifier to be queried. If so, execute S920; if not, execute S921.

[0226] S920: The storage node returns the block data to be queried to the blockchain node and executes S 924.

[0227] S921: The storage node determines whether the block to be queried is stored in the decompressed block. If so, execute S922; if not, execute S923.

[0228] S922: The storage node loads the block to be queried into the cache and executes S920.

[0229] S923: The storage node decompresses the block to be queried from the undecompressed block and executes S922.

[0230] S924: End.

[0231] See also Figure 10A-10C , are schematic diagrams of a transaction data query process provided by an embodiment of the present application. Among them, Fig. 10A Node a in Fig. 10B Node a in the connection, Fig. 10A Node b in Fig. 10B Node b in the connection, Fig. 10B The node c in Fig. 10C Node c in is connected.

[0232] S1001: Start.

[0233] S1002: The blockchain node determines whether the storage node where the transaction data to be queried is archived is clear. If not, execute S1003; if not, execute S1013.

[0234] S1003: The blockchain node sends a transaction data query request to the routing node.

[0235] The transaction data query request includes a digital certificate, authority information, and a transaction identifier of the transaction data to be queried.

[0236] S1004: The routing node determines whether the blockchain node is trustworthy based on the digital certificate. If so, execute S1005; if not, execute S1006.

[0237] S1005: The routing node determines whether the blockchain node is trustworthy based on the permission information. If so, execute S1007; if not, execute S1006.

[0238] S1006: The routing node returns the authentication failure result to the blockchain node.

[0239] S1007: The routing node obtains the archived block height of the transaction to be queried in the blockchain according to the transaction identifier to be queried, and obtains the block height of the block in which the transaction to be queried is located.

[0240] S1008: The routing node obtains the corresponding Bloom filter.

[0241] S1009: The routing node determines whether the transaction to be queried exists based on the corresponding Bloom filter. If not, execute S1010; if yes, execute S1011.

[0242] S1010: The routing node returns the result of transaction query failure to the blockchain node.

[0243] S1011: The routing node determines the storage node corresponding to the transaction identifier to be queried based on the correspondence between the transaction identifier and the storage node.

[0244] S1012: The routing node returns the storage node corresponding to the transaction identifier to be queried to the blockchain node.

[0245] For the convenience of subsequent explanation, the storage node corresponding to the transaction identifier to be queried is referred to as the storage node.

[0246] S1013: The blockchain node sends a transaction data query request to the storage node.

[0247] S1014: The storage node determines whether the blockchain node is trustworthy based on the digital certificate. If so, execute S1015; if not, execute S1016.

[0248] S1015: The storage node determines whether the blockchain node is trustworthy based on the permission information. If so, execute S1017; if not, execute S1016.

[0249] S1016: The storage node returns the authentication failure result to the blockchain node.

[0250] S1017: The storage node determines whether the transaction to be queried exists based on the corresponding Bloom filter. If so, execute S1019; if not, execute S1018.

[0251] S1018: The storage node returns the result of transaction query failure to the blockchain node.

[0252] S1019: The storage node determines whether the transaction data to be queried is stored in the cache. If so, execute S1020; if not, execute S1021.

[0253] S1020: The storage node sends the transaction data to be queried to the blockchain node and executes S1025.

[0254] S1021: The storage node determines the block where the transaction data to be queried is located.

[0255] S1022: The storage node determines whether the block containing the transaction data to be queried is stored in the decompressed block. If so, execute S1023; if not, execute S1024.

[0256] S1023: The storage node loads the block containing the transaction data to be queried into the cache and executes S1020.

[0257] S1024: The storage node decompresses the block containing the transaction data to be queried from the uncompressed block, and executes S1023.

[0258] S1025: End.

[0259] As can be seen from the above scheme, the embodiment of the present application designs a processing system for block data, and also redesigns the internal structure of the processing system for block data, including routing nodes and storage nodes. Among them, the routing node includes a network module, an authentication module, an API module, a message queue, a storage module and a node status table module. The storage node includes a network module, an authentication module, an API module, a consumption module and a storage module. The routing node and the storage node are the operating basis of the processing system for block data, which can ensure that the processing system for block data operates efficiently and stably.

[0260] In addition, a full life cycle process is designed based on the above block data processing system. Including block data archiving process (as shown in Figure 8), block data query process (as shown in Figure 9), transaction data query process (as shown in Figure 10), routing node load balancing process (as shown in Figure 11), and transaction data query process (as shown in Figure 12). Figure 5 The design of these processes can ensure the stable and efficient operation of the block data processing system throughout its life cycle.

[0261] As a result, blockchain nodes do not need to implement a large amount of storage themselves to transfer data. While reducing the storage space of blockchain nodes, it can facilitate cluster expansion and improve the efficiency of archiving and query. Moreover, through mechanisms such as digital certificates and permission verification, the identity of all blockchain nodes can be guaranteed to be credible and can be widely reused in the industry. In addition, multi-copy high-efficiency storage query is achieved through message queues. The cloud service scalability achieved by multiple storage nodes can ensure that the architecture can be deployed in the cloud more quickly.

[0262] With respect to the block data processing method described above, the present application also provides a corresponding block data processing device, so that the block data processing method described above can be applied and implemented in practice.

[0263] See also Fig.11 , which is a schematic diagram of the structure of a block data processing device provided in an embodiment of the present application. Fig.11 As shown, the block data processing device 1100 includes: an acquisition unit 1101, a determination unit 1102 and a storage unit 1103;

[0264] The acquisition unit 1101 is used to acquire a block data archiving request from a blockchain node, wherein the block data archiving request includes block data to be archived;

[0265] The determining unit 1102 is configured to determine, based on the block data archiving request, a first storage node from a plurality of storage nodes included in the storage cluster, wherein the remaining storage space of the first storage node is greater than or equal to the storage space required by the block data to be archived, and the remaining storage space is the remaining storage space of the storage node;

[0266] The storage unit 1103 is used to store the block data to be archived in the first message queue corresponding to the first storage node, so that the first storage node obtains and archives the block data to be archived from the first message queue.

[0267] It can be seen from the above technical solution that after obtaining the block data archiving request from the blockchain node, a storage node is determined from the multiple storage nodes included in the storage cluster as the first storage node, wherein the remaining storage space of the first storage node is greater than or equal to the storage space required for the block data to be archived, that is, the first storage node has the storage capacity to store the block data to be archived included in the block data archiving request, so the block data to be archived is stored in the first message queue corresponding to the first storage node, so that the first storage node can obtain the block data to be archived from the first message queue and archive the block data to be archived. Therefore, the storage cluster includes multiple storage nodes, and the first storage node for storing the block data to be archived is determined based on the remaining storage space of each storage node, which not only enables the block data to be archived to be stably stored in the storage cluster, but also enables different block data to be archived from different blockchain nodes to be archived in different storage nodes, that is, the storage node only stores the block data generated by the corresponding blockchain node, rather than storing the block data generated by all blockchain nodes on the blockchain, which not only reduces the storage space of the blockchain node, but also reduces the storage space of each storage node.

[0268] As a possible implementation manner, the determining unit 1102 is specifically configured to:

[0269] Based on the block data archiving request, obtaining the block height of the block to be archived identified by the block data to be archived;

[0270] If it is determined based on the block height of the block to be archived that the block to be archived is a genesis block, then obtaining the remaining storage spaces respectively corresponding to the multiple storage nodes, and the genesis block is the first block of the blockchain;

[0271] Among the remaining storage spaces respectively corresponding to the multiple storage nodes, a storage node corresponding to the largest remaining storage space is determined as the first storage node.

[0272] As a possible implementation manner, the determining unit 1102 is specifically configured to:

[0273] Based on the block data archiving request, obtaining the block height of the block to be archived identified by the block data to be archived;

[0274] If it is determined based on the block height of the block to be archived that the block to be archived is not a genesis block, the remaining storage space of the pending storage node is obtained, the pending storage node is the storage node corresponding to the blockchain where the block to be archived is located, and the genesis block is the first block of the blockchain;

[0275] If the remaining storage space of the pending storage node is greater than a preset storage threshold, determining the pending storage node as the first storage node;

[0276] If the remaining storage space of the pending storage node is less than or equal to the preset storage threshold, the remaining storage spaces corresponding to the multiple storage nodes are obtained, and the storage node corresponding to the largest remaining storage space among the remaining storage spaces corresponding to the multiple storage nodes is determined as the first storage node.

[0277] As a possible implementation, the block data processing device 1100 further includes a message queue determining unit, which is used to:

[0278] If the storage node corresponding to the largest remaining storage space among the remaining storage spaces respectively corresponding to the multiple storage nodes is determined to be the first storage node, a new message queue is created, the new message queue is determined to be the first message queue, and a corresponding relationship between the new message queue and the first storage node is established, and based on the corresponding relationship between the new message queue and the first storage node, the corresponding relationship between the message queue and the storage node is updated;

[0279] If the pending storage node is determined to be the first storage node, then based on the correspondence between the message queues and storage nodes, the message queue corresponding to the first storage node is determined to be the first message queue.

[0280] As a possible implementation, the block data processing device 1100 further includes a corresponding relationship establishing unit, which is used to:

[0281] Establishing a correspondence between a block identifier to be archived and the first storage node, wherein the block identifier to be archived is a block identifier of the block to be archived identified by the block data to be archived;

[0282] Based on the correspondence between the to-be-archived block identifier and the first storage node, updating the correspondence between the block identifier and the storage node;

[0283] If a block data query request including a block identifier to be queried is obtained, the block identifier to be queried is the block identifier of the block to be queried of the block data identifier to be queried, the block data processing device 1100 further includes a block query unit, which is used to:

[0284] Based on the correspondence between the block identifier and the storage node, the storage node corresponding to the block identifier to be queried is determined, so that the blockchain node obtains the block data to be queried from the storage node corresponding to the block identifier to be queried.

[0285] As a possible implementation, the block data processing device 1100 further includes a block query unit, which is used to:

[0286] According to the block identifier to be queried, obtaining the archived block height of the blockchain where the block to be queried is located, and obtaining the block height of the block to be queried, wherein the archived block height is the block height of the archived block;

[0287] If the block height of the block to be queried is less than or equal to the archived block height of the blockchain where the block to be queried is located, then based on the correspondence between the block identifier and the storage node, determine the storage node corresponding to the block identifier to be queried;

[0288] If the block height of the block to be queried is greater than the archived block height of the blockchain where the block to be queried is located, a result indicating that the block query failed is returned.

[0289] As a possible implementation, the block data processing device 1100 further includes an updating unit, which is used to:

[0290] After storing the block data to be archived in the first message queue corresponding to the first storage node, obtaining the block height of the block to be archived;

[0291] Based on the block height of the block to be archived, the archived block height of the blockchain where the block to be archived is located is updated.

[0292] As a possible implementation manner, the obtaining unit 1101 is further configured to:

[0293] Obtaining the block height of the block to be archived identified by the block data to be archived, and obtaining the archived block height of the blockchain where the block to be archived is located, wherein the archived block height is the block height of the archived block;

[0294] The storage unit 1103 is specifically used for:

[0295] If the block height of the block to be archived is greater than the archived block height of the blockchain where the block to be archived is located, the block data to be archived is stored in the first message queue corresponding to the first storage node.

[0296] As a possible implementation, the block data processing device 1100 further includes an extraction unit, which is used to:

[0297] Extracting a target transaction identifier from the block data to be archived;

[0298] The storage unit 1103 is specifically used for:

[0299] The target transaction identifier and the block data to be archived are stored in the first message queue.

[0300] As a possible implementation, the block data processing device 1100 further includes a corresponding relationship establishing unit, which is used to:

[0301] Establishing a correspondence between the target transaction identifier and the first storage node;

[0302] Based on the correspondence between the target transaction identifier and the first storage node, updating the correspondence between the transaction identifier and the storage node;

[0303] If a transaction data query request including a transaction identifier to be queried is obtained, where the transaction identifier to be queried is a transaction identifier of a transaction to be queried of the transaction data identifier to be queried, the block data processing device 1100 further includes a transaction query unit for:

[0304] Based on the correspondence between the transaction identifier and the storage node, the storage node corresponding to the transaction identifier to be queried is determined, so that the blockchain node obtains the transaction data to be queried from the storage node corresponding to the transaction identifier to be queried.

[0305] As a possible implementation, the block data processing device 1100 further includes an inserting unit, which is used to:

[0306] Putting the target transaction identifier into the Bloom filter corresponding to the block to be archived identified by the block data to be archived;

[0307] The block data processing device 1100 further includes a transaction query unit, which is used to:

[0308] If it is determined based on the Bloom filter corresponding to the block to be archived that the transaction to be queried exists, then based on the correspondence between the transaction identifier and the storage node, determine the storage node corresponding to the transaction identifier to be queried;

[0309] If it is determined based on the Bloom filter corresponding to the block to be archived that the transaction to be queried does not exist, a result indicating that the transaction query failed is returned.

[0310] As a possible implementation manner, the block data archiving request further includes permission information, and the determining unit 1102 is specifically configured to:

[0311] Based on the permission information, the first storage node is determined from the plurality of storage nodes.

[0312] As a possible implementation method, the higher the authority of the blockchain node identified by the authority information, the faster the reading and writing speed of the first storage node.

[0313] As a possible implementation manner, the determining unit 1102 is further configured to:

[0314] A second storage node is determined from the multiple storage nodes so that the second storage node obtains and archives the block data to be archived, the second storage node and the first storage node are different storage nodes, and the remaining storage space of the second storage node is greater than or equal to the storage space required for the block data to be archived.

[0315] With respect to the block data processing method described above, the present application also provides a corresponding block data processing device, so that the block data processing method described above can be applied and implemented in practice.

[0316] See also Fig.12 , which is a schematic diagram of the structure of a block data processing device provided in an embodiment of the present application. Fig.12 As shown, the block data processing device 1200 includes: an acquisition unit 1201, a sending unit 1202, a loading unit 1203 and a decompression unit 1204;

[0317] The acquisition unit 1201 is used to acquire a data query request from a blockchain node, wherein the data query request includes a to-be-queried identifier, and the to-be-queried identifier is a to-be-queried block identifier or a to-be-queried transaction identifier;

[0318] The sending unit 1202 is configured to send the to-be-queried data to the blockchain node if it is determined based on the data query request that the to-be-queried data corresponding to the to-be-queried identifier is stored in the cache, and the cache stores data with a query frequency greater than a preset frequency threshold;

[0319] The loading unit 1203 is configured to load the data to be queried into the cache and send the data to be queried to the blockchain node if it is determined based on the data query request that the data to be queried corresponding to the identifier to be queried is not stored in the cache and the data to be queried is stored in the decompressed block;

[0320] The decompression unit 1204 is used to decompress the block corresponding to the to-be-queried identifier from the uncompressed block, load the to-be-queried data into the cache, and send the to-be-queried data to the blockchain node if it is determined based on the data query request that the to-be-queried data corresponding to the to-be-queried identifier is not stored in the cache, and the to-be-queried data is not stored in the decompressed block.

[0321] It can be seen from the above technical solution that after obtaining the data query request from the blockchain node, it is possible to first query whether the cache stores the data to be queried corresponding to the identifier to be queried based on the data query request. If not, query whether the block where the data to be queried is stored is stored in the decompressed block. If not, decompress the block corresponding to the identifier to be queried from the undecompressed block so as to send the data to be queried to the blockchain node. In this way, hot data can be stored in the cache of the storage node to facilitate quick query, and non-hot data can be compressed and stored in the compressed block to reduce storage space. If you want to use the block data in the compressed block, you can decompress the compressed block to obtain the decompressed block.

[0322] The present application also provides a computer device, which is the computer device described above. The computer device can be a server or a terminal device. The block data processing device described above can be built into the server or the terminal device. The computer device provided by the present application will be introduced from the perspective of hardware entity. Fig.13 The following is a schematic diagram of the server structure. Fig.14 Shown is a schematic diagram of the structure of the terminal equipment.

[0323] See also Fig.13 , which is a schematic diagram of a server structure provided in an embodiment of the present application. The server 1400 may have relatively large differences due to different configurations or performances, and may include one or more processors 1422, such as central processing units (CPU), memory 1432, one or more application programs 1442 or storage media 1430 (such as one or more massive storage devices) for data 1444. Among them, the memory 1432 and the storage medium 1430 may be temporary storage or permanent storage. The program stored in the storage medium 1430 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Furthermore, the processor 1422 may be configured to communicate with the storage medium 1430 to execute a series of instruction operations in the storage medium 1430 on the server 1400.

[0324] The server 1400 may also include one or more power supplies 1426, one or more wired or wireless network interfaces 1450, one or more input and output interfaces 1458, and / or one or more operating systems 1441, such as Windows Server 2003. TM , Mac OS X TM , Unix TM ,Linux TM , FreeBSD TMetc.

[0325] The steps performed by the server in the above embodiment can be based on the Fig.13 The server structure shown.

[0326] The CPU 1422 is used to perform the following steps:

[0327] Obtaining a block data archiving request from a blockchain node, wherein the block data archiving request includes block data to be archived;

[0328] Based on the block data archiving request, determine a first storage node from a plurality of storage nodes included in the storage cluster, wherein the remaining storage space of the first storage node is greater than or equal to the storage space required by the block data to be archived, and the remaining storage space is the remaining storage space of the storage node;

[0329] The block data to be archived is stored in a first message queue corresponding to the first storage node, so that the first storage node obtains and archives the block data to be archived from the first message queue.

[0330] Alternatively, the CPU 1422 is configured to execute the following steps:

[0331] Obtaining a data query request from a blockchain node, wherein the data query request includes a to-be-queried identifier, and the to-be-queried identifier is a to-be-queried block identifier or a to-be-queried transaction identifier;

[0332] If it is determined based on the data query request that the cache stores the data to be queried corresponding to the identifier to be queried, the data to be queried is sent to the blockchain node, and the cache stores data with a query frequency greater than a preset frequency threshold;

[0333] If it is determined based on the data query request that the cache does not store the data to be queried corresponding to the identifier to be queried, and the data to be queried is stored in the decompressed block, the data to be queried is loaded into the cache, and the data to be queried is sent to the blockchain node;

[0334] If it is determined based on the data query request that the data to be queried corresponding to the identifier to be queried is not stored in the cache, and the data to be queried is not stored in the decompressed block, the block corresponding to the identifier to be queried is decompressed from the uncompressed block, the data to be queried is loaded into the cache, and the data to be queried is sent to the blockchain node.

[0335] Optionally, the CPU 1422 may also execute method steps of any specific implementation of the method for processing block data in the embodiments of the present application.

[0336] See also Fig.14 , which is a structural diagram of a terminal device provided in an embodiment of the present application. Fig.14 The block diagram shows a partial structure of a smart phone related to a terminal device provided in an embodiment of the present application, and the smart phone includes: a radio frequency (RF) circuit 1510, a memory 1520, an input unit 1530, a display unit 1540, a sensor 1550, an audio circuit 1560, a wireless fidelity (WiFi) module 1570, a processor 1580, and a power supply 1590. Those skilled in the art can understand that Fig.14 The structure of the smartphone shown in the figure does not constitute a limitation of the smartphone, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0337] Combine the following Fig.14 A detailed introduction to the various components of a smartphone:

[0338] The RF circuit 1510 may be used for receiving and sending signals during information transmission or calls. In particular, after receiving the downlink information from the base station, it is sent to the processor 1580 for processing; in addition, the designed uplink data is sent to the base station.

[0339] The memory 1520 may be used to store software programs and modules. The processor 1580 implements various functional applications and data processing of the smartphone by running the software programs and modules stored in the memory 1520 .

[0340] The input unit 1530 can be used to receive input digital or character information, and to generate key signal input related to the user settings and function control of the smartphone. Specifically, the input unit 1530 may include a touch panel 1531 and other input devices 1532. The touch panel 1531, also known as a touch screen, can collect user touch operations on or near it and drive the corresponding connection device according to a pre-set program. In addition to the touch panel 1531, the input unit 1530 may also include other input devices 1532. Specifically, other input devices 1532 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, and the like.

[0341] The display unit 1540 may be used to display information input by the user or information provided to the user and various menus of the smartphone. The display unit 1540 may include a display panel 1541, and the display panel 1541 may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.

[0342] The smartphone may also include at least one sensor 1550, such as a light sensor, a motion sensor, and other sensors. As for other sensors that may be configured in the smartphone, such as a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., they will not be described in detail here.

[0343] The audio circuit 1560, the speaker 1561, and the microphone 1562 can provide an audio interface between the user and the smartphone. The audio circuit 1560 can transmit the received audio data to the speaker 1561 after converting the received audio data into an electrical signal, which is converted into a sound signal for output; on the other hand, the microphone 1562 converts the collected sound signal into an electrical signal, which is received by the audio circuit 1560 and converted into audio data, and then the audio data is output to the processor 1580 for processing, and then sent to another smartphone through the RF circuit 1510, or the audio data is output to the memory 1520 for further processing.

[0344] The processor 1580 is the control center of the smartphone, and uses various interfaces and lines to connect various parts of the entire smartphone, and executes various functions of the smartphone and processes data by running or executing software programs and / or modules stored in the memory 1520, and calling data stored in the memory 1520. Optionally, the processor 1580 may include one or more processing units.

[0345] The smart phone also includes a power supply 1590 (such as a battery) for supplying power to various components. Preferably, the power supply can be logically connected to the processor 1580 through a power management system, so that the power management system can manage functions such as charging, discharging, and power consumption management.

[0346] Although not shown, the smartphone may also include a camera, a Bluetooth module, etc., which will not be described in detail here.

[0347] In the embodiment of the present application, the memory 1520 included in the smart phone can store program codes and transmit the program codes to the processor.

[0348] The processor 1580 included in the smart phone can execute the block data processing method provided in the above embodiment according to the instructions in the program code.

[0349] The embodiment of the present application also provides a computer-readable storage medium for storing a computer program, wherein the computer program is used to execute the block data processing method provided in the above embodiment.

[0350] The embodiment of the present application also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. The processor of the computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the block data processing method provided in various optional implementations of the above aspects.

[0351] A person skilled in the art can understand that all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the above program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the above storage medium can be at least one of the following media: read-only memory (English: Read-Only Memory, abbreviated: ROM), RAM, magnetic disk or optical disk, etc. Various media that can store program codes.

[0352] It should be noted that each embodiment in this specification is described in a progressive manner, and the same and similar parts between the embodiments can refer to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiments. The device and system embodiments described above are merely schematic, in which the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative work.

[0353] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a technician familiar with the technical field within the technical scope disclosed in the present application should be included in the protection scope of the present application. Based on the implementation methods provided in the above aspects, the present application can also be further combined to provide more implementation methods. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A method for processing block data, characterized in that: The method comprises: Obtaining a block data archiving request from a blockchain node, wherein the block data archiving request includes block data to be archived; Based on the block data archiving request, determine a first storage node from a plurality of storage nodes included in the storage cluster, wherein the remaining storage space of the first storage node is greater than or equal to the storage space required by the block data to be archived, and the remaining storage space is the remaining storage space of the storage node; The block data to be archived is stored in a first message queue corresponding to the first storage node, so that the first storage node obtains and archives the block data to be archived from the first message queue.

2. The method according to claim 1, characterized in that The determining, based on the block data archiving request, a first storage node from a plurality of storage nodes included in the storage cluster comprises: Based on the block data archiving request, obtaining the block height of the block to be archived identified by the block data to be archived; If it is determined based on the block height of the block to be archived that the block to be archived is a genesis block, then obtaining the remaining storage spaces respectively corresponding to the multiple storage nodes, and the genesis block is the first block of the blockchain; Among the remaining storage spaces respectively corresponding to the multiple storage nodes, a storage node corresponding to the largest remaining storage space is determined as the first storage node.

3. The method according to claim 1, characterized in that The determining, based on the block data archiving request, a first storage node from a plurality of storage nodes included in the storage cluster comprises: Based on the block data archiving request, obtaining the block height of the block to be archived identified by the block data to be archived; If it is determined based on the block height of the block to be archived that the block to be archived is not a genesis block, the remaining storage space of the pending storage node is obtained, the pending storage node is the storage node corresponding to the blockchain where the block to be archived is located, and the genesis block is the first block of the blockchain; If the remaining storage space of the pending storage node is greater than a preset storage threshold, determining the pending storage node as the first storage node; If the remaining storage space of the pending storage node is less than or equal to the preset storage threshold, the remaining storage spaces corresponding to the multiple storage nodes are obtained, and the storage node corresponding to the largest remaining storage space among the remaining storage spaces corresponding to the multiple storage nodes is determined as the first storage node.

4. The method according to claim 2 or 3, characterized in that: The method further comprises: If the storage node corresponding to the largest remaining storage space among the remaining storage spaces respectively corresponding to the multiple storage nodes is determined to be the first storage node, a new message queue is created, the new message queue is determined to be the first message queue, and a corresponding relationship between the new message queue and the first storage node is established, and based on the corresponding relationship between the new message queue and the first storage node, the corresponding relationship between the message queue and the storage node is updated; If the pending storage node is determined to be the first storage node, then based on the correspondence between the message queues and storage nodes, the message queue corresponding to the first storage node is determined to be the first message queue.

5. The method according to claim 1, characterized in that The method further comprises: Establishing a correspondence between a block identifier to be archived and the first storage node, wherein the block identifier to be archived is a block identifier of the block to be archived identified by the block data to be archived; Based on the correspondence between the to-be-archived block identifier and the first storage node, updating the correspondence between the block identifier and the storage node; If a block data query request including a block identifier to be queried is obtained, wherein the block identifier to be queried is a block identifier of a block to be queried of the block data identifier to be queried, the method further includes: Based on the correspondence between the block identifier and the storage node, the storage node corresponding to the block identifier to be queried is determined, so that the blockchain node obtains the block data to be queried from the storage node corresponding to the block identifier to be queried.

6. The method according to claim 5, characterized in that The determining, based on the correspondence between the block identifier and the storage node, the storage node corresponding to the block identifier to be queried includes: According to the block identifier to be queried, obtaining the archived block height of the blockchain where the block to be queried is located, and obtaining the block height of the block to be queried, wherein the archived block height is the block height of the archived block; If the block height of the block to be queried is less than or equal to the archived block height of the blockchain where the block to be queried is located, then based on the correspondence between the block identifier and the storage node, determine the storage node corresponding to the block identifier to be queried; If the block height of the block to be queried is greater than the archived block height of the blockchain where the block to be queried is located, a result indicating that the block query failed is returned.

7. The method according to claim 6, characterized in that After storing the block data to be archived in the first message queue corresponding to the first storage node, the method further includes: Obtaining the block height of the block to be archived; Based on the block height of the block to be archived, the archived block height of the blockchain where the block to be archived is located is updated.

8. The method according to claim 1, characterized in that: The method further comprises: Obtaining the block height of the block to be archived identified by the block data to be archived, and obtaining the archived block height of the blockchain where the block to be archived is located, wherein the archived block height is the block height of the archived block; The step of storing the block data to be archived in the first message queue corresponding to the first storage node includes: If the block height of the block to be archived is greater than the archived block height of the blockchain where the block to be archived is located, the block data to be archived is stored in the first message queue corresponding to the first storage node.

9. The method according to claim 1, characterized in that: The method further comprises: Extracting a target transaction identifier from the block data to be archived; The step of storing the block data to be archived in the first message queue corresponding to the first storage node includes: The target transaction identifier and the block data to be archived are stored in the first message queue.

10. The method according to claim 9, characterized in that The method further comprises: Establishing a correspondence between the target transaction identifier and the first storage node; Based on the correspondence between the target transaction identifier and the first storage node, updating the correspondence between the transaction identifier and the storage node; If a transaction data query request including a transaction identifier to be queried is obtained, where the transaction identifier to be queried is a transaction identifier of the transaction to be queried of the transaction data identifier to be queried, the method further includes: Based on the correspondence between the transaction identifier and the storage node, the storage node corresponding to the transaction identifier to be queried is determined, so that the blockchain node obtains the transaction data to be queried from the storage node corresponding to the transaction identifier to be queried.

11. The method according to claim 10, characterized in that The method further comprises: Putting the target transaction identifier into the Bloom filter corresponding to the block to be archived identified by the block data to be archived; The determining, based on the correspondence between the transaction identifier and the storage node, the storage node corresponding to the transaction identifier to be queried includes: If it is determined based on the Bloom filter corresponding to the block to be archived that the transaction to be queried exists, then based on the correspondence between the transaction identifier and the storage node, determine the storage node corresponding to the transaction identifier to be queried; If it is determined based on the Bloom filter corresponding to the block to be archived that the transaction to be queried does not exist, a result indicating that the transaction query failed is returned.

12. The method according to claim 1, characterized in that The block data archiving request further includes permission information, and determining the first storage node from a plurality of storage nodes included in the storage cluster based on the block data archiving request includes: Based on the permission information, the first storage node is determined from the plurality of storage nodes.

13. The method according to claim 12, characterized in that The higher the authority of the blockchain node identified by the authority information, the faster the reading and writing speed of the first storage node.

14. The method according to claim 1, characterized in that The method further comprises: A second storage node is determined from the multiple storage nodes so that the second storage node obtains and archives the block data to be archived, the second storage node and the first storage node are different storage nodes, and the remaining storage space of the second storage node is greater than or equal to the storage space required for the block data to be archived.

15. A method for processing block data, characterized in that: The method comprises: Obtaining a data query request from a blockchain node, wherein the data query request includes a to-be-queried identifier, and the to-be-queried identifier is a to-be-queried block identifier or a to-be-queried transaction identifier; If it is determined based on the data query request that the cache stores the data to be queried corresponding to the identifier to be queried, the data to be queried is sent to the blockchain node, and the cache stores data with a query frequency greater than a preset frequency threshold; If it is determined based on the data query request that the cache does not store the data to be queried corresponding to the identifier to be queried, and the data to be queried is stored in the decompressed block, the data to be queried is loaded into the cache, and the data to be queried is sent to the blockchain node; If it is determined based on the data query request that the data to be queried corresponding to the identifier to be queried is not stored in the cache, and the data to be queried is not stored in the decompressed block, the block corresponding to the identifier to be queried is decompressed from the uncompressed block, the data to be queried is loaded into the cache, and the data to be queried is sent to the blockchain node.

16. A block data processing device, characterized in that: The device comprises: an acquisition unit, a determination unit and a storage unit; The acquisition unit is used to acquire a block data archiving request from a blockchain node, wherein the block data archiving request includes block data to be archived; The determining unit is configured to determine, based on the block data archiving request, a first storage node from a plurality of storage nodes included in the storage cluster, wherein the remaining storage space of the first storage node is greater than or equal to the storage space required by the block data to be archived, and the remaining storage space is the remaining storage space of the storage node; The storage unit is used to store the block data to be archived in a first message queue corresponding to the first storage node, so that the first storage node obtains and archives the block data to be archived from the first message queue.

17. A block data processing device, characterized in that: The device comprises: an acquisition unit, a sending unit, a loading unit and a decompression unit; The acquisition unit is used to acquire a data query request from a blockchain node, wherein the data query request includes a to-be-queried identifier, and the to-be-queried identifier is a to-be-queried block identifier or a to-be-queried transaction identifier; The sending unit is configured to send the to-be-queried data to the blockchain node if it is determined based on the data query request that the to-be-queried data corresponding to the to-be-queried identifier is stored in the cache, wherein the cache stores data with a query frequency greater than a preset frequency threshold; The loading unit is configured to load the data to be queried into the cache and send the data to be queried to the blockchain node if it is determined based on the data query request that the data to be queried corresponding to the identifier to be queried is not stored in the cache and the data to be queried is stored in the decompressed block; The decompression unit is used to decompress the block corresponding to the to-be-queried identifier from the uncompressed block, load the to-be-queried data into the cache, and send the to-be-queried data to the blockchain node if it is determined based on the data query request that the to-be-queried data corresponding to the to-be-queried identifier is not stored in the cache, and the to-be-queried data is not stored in the decompressed block.

18. A computer device, characterized in that: The computer device comprises a processor and a memory: The memory is used to store a computer program and transmit the computer program to the processor; The processor is configured to execute the method of any one of claims 1 to 15 or the method of claim 16 according to the computer program.

19. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method according to any one of claims 1 to 15, or to execute the method according to claim 16.

20. A computer program product comprising a computer program, characterized in that When the method is executed on a computer device, the computer device executes the method according to any one of claims 1 to 15, or executes the method according to claim 16.