Data processing method and device based on block chain and readable storage medium

By archiving transaction data at the transaction level in the blockchain, and obtaining an index based on the comparison of occupied space with a threshold, and storing it in the archiving device, the problem of insufficient blockchain storage resources is solved, and efficient storage resource management and query performance optimization are achieved.

CN120910057APending Publication Date: 2025-11-07TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410554161.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-06
Publication Date
2025-11-07

AI Technical Summary

Technical Problem

The blockchain suffers from insufficient storage resources, leading to problems such as insufficient storage space and slow response as data continues to increase.

Method used

By comparing the space occupied by the transaction data with the archiving threshold, if the threshold is exceeded, the transaction index is obtained and the data is sent to the archiving device for storage. The data is then deleted from the blockchain. A transaction-granular archiving method is adopted to dynamically select the transactions that need to be archived.

Benefits of technology

It reduces the storage burden on the blockchain, improves the efficiency of storage resource utilization, and optimizes query performance and system flexibility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120910057A_ABST
    Figure CN120910057A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a block chain-based data processing method and device and a readable storage medium, and the method comprises the steps: obtaining first transaction data in a first block, obtaining a first transaction archiving threshold value corresponding to the first block, and comparing the occupied space of the first transaction data with the first transaction archiving threshold value; if the occupied space of the first transaction data is equal to or greater than a first transaction archiving threshold value, obtaining a transaction index corresponding to the first transaction data; sending the first transaction data carrying the transaction index to an archiving device, so that the archiving device stores the first transaction data according to the transaction index; and obtaining a transaction archiving success message for the first transaction data returned by the archiving device, and deleting the first transaction data in the first block according to the transaction archiving success message. According to the invention, the storage resources of the block chain can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of Internet, and particularly relates to a data processing method and device based on a block chain and a readable storage medium. BACKGROUND

[0002] With the rapid development of network technology and the emphasis of enterprises on data security, the block chain has been greatly valued and applied.

[0003] For a block chain with public credibility, the storage space is limited, so as the block chain continuously works, the stored data will continuously increase, at this time, the block chain will face the dilemma of insufficient storage resources. SUMMARY

[0004] The embodiments of the present application provide a data processing method, device and readable storage medium based on a block chain, which can alleviate the storage resources of the block chain.

[0005] The embodiments of the present application provide a data processing method based on a block chain, the method is executed by a first block chain node, and the method comprises the following steps:

[0006] acquiring first transaction data in a first block, acquiring a first transaction archiving threshold corresponding to the first block, and comparing the occupied space of the first transaction data with the first transaction archiving threshold;

[0007] if the occupied space of the first transaction data is equal to or greater than the first transaction archiving threshold, acquiring a transaction index corresponding to the first transaction data;

[0008] sending the first transaction data carrying the transaction index to an archiving device, so that the archiving device stores the first transaction data according to the transaction index;

[0009] acquiring a transaction archiving success message returned by the archiving device for the first transaction data, and deleting the first transaction data in the first block according to the transaction archiving success message.

[0010] The embodiments of the present application provide a data processing device based on a block chain, the device runs in a first block chain node, and the device comprises the following steps:

[0011] an acquisition module, configured to acquire first transaction data in a first block, acquire a first transaction archiving threshold corresponding to the first block, and compare the occupied space of the first transaction data with the first transaction archiving threshold;

[0012] the acquisition module is further configured to acquire a transaction index corresponding to the first transaction data if the occupied space of the first transaction data is equal to or greater than the first transaction archiving threshold;

[0013] The sending module is configured to send the first transaction data carrying the transaction index to the archiving device, so that the archiving device stores the first transaction data according to the transaction index;

[0014] The deleting module is configured to acquire the transaction archiving success message for the first transaction data returned by the archiving device, and delete the first transaction data in the first block according to the transaction archiving success message.

[0015] In a possible implementation, the acquiring module acquires the first transaction data in the first block, and is configured to perform the following operations:

[0016] According to the number of active blocks, determine active blocks in the block chain; the number of active blocks is the number of active blocks; the active block refers to a block that does not undergo archiving processing;

[0017] Determine blocks other than the active blocks in the block chain as archiving blocks; the block height of the archiving block is less than the block height of the active block; the archiving block refers to a block that undergoes archiving processing; the archiving block includes the first block;

[0018] Acquire the first transaction data in the first block.

[0019] In a possible implementation, the acquiring module is further configured to perform the following operations:

[0020] Acquire an archiving gradient rule; the archiving gradient rule includes the number of active blocks and the block numbers corresponding to a plurality of transaction archiving thresholds respectively; the number of active blocks is used to indicate the number of blocks in the block chain that do not undergo archiving processing; the block number corresponding to one transaction archiving threshold is used to indicate the number of archiving blocks corresponding to the one transaction archiving threshold;

[0021] If the number of blocks in the block chain is less than or equal to the number of active blocks, determine the blocks in the block chain as active blocks;

[0022] If the number of blocks in the block chain is greater than the number of active blocks, determine the active blocks in the block chain and the archiving blocks corresponding to a plurality of transaction archiving thresholds according to the archiving gradient rule; the block height of the active block is greater than the block heights of the plurality of archiving blocks respectively; the plurality of transaction archiving thresholds include the first transaction archiving threshold; the plurality of archiving blocks include the first block.

[0023] In a possible implementation, the plurality of transaction archiving thresholds include a transaction archiving threshold B c and a transaction archiving threshold B c+1 c is a positive integer and c is less than the total number of the plurality of transaction archiving thresholds;

[0024] The acquisition module determines, according to the archiving gradient rule, an active block in the blockchain and an archiving block corresponding to each of the plurality of transaction archiving thresholds, for performing the following operations:

[0025] If the transaction archiving threshold B c is greater than the transaction archiving threshold B c+1 , it is determined that the transaction archiving threshold B c corresponds to a block priority greater than the transaction archiving threshold B c+1 .

[0026] The block priority corresponding to the number of active blocks is determined to be greater than the block priority corresponding to each of the plurality of transaction archiving thresholds.

[0027] According to the block priority corresponding to the number of active blocks, the active block is determined in the blockchain.

[0028] According to the block priority corresponding to each of the plurality of transaction archiving thresholds, the archiving block corresponding to each of the plurality of transaction archiving thresholds is determined in the blockchain.

[0029] In a possible implementation, the acquisition module determines, according to the block priority corresponding to each of the plurality of transaction archiving thresholds, the archiving block corresponding to each of the plurality of transaction archiving thresholds in the blockchain, for performing the following operations:

[0030] A first number of first remaining blocks in the blockchain other than the active block is determined.

[0031] If the transaction archiving threshold B c is the maximum transaction archiving threshold in the plurality of transaction archiving thresholds, and the first number is greater than the block number corresponding to the transaction archiving threshold B c , the block adjacent to the active block and having a number of blocks corresponding to the transaction archiving threshold B c in the first remaining blocks is determined as the archiving block corresponding to the transaction archiving threshold B c .

[0032] A second remaining block in the first remaining blocks other than the archiving block corresponding to the transaction archiving threshold B c is determined.

[0033] According to the block priority corresponding to the second transaction archiving threshold, the archiving block corresponding to the second transaction archiving threshold is determined in the second remaining block; the second transaction archiving threshold includes a transaction archiving threshold other than the transaction archiving threshold B c in the plurality of transaction archiving thresholds.

[0034] In a possible implementation, the acquisition module is further configured to perform the following operations:

[0035] If the transaction archiving threshold B c is the maximum transaction archiving threshold in the plurality of transaction archiving thresholds, and the first number is greater than the block number corresponding to the transaction archiving threshold B c , the block adjacent to the active block and having a number of blocks corresponding to the transaction archiving threshold B c in the first remaining blocks is determined as the archiving block corresponding to the transaction archiving threshold B c .c The largest transaction archiving threshold among multiple transaction archiving thresholds, and the first number is less than or equal to the transaction archiving threshold B. c The corresponding number of blocks is used to determine the first remaining block as the transaction archiving threshold B. c The corresponding archived block; the first transaction archive threshold is transaction archive threshold B. c ; Transaction archiving threshold B c The corresponding archived blocks include the first block;

[0036] The empty set is identified as the archive block corresponding to the second transaction archiving threshold.

[0037] In one possible implementation, the acquisition module obtains the first transaction archiving threshold corresponding to the first block and performs the following operations:

[0038] From multiple archive blocks, determine the archive block to which the first block belongs;

[0039] Among multiple transaction archiving thresholds, the transaction archiving threshold corresponding to the archiving block to which the first block belongs is determined as the first transaction archiving threshold.

[0040] In one possible implementation, the acquisition module will obtain the first transaction archiving threshold corresponding to the first block, and use it to perform the following operations:

[0041] At the first moment, the first transaction archiving threshold corresponding to the first block is obtained; at the first moment, the blockchain includes the second block with the largest block height; the second block is an active block;

[0042] The acquisition module is also used to perform the following operations:

[0043] If the space occupied by the first transaction data is less than the first transaction archiving threshold, then at the second time point, the third transaction archiving threshold corresponding to the first block is determined according to the archiving gradient rule and the third block; the third block is the block with the maximum block height in the blockchain at the second time point; the second time point is later than the first time point; the block height of the third block is greater than the block height of the second block;

[0044] If the third transaction archiving threshold is different from the first transaction archiving threshold, then the space occupied by the first transaction data is compared with the third transaction archiving threshold; if the third transaction archiving threshold is less than the first transaction archiving threshold, and the third transaction archiving threshold belongs to multiple transaction archiving thresholds;

[0045] If the space occupied by the first transaction data is equal to or greater than the third transaction archiving threshold, then the first transaction data will be archived.

[0046] In a possible implementation, the obtaining module determines, according to the archiving gradient rule and the third block, a third transaction archiving threshold corresponding to the first block, for performing the following operations:

[0047] According to the archiving gradient rule, determine the update active block in the block chain with the third block, and the update archiving block corresponding to the plurality of transaction archiving thresholds; the block height of the update active block is greater than the block height of the active block; the block height of the plurality of update archiving blocks is greater than the block height of the plurality of archiving blocks;

[0048] From the plurality of update archiving blocks, determine the update archiving block to which the first block belongs;

[0049] Among the plurality of transaction archiving thresholds, the transaction archiving threshold corresponding to the update archiving block to which the first block belongs is determined as the third transaction archiving threshold.

[0050] In a possible implementation, the obtaining module is further configured to perform the following operations:

[0051] Obtain an archiving rule obtaining request sent by the business device, and return the archiving gradient rule to the business device according to the archiving rule obtaining request;

[0052] Obtain a maximum block height obtaining request sent by the business device, and return the maximum block height of the block chain to the business device according to the maximum block height obtaining request, so that the business device determines a predicted transaction archiving threshold corresponding to the first transaction data according to the predicted block height of the first transaction data, the archiving gradient rule and the maximum block height; the predicted transaction archiving threshold is used for comparison processing with the predicted occupied space of the first transaction data generated by the business device; the comparison processing is used for determining an archiving prediction result of the first transaction data;

[0053] If the archiving prediction result is a to-be-archived prediction result, obtain a transaction query request including a transaction index sent by the business device;

[0054] Generate a transaction archiving message according to the transaction query request; the transaction archiving message is used to indicate that the first transaction data indicated by the transaction index has been archived to the archiving device;

[0055] Return the transaction archiving message to the business device, so that the business device sends the transaction query request to the archiving device according to the transaction archiving message; the archiving device returns the first transaction data to the business device according to the transaction index in the transaction query request.

[0056] In a possible implementation, if the archiving prediction result is an already-archived prediction result, the business device is configured to send the transaction query request to the archiving device; and the archiving device is configured to return the first transaction data to the business device according to the transaction index in the transaction query request.

[0057] In a possible implementation, the sending module sends the first transaction data carrying the transaction index to the archiving device, so that the archiving device stores the first transaction data according to the transaction index, for performing the following operations:

[0058] The first transaction data carrying the transaction index is signed by using the node private key, to obtain a data signature;

[0059] The archiving component is invoked, and the first transaction data carrying the data signature and the transaction index is sent to the archiving device by using the archiving component, so that the archiving device verifies the data signature by using the node public key, to obtain a verification result; the verification result includes a verification success result; the verification success result indicates that the first transaction data carrying the transaction index has a legal attribute, and the verification success result indicates that the archiving device stores the first transaction data according to the transaction index.

[0060] In a possible implementation, the sending module is further configured to perform the following operations:

[0061] A transaction deletion message including the transaction index is generated, and the transaction deletion message is sent to the second blockchain node, so that the second blockchain node deletes the first transaction data according to the transaction index in the transaction deletion message.

[0062] An aspect of the present application provides a computer device, including: a processor, a memory, and a network interface.

[0063] The processor is connected with the memory and the network interface, the network interface is configured to provide a data communication function, the memory is configured to store a computer program, and the processor is configured to invoke the computer program, so that the computer device executes the method in the embodiments of the present application.

[0064] An aspect of the embodiments of the present application provides a computer readable storage medium, the computer readable storage medium stores a computer program, and the computer program is suitable for being loaded by a processor and executing the method in the embodiments of the present application.

[0065] An aspect of the embodiments of the present application provides a computer program product, which includes a computer program stored in a computer readable storage medium; a processor of a computer device reads the computer program from the computer readable storage medium, and the processor executes the computer program, so that the computer device executes the method in the embodiments of the present application.

[0066] In the embodiment of the present application, the computer device obtains first transaction data in a first block, obtains a first transaction archiving threshold corresponding to the first block, compares the occupied space of the first transaction data with the first transaction archiving threshold, and if the occupied space of the first transaction data is equal to or greater than the first transaction archiving threshold, obtains a transaction index corresponding to the first transaction data. The first transaction data carrying the transaction index is sent to the archiving device, so that the archiving device stores the first transaction data according to the transaction index. The transaction archiving success message returned by the archiving device for the first transaction data is obtained, and the first transaction data is deleted in the first block according to the transaction archiving success message. As can be seen from the above, the embodiment of the present application can archive transaction data equal to or greater than the transaction archiving threshold. Through archiving, the storage of the blockchain for transaction data with large occupied space can be reduced, so that the storage resources can be reduced. BRIEF DESCRIPTION OF DRAWINGS

[0067] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or the prior art description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0068] Figure 1 is a system architecture schematic diagram provided by the embodiment of the present application;

[0069] Figure 2 is a scene schematic diagram of data processing based on a blockchain provided by the embodiment of the present application Figure 1 ;

[0070] Figure 3 is a flow schematic diagram of a data processing method based on a blockchain provided by the embodiment of the present application Figure 1 ;

[0071] Figure 4 is a schematic diagram of the internal structure of a blockchain node provided by the embodiment of the present application;

[0072] Figure 5 is a flow schematic diagram of a data processing method based on a blockchain provided by the embodiment of the present application Figure 2 ;

[0073] Figure 6 is a scene schematic diagram of data processing based on a blockchain provided by the embodiment of the present application Figure 2 ;

[0074] Figure 7 is a flow schematic diagram of a data processing method based on a blockchain provided by the embodiment of the present application Figure 3 ;

[0075] Figure 8 is a flowchart of a data processing method based on a blockchain provided by an embodiment of the present application Figure 4 ;

[0076] Figure 9 is a structural diagram of a data processing device based on a blockchain provided by an embodiment of the present application

[0077] Figure 10 is a structural diagram of a computer device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0078] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative labor fall within the scope of protection of the present application.

[0079] For the convenience of understanding, first, some nouns are simply explained as follows:

[0080] 1. Blockchain: In a narrow sense, blockchain is a chain-like data structure with blocks as basic units, which uses digital digest to verify the transaction history obtained before, and is suitable for the needs of tamper resistance and scalability in a distributed accounting scenario; in a broad sense, blockchain also refers to the distributed accounting technology realized by the blockchain structure, including distributed consensus, privacy and security protection, point-to-point communication technology, network protocol, smart contract, etc. The goal of blockchain is to realize a distributed data record book, which only allows addition and does not allow deletion. The basic structure at the bottom of the book is a linear linked list. The linked list is composed of a series of "blocks", and the hash value of the predecessor block is recorded in the successor block. Whether each block (and the transaction in the block) is legal can be quickly verified by calculating the hash value. If a node in the network proposes to add a new block, it must go through a consensus mechanism to reach a consensus on the block.

[0081] For a blockchain with public credibility, its computing resources and storage space are limited, so when the number of blocks increases continuously, the available storage space corresponding to the blockchain with public credibility may not be enough, and the response may be slower than the request, at which time the storage space of the blockchain needs to be relieved.

[0082] 2. Blockchain: The blockchain is the core data structure in a blockchain system, used to store and manage all confirmed blocks. The blockchain is organized in a chain structure, each block contains a set of transactions, a block header (including the hash of the previous block, timestamp, and other metadata), and other information. The blockchain provides a public, tamper-proof transaction history for the blockchain system, ensuring transparency and consistency of the system.

[0083] 3. Transaction Pool: The transaction pool (also known as the mempool or mempool) is a data structure in the blockchain network used to store pending transactions that have not yet been packaged into blocks. When a business device submits a new transaction to the blockchain network, the transaction will first enter the transaction pool. When a blockchain node prepares to generate a new block, it will select a certain number of transactions from the transaction pool for packaging. The transaction pool helps improve the processing capacity of the blockchain network, and also serves as a strategy to allow block nodes to preferentially select transactions with higher fees for packaging, thereby increasing block income.

[0084] 4. Block data archiving: Block data archiving refers to the process of transferring old block data in the blockchain from the main storage (usually a high-performance and high-cost storage system) to the archiving center (referred to as the archiving device in this application). This process usually involves data backup, migration, and storage management. The purpose of block data archiving is to optimize the use of main storage space, maintain the efficient operation of the blockchain network, and ensure the integrity and accessibility of old data.

[0085] 5. Archiving Center: The archiving center, also referred to as the archiving device in this application, is a system or service specifically designed for long-term storage of blockchain data. Its main purpose is to alleviate the storage burden of the blockchain network by transferring data that is no longer frequently accessed to a more economical storage solution. The archiving center usually has high-capacity storage capabilities and can ensure data integrity and retrievability. In the blockchain system, the archiving center can be a distributed network or a centralized data warehouse, which can receive archiving requests from blockchain nodes and store corresponding block data according to preset rules or strategies. In this application, the blockchain node is the one that stores transaction data to the archiving center.

[0086] 6. Hash: Also known as information characteristic value or characteristic value, the hash value is generated by hashing algorithm to convert input data of arbitrary length into password and fixed output, and the original input data cannot be retrieved by decrypting the hash value, it is a one-way encryption function. Hash value is the potential core foundation and the most important aspect of blockchain technology, which preserves the authenticity of the record and the integrity of the blockchain as a whole.

[0087] 7. Blockchain node: The blockchain network distinguishes nodes into consensus nodes (also known as core nodes, full nodes) and business nodes (also known as light nodes). Among them, the consensus node is responsible for the consensus business of the whole blockchain network; the business node is responsible for synchronizing the account book information of the consensus node, that is, synchronizing the latest block data. Whether it is a consensus node or a business node, its internal structure includes a network communication component, because the blockchain network is essentially a peer-to-peer network, and it needs to communicate with other nodes in the blockchain network through the network communication component. The resources and services in the blockchain network are distributed on each node, and the transmission of information and the implementation of services are directly between nodes, without the need for intermediate links or centralized servers (third parties) to intervene.

[0088] Please refer to Figure 1 , Figure 1 is a system architecture diagram provided by an embodiment of the present application. As Figure 1 indicated, the system architecture can be a blockchain network 10, wherein the blockchain network 10 can include a witness network 10a (also known as a business network) and a consensus network 10b; the nodes in the witness network 10a can be called business nodes, which have part of the data, and the business nodes mainly perform business execution and do not participate in the accounting consensus, and obtain block header data and part of the authorized visible data from the consensus network 10b through identity authentication. The consensus network 10b can also be called a core network and an accounting network, and the nodes in the consensus network 10b can be called consensus nodes, which have full data. The witness network 10a and the consensus network 10b are in different network environments, and generally, the witness network 10a is in a public network and the consensus network 10b is in a private network, and the two interact through a routing boundary.

[0089] Please refer to Figure 1 , the witness network 10a can include a business node 101a, a business node 102a, a business node 103a, …, and a business node 104a. It can be understood that the above-mentioned witness network 10a can include one or more witness networks, and in actual application, due to different application scenarios, one or more types of witness networks can be set, and here the number of witness networks will not be limited. The above-mentioned witness network 10a can include one or more business nodes, and here the number of business nodes will not be limited.

[0090] Please refer to Figure 1The consensus network 10b can include a consensus node 101b, a consensus node 102b, a consensus node 103b, …, and a consensus node 104b. It can be understood that the consensus network 10b described above can include one or more consensus networks. In actual applications, due to different application scenarios, one or more types of consensus networks can be set, and the number of consensus networks will not be limited here. The consensus network 10b described above can include one or more consensus nodes, and the number of consensus nodes will not be limited here.

[0091] Each blockchain node (including the consensus nodes in the consensus network 10b and the business nodes in the witness network 10a) can receive a business transaction sent by a client when normally working, generate a block based on the received business transaction, and then perform block chaining processing. It can be understood that in the specific embodiments of the present application, the data related to user information (such as business transactions) needs to obtain user permission or consent when the embodiments of the present application are applied to specific products or technologies, and the collection, use, and processing of related data need to comply with relevant laws, regulations, and standards in the relevant region.

[0092] In order to ensure data intercommunication between each blockchain node, data connections can exist between each blockchain node, such as a data connection between the business node 101a and the business node 102a, a data connection between the business node 101a and the business node 103a, and a data connection between the consensus node 101b and the consensus node 104b.

[0093] Further, the witness network 10a and the consensus network 10b have data connections, such as a data connection between the business node 101a and the consensus node 102b, a data connection between the business node 101a and the consensus node 103b, and a data connection between the consensus node 101b and the business node 104a.

[0094] It can be understood that the blockchain nodes can transmit data or blocks through the data connections described above. The data connections between the blockchain nodes described above can be based on node identifiers. Each blockchain node in the blockchain network 10 has a node identifier corresponding thereto, and each blockchain node described above can store the node identifiers of other blockchain nodes having a connection relationship with itself, so as to subsequently broadcast the obtained data or generated blocks to other blockchain nodes according to the node identifiers of other blockchain nodes. For example, the business node 101a can maintain a node identifier list as shown in Table 1, which saves the node names and node identifiers of other blockchain nodes.

[0095] Table 1

[0096] Node name Node identification Consensus node 101b AAAAA Consensus node 102b BBBBB … … Consensus node 104b CCCCC Business node 102a DDDDD Business node 103a EEEEE … …

[0097] The node identifier can be an Internet Protocol (IP) address and any other information that can be used to identify a blockchain node in a blockchain network.

[0098] Assuming that the node identifier of the service node 101a is FFFFF, the service node 101a can send a to-be-chained service transaction to the consensus node 104b through the node identifier CCCCC, and the consensus node 104b can determine that the to-be-chained service transaction is sent by the service node 101a through the node identifier FFFFF. Similarly, the consensus node 104b can send a block consensus request to the consensus node 102b through the node identifier BBBBB, and the consensus node 102b can determine that the block consensus request is sent by the consensus node 104b through the node identifier CCCCC. The data transmission between other blockchain nodes is also the same, and thus will not be described one by one.

[0099] It can be understood that the data connection described above is not limited to the connection manner, and can be directly or indirectly connected through a wired communication manner, directly or indirectly connected through a wireless communication manner, or connected through other connection manners, which are not limited in the present application.

[0100] It can be understood that the data processing method based on a blockchain provided in the embodiments of the present application can be executed by a computer device, which includes but is not limited to a service node (which can be a terminal device or a server) or a consensus node (which can be a terminal device or a server). The server can be a stand-alone physical server, a server cluster or a distributed system composed of multiple physical servers, a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content distribution networks (CDN), and basic cloud computing services such as big data and artificial intelligence platforms. The terminal device includes but is not limited to a mobile phone, a computer, a smart voice interaction device, a smart home appliance, a vehicle-mounted terminal, an aircraft, etc. The terminal device and the server can be directly or indirectly connected through a wired or wireless manner, which is not limited in the embodiments of the present application.

[0101] Further, referring to Figure 2 , Figure 2 is a scene diagram of a data processing method based on a blockchain provided in the embodiments of the present application Figure 1 . The implementation process of the data processing method based on a blockchain can be performed in a first blockchain node in a blockchain network, wherein the first blockchain node can be the service node 101a or the consensus node 104b described above. Figure 1any one of the blockchain nodes in the blockchain network 10 of the corresponding embodiment, Figure 2 Take the blockchain node 20a as an example.

[0102] As shown in Figure 2 The blockchain node 20a stores a first block 201a, which can include a plurality of transactions, Figure 2 The example first block 201a includes transaction 1, transaction 2, and transaction 3. When the first block 201a belongs to the archive block, the blockchain node 20a performs the occupied space identification processing on each transaction in the first block 201a, Figure 2 Take transaction 1 as the first transaction data 20b. The blockchain node 20a obtains the occupied space 201b of transaction 1, Figure 2 The occupied space 201b of transaction 1 is exemplified as 6 kilobytes (Kbytes, abbreviated as kb). According to the block height of the first block 201a and the current highest block height of the blockchain, the blockchain node 201a obtains the first transaction archive threshold 20c corresponding to the first block 201a, Figure 2 The first transaction archive threshold 20c is exemplified as 5 kilobytes (abbreviated as 5 kb).

[0103] As shown in Figure 2 The blockchain node 20a compares the first transaction archive threshold 20c and the occupied space 201b of transaction 1. Obviously, the occupied space 201b (exemplified as 6 kb) is greater than the first transaction archive threshold 20c (exemplified as 5 kb), so the blockchain node 20a obtains the transaction index 202b corresponding to transaction 1 (representing the first transaction data 20b). The transaction index 202b can be any information that can be used to uniquely identify transaction 1 in the blockchain, Figure 2 Take the transaction hash of transaction 1 as the transaction index 202b of transaction 1, that is, Figure 2 ABC4g...df in

[0104] Further, the blockchain node 20a carries the first transaction data 20b (exemplified as ABC4g...df) of the transaction index 202b (exemplified as ABC4g...df) to the first block 201a, Figure 2 Figure 2 ​The first transaction data 20b is sent to an archiving device 20d, where the archiving device 20d includes but is not limited to a terminal device or a server. The server can be a standalone physical server, a server cluster composed of multiple physical servers, or a distributed system, and can also be a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and basic cloud computing services such as big data and artificial intelligence platforms. The terminal device includes but is not limited to a mobile phone, a computer, a smart voice interaction device, a smart home appliance, a vehicle-mounted terminal, an aircraft, and the like.

[0105] The archiving device 20d stores the first transaction data 20b according to the transaction index 202b, for example Figure 2 The example uses the transaction index as the index key and the transaction (transaction data) as the index value to construct an index key-value pair and store the index key-value pair. Figure 2 The example index key-value table 20e includes three index key-value pairs. The first index key-value pair includes the index key generated by Sfg56...87 and the index value generated by transaction a. The second index key-value pair includes the index key generated by Df53b...ju and the index value generated by transaction b. The third index key-value pair includes the index key generated by ABC4g...df and the index value generated by transaction 1.

[0106] Subsequently, the archiving device 20d returns a transaction archiving success message for the first transaction data 20b (such as Figure 2 The example transaction 1) to the blockchain node 20a, so that the blockchain node 20a can delete the first transaction data 20b in the first block 201a according to the transaction archiving success message, such as Figure 2 As shown, the blockchain node 20a deletes transaction 1 in the first block 201a to obtain the block 202a after deleting transaction 1. It can be understood that the data in the block header in the block 202a will not change, that is, transaction 1 is not included in the block body.

[0107] The transaction data described in the embodiments of the present application includes business transactions and transaction execution results. It can be understood that for Figure 3 The processing process of the blockchain node 20a for transaction 2 and transaction 3 in the block 201a is the same as that for transaction 1, and thus is not described here.

[0108] As can be seen from the above, the embodiment of the application proposes a transaction granularity archiving. Compared with block granularity archiving, transaction granularity archiving is a more refined data archiving method. Instead of archiving the data of the entire block, it determines whether to archive based on the size, importance or other specific standards of a single transaction. This method allows the system to dynamically select which transactions need to be archived and which can be retained in the main storage according to the characteristics of each transaction. Transaction granularity archiving can improve the utilization efficiency of storage resources, reduce unnecessary archiving operations, and also optimize query performance according to the access frequency and importance of transactions. This method provides higher flexibility and scalability for blockchain data management.

[0109] Further, please refer to Figure 3 , Figure 1 is a flowchart of a data processing method based on a blockchain provided by the embodiment of the application Figure 3 . The data processing method based on a blockchain can be executed by a first blockchain node in a blockchain network, wherein the first blockchain node can be any blockchain node in the blockchain network. As shown in Figure 2 , the data processing method based on a blockchain can at least include the following steps S101-S104.

[0110] Step S101, acquiring first transaction data in a first block, acquiring a first transaction archiving threshold corresponding to the first block, and comparing the occupied space of the first transaction data with the first transaction archiving threshold.

[0111] Specifically, according to the number of active blocks, an active block is determined in the blockchain; the number of active blocks is the number of active blocks; the active block refers to a block that is not subject to archiving processing; a block in the blockchain other than the active block is determined as an archiving block; the block height of the archiving block is less than the block height of the active block; the archiving block refers to a block that is subject to archiving processing; the archiving block includes the first block; the first transaction data in the first block is acquired.

[0112] Specifically, from a plurality of archiving blocks, the archiving block to which the first block belongs is determined; from a plurality of transaction archiving thresholds, the transaction archiving threshold corresponding to the archiving block to which the first block belongs is determined as the first transaction archiving threshold.

[0113] It can be understood that, compared with the blocks with low block height in the blockchain, the newly generated blocks in the blockchain are accessed or queried more frequently, so according to the block height, the blocks in the blockchain can be determined as the archived blocks and the active blocks. For example, the blockchain includes 1000 blocks, and it can also be understood that the current maximum block height of the blockchain is 1000, and the number of active blocks is an adjustable parameter, which can be set according to the actual application scenario. In order to facilitate understanding and description, the number of active blocks is exemplified as 100, and the latest 100 blocks generated in the blockchain can be determined as active blocks, that is, the latest 100 blocks do not need to be archived, and the blocks in the blockchain other than the active blocks belong to the blocks that need to be archived, that is, the archived blocks. Any one of the archived blocks can be referred to as a first block.

[0114] In step S102, if the occupied space of the first transaction data is equal to or greater than the first transaction archiving threshold, the transaction index corresponding to the first transaction data is obtained.

[0115] Specifically, the first transaction data can include business transactions and transaction execution results. The application embodiments do not limit the transaction types of business transactions, including but not limited to business transactions corresponding to the financial service industry, business transactions corresponding to the supply chain, business transactions corresponding to the medical service industry, business transactions corresponding to legal compliance and audit, and business transactions corresponding to big data analysis.

[0116] The occupied space of the first transaction data refers to the space occupied by the first transaction data in the blockchain, and the first transaction archiving threshold refers to the threshold for evaluating whether the transaction data (including the first transaction data) in the block (including the first block) can be archived, which is an adjustable parameter, that is, the value can be set according to the actual application scenario.

[0117] The transaction index can be any information that can be used to uniquely identify the first transaction data. The above Figure 4 The transaction index 202b of transaction 1 is exemplified by the transaction hash of transaction 1. In the actual application scenario, the transaction index can be one or a combination of at least two of the following: transaction hash, transaction sequence number in the blockchain, block height, and combination of transaction sequence number in the block.

[0118] In step S103, the first transaction data carrying the transaction index is sent to the archiving device, so that the archiving device stores the first transaction data according to the transaction index.

[0119] Specifically, the first transaction data carrying the transaction index is signed by the node private key to obtain a data signature; the archiving component is called, and the first transaction data carrying the data signature and the transaction index is sent to the archiving device through the archiving component, so that the archiving device verifies the data signature by the node public key to obtain a verification result; the verification result includes a verification success result; the verification success result indicates that the first transaction data carrying the transaction index has a legal attribute, and the verification success result indicates that the archiving device stores the first transaction data according to the transaction index.

[0120] In step S104, a transaction archiving success message for the first transaction data returned by the archiving device is obtained, and the first transaction data is deleted in the first block according to the transaction archiving success message.

[0121] Specifically, a transaction deletion message including the transaction index is generated, and the transaction deletion message is sent to the second blockchain node, so that the second blockchain node deletes the first transaction data according to the transaction index in the transaction deletion message.

[0122] The second blockchain node includes the remaining blockchain nodes in the blockchain network except the first blockchain node.

[0123] The embodiment of the application provides a kind of dynamic blockchain data archiving scheme system architecture based on transaction granularity and block height. The internal implementation of blockchain node (including first blockchain node) is specifically described below, the interaction between each component. Please see Figure 4 , Figure 5 is a schematic diagram of the internal structure of a blockchain node provided by the embodiment of the application, which is described in detail as follows:

[0124] 1. Network component: The network component is responsible for communication between blockchain nodes, including data sending and receiving. It handles all network protocol related tasks, such as connection management, data transmission, node discovery and information broadcast. The network component ensures that the blockchain node can correctly transmit information in the blockchain network and keep synchronized with other blockchain nodes.

[0125] 2. Verification component: The verification component is responsible for checking the validity of transactions and blocks. This component usually contains two sub-components:

[0126] 2.1 Certificate verification sub-component: responsible for verifying identity certificates in the blockchain network to ensure that the source of transactions or blocks is trustworthy.

[0127] 2.2 Permission verification sub-component: responsible for checking whether the entity initiating the transaction has the permission to execute the transaction, and whether the transaction complies with the rules of the network.

[0128] 3. Transaction Pool Component: The transaction pool component is a temporary storage area for transactions waiting to be packaged into blocks. When transactions are received by network nodes, they are first placed in the transaction pool, and then selected and added to a new block according to certain rules (such as fees, timestamps, etc.).

[0129] 4. Scheduling Component: The scheduling component is responsible for managing the core business logic of the blockchain node, including the following sub-components:

[0130] 4.1 Block Generator: Responsible for creating new blocks. It selects transactions from the transaction pool, performs necessary verification, and packages them into a new block.

[0131] 4.2 Transaction Scheduling Component: Responsible for deciding which transactions should be included in the next block, possibly based on transaction fees, priority, etc.

[0132] 4.3 Contract Repository: Stores the code and related metadata of smart contracts.

[0133] 4.4 Contract Process Pool: Responsible for the environment for executing smart contracts, which can handle multiple smart contract executions in parallel.

[0134] 5. Consensus Component: The consensus component is the part of the blockchain node that implements the network consensus mechanism. It ensures the consistency of the network state among all nodes. This component can implement different consensus algorithms, such as Proof-of-Work (PoW), Proof of Stake (PoS), or Byzantine Fault Tolerance (BFT), etc.

[0135] 6. Archiving Component: The archiving component is responsible for handling the archiving process of data, including the following sub-components:

[0136] 6.1 Archiving Algorithm Model: Responsible for deciding which data should be archived, as well as the timing and method of archiving.

[0137] 6.2 Archiving Center Client: Also known as the archiving component in the present application, it serves as an interface for communication with the archiving center, responsible for sending data to the archiving center and retrieving data from it.

[0138] 6.3 Block Transaction Incremental Archiver: Responsible for implementing transaction granularity archiving, selecting transactions of large size or determined by other standards for archiving.

[0139] 7. Storage Component: The storage component is responsible for the data persistence of the node, including the following sub-components:

[0140] 7.1 State Database: stores the current state of the blockchain, such as account balances, the state of smart contracts, etc.

[0141] 7.2 Block Ledger: stores the historical data of the blockchain, including all the blocks and transaction records that have been generated.

[0142] The above components work together to ensure that the blockchain node can process transactions, generate and verify blocks, and maintain the overall state of the blockchain.

[0143] As can be seen from the above, the embodiments of the present application can archive transaction data equal to or greater than the transaction archiving threshold. Through archiving, the storage of large transaction data by the blockchain can be reduced, thereby reducing the storage resources.

[0144] Please refer to Figure 5 , Figure 2 is a flowchart of a data processing method based on a blockchain provided by an embodiment of the present application Figure 1 . The data processing method based on a blockchain can be executed by a first blockchain node, wherein the first blockchain node can be any one of the blockchain nodes in the blockchain network 10 of the above Figure 5 corresponding embodiment. As shown in Figure 6 , the method can at least include the following steps.

[0145] Step S201, obtaining an archiving gradient rule; the archiving gradient rule includes an active block quantity and a block quantity corresponding to a plurality of transaction archiving thresholds respectively; the active block quantity is used to indicate the number of blocks in the blockchain that do not undergo archiving processing; the block quantity corresponding to one transaction archiving threshold is used to indicate the number of archiving blocks corresponding to one transaction archiving threshold.

[0146] Specifically, the archiving gradient rule is not limited by the embodiments of the present application, and can be set according to actual application scenarios. For ease of understanding and description, please refer to Figure 6 , Figure 2 is a scenario diagram of a data processing method based on a blockchain provided by an embodiment of the present application Figure 6 . As shown in Figure 6 , the blockchain node 60a (as a first blockchain node) obtains an archiving gradient rule 60b, Figure 6 The example gradient rule 60b includes three important fields, namely the archiving threshold, the quantity, and the priority, wherein the archiving threshold is the transaction archiving threshold, that is, the threshold for determining whether the transaction data in the block undergoes archiving processing, Figure 6 The example illustrates five transaction archiving thresholds, which are positive infinity (+∞), 4 kilobytes (4kb), 3 kilobytes (3kb), 2 kilobytes (2kb), and 1 kilobyte (1kb).

[0147] The quantity in the archiving gradient rule 60b represents the number of blocks corresponding to a transaction archiving threshold, Figure 6 The number of blocks corresponding to the transaction archiving threshold of +∞ is 50, which can represent the number of active blocks in the embodiments of the present application; the number of blocks corresponding to the transaction archiving threshold of 4kb is 100, the number of blocks corresponding to the transaction archiving threshold of 3kb is 200, the number of blocks corresponding to the transaction archiving threshold of 2kb is 300, and the number of blocks corresponding to the transaction archiving threshold of 1kb is the remaining, which will be explained in combination with the priority.

[0148] The priority in the archiving gradient rule 60b represents the block priority, and the value is positively related to the priority, that is, the greater the value, the higher the block priority, so the block priority corresponding to the transaction archiving threshold of +∞ (taking the value of 5) is greater than the block priority corresponding to the transaction archiving threshold of 4kb (taking the value of 4), so the blockchain node first determines the block corresponding to the transaction archiving threshold of +∞, and then determines the block corresponding to the transaction archiving threshold of 4kb. It can be understood that the block corresponding to +∞ is the active block. Similarly, it can be understood that the block priority corresponding to the transaction archiving threshold of 4kb is greater than the block priority corresponding to the transaction archiving threshold of 3kb (taking the value of 3), so the blockchain node first determines the block corresponding to the transaction archiving threshold of 4kb, and then determines the block corresponding to the transaction archiving threshold of 3kb; the block priority corresponding to the transaction archiving threshold of 3kb is greater than the block priority corresponding to the transaction archiving threshold of 2kb (taking the value of 2), so the blockchain node first determines the block corresponding to the transaction archiving threshold of 3kb, and then determines the block corresponding to the transaction archiving threshold of 2kb; the block priority corresponding to the transaction archiving threshold of 2kb is greater than the block priority corresponding to the transaction archiving threshold of 1kb (taking the value of 1), so the blockchain node first determines the block corresponding to the transaction archiving threshold of 2kb, and then determines the block corresponding to the transaction archiving threshold of 1kb.

[0149] In summary, the blockchain node first acquires the block corresponding to the transaction archiving threshold of +∞, and when the number of blocks of the blockchain is greater than 50, the last generated 50 blocks are determined as the active blocks (i.e., the block corresponding to the transaction archiving threshold of +∞).

[0150] When the number of blocks of the blockchain is greater than 150, the blockchain node determines the last generated 50 blocks as the active blocks, and determines the 100 blocks adjacent to the active blocks as the archiving blocks corresponding to the transaction archiving threshold of 4kb. For ease of description, the archiving blocks corresponding to the transaction archiving threshold of 4kb are simply referred to as the first archiving blocks.

[0151] When the number of blocks in the blockchain is greater than 350, the blockchain node determines the last generated 50 blocks as active blocks, determines 100 blocks adjacent to the active blocks as the archiving blocks corresponding to the transaction archiving threshold of 4kb, i.e., the first archiving blocks, determines 200 blocks adjacent to the first archiving blocks as the archiving blocks corresponding to the transaction archiving threshold of 3kb, for the sake of description, the archiving blocks corresponding to the transaction archiving threshold of 3kb are referred to as the second archiving blocks.

[0152] When the number of blocks in the blockchain is greater than 650, the last generated 50 blocks are determined as active blocks, 100 blocks adjacent to the active blocks are determined as the archiving blocks corresponding to the transaction archiving threshold of 4kb, i.e., the first archiving blocks, 200 blocks adjacent to the first archiving blocks are determined as the archiving blocks corresponding to the transaction archiving threshold of 3kb, i.e., the second archiving blocks, 300 blocks adjacent to the second archiving blocks are determined as the archiving blocks corresponding to the transaction archiving threshold of 2kb, for the sake of description, the archiving blocks corresponding to the transaction archiving threshold of 2kb are referred to as the third archiving blocks, and the remaining blocks in the blockchain except the active blocks, the first archiving blocks, the second archiving blocks and the third archiving blocks are determined as the archiving blocks corresponding to the transaction archiving threshold of 1kb.

[0153] As can be seen from the above, the transaction archiving proposed in the embodiments of the present application has different threshold requirements for the transaction size based on different block heights, and the transactions exceeding the threshold in the blocks are put into the archiving center.

[0154] In step S202, if the number of blocks in the blockchain is less than or equal to the number of active blocks, the blocks in the blockchain are determined as active blocks.

[0155] Specifically, the number of active blocks refers to the number of blocks that do not undergo archiving processing, i.e., the number of active blocks. Please refer to Figure 6 , if the transaction archiving threshold is positive infinity, the number corresponding to the transaction archiving threshold represents the number of active blocks, Figure 6 For example, the number of active blocks is equal to 50, when the blockchain 60c is stored, since the number of blocks of the blockchain 60c is 4, i.e., the blockchain 60c includes 4 blocks, since the number of blocks is less than the number of active blocks, the blockchain node 60a determines the 4 blocks in the blockchain 60c as active blocks. Since the number of blocks is less than the number of active blocks, there are no blocks in the blockchain 60c that undergo archiving processing, i.e., there are no archiving blocks.

[0156] In step S203, if the number of blocks in the block chain is greater than the number of active blocks, the active blocks in the block chain and the archiving blocks corresponding to the plurality of transaction archiving thresholds are determined according to the archiving gradient rule; the block height of the active blocks is greater than the block height of the archiving blocks corresponding to the plurality of transaction archiving thresholds; the plurality of transaction archiving thresholds include a first transaction archiving threshold; and the plurality of archiving blocks include a first block.

[0157] Specifically, the plurality of transaction archiving thresholds include a transaction archiving threshold B c and a transaction archiving threshold B c+1 , and c is a positive integer and c is less than the total number of the plurality of transaction archiving thresholds.

[0158] If the transaction archiving threshold B c is greater than the transaction archiving threshold B c+1 , it is determined that the block priority corresponding to the transaction archiving threshold B c is greater than the block priority corresponding to the transaction archiving threshold B c+1 ; it is determined that the block priority corresponding to the number of active blocks is greater than the block priority corresponding to the plurality of transaction archiving thresholds; the active blocks in the block chain are determined according to the block priority corresponding to the number of active blocks; and the archiving blocks corresponding to the plurality of transaction archiving thresholds in the block chain are determined according to the block priority corresponding to the plurality of transaction archiving thresholds.

[0159] In the specific process of determining the archiving blocks corresponding to the plurality of transaction archiving thresholds in the block chain according to the block priority corresponding to the plurality of transaction archiving thresholds, the first number of the first remaining blocks in the block chain other than the active blocks can be determined; if the transaction archiving threshold B c is the maximum transaction archiving threshold in the plurality of transaction archiving thresholds, and the first number is greater than the number of blocks corresponding to the transaction archiving threshold B c , the blocks adjacent to the active blocks and having a number of blocks corresponding to the number of blocks corresponding to the transaction archiving threshold B c in the first remaining blocks are determined as the archiving blocks corresponding to the transaction archiving threshold B c ; the second remaining blocks in the first remaining blocks other than the archiving blocks corresponding to the transaction archiving threshold B c are determined; the archiving blocks corresponding to the second transaction archiving threshold in the second remaining blocks are determined according to the block priority corresponding to the second transaction archiving threshold; and the second transaction archiving threshold includes the transaction archiving threshold in the plurality of transaction archiving thresholds other than the transaction archiving threshold B c .

[0160] The specific process of this step can further include: if the transaction archiving threshold B c is the maximum transaction archiving threshold in the plurality of transaction archiving thresholds, and the first number is less than or equal to the number of blocks corresponding to the transaction archiving threshold B cThe first remaining blocks are determined as the transaction archiving threshold B corresponding to the number of blocks c The first transaction archiving threshold is the transaction archiving threshold B corresponding to the archiving blocks c The transaction archiving threshold B c The archiving blocks corresponding to the first transaction archiving threshold include the first blocks, and the empty set is determined as the archiving blocks corresponding to the second transaction archiving threshold.

[0161] The number of multiple transaction archiving thresholds is not limited, and the value of each transaction archiving threshold is not limited. The number of transaction archiving thresholds and the value of transaction archiving thresholds can be determined according to actual application scenarios. Similarly, the number of archiving blocks corresponding to one transaction archiving threshold is not limited, and can also be set according to actual application scenarios.

[0162] Please refer to Figure 6 The blockchain network continuously consensus new blocks, so the blockchain 60c will continuously increase new blocks. For example, the blockchain node 60a generates the blockchain 601c, and the number of blocks of the blockchain 601c is 60, that is, the blockchain 601c adds 56 new blocks on the basis of the blockchain 60c, and there are a total of 60 blocks. Since the number of blocks of the blockchain 601c is 60, which is greater than the number of active blocks 50 of the example, the blockchain node 60a can determine the newly generated 50 blocks in the blockchain 601c as active blocks. It can be understood that the block height interval corresponding to the active block is (11, 60), that is, blocks 11-60 belong to active blocks, and do not need to be archived. Figure 6 The blockchain node 60a can determine the newly generated 50 blocks in the blockchain 601c as active blocks. It can be understood that the block height interval corresponding to the active block is (11, 60), that is, blocks 11-60 belong to active blocks, and do not need to be archived.

[0163] The 10 blocks in the blockchain 601c other than the active blocks can represent the first remaining blocks described above, that is, blocks 1-10 belong to the first remaining blocks. Since the first number (10) corresponding to the first remaining blocks is less than the block number (100) corresponding to the transaction archiving threshold of 4kb, the blockchain node 60a determines blocks 1-10 as the archiving blocks corresponding to the transaction archiving threshold of 4kb. In the blockchain 601c, there is no archiving block corresponding to the transaction archiving threshold of 3kb, the transaction archiving threshold of 2kb, and the transaction archiving threshold of 1kb, respectively.

[0164] Subsequently, the blockchain node 60a generates the blockchain 602c, and the number of blocks of the blockchain 602c is 999, that is, the blockchain 602c adds 939 new blocks on the basis of the blockchain 601c, and there are a total of 999 blocks. Since the number of blocks of the blockchain 602c is 999, which is greater than the number of active blocks 50 of the example, the blockchain node 60a can determine the newly generated 50 blocks in the blockchain 602c as active blocks. It can be understood that the block height interval corresponding to the active block is (11, 999), that is, blocks 11-999 belong to active blocks, and do not need to be archived. Figure 6The example number of active blocks 50, so the blockchain node 60a can determine the newly generated 50 blocks in the blockchain 602c as active blocks, it needs to be emphasized that the active blocks corresponding to the blockchain 602c are different from the active blocks corresponding to the blockchain 601c, and the active blocks corresponding to the blockchain 602c correspond to a block height interval (950, 999), that is, blocks 950-999 belong to active blocks.

[0165] The 949 blocks in the blockchain 602c other than the active blocks can represent the first remaining blocks described above, that is, blocks 1-949 belong to the first remaining blocks, and since the first number (949) corresponding to the first remaining blocks is greater than the block number (100) corresponding to the transaction archiving threshold of 4kb, the blockchain node 60a determines blocks 850-949 as the archiving blocks corresponding to the transaction archiving threshold of 4kb. Further, according to the example priority shown in the table, the blockchain node 60a determines blocks 650-849 as the archiving blocks corresponding to the transaction archiving threshold of 3kb; determines blocks 350-649 as the archiving blocks corresponding to the transaction archiving threshold of 2kb; and determines the remaining blocks in the blockchain 602c, that is, blocks 1-349, as the archiving blocks corresponding to the transaction archiving threshold of 1kb. Figure 6

[0166] As described above, with the continuous addition of blocks to the blockchain, the blocks corresponding to each transaction archiving threshold change, and vice versa, the transaction archiving threshold corresponding to each block is updated. The farther the block is from the current maximum block, the smaller the transaction archiving threshold corresponding to the block.

[0167] Step S204, obtaining first transaction data in the first block, obtaining a first transaction archiving threshold corresponding to the first block, and comparing the occupied space of the first transaction data with the first transaction archiving threshold.

[0168] Specifically, it can be understood that the occupied space of the first transaction data is a fixed value, but the first transaction archiving threshold corresponding to the first transaction data will be updated as the blockchain grows. Please see again Figure 6 , assuming that the first block is block 5, if the blockchain node 60a generates the blockchain 601c, then the first block of block 5 belongs to the archiving blocks corresponding to the transaction archiving threshold of 4kb, so the first transaction archiving threshold corresponding to the first block is equal to 4kb.

[0169] If the blockchain node 60a generates the blockchain 602c, then the first block of block 5 belongs to the archiving blocks corresponding to the transaction archiving threshold of 1kb, so the first transaction archiving threshold corresponding to the first block is equal to 1kb. Obviously, the first block of block 5 is in Figure 7 ​The example blockchain 601c and the corresponding transaction archiving threshold in the blockchain 602c are different.

[0170] In step S205, if the first transaction data occupies a space equal to or greater than the first transaction archiving threshold, the transaction index corresponding to the first transaction data is obtained.

[0171] In step S206, the first transaction data carrying the transaction index is sent to the archiving device, so that the archiving device stores the first transaction data according to the transaction index.

[0172] Specifically, in combination with steps S205-S206, many current blockchain systems support blockchain archiving, but the archiving granularity is based on blocks, that is, one entire block is archived at a time. This method is relatively simple and direct, but the archiving effect is not good. In order to save the storage space of the blockchain node, as many blocks as possible are stored in the archiving center, but this brings a very large query pressure to the archiving center. Based on this, the present application proposes a transaction granularity-based archiving scheme, which can identify larger transactions in a block and save them to the archiving center, while retaining other transactions, thereby avoiding a large number of query requests from flowing into the archiving center. At the same time, since the query frequency of old blocks is low, the present application combines the block height, and the lower the threshold of the size of the transaction that needs to be archived in the block that is farther away from the current block, that is, the easier it is to be archived. Therefore, the size threshold of the transaction in the block is dynamically updated during the production of the block.

[0173] The present application proposes a dynamic blockchain data archiving scheme based on transaction granularity and block height, which focuses on solving the above problems. The main innovations of the present application are as follows:

[0174] 1. Adaptive transaction size-aware blockchain data incremental archiving mechanism: This innovation point relates to a new archiving mechanism that can dynamically determine whether to archive transaction data according to the size (i.e., the occupied space) of the transaction. This mechanism can identify and separate large-size transactions and archive them independently, while retaining small-size transactions in the main storage. This method not only can effectively reduce the query pressure of the archiving center, but also can optimize the use of storage space, and can avoid unnecessary archiving of small transactions, thereby reducing the storage demand for the archiving center.

[0175] 2. Dynamic Archiving Threshold Adjustment Strategy Based on Block Height Difference: The second innovation is a dynamic archiving threshold adjustment strategy based on block height. In this strategy, the system dynamically adjusts the archiving threshold according to the height difference between the block and the current latest block (i.e., the "age" of the block). As the block height increases, i.e., the block becomes more "old", the system reduces the transaction size threshold for archiving, so that more transactions meet the archiving conditions. This method can ensure that the storage space of the blockchain is more efficiently released over time, while maintaining the ability to quickly access transactions in new blocks. The implementation of this strategy can significantly improve the storage efficiency and query performance of the blockchain system.

[0176] Step S207, obtaining the transaction archiving success message returned by the archiving device for the first transaction data, and deleting the first transaction data in the first block according to the transaction archiving success message.

[0177] Specifically, the advantages of the embodiments of the present application are as follows:

[0178] 1. Optimizing storage space utilization: Traditional archiving schemes usually archive the entire block data without considering the actual size and importance of each transaction within the block. This scheme identifies and archives large-size transactions while retaining small-size transactions in the main storage, allowing for more fine-grained management of storage space. This transaction-granularity-based archiving method can reduce the storage demand on the archiving center, thereby reducing storage costs and improving storage space utilization efficiency.

[0179] 2. Improving query performance and response speed: In traditional schemes, due to the coarse granularity of archiving operations, frequently accessed data may be archived, increasing query latency. This scheme dynamically adjusts the archiving threshold so that small transactions in frequently accessed newer blocks are retained in the main storage, while large transactions in older blocks are archived. This strategy can reduce query requests to the archiving center, improving query performance and system response speed, especially for real-time application scenarios with higher requirements.

[0180] 3. Enhancing the scalability and flexibility of the system: This scheme introduces a dynamic archiving threshold adjustment based on block height, which means that as the blockchain continues to grow, the system can adaptively adjust the archiving strategy to adapt to different storage and query requirements. This adaptive capability enables the blockchain system to be more flexible in optimizing when facing changing data access patterns and storage pressures. In addition, this strategy can also be adjusted according to actual business needs and storage costs, providing more possibilities for the long-term operation and expansion of the blockchain system.

[0181] It can be known from the above that the embodiments of the present application can archive transaction data equal to or greater than the transaction archiving threshold. Through archiving, the storage of the blockchain for transaction data occupying a large space can be reduced, and thus the storage resources can be relieved.

[0182] Please refer to Figure 7 , Figure 3 is a flowchart of a data processing method based on a blockchain provided by the embodiments of the present application Figure 1 . The data processing method based on a blockchain can be executed by a first blockchain node, wherein the first blockchain node can be any one of the blockchain nodes in the blockchain network 10 of the embodiments corresponding to the above Figure 7 . As shown in Figure 6 , the method can at least include the following steps.

[0183] Step S301, acquiring first transaction data in a first block, at a first time, acquiring a first transaction archiving threshold corresponding to the first block, comparing the occupied space of the first transaction data with the first transaction archiving threshold; the blockchain at the first time includes a second block with the largest block height; the second block belongs to active blocks.

[0184] Specifically, it can be understood that the blockchain is constantly increasing over time, so the blocks included in the blockchain at different times are not the same, as shown in the above Figure 3 example, assuming that the blockchain node 60a stores the blockchain 601c at the first time, and stores the blockchain 602c at the second time, the blockchain 602c is generated based on the blockchain 601c, but the latest block (i.e. the second block) of the blockchain 601c is block 60, and the latest block (i.e. the third block described below) of the blockchain 602c is block 999.

[0185] Step S302, if the occupied space of the first transaction data is equal to or greater than the first transaction archiving threshold, acquiring a transaction index corresponding to the first transaction data.

[0186] Step S303, sending the first transaction data carrying the transaction index to an archiving device, so that the archiving device stores the first transaction data according to the transaction index.

[0187] Step S304, acquiring a transaction archiving success message returned by the archiving device for the first transaction data, and deleting the first transaction data in the first block according to the transaction archiving success message.

[0188] The specific implementation process of steps S302-S304 can be found in steps S102-S104 in the embodiments corresponding to the above Figure 6 , which will not be described here.

[0189] Step S305: If the space occupied by the first transaction data is less than the first transaction archiving threshold, then at the second time point, the third transaction archiving threshold corresponding to the first block is determined according to the archiving gradient rule and the third block; the third block is the block with the maximum block height in the blockchain at the second time point; the second time point is later than the first time point; the block height of the third block is greater than the block height of the second block.

[0190] Specifically, based on the archiving gradient rules, the updated active blocks in the blockchain with a third block are determined, as well as the updated archive blocks corresponding to multiple transaction archiving thresholds; the block height corresponding to the updated active block is greater than the block height of the active block; the block height corresponding to multiple updated archive blocks is greater than the block height corresponding to multiple archive blocks; from the multiple updated archive blocks, the updated archive block to which the first block belongs is determined; and the transaction archiving threshold corresponding to the updated archive block to which the first block belongs among the multiple transaction archiving thresholds is determined as the third transaction archiving threshold.

[0191] It is understandable that the process by which a blockchain node determines the active block and the archived blocks corresponding to multiple transaction archiving thresholds according to the prescribed gradient rules in the first moment is the same as the process by which it determines the active block and the archived blocks corresponding to multiple transaction archiving thresholds according to the prescribed gradient rules in the second moment. Therefore, it will not be described in detail here, but can be referred to the description in the above embodiment.

[0192] Step S306: If the third transaction archiving threshold is different from the first transaction archiving threshold, then the space occupied by the first transaction data is compared with the third transaction archiving threshold; the third transaction archiving threshold is less than the first transaction archiving threshold, and the third transaction archiving threshold belongs to multiple transaction archiving thresholds.

[0193] Step S307: If the space occupied by the first transaction data is equal to or greater than the third transaction archiving threshold, then the first transaction data is archived.

[0194] Specifically, referring to steps S306-S307, for ease of understanding and description, the first block is shown as an example. Figure 6 In block 4 of the blockchain, the space occupied by the first transaction data is 3kb. At the first moment, blockchain node 60a generates blockchain 601c. The first block (block 4 in this example) belongs to the archive block corresponding to a transaction archiving threshold of 4kb. Therefore, the first transaction archiving threshold corresponding to the first transaction data is equal to 4kb. Since the space occupied by the first transaction data is 3kb, which is less than the first transaction archiving threshold of 4kb, blockchain node 60a does not perform archiving processing on the first transaction data; that is, the first transaction data is stored in the blockchain.

[0195] Subsequently, the blockchain network continuously adds new blocks, the first block (e.g.)Figure 8 If the archived block to which block 4 belongs is updated, for example, at the second moment, the length of the blockchain is 153, meaning the number of blocks in the blockchain is 153; in this scenario, active blocks include blocks 153-104, the archived blocks corresponding to a transaction archiving threshold of 4kb include blocks 4-103, and the archived blocks corresponding to a transaction archiving threshold of 3kb include blocks 1-3. Clearly, block 4 belongs to the archived blocks corresponding to the transaction archiving threshold of 4kb, and is updated to belong to the archived blocks corresponding to the transaction archiving threshold of 3kb. Therefore, the transaction archiving threshold corresponding to block 4 is updated from 4kb to 3kb. The space occupied by the first transaction data does not change and remains 3kb. At this time, the space occupied by the first transaction data (3kb) is equal to the transaction archiving threshold of 3kb corresponding to block 4. Therefore, at the second moment, the blockchain node archives the first transaction data.

[0196] When a new block is generated, a blockchain node can execute the embodiment of this application, that is, according to the prescribed gradient rules, determine the active blocks in the blockchain and the archive blocks corresponding to multiple transaction archive thresholds respectively. For each block, first determine the archive block to which it belongs, and then determine the corresponding transaction archive threshold. Then, compare the space occupied by the transactions in each block with the transaction archive threshold corresponding to the block to determine whether to archive the transactions in the block.

[0197] In one feasible implementation, blockchain nodes can also set a batch block value, for example, a batch block value of 20. Then, the blockchain network performs an archiving process every 20 newly generated blocks. That is, if the number of newly generated blocks is less than 20 after the last batch archiving, no archiving process is performed until the number of newly generated blocks equals 20. Then, according to the prescribed gradient rules, the active blocks in the blockchain and the archived blocks corresponding to the multiple transaction archiving thresholds are re-determined. The subsequent process is the same as above, so it will not be repeated here.

[0198] As can be seen from the above, the embodiments of this application can archive transaction data that is equal to or greater than the transaction archiving threshold. By archiving, the storage of transaction data that occupies a large amount of space in the blockchain can be reduced, thus alleviating storage resources.

[0199] Please see Figure 8 , Figure 4 This is a flowchart illustrating a blockchain-based data processing method provided in an embodiment of this application. Figure 1 This blockchain-based data processing method can be executed by a first blockchain node, which can be one of the aforementioned... Figure 8 Any blockchain node in the blockchain network 10 of the corresponding embodiment. For example... Figure 3 As shown, the method may include at least the following steps.

[0200] In step S401, the first transaction data in the first block is obtained, the first transaction archiving threshold corresponding to the first block is obtained, and the occupied space of the first transaction data is compared with the first transaction archiving threshold.

[0201] In step S402, if the occupied space of the first transaction data is equal to or greater than the first transaction archiving threshold, the transaction index corresponding to the first transaction data is obtained.

[0202] In step S403, the first transaction data carrying the transaction index is sent to the archiving device, so that the archiving device stores the first transaction data according to the transaction index.

[0203] In step S404, the transaction archiving success message for the first transaction data returned by the archiving device is obtained, and the first transaction data is deleted in the first block according to the transaction archiving success message.

[0204] The specific implementation process of steps S401-S404 is described above Figure 9 The steps S101-S104 in the corresponding embodiments are not repeated here.

[0205] In step S405, the archiving rule obtaining request sent by the business device is obtained, and the archiving gradient rule is returned to the business device according to the archiving rule obtaining request.

[0206] Specifically, the application scenarios of the present scheme on the product side include but are not limited to the following aspects:

[0207] 1. Blockchain application in the financial services industry: In the financial services industry, blockchain technology is used for transaction records, asset management, compliance detection, and other aspects. The adaptive transaction size-aware blockchain data incremental archiving mechanism of the present scheme can be used to optimize the storage of transaction data. For example, transaction records with high resource values may occupy more storage space due to their importance and complexity, and the present scheme can prioritize the archiving of these high-resource-value transactions, thereby preserving the ability to quickly access more frequent low-resource-value transactions. At the same time, the dynamic archiving threshold adjustment strategy based on block height differentiation can automatically adjust the archiving strategy over time, ensuring that old transaction records are effectively archived without affecting query performance.

[0208] 2. Supply Chain Management: Blockchain applications in supply chain management require recording and tracing a large amount of commodity flow information. Over time, the query frequency of certain historical transaction data may decrease. This solution can dynamically archive these data according to the size of the transaction and the block height, thereby providing more storage space and faster access speed for currently active transaction data. This is very valuable for supply chain management systems that need to detect the status and location of goods in real time.

[0209] 3. Medical Health Data Management: Blockchain applications in the medical health field involve a large amount of data and medical records. These data usually have high sensitivity and long-term preservation requirements. This solution can help medical institutions dynamically archive medical records according to the size of the data and the access frequency, ensuring fast access to critical medical data while reasonably managing the cost of long-term storage.

[0210] 4. Legal Compliance and Audit: Legal compliance and audit fields require long-term storage of a large number of transaction records and contract information. This solution can provide an efficient data archiving method for these applications, so that old contracts and transaction records meet compliance requirements without occupying too much main storage space. The strategy of dynamically adjusting the archiving threshold can automatically optimize the archiving process according to the audit cycle and compliance requirements.

[0211] 5. Big Data Analysis and Blockchain: Big data analysis needs to process and store a large number of data sets. In big data analysis applications combined with blockchain technology, this solution can help dynamically manage a large amount of data generated during analysis. By archiving transaction granularity, frequently accessed data during analysis can be ensured to be quickly available, while large data sets that are not frequently used can be archived to save storage space.

[0212] In the above application scenarios of examples, the innovation of this solution can help enterprises and organizations more effectively manage blockchain data, improve system performance, reduce storage costs, and provide better user experience.

[0213] Step S406, obtain the maximum block height acquisition request sent by the business device, and return the maximum block height of the blockchain to the business device according to the maximum block height acquisition request, so that the business device determines the predicted transaction archiving threshold corresponding to the first transaction data according to the predicted block height of the first transaction data, the archiving gradient rule and the maximum block height; The predicted transaction archiving threshold is used for comparison processing with the predicted occupied space of the first transaction data generated by the business device; The comparison processing is used to determine the archiving prediction result for the first transaction data.

[0214] Specifically, if the archiving prediction result is an archived prediction result, the business device is configured to send a transaction query request to the archiving device; and the archiving device is configured to return first transaction data to the business device according to a transaction index in the transaction query request.

[0215] The predicted block height refers to a block height predicted by the business device for the first transaction data, which may deviate from a block height to which the first transaction data belongs in the blockchain. Like the blockchain node, the business device can also determine active blocks of the blockchain and archiving blocks corresponding to the plurality of transaction archiving thresholds according to the archiving gradient rule and the maximum block height, so as to determine whether the predicted block height belongs to an active block or an archiving block corresponding to a transaction archiving threshold. If the business device determines that the predicted block height corresponds to an archiving block corresponding to a transaction archiving threshold, the transaction archiving threshold is determined as the predicted transaction archiving threshold.

[0216] Further, the business device predicts the occupied space of the first transaction data, and the predicted occupied space is referred to as a predicted occupied space, which has a smaller gap with the real occupied space of the first transaction data. The business device compares the predicted occupied space of the first transaction data with the predicted transaction archiving threshold. If the predicted occupied space is equal to or greater than the predicted transaction archiving threshold, the business device can determine that the first transaction data has been archived, that is, the archived prediction result is determined as the archiving prediction result, so that the business device sends the transaction query request for the first transaction data to the archiving device, so that the archiving device queries the first transaction data in its own database according to the transaction query request.

[0217] If the first transaction data is stored in the archiving device, the archiving device returns the first transaction data to the business device; if the archiving device does not store the first transaction data, that is, the first transaction data remains in the blockchain, at this time, the archiving device can forward the transaction query request for the first transaction data to the blockchain network, so that the blockchain network returns the first transaction data to the business device according to the transaction query request; or, the archiving device returns a query failure message to the business device, at this time, the business device can send the transaction query request for the first transaction data to the blockchain network, so that the blockchain network returns the first transaction data to the business device according to the transaction query request.

[0218] It can be understood that, based on the judgment of the transaction size estimation and the block range estimation, it is estimated whether the transaction data is archived, and then directly accessed, which has a high probability of hitting.

[0219] In step S407, if the archiving prediction result is a to-be-archived prediction result, a transaction query request including a transaction index sent by the business device is obtained.

[0220] Specifically, if the predicted occupied space is less than the predicted transaction archiving threshold, the business device can determine that the first transaction data is not archived, i.e., the to-be-archived prediction result is determined as the archiving prediction result, so the business device sends the transaction query request for the first transaction data to the blockchain network, so that the blockchain network queries the first transaction data in the blockchain according to the transaction query request.

[0221] If the first transaction data has been stored in the archiving device, i.e., the first transaction data has actually been archived, the blockchain node can forward the transaction query request for the first transaction data to the archiving device, so that the archiving device returns the first transaction data to the business device according to the transaction query request; or, the blockchain node returns a query failure message to the business device, at this time, the business device can send the transaction query request for the first transaction data to the archiving device, so that the archiving device returns the first transaction data to the business device according to the transaction query request.

[0222] If the first transaction data is stored in the blockchain, the blockchain node returns the first transaction data to the business device.

[0223] Step S408, generating a transaction archiving message according to the transaction query request; the transaction archiving message is used to indicate that the first transaction data indicated by the transaction index has been archived to the archiving device.

[0224] Step S409, returning the transaction archiving message to the business device, so that the business device sends the transaction query request to the archiving device according to the transaction archiving message; the archiving device returns the first transaction data to the business device according to the transaction index in the transaction query request.

[0225] Specifically, the architecture of the embodiments of the present application can be as follows:

[0226] 1. The dynamic blockchain data archiving scheme system architecture based on transaction granularity and block height is described, and the system architecture of the whole scheme is designed, including the network component, the verification component, the transaction pool component, the scheduling component, the archiving component, the consensus component and the storage component of the blockchain node.

[0227] At the same time, the dynamic blockchain data archiving interaction diagram based on transaction granularity and block height, the direct query scheme based on transaction size estimation, and the phased dynamic transaction archiving interaction scheme are introduced in detail.

[0228] The above system architecture is the running basis of the whole environment, and the above scheme and system architecture ensure that the system runs efficiently and stably.

[0229] 2. A full life cycle process of a dynamic blockchain data archiving scheme based on transaction granularity and block height is designed. A dynamic incremental transaction archiving process based on block height change (when the block height changes, the incremental archiving threshold is reached, and the process of incremental archiving of transactions), a transaction direct query process based on transaction size (the business device directly queries the transaction from the block chain node or the archiving center based on the range estimation of the transaction size and the block height).

[0230] As known above, the embodiments of the present application can archive transaction data equal to or greater than the transaction archiving threshold. Through archiving, the storage of blockchains for transaction data occupying a large space can be reduced, and thus the storage resources can be relieved.

[0231] Further, please refer to Figure 9 , Figure 9 is a structural schematic diagram of a data processing apparatus based on a blockchain provided by an embodiment of the present application. The data processing apparatus based on a blockchain can run on a first block chain node. The above-mentioned data processing apparatus based on a blockchain 1 can be used to execute the corresponding steps in the method provided by the embodiments of the present application. As shown in Figure 10 , the data processing apparatus based on a blockchain 1 can include an acquisition module 11, a sending module 12, and a deletion module 13.

[0232] The acquisition module 11 is configured to acquire first transaction data in a first block, acquire a first transaction archiving threshold corresponding to the first block, and compare the occupied space of the first transaction data with the first transaction archiving threshold.

[0233] The acquisition module 11 is further configured to acquire a transaction index corresponding to the first transaction data if the occupied space of the first transaction data is equal to or greater than the first transaction archiving threshold.

[0234] The sending module 12 is configured to send the first transaction data carrying the transaction index to an archiving device, so that the archiving device stores the first transaction data according to the transaction index.

[0235] The deletion module 13 is configured to acquire a transaction archiving success message for the first transaction data returned by the archiving device, and delete the first transaction data in the first block according to the transaction archiving success message.

[0236] In a possible implementation, the acquisition module 11 acquires first transaction data in a first block, and is configured to perform the following operations:

[0237] According to the number of active blocks, an active block in the block chain is determined. The number of active blocks is the number of active blocks. The active block refers to a block that does not undergo archiving.

[0238] The blocks in the blockchain other than the active block are determined as archive blocks; the block height of the archive block is less than the block height of the active block; the archive block refers to a block that is subjected to archiving processing; and the archive block includes the first block;

[0239] The first transaction data in the first block is obtained.

[0240] In a possible implementation, the obtaining module 11 is further configured to perform the following operations:

[0241] The archiving gradient rule is obtained; the archiving gradient rule includes the number of active blocks and the number of blocks corresponding to each of the plurality of transaction archiving thresholds; the number of active blocks is used to indicate the number of blocks in the blockchain that are not subjected to archiving processing; and the number of blocks corresponding to each of the plurality of transaction archiving thresholds is used to indicate the number of archive blocks corresponding to each of the plurality of transaction archiving thresholds;

[0242] If the number of blocks in the blockchain is less than or equal to the number of active blocks, the blocks in the blockchain are determined as active blocks;

[0243] If the number of blocks in the blockchain is greater than the number of active blocks, the active blocks in the blockchain and the archive blocks corresponding to each of the plurality of transaction archiving thresholds are determined according to the archiving gradient rule; the block height of the active block is greater than the block height of each of the plurality of archive blocks; the plurality of transaction archiving thresholds include the first transaction archiving threshold; and the plurality of archive blocks include the first block.

[0244] In a possible implementation, the plurality of transaction archiving thresholds include a transaction archiving threshold B c and a transaction archiving threshold B c+1 c is a positive integer and c is less than the total number of the plurality of transaction archiving thresholds;

[0245] The obtaining module 11 determines the active blocks in the blockchain and the archive blocks corresponding to each of the plurality of transaction archiving thresholds according to the archiving gradient rule, and is configured to perform the following operations:

[0246] If the transaction archiving threshold B c is greater than the transaction archiving threshold B c+1 , it is determined that the block priority corresponding to the transaction archiving threshold B c is greater than the block priority corresponding to the transaction archiving threshold B c+1 .

[0247] The block priority corresponding to the number of active blocks is determined to be greater than the block priority corresponding to each of the plurality of transaction archiving thresholds;

[0248] The active blocks in the blockchain are determined according to the block priority corresponding to the number of active blocks.

[0249] According to the block priorities corresponding to the plurality of transaction archiving thresholds, determine the archiving blocks corresponding to the plurality of transaction archiving thresholds in the blockchain.

[0250] In a possible implementation, the obtaining module 11 determines the archiving blocks corresponding to the plurality of transaction archiving thresholds in the blockchain according to the block priorities corresponding to the plurality of transaction archiving thresholds, and is configured to perform the following operations:

[0251] Determine a first quantity of first remaining blocks in the blockchain except the active block;

[0252] If the transaction archiving threshold B c is the maximum transaction archiving threshold in the plurality of transaction archiving thresholds, and the first quantity is greater than the block quantity corresponding to the transaction archiving threshold B c , determine, as the archiving block corresponding to the transaction archiving threshold B c , a block adjacent to the active block in the first remaining blocks and having a quantity of blocks corresponding to the transaction archiving threshold B c .

[0253] Determine a second remaining block in the first remaining blocks except the archiving block corresponding to the transaction archiving threshold B c .

[0254] According to the block priority corresponding to the second transaction archiving threshold, determine the archiving block corresponding to the second transaction archiving threshold in the second remaining block; the second transaction archiving threshold includes a transaction archiving threshold in the plurality of transaction archiving thresholds except the transaction archiving threshold B c .

[0255] In a possible implementation, the obtaining module 11 is further configured to perform the following operations:

[0256] If the transaction archiving threshold B c is the maximum transaction archiving threshold in the plurality of transaction archiving thresholds, and the first quantity is less than or equal to the block quantity corresponding to the transaction archiving threshold B c , determine, as the archiving block corresponding to the transaction archiving threshold B c , the first remaining block; the first transaction archiving threshold is the transaction archiving threshold B c ; the archiving block corresponding to the transaction archiving threshold B c includes the first block.

[0257] Determine an empty set as the archiving block corresponding to the second transaction archiving threshold.

[0258] In a possible implementation, the obtaining module 11 obtains the first transaction archiving threshold corresponding to the first block, and is configured to perform the following operations:

[0259] determining, from the plurality of archiving blocks, an archiving block to which the first block belongs;

[0260] determining, from the plurality of archiving blocks, an archiving block to which the first block belongs;

[0261] In a possible implementation, the obtaining module 11 obtains the first transaction archiving threshold corresponding to the first block, for performing the following operations:

[0262] At the first time, the first transaction archiving threshold corresponding to the first block is obtained; the blockchain comprises a second block with a maximum block height at the first time; the second block belongs to active blocks;

[0263] The obtaining module 11 is further configured to perform the following operations:

[0264] If the first transaction data occupies a space smaller than the first transaction archiving threshold, at a second time, a third transaction archiving threshold corresponding to the first block is determined according to the archiving gradient rule and a third block; the third block is a block with a maximum block height of the blockchain at the second time; the second time is later than the first time; the third block has a block height greater than that of the second block;

[0265] If the third transaction archiving threshold is different from the first transaction archiving threshold, the first transaction data occupies a space smaller than the third transaction archiving threshold; the third transaction archiving threshold is smaller than the first transaction archiving threshold, and the third transaction archiving threshold belongs to the plurality of transaction archiving thresholds;

[0266] If the first transaction data occupies a space equal to or greater than the third transaction archiving threshold, the first transaction data is archived.

[0267] In a possible implementation, the obtaining module 11 determines the third transaction archiving threshold corresponding to the first block according to the archiving gradient rule and the third block, for performing the following operations:

[0268] According to the archiving gradient rule, updated active blocks in the blockchain with the third block are determined, and the plurality of transaction archiving thresholds correspond to updated archiving blocks respectively; the updated active blocks correspond to block heights greater than that of the active blocks; the plurality of updated archiving blocks correspond to block heights greater than that of the plurality of archiving blocks;

[0269] determining, from the plurality of updated archiving blocks, an updated archiving block to which the first block belongs;

[0270] determining, from the plurality of archiving blocks, an archiving block to which the first block belongs;

[0271] In a possible implementation, the obtaining module 11 is further configured to perform the following operations:

[0272] obtain an archiving rule obtaining request sent by the business device, and return an archiving gradient rule to the business device according to the archiving rule obtaining request;

[0273] obtain a maximum block height obtaining request sent by the business device, return a maximum block height of the block chain to the business device according to the maximum block height obtaining request, so that the business device determines a predicted transaction archiving threshold corresponding to the first transaction data according to the predicted block height of the first transaction data, the archiving gradient rule and the maximum block height; the predicted transaction archiving threshold is used for comparison processing with a predicted occupied space of the first transaction data generated by the business device; the comparison processing is used for determining an archiving prediction result of the first transaction data;

[0274] if the archiving prediction result is a to-be-archived prediction result, obtain a transaction query request including a transaction index sent by the business device;

[0275] generate a transaction archiving message according to the transaction query request; the transaction archiving message is used for indicating that the first transaction data indicated by the transaction index has been archived to the archiving device;

[0276] return the transaction archiving message to the business device, so that the business device sends the transaction query request to the archiving device according to the transaction archiving message; and the archiving device returns the first transaction data to the business device according to the transaction index in the transaction query request.

[0277] In a possible implementation, if the archiving prediction result is an already-archived prediction result, the business device is configured to send the transaction query request to the archiving device; and the archiving device is configured to return the first transaction data to the business device according to the transaction index in the transaction query request.

[0278] In a possible implementation, the sending module 12 sends the first transaction data carrying the transaction index to the archiving device, so that the archiving device stores the first transaction data according to the transaction index, to perform the following operations:

[0279] perform signature processing on the first transaction data carrying the transaction index by using a node private key, to obtain a data signature;

[0280] invoke an archiving component, send the first transaction data carrying the data signature and the transaction index to the archiving device by using the archiving component, so that the archiving device performs signature verification processing on the data signature by using a node public key, to obtain a signature verification result; the signature verification result includes a signature verification success result; the signature verification success result is used for indicating that the first transaction data carrying the transaction index has a legal attribute, and the signature verification success result is used for indicating that the archiving device stores the first transaction data according to the transaction index.

[0281] In a possible implementation, the sending module 12 is further configured to perform the following operations:

[0282] generating a transaction deletion message including the transaction index, and sending the transaction deletion message to the second blockchain node, so that the second blockchain node deletes the first transaction data according to the transaction index in the transaction deletion message.

[0283] As known from the above, the embodiments of the present application can archive the transaction data equal to or greater than the transaction archiving threshold. Through the archiving, the storage of the blockchain for the transaction data occupying a larger space can be reduced, and thus the storage resource can be relieved.

[0284] Further, referring to Figure 10 , Figure 10 is a structural schematic diagram of a computer device provided by the embodiments of the present application. As shown in Figure 10 , the computer device 1000 can include at least one processor 1001, such as a CPU, at least one network interface 1004, a user interface 1003, a memory 1005, and at least one communication bus 1002. The communication bus 1002 is used to realize the connection and communication between the components. In some embodiments, the user interface 1003 can include a display screen (Display) and a keyboard (Keyboard), and the network interface 1004 can optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 can be a high-speed RAM memory or a non-volatile memory, such as at least one disk memory. The memory 1005 can also be at least one storage device located away from the aforementioned processor 1001. As shown in Figure 10 , the memory 1005 as a computer storage medium can include an operating system, a network communication module, a user interface module, and a device control application program.

[0285] In the computer device 1000 shown in ​ , the network interface 1004 can provide network communication functions; the user interface 1003 is mainly used to provide an interface for user input; and the processor 1001 can be used to call the device control application program stored in the memory 1005 to realize:

[0286] obtaining first transaction data in a first block, obtaining a first transaction archiving threshold corresponding to the first block, and comparing an occupied space of the first transaction data with the first transaction archiving threshold;

[0287] if the occupied space of the first transaction data is equal to or greater than the first transaction archiving threshold, obtaining a transaction index corresponding to the first transaction data;

[0288] sending the first transaction data carrying the transaction index to the archiving device, so that the archiving device stores the first transaction data according to the transaction index;

[0289] obtaining a transaction archiving success message returned by the archiving device for the first transaction data, and deleting the first transaction data in the first block according to the transaction archiving success message.

[0290] It should be understood that the computer device 1000 described in the embodiments of the present application can execute the description of the data processing method or device based on the blockchain in the foregoing embodiments, which will not be repeated here. In addition, the beneficial effects of using the same method will not be described again.

[0291] The embodiments of the present application also provide a computer readable storage medium, which stores a computer program. When the computer program is executed by a processor, the description of the data processing method or device based on the blockchain in the foregoing embodiments is implemented, which will not be repeated here. In addition, the beneficial effects of using the same method will not be described again.

[0292] The computer readable storage medium can be an internal storage unit of the data processing device based on the blockchain provided by any of the foregoing embodiments or the computer device, for example, a hard disk or a memory of the computer device. The computer readable storage medium can also be an external storage device of the computer device, for example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. Further, the computer readable storage medium can include both the internal storage unit and the external storage device of the computer device. The computer readable storage medium is used to store the computer program and other programs and data required by the computer device. The computer readable storage medium can also be used to temporarily store data that has been output or will be output.

[0293] The embodiments of the present application also provide a computer program product, which includes a computer program stored in a computer readable storage medium. The processor of the computer device reads the computer program from the computer readable storage medium. The processor executes the computer program, so that the computer device can execute the description of the data processing method or device based on the blockchain in the foregoing embodiments, which will not be repeated here. In addition, the beneficial effects of using the same method will not be described again.

[0294] The terms "first", "second", etc. in the specification and claims of the present application and the drawings are used to distinguish different objects, and are not used to describe a specific order. In addition, the term "comprising" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, device, product or apparatus that includes a series of steps or units is not limited to the listed steps or units, but can optionally include steps or units not listed, or can optionally include other steps or units inherent to such processes, methods, devices, products or apparatus.

[0295] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized in electronic hardware, computer software or a combination of both. In order to clearly illustrate the interchangeability of hardware and software, each example has been described in general terms in the above description. Whether the functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. A skilled person can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0296] The above disclosure is only the preferred embodiments of the present application, and of course cannot limit the scope of the rights of the present application, so the equivalent changes made in accordance with the claims of the present application are still within the scope of the present application.

Claims

1. A blockchain-based data processing method, characterized by, The method is executed by a first blockchain node, and the method comprises: obtaining first transaction data in a first block, obtaining a first transaction archiving threshold corresponding to the first block, comparing an occupied space of the first transaction data with the first transaction archiving threshold; if the occupied space of the first transaction data is equal to or greater than the first transaction archiving threshold, obtaining a transaction index corresponding to the first transaction data; sending the first transaction data carrying the transaction index to an archiving device, so that the archiving device stores the first transaction data according to the transaction index; obtaining a transaction archiving success message returned by the archiving device for the first transaction data, and deleting the first transaction data in the first block according to the transaction archiving success message.

2. The method of claim 1, wherein, The method further comprises: determining active blocks in the blockchain according to the number of active blocks; the number of active blocks is the number of active blocks; the active blocks refer to blocks that do not undergo archiving processing; determining blocks other than the active blocks in the blockchain as archiving blocks; the block height of the archiving blocks is less than the block height of the active blocks; the archiving blocks refer to blocks that undergo archiving processing; the archiving blocks include the first block; obtaining first transaction data in the first block.

3. The method of claim 1, wherein, The method further comprises: obtaining an archiving gradient rule; the archiving gradient rule comprises the number of active blocks and the number of blocks corresponding to a plurality of transaction archiving thresholds respectively; the number of active blocks is used to indicate the number of blocks in the blockchain that do not undergo archiving processing; the number of blocks corresponding to one transaction archiving threshold is used to indicate the number of archiving blocks corresponding to one transaction archiving threshold; if the number of blocks in the blockchain is less than or equal to the number of active blocks, the blocks in the blockchain are determined as active blocks; if the number of blocks in the blockchain is greater than the number of active blocks, the active blocks in the blockchain and the archiving blocks corresponding to the plurality of transaction archiving thresholds respectively are determined according to the archiving gradient rule; the block height of the active blocks is greater than the block height of the plurality of archiving blocks respectively; the plurality of transaction archiving thresholds include the first transaction archiving threshold; the plurality of archiving blocks include the first block.

4. The method of claim 3, wherein, The plurality of transaction archiving thresholds includes a transaction archiving threshold B c and a transaction archiving threshold B c+1 c is a positive integer and c is less than a total number of the plurality of transaction archiving thresholds; The method further comprises: if the transaction archival threshold B c is greater than the transaction archival threshold B c+1 then determine the transaction archival threshold B c corresponding block priority is greater than the transaction archival threshold B c+1 corresponding block priority; determining the block priority corresponding to the number of active blocks to be greater than the block priority corresponding to the plurality of transaction archiving thresholds respectively; determining active blocks in the blockchain according to the block priority corresponding to the number of active blocks; determining the archiving blocks corresponding to the plurality of transaction archiving thresholds respectively in the blockchain according to the block priority corresponding to the plurality of transaction archiving thresholds respectively.

5. The method of claim 4, wherein, The method further comprises: determining the block priority corresponding to the number of active blocks to be greater than the block priority corresponding to the plurality of transaction archiving thresholds respectively; determining active blocks in the blockchain according to the block priority corresponding to the number of active blocks; determining the archiving blocks corresponding to the plurality of transaction archiving thresholds respectively in the blockchain according to the block priority corresponding to the plurality of transaction archiving thresholds respectively. determining a first quantity of first remaining blocks in the blockchain except for the active block; if the transaction filing threshold B c is the largest transaction filing threshold among the plurality of transaction filing thresholds, and the first number is greater than the transaction filing threshold B c corresponding block quantity, then the blocks in the first remaining blocks adjacent to the active block and with a quantity of the transaction filing threshold B c corresponding block quantity are determined as the transaction filing threshold B c corresponding filing blocks; determining a second remaining block of the first remaining block other than the transaction filing threshold B c a second remaining block other than the corresponding filing block determining, according to a block priority corresponding to a second transaction archiving threshold, an archiving block corresponding to the second transaction archiving threshold in the second remaining block; the second transaction archiving threshold comprises a transaction archiving threshold in the plurality of transaction archiving thresholds, except for the transaction archiving threshold B c .

6. The method of claim 5, wherein, Further comprising: if the transaction filing threshold B c is a largest transaction filing threshold among the plurality of transaction filing thresholds, and the first number is less than or equal to the transaction filing threshold B c corresponding block quantity, the first remaining block is determined as the transaction filing threshold B c corresponding filing block; the first transaction filing threshold is the transaction filing threshold B c ; the transaction filing threshold B c corresponding filing block includes the first block; determining an empty set as an archiving block corresponding to the second transaction archiving threshold.

7. The method of claim 3, wherein, The acquiring the first transaction archiving threshold corresponding to the first block comprises: determining, from the plurality of archiving blocks, an archiving block to which the first block belongs; determining, from the plurality of transaction archiving thresholds, a transaction archiving threshold corresponding to the archiving block to which the first block belongs, as the first transaction archiving threshold.

8. The method of claim 3, wherein, The acquiring the first transaction archiving threshold corresponding to the first block comprises: acquiring the first transaction archiving threshold corresponding to the first block at a first time; the blockchain comprises a second block with the largest block height at the first time; the second block belongs to the active block; The method further comprises: if the first transaction data occupies a space smaller than the first transaction archiving threshold, then at a second time, according to the archiving gradient rule and a third block, determining a third transaction archiving threshold corresponding to the first block; the third block is a block with the largest block height in the blockchain at the second time; the second time is later than the first time; the block height of the third block is greater than the block height of the second block; if the third transaction archiving threshold is different from the first transaction archiving threshold, then comparing the space occupied by the first transaction data with the third transaction archiving threshold; the third transaction archiving threshold is smaller than the first transaction archiving threshold, and the third transaction archiving threshold belongs to the plurality of transaction archiving thresholds; if the space occupied by the first transaction data is equal to or greater than the third transaction archiving threshold, then archiving the first transaction data.

9. The method of claim 8, wherein, The determining the third transaction archiving threshold corresponding to the first block according to the archiving gradient rule and the third block comprises: determining, according to the archiving gradient rule, an updated active block in the blockchain with the third block chained, and updated archiving blocks respectively corresponding to the plurality of transaction archiving thresholds; the block height of the updated active block is greater than the block height of the active block; the block heights of the plurality of updated archiving blocks are greater than the block heights of the plurality of archiving blocks; determining, from the plurality of updated archiving blocks, an updated archiving block to which the first block belongs; determining, from the plurality of transaction archiving thresholds, a transaction archiving threshold corresponding to the updated archiving block to which the first block belongs, as the third transaction archiving threshold.

10. The method of claim 3, wherein, The method further comprises: acquiring an archiving rule acquisition request sent by a business device, and returning the archiving gradient rule to the business device according to the archiving rule acquisition request; obtaining a maximum block height obtaining request sent by the service device, and returning a maximum block height of the block chain to the service device according to the maximum block height obtaining request, so that the service device determines a predicted transaction archiving threshold corresponding to the first transaction data according to a predicted block height of the first transaction data, the archiving gradient rule and the maximum block height; the predicted transaction archiving threshold is used for comparison processing with a predicted occupied space of the first transaction data generated by the service device; the comparison processing is used for determining an archiving prediction result of the first transaction data; if the archiving prediction result is a to-be-archived prediction result, obtaining a transaction query request sent by the service device and including the transaction index; generating a transaction archiving message according to the transaction query request; the transaction archiving message is used for indicating that the first transaction data indicated by the transaction index has been archived to the archiving device; returning the transaction archiving message to the service device, so that the service device sends the transaction query request to the archiving device according to the transaction archiving message; and the archiving device returns the first transaction data to the service device according to the transaction index in the transaction query request.

11. The method of claim 10, wherein, if the archiving prediction result is an already-archived prediction result, the service device is configured to send the transaction query request to the archiving device; and the archiving device is configured to return the first transaction data to the service device according to the transaction index in the transaction query request.

12. The method of claim 1, wherein, the sending of the first transaction data carrying the transaction index to the archiving device, so that the archiving device stores the first transaction data according to the transaction index, comprises: performing signature processing on the first transaction data carrying the transaction index by using a node private key to obtain a data signature; calling an archiving component, and sending the first transaction data carrying the data signature and the transaction index to the archiving device through the archiving component, so that the archiving device performs signature verification processing on the data signature by using a node public key to obtain a signature verification result; the signature verification result includes a signature verification success result; the signature verification success result is used for indicating that the first transaction data carrying the transaction index has a legal attribute, and the signature verification success result is used for indicating that the archiving device stores the first transaction data according to the transaction index.

13. The method of claim 1, wherein, The method further comprises: generating a transaction deletion message including the transaction index, and sending the transaction deletion message to a second block chain node, so that the second block chain node deletes the first transaction data according to the transaction index in the transaction deletion message. 14.A blockchain-based data processing apparatus, characterized by comprising: The device runs on a first block chain node, and the device comprises: an obtaining module, configured to obtain first transaction data in a first block, obtain a first transaction archiving threshold corresponding to the first block, and compare an occupied space of the first transaction data with the first transaction archiving threshold. The acquisition module is further configured to acquire a transaction index corresponding to the first transaction data if an occupied space of the first transaction data is equal to or greater than the first transaction archiving threshold. The sending module is configured to send the first transaction data carrying the transaction index to an archiving device, so that the archiving device stores the first transaction data according to the transaction index. The deleting module is configured to acquire a transaction archiving success message returned by the archiving device for the first transaction data, and delete the first transaction data in the first block according to the transaction archiving success message.

15. A computer device, comprising: Comprising: a processor, a memory and a network interface; The network interface is configured to provide a data communication function, the memory is configured to store a computer program, and the processor is configured to call the computer program to enable the computer device to execute the method in any one of claims 1 to 13.

16. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is adapted to be loaded and executed by the processor to enable the computer device with the processor to execute the method in any one of claims 1 to 13.

17. A computer program product, characterised in that, The computer program product comprises a computer program stored in a computer readable storage medium, and the computer program is adapted to be read and executed by the processor to enable the computer device with the processor to execute the method in any one of claims 1 to 13.