Block chain data processing method, device and system, electronic equipment and storage medium
By introducing intermediate nodes in blockchain data processing and allowing business nodes to actively generate transaction IDs, the problems of thread occupation and speed limitation in large data-loaded chain scenarios are solved, and more efficient chain-loading processing is achieved.
Patent Information
- Application Number
- CN202311614205.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-29
- Publication Date
- 2025-05-30
AI Technical Summary
In the large data volume and high concurrency on-chain scenario, blockchain nodes roll the business data and generate transaction IDs, resulting in the inability to release the thread quickly, occupying a large amount of memory in the system, affecting the speed of on-chain.
A blockchain data processing method is proposed, which receives transaction identification data and data to be put on by the service node through the intermediate node, generates a signature and sends it to the blockchain node, and realizes on-chain processing. This method allows business nodes to actively generate transaction IDs, decouple the generation and on-chain processing of transaction IDs.
Through business nodes, the transaction ID is actively generated, the time when threads wait for transaction ID generation is reduced, the speed of large data is increased, and the system memory usage is reduced.
Smart Images

Figure CN120067203A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of blockchain technology, and in particular, to a blockchain data processing method, apparatus, system, electronic device, and storage medium. Background Art
[0002] A blockchain transaction ID (Transaction ID, TxID) refers to the unique identifier of each transaction on the blockchain. Based on the transaction ID, it is convenient to trace and check transaction records, that is, both the transaction sender and the transaction receiver can find the corresponding transaction information through the transaction ID.
[0003] Currently, in the scenario of uploading a large amount of data with high concurrency to the blockchain, the blockchain node generates a transaction ID only after the business data generated by the business system is uploaded to the blockchain. Since the business system needs to keep the thread listening for the upload result, that is, the business data can release the thread occupied by the business system only after matching the transaction ID, the above processing method will cause the thread to be unable to be released quickly and occupy a large amount of system memory, thus affecting the upload speed of a large amount of data. Based on this, how to provide a blockchain data processing method to improve the upload speed of a large amount of data has become an urgent technical problem to be solved. Summary of the Invention
[0004] The main purpose of the embodiments of this application is to propose a blockchain data processing method, apparatus, system, electronic device, and storage medium, aiming to improve the upload speed of a large amount of data.
[0005] To achieve the above object, a first aspect of the embodiments of this application proposes a blockchain data processing method, which is applied to an intermediate node, and the method includes:
[0006] Receiving first transaction identification data and data to be uploaded sent by a business node, where the first transaction identification data is generated by the business node based on the data to be uploaded and business identification data;
[0007] Signing based on the first transaction identification data to obtain a first signature;
[0008] Sending the first signature to the blockchain node, so that the blockchain node performs an upload process on the data to be uploaded after the verification of the first signature is successful.
[0009] In some embodiments, the signing based on the first transaction identification data to obtain a first signature includes:
[0010] Performing a digest calculation on the first transaction identification data and a first random number based on a preset digest algorithm to obtain a first digest;
[0011] Sign the first digest with the obtained private key to obtain the first signature.
[0012] In some embodiments, the step of sending the first signature to the blockchain node so that the blockchain node performs an on-chain process on the data to be on-chained after successful verification of the first signature includes:
[0013] Send the first signature, the data to be on-chained, the first transaction identification data, the service identification data, and the first random number to the blockchain node, so that the blockchain node verifies the first signature based on the first signature, the data to be on-chained, the first transaction identification data, the service identification data, and the first random number, and the blockchain node performs an on-chain process on the data to be on-chained after successful verification of the first signature.
[0014] In some embodiments, before receiving the first transaction identification data and the data to be on-chained sent by the service node, the method further includes:
[0015] Receive the off-peak data to be on-chained sent by the service node, where the off-peak data to be on-chained is sent by the service node when the system thread occupancy rate is less than the preset occupancy rate;
[0016] Sign the off-peak data to be on-chained to obtain a second signature;
[0017] Send the second signature to the blockchain node, so that the blockchain node performs an on-chain process on the off-peak data to be on-chained after successful verification of the second signature, and the blockchain node performs an on-chain process on the off-peak data to be on-chained after successful verification of the first signature.
[0018] In some embodiments, before receiving the first transaction identification data and the data to be on-chained sent by the service node, the method further includes:
[0019] Receive a data query request sent by the service node, where the data query request carries second transaction identification data;
[0020] Sign the second transaction identification data to obtain a third signature;
[0021] Send the third signature to the blockchain node, so that the blockchain node performs a data query operation on the off-peak data to be on-chained after successful verification of the third signature.
[0022] To achieve the above object, a second aspect of the embodiments of the present application provides a blockchain data processing method, which is applied to a service node, and the method includes:
[0023] Generate first transaction identification data based on the data to be chained and service identification data;
[0024] Send the first transaction identification data and the data to be chained to an intermediate node, so that the intermediate node executes the method described in any of the above embodiments.
[0025] In some embodiments, the sending the first transaction identification data and the data to be chained to an intermediate node includes:
[0026] Obtain the occupancy rate of system threads;
[0027] If the occupancy rate of the system threads is greater than or equal to a preset occupancy rate, send the first transaction identification data and the data to be chained to the intermediate node.
[0028] To achieve the above object, a third aspect of the embodiments of the present application proposes a blockchain data processing device, which is used for an intermediate node, and the device includes:
[0029] A data receiving module, configured to receive the first transaction identification data and the data to be chained sent by a service node, wherein the first transaction identification data is generated by the service node based on the data to be chained and service identification data;
[0030] A signature module, configured to perform a signature based on the first transaction identification data to obtain a first signature;
[0031] A signature sending module, configured to send the first signature to a blockchain node, so that the blockchain node performs a chaining process on the data to be chained after the verification of the first signature is successful.
[0032] To achieve the above object, a fourth aspect of the embodiments of the present application proposes a blockchain data processing system, and the system includes:
[0033] A service node, configured to send the data to be chained, or send the data to be chained and the first transaction identification data;
[0034] An intermediate node, configured to receive the data to be chained sent by the service node, or receive the data to be chained and the first transaction identification data sent by the service node, so as to execute the method described in the first aspect;
[0035] A blockchain node, configured to perform a chaining process on the data to be chained.
[0036] To achieve the above object, a fifth aspect of the embodiments of the present application proposes an electronic device, which includes a memory and a processor, the memory stores a computer program, and when the processor executes the computer program, the method described in the first aspect or the method described in the second aspect is implemented.
[0037] To achieve the above object, a sixth aspect of the embodiments of the present application provides a computer-readable storage medium storing a computer program, which when executed by a processor implements the method described in the first aspect or the method described in the second aspect above.
[0038] In the blockchain data processing method, apparatus, system, electronic device, and storage medium proposed by the present application, a service node generates first transaction identification data based on data to be chained and service identification data. After a blockchain node successfully verifies the first signature obtained based on the first transaction identification data, the data to be chained can be processed for chaining. It can be seen that the service node can actively generate a transaction ID, that is, in the embodiments of the present application, the generation of the transaction ID is decoupled from whether the data to be chained is successfully chained. Therefore, in the scenario of chaining a large amount of data, the time for a thread to wait for the generation of the transaction ID can be reduced, thereby improving the chaining speed of a large amount of data and reducing the situation where a large amount of system memory is occupied. Description of the Drawings
[0039] Figures 1A to 1C is a schematic diagram of blockchain data processing according to an embodiment of the present application;
[0040] Figure 2 is a flowchart of a blockchain data processing method applied to an intermediate node according to an embodiment of the present application;
[0041] Figure 3 is Figure 2 a flowchart of step S202 in
[0042] Figures 4A to 4B is another flowchart of an embodiment of a blockchain data processing method applied to an intermediate node according to an embodiment of the present application;
[0043] Figure 5 is another flowchart of an embodiment of a blockchain data processing method applied to an intermediate node according to an embodiment of the present application;
[0044] Figure 6 is a flowchart of a blockchain data processing method applied to a service node according to an embodiment of the present application;
[0045] Figure 7 is a schematic structural diagram of a blockchain data processing apparatus according to an embodiment of the present application;
[0046] Figure 8 is a schematic hardware structure diagram of an electronic device according to an embodiment of the present application. Detailed Embodiments
[0047] In order to make the objectives, technical solutions and advantages of the present application more clearly understood, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0048] It should be noted that although functional module division is performed in the device schematic diagram and the logical sequence is shown in the flowchart, in some cases, the steps shown or described may be executed in a different module division in the device or a different order in the flowchart. Terms such as "first" and "second" in the specification, claims and the above-mentioned drawings are used to distinguish similar objects and do not necessarily need to describe a specific order or sequence.
[0049] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the technical field to which the present application belongs. The terms used herein are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.
[0050] Before further elaborating on the embodiments of the present application, the nouns and terms involved in the embodiments of the present application are described. The nouns and terms involved in the embodiments of the present application are applicable to the following explanations:
[0051] Blockchain: A blockchain is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, and encryption algorithms. Essentially, a blockchain is a decentralized database, a string of data blocks generated by using cryptographic methods. Each data block contains information about a batch of transactions, which is used to verify the validity (anti-counterfeiting) of the information and link to the previous block.
[0052] Signature algorithm: The signature algorithm is an important part of blockchain security. The address, public key, private key, etc. of the blockchain are all related to the signature algorithm. The ownership of the blockchain is realized through the private key, blockchain address, and digital signature. The private key is only owned by the object itself and is only stored in the object terminal. The authentication and management of ownership are both based on the signature algorithm. Therefore, it can also be said that the trust of the blockchain is based on the successful verification of the signature algorithm.
[0053] Smart contract: It is a piece of code written on the blockchain. Once a certain condition in the blockchain triggers the execution of the terms in the contract, the code will be automatically executed.
[0054] Currently, as Figure 1A shown, during the process of a business node calling a blockchain node, it is usually necessary to store the result on the chain in a database for the convenience of query by the business node and the display of relevant data. However, when a business node directly calls a blockchain node, it is prone to couple many blockchain technology problems unrelated to the business and is difficult to iterate and update. To solve the above problems, asFigure 1B As shown in the figure, an intermediate node can be added between the service node and the blockchain node, which is used to coordinate the complexity and ease of use of the service node calling the blockchain node. Specifically, the intermediate node can solve problems related to request parameters, smart contracts, consortium chains, digital identities, certificates, etc. when the service node calls the blockchain node.
[0055] In addition, the performance of the blockchain node is lower than that of the service node. In the scenario of uploading a large amount of data and high concurrency to the blockchain, the asynchronous method of uploading to the blockchain is usually adopted to solve the bottleneck problem of uploading performance. Specifically, a transaction ID will be returned after each piece of data is uploaded to the blockchain, and this transaction ID is used to represent the uniqueness of the data transaction. However, this transaction ID is generated by the blockchain node only after the data is successfully uploaded to the blockchain, resulting in an increase in the complexity of the calling program and an increase in the complexity of subsequent query operations in the scenario where the service node and the intermediate node make asynchronous data calls to the blockchain node. As Figure 1C shown in the figure, the service node needs to maintain a service ID in each data record, and the intermediate node also needs to maintain a serial ID. The service ID, the serial ID, and the transaction ID generated by the blockchain node should correspond to each other.
[0056] It can be seen from this that the above blockchain data uploading method has the following problems:
[0057] (1) High performance loss. The service node and the intermediate node need to keep the thread listening for the result of data uploading to the blockchain. The service node and the intermediate node can release the thread only after the uploaded data matches and obtains the transaction ID. Therefore, in the scenario of uploading a large amount of data and high concurrency to the blockchain, the intermediate node has a large number of threads that cannot be quickly released, resulting in a large amount of system content memory being occupied, thereby reducing the throughput.
[0058] (2) Complex process. The service node needs to use the service ID, the serial ID, and the transaction ID to query the corresponding data on the blockchain from the blockchain node. Moreover, the generation of the transaction ID not only depends on the digest of the data on the blockchain, but also needs to be persistently saved to ensure the one-to-one correspondence between the data on the blockchain and the business data.
[0059] Based on this, the embodiments of the present application provide a blockchain data processing method, device, system, electronic device, and storage medium, aiming to improve the speed of uploading a large amount of data to the blockchain.
[0060] The blockchain data processing method, device, system, electronic device, and storage medium provided by the embodiments of the present application will be specifically described through the following embodiments. First, the blockchain data processing method in the embodiments of the present application will be described.
[0061] Figure 2It is an optional flowchart of the blockchain data processing method provided by an embodiment of the present application. The blockchain data processing method is applied to an intermediate node. Figure 2 The method in
[0062] Step S201: Receive the first transaction identification data and the data to be chained sent by the business node. The first transaction identification data is generated by the business node based on the data to be chained and the business identification data.
[0063] Step S202: Sign based on the first transaction identification data to obtain a first signature.
[0064] Step S203: Send the first signature to the blockchain node so that the blockchain node performs the chaining process on the data to be chained after the verification of the first signature is successful.
[0065] In steps S201 to S203 illustrated in the embodiments of the present application, the business node generates the first transaction identification data based on the data to be chained and the business identification data. After the blockchain node successfully verifies the first signature obtained based on the first transaction identification data, it can perform the chaining process on the data to be chained. Thus, it can be seen that the business node can actively generate a transaction ID, that is, in the embodiments of the present application, the generation of the transaction ID is decoupled from whether the data to be chained is successfully chained. Therefore, in the scenario of chaining a large amount of data, the waiting time of the thread for generating the transaction ID can be reduced, thereby improving the chaining speed of a large amount of data and reducing the situation where the system memory is occupied in large quantities.
[0066] In step S201 of some embodiments, the business node may refer to a business system that can perform business operations and generate corresponding business data. The business system can be a system for different scenarios, such as systems corresponding to logistics scenarios, shopping scenarios, after-sales scenarios, etc. The first transaction identification data may refer to a transaction ID. The data to be chained refers to the data generated by an object during a transaction in the business node and needs to be chained and stored in the blockchain node. The first transaction identification data can be generated by the business node based on the data to be chained and the business identification data. The business identification data refers to the data generated by the business node that can uniquely identify each transaction, and can be, for example, a combination of one or more of a time stamp, the identity information of the transaction object, the transaction address, etc. It can be understood that the time stamp can be the data generation time stamp of the data to be chained, or the time stamp when the data to be chained starts the chaining operation, etc. The embodiments of the present application do not make specific limitations on this. Specifically, taking the business identification data as the time stamp as an example, as shown in the following formula (1), the business node can obtain the first transaction identification data TxID1 by calculating the digest of the data to be chained data and the business identification data timestamp based on a preset digest algorithm (such as a hash algorithm). Where SHA() represents calculating the digest using the digest algorithm.
[0067] TxID1 = SHA(data + timestamp)......Equation (1)
[0068] In step S202 of some embodiments, the intermediate node uses a preset signature algorithm to perform a signature calculation on the first transaction identification data to obtain a first signature. It can be understood that the general rule of signature is to calculate the digest of the subject to be signed using a digest algorithm (such as a hash algorithm), and then encrypt the digest using the private key (or public key) of the signer. It can be understood that the first signature can be used to determine that the data is signed and sent by the data sender, and can be used to determine the integrity of the data sent.
[0069] Refer to Figure 3 , in some embodiments, step S202 includes but is not limited to steps S301 to S302.
[0070] Step S301, based on a preset digest algorithm, calculate the digest of the first transaction identification data and the first random number to obtain a first digest;
[0071] Step S302, sign the first digest based on the obtained private key to obtain a first signature.
[0072] In step S301 of some embodiments, as shown in the following Equation (2), the intermediate node takes the first transaction identification data TxID1 and the first random number nonce as the subject to be signed, and based on a preset digest algorithm (such as a hash algorithm), calculates the digest of the first transaction identification data TxID1 and the first random number nonce1 to obtain a first digest hash 1. It can be understood that hash represents the digest.
[0073] hash 1 = SHA(TxID1 + nonce1)......Equation (2)
[0074] It can be understood that the first random number can be obtained through a hardware random number generator, a blockchain software development kit (SDK), a pseudo-random number generation algorithm, etc., and the embodiments of the present application do not make specific limitations on this.
[0075] It can be understood that the digest algorithm can refer to an algorithm that converts a piece of data into a string of fixed length. This string (such as the first digest) can uniquely represent the original data and is used to verify the integrity of the data to ensure that the data has not been tampered with during transmission or storage. The digest algorithm can include MD5, SHA-1, and SHA-256, etc.
[0076] In step S302 of some embodiments, the service node may obtain the private key through relevant operations on the object and send the private key to the intermediate node. As shown in the following formula (3), the intermediate node may encrypt and sign the first digest based on the private key to obtain the first signature sign 1. Wherein, SIGN() represents signing using the signature algorithm.
[0077] sign 1 = SIGN(hash 1)......Formula (3)
[0078] In step S203 of some embodiments, the intermediate node sends the first signature to the blockchain node, so that the blockchain node verifies the signature of the first signature. After the verification of the first signature is successful, the blockchain node can perform the on-chain processing on the data to be on-chain. It can be understood that the general rule of signature verification is to decrypt the signature with the public key (or private key) of the signer, calculate the digest of the subject to be signed using a digest algorithm (such as a hash algorithm), and compare the decryption result with the digest. If the two are the same, the signature verification is successful. The on-chain processing may refer to storing the data to be on-chain on the blockchain node.
[0079] In some embodiments, step S203 may include but is not limited to the following steps:
[0080] Send the first signature, the data to be on-chain, the first transaction identification data, the service identification data, and the first random number to the blockchain node, so that the blockchain node verifies the signature of the first signature based on the first signature, the data to be on-chain, the first transaction identification data, the service identification data, and the first random number, and the blockchain node performs the on-chain processing on the data to be on-chain after the verification of the first signature is successful.
[0081] In some embodiments, the intermediate node sends the first signature, the data to be on-chain, the first transaction identification data, the service identification data, and the first random number to the blockchain node, so that the blockchain node performs the following steps:
[0082] Calculate the second digest based on the preset digest algorithm for the first transaction identification data and the first random number; decrypt the first signature based on the obtained public key to obtain the decryption data; if the decryption data is equal to the second digest, calculate the data to be verified identification data based on the data to be on-chain and the service identification data; compare the data to be verified identification data with the first transaction identification data; the blockchain node determines that the verification of the first signature is successful by the following method: if the data to be verified identification data is the same as the first transaction identification data, the verification of the first signature is successful, and the on-chain processing is performed on the data to be on-chain.
[0083] Specifically, the intermediate node encapsulates the data to be uploaded to the chain, the first transaction identification data, the service identification data, and the first random number, and sends the encapsulated data to the blockchain node. The blockchain node can use the first transaction identification data TxID1 and the first random number nonce1 in the encapsulated data as the subject to be signed. As shown in the following formula (4), the blockchain node can calculate the digest of the subject to be signed based on a preset digest algorithm (such as the hash algorithm) to obtain the second digest hash 2.
[0084] hash 2 = SHA(TxID1 + nonce1)...... Formula (4)
[0085] The blockchain node can pre-obtain the public key and decrypt the first signature based on the public key to obtain the decryption result, that is, the decrypted data. The blockchain node compares the decrypted data with the second digest. If the decrypted data is the same as the second digest, it indicates that the first transaction identification data has not been tampered with. At this time, the blockchain node can verify whether the data to be uploaded to the chain has been tampered with. Specifically, the blockchain node can use the data to be uploaded to the chain and the service identification data in the encapsulated data as the subject to be signed, and calculate the digest of the data to be uploaded to the chain and the service identification data based on the following formula (5) to obtain the identification data TxID' to be verified.
[0086] TxID' = SHA(data + timestamp)...... Formula (5)
[0087] Since it has been determined above that the first transaction identification data has not been tampered with, the first transaction identification data can be compared with the identification data to be verified to determine whether the data to be uploaded to the chain has been tampered with.
[0088] It can be understood that if the first transaction identification data is the same as the identification data to be verified, it means that the data to be uploaded to the chain has not been tampered with. At this time, it can be considered that the verification of the first signature is successful, and the blockchain node can perform the operation of uploading the data to be uploaded to the chain.
[0089] The advantage of the above intermediate node sending the first signature, the data to be uploaded to the chain, the first transaction identification data, the service data, and the first random number to the blockchain node is that the blockchain node can verify whether the first transaction identification data and the data to be uploaded to the chain have been tampered with, thereby improving the accuracy of the transaction ID and the data to be uploaded to the chain.
[0090] It can be understood that after the data to be uploaded to the chain has been successfully uploaded, when the subsequent service node calls the blockchain node to query data through the intermediate node, the blockchain node can also perform signature verification based on the method described in the above steps. The embodiments of this application will not elaborate on this.
[0091] In other embodiments, step S203 may include but is not limited to the following steps:
[0092] Send the first signature to the blockchain node so that the blockchain node performs the following steps:
[0093] After the verification of the first signature is successful, call the contract data to process the data to be uploaded to obtain the target data; generate a target block based on the target data and store the target block on the chain.
[0094] In some embodiments, the intermediate node sends the first signature to the blockchain node so that when the verification of the first signature is successful, the blockchain node can call the contract data (i.e., smart contract) according to the preset trigger conditions to process the data to be uploaded. The data processing methods may include verifying the data format of the data to be uploaded, converting the data format of the data to be uploaded, performing logical calculations on the data to be uploaded, etc., which are not specifically limited in the embodiments of the present application. The data to be uploaded after data processing is used as the target data. The blockchain node can perform operations such as P2P broadcast (P2P broadcast is a way of spreading messages and data communication between nodes), consensus, etc., and generate a target block based on the target data. The blockchain node broadcasts the target block for storing the target block on the chain.
[0095] It can be understood that the methods described in the above embodiments are data processing methods for the service node to actively generate a transaction ID (i.e., the first transaction identification data). In some embodiments, when the thread is in a large amount of idle state, the generation method of the transaction ID can be selected. For example, the method of generating the transaction ID by the blockchain node can be selected. Hereinafter, this generation method will be described.
[0096] Refer to Figure 4A In some embodiments, the method provided by the embodiments of the present application may further include but is not limited to steps S401 to S403.
[0097] Step S401: Receive the idle-time data to be uploaded sent by the service node, where the idle-time data to be uploaded is sent by the service node when the system thread occupancy rate is less than the preset occupancy rate;
[0098] Step S402: Sign the idle-time data to be uploaded to obtain a second signature;
[0099] Step S403: Send the second signature to the blockchain node so that the blockchain node performs an on-chain process on the data to be uploaded after the verification of the second signature is successful, and the blockchain node sends the second transaction identification data after the idle-time data to be uploaded is successfully uploaded to the chain.
[0100] In step S401 of some embodiments, the system thread occupancy rate may refer to the ratio of the line occupied when the intermediate node sends the data to be uploaded to the blockchain node (or the data to be uploaded during idle time) for storage in response to the storage instruction of the service node, or may refer to the ratio of the line occupied when the intermediate node calls the blockchain node to query the data on the chain in response to the query instruction of the service node, or may refer to the sum of the above two line occupancy ratios. The preset occupancy rate may refer to the pre-set ratio of the line occupied, and the specific value of the preset occupancy rate can be adaptively set according to the actual situation, and the embodiments of the present application do not make specific limitations on this. When the system thread occupancy rate is less than the preset occupancy rate, it can indicate that there are more idle threads, and at this time, the service node can only send the data to be uploaded during idle time to the intermediate node.
[0101] In step S402 of some embodiments, the intermediate node may calculate the digest of the data to be uploaded during idle time based on a preset digest algorithm (such as the hash algorithm), and sign the calculated digest data based on the private key to obtain the second signature.
[0102] In step S403 of some embodiments, the intermediate node sends the second signature to the blockchain node, and the blockchain node verifies the second signature. When the verification of the second signature is successful, that is, when it is verified that the data to be uploaded during idle time has not been tampered with, the blockchain node can perform the on-chain processing on the data to be uploaded during idle time.
[0103] After the data to be uploaded during idle time is successfully uploaded to the chain, the blockchain node may generate the second transaction identification data (i.e., the transaction ID) based on the data to be uploaded during idle time, and broadcast and send the second transaction identification data to the service node. Specifically, the blockchain node may generate the second transaction identification data TxID2 based on the data to be uploaded during idle time "data", the random number "nonce", the signature "sign", as shown in the following formula (6) and formula (7).
[0104] sign" = SIGN(data" + nonce")...... Formula (6)
[0105] TxID2 = SHA(data" + nonce" + sign")...... Formula (7)
[0106] Among them, the signature "sign" can be calculated by the blockchain node based on the private key carried by the SDK itself.
[0107] Refer to Figure 4B , in some embodiments, in the scenario where the blockchain node generates the transaction ID, the method provided by the embodiments of the present application may further include but is not limited to steps S404 to S406.
[0108] Step S404: Receive a data query request sent by a service node, where the data query request carries second transaction identification data;
[0109] Step S405: Sign based on the second transaction identification data to obtain a third signature;
[0110] Step S406: Send the third signature to a blockchain node so that the blockchain node can perform a data query operation on the data to be uploaded during idle time after the third signature verification is successful.
[0111] In step S404 of some embodiments, when the service node needs to query the data to be uploaded during idle time, it may send a data query request to an intermediate node, and the data query request may carry second transaction identification data.
[0112] In step S405 of some embodiments, the intermediate node may sign the second transaction identification data, the data to be uploaded during idle time, a random number, etc. to obtain a third signature.
[0113] In step S406 of some embodiments, the intermediate node sends the third signature to the blockchain node, and the blockchain node may perform signature verification based on the method shown in the following formula (8), that is, verify whether the transaction ID (i.e., "TxID") obtained by calculating the digest based on the data to be uploaded during idle time, the random number, and the signature is the same as the second transaction identification data (i.e., "TxID2") directly sent by the intermediate node, that is, verify whether the second transaction identification data has been tampered with. When it is determined that the second transaction identification data has not been tampered with, it indicates that the third signature verification is successful, and at this time, the data on the chain can be queried based on the second transaction identification data.
[0114] TxID" = SHA(data" + nonce" + sign")...... Formula (8)
[0115] It can be understood that the blockchain node may send the result of the data to be uploaded during idle time to the intermediate node, the intermediate node may send the result to the service system, and the service system may inform the user of the specific content of the result through a pop-up window or the like.
[0116] The advantages of steps S401 to S406 are that when it is determined that there are many idle threads (i.e., the system thread occupancy rate is less than the preset occupancy rate), a transaction ID can be generated based on the blockchain node. At this time, the immutability of the transaction ID can be improved, and no centralized coordination is required. When it is determined that there are many busy threads (i.e., the system thread occupancy rate is greater than or equal to the preset occupancy rate), a transaction ID can be generated based on the business node. At this time, the customizability, operation flexibility, etc. of the transaction ID can be improved, the intrusion of the blockchain node into the business node can be reduced, and the maintenance cost can be reduced. In the scenario of uploading a large amount of data to the blockchain, the business node can directly generate a transaction ID without waiting for the result response of the blockchain node, thereby improving the speed of uploading a large amount of data to the blockchain.
[0117] Referring to Figure 5 , in a specific embodiment, the business node can generate first transaction identification data according to the data to be uploaded to the blockchain and the timestamp, and send the first transaction identification data and the data to be uploaded to the blockchain to the intermediate node. The intermediate node archives the data to be uploaded to the blockchain, and encapsulates the smart contract call request and the consortium chain transaction request. The intermediate node signs based on the first transaction identification data to obtain a first signature. The intermediate node sends the first signature to the blockchain node, and the blockchain node receives the first signature and the transaction request. The blockchain node verifies the first signature. When the verification of the first signature is successful, the blockchain node can call the smart contract to process the data to be uploaded to the blockchain to obtain the target data. The blockchain node performs operations such as P2P broadcasting and consensus, and generates a target block based on the target data. The blockchain node performs block broadcasting (i.e., broadcasts the target block) to store the target block on the blockchain.
[0118] The intermediate node can perform operations such as block listening and parsing whether the data to be uploaded to the blockchain is successfully uploaded. The intermediate node can send the listening result and / or the parsing result to the business node, and the business node can determine the validity of the transaction corresponding to the data to be uploaded to the blockchain based on the listening result and / or the parsing result. When it is confirmed that the transaction is valid, the business node can inform the user that the transaction is successful through a pop-up window or the like.
[0119] In some embodiments, the embodiments of the present application further provide another blockchain data processing method, which is applied to the business node, and the method may include but is not limited to the following steps:
[0120] Generate first transaction identification data based on the data to be uploaded to the blockchain and the business identification data;
[0121] Send the first transaction identification data and the data to be uploaded to the blockchain to the intermediate node, so that the intermediate node executes any of the above blockchain data processing methods applied to the intermediate node.
[0122] The specific implementation of the blockchain data processing method applied to business nodes is basically the same as the specific embodiments of the blockchain data processing method applied to intermediate nodes described above, and will not be elaborated here.
[0123] Referring to Figure 6 , in some embodiments, the step of "sending the first transaction identification data and the data to be chained to the intermediate node" may include but is not limited to steps S601 to S602.
[0124] Step S601, obtaining the system thread occupancy rate;
[0125] Step S602, if the system thread occupancy rate is greater than or equal to the preset occupancy rate, sending the first transaction identification data and the data to be chained to the intermediate node.
[0126] In step S601 of some embodiments, the system thread occupancy rate may refer to the ratio of the line occupied when the intermediate node sends the data to be chained to the blockchain node for storage in response to the storage instruction of the business node, or may refer to the ratio of the line occupied when the intermediate node invokes the blockchain node to query the on-chain data in response to the query instruction of the business node, or may refer to the sum of the above two line occupancy ratios.
[0127] In step S602 of some embodiments, the preset occupancy rate may refer to the preset ratio of the line occupied, and the specific value of the preset occupancy rate can be adaptively set according to the actual situation, and the embodiments of the present application do not make specific limitations thereto. Comparing the system thread occupancy rate with the preset occupancy rate, if the system thread occupancy rate is greater than or equal to the preset occupancy rate, it indicates that the current may be in the scenario of large data volume chaining. In order to improve the chaining speed of large data volume at this time, the business node can actively generate the first transaction identification data and send the first transaction identification data and the data to be chained to the intermediate node. This method of the business node actively generating the first transaction identification data can reduce the time for the thread to wait for the generation of the transaction ID, thereby improving the chaining speed of large data volume and reducing the situation where the system memory is occupied in large quantities.
[0128] Referring to Figure 7 , the embodiments of the present application further provide a blockchain data processing device, which is applied to the intermediate node and can implement the blockchain data processing method applied to the intermediate node described above. The device includes:
[0129] A data receiving module 701, configured to receive the first transaction identification data and the data to be chained sent by the business node, where the first transaction identification data is generated by the business node based on the data to be chained and the business identification data;
[0130] A signature module 702, configured to perform a signature based on the first transaction identification data to obtain a first signature;
[0131] The signature sending module 703 is configured to send the first signature to the blockchain node, so that the blockchain node performs the on-chain processing on the data to be on-chained after the verification of the first signature is successful.
[0132] The specific implementation manner of this blockchain data processing device is basically the same as the specific embodiments of the above-mentioned blockchain data processing method applied to the intermediate node, and will not be elaborated here.
[0133] Combined Figure 5 As shown, an embodiment of the present application further provides a blockchain data processing system, which includes a service node, an intermediate node, and a blockchain node. This system can execute the blockchain data processing method for generating a transaction ID by the service node as described in Figure 5 or execute the blockchain data processing method for generating a transaction ID by the blockchain node as described in the above embodiments.
[0134] In some embodiments, an embodiment of the present application further provides a blockchain data processing system, which includes:
[0135] A service node, configured to send the data to be on-chained, or send the data to be on-chained and the first transaction identification data;
[0136] An intermediate node, configured to receive the data to be on-chained sent by the service node, or receive the data to be on-chained and the first transaction identification data sent by the service node, so as to execute any of the above-mentioned blockchain data processing methods applied to the intermediate node;
[0137] A blockchain node, configured to perform the on-chain processing on the data to be on-chained.
[0138] An embodiment of the present application further provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, the above-mentioned blockchain data processing method is implemented. This electronic device can be any intelligent terminal including a tablet computer, an in-vehicle computer, etc.
[0139] Please refer to Figure 8 , Figure 8 which illustrates the hardware structure of an electronic device in another embodiment. The electronic device includes:
[0140] A processor 801, which can be implemented in ways such as a general-purpose CPU (Central Processing Unit, central processor), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is configured to execute relevant programs to implement the technical solutions provided by the embodiments of the present application;
[0141] The memory 802 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM), etc. The memory 802 can store an operating system and other application programs. When implementing the technical solutions provided in the embodiments of this specification through software or firmware, the relevant program codes are stored in the memory 802, and the processor 801 is used to call and execute the blockchain data processing method applied to the intermediate node or the blockchain data processing method applied to the service node in the embodiments of this application;
[0142] The input / output interface 803 is used to implement information input and output;
[0143] The communication interface 804 is used to implement communication and interaction between this device and other devices. It can communicate through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.);
[0144] The bus 805 transmits information between the various components of the device (such as the processor 801, the memory 802, the input / output interface 803, and the communication interface 804);
[0145] Among them, the processor 801, the memory 802, the input / output interface 803, and the communication interface 804 are communicatively connected to each other inside the device through the bus 805.
[0146] The embodiments of this application also provide a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the above-mentioned blockchain data processing method applied to the intermediate node or the blockchain data processing method applied to the service node.
[0147] As a non-transitory computer-readable storage medium, the memory can be used to store non-transitory software programs and non-transitory computer-executable programs. In addition, the memory can include high-speed random access memory, and can also include non-transitory memory, such as at least one magnetic disk storage device, a flash memory device, or other non-transitory solid-state storage devices. In some embodiments, the memory optionally includes a memory remotely set relative to the processor, and these remote memories can be connected to the processor through a network. Examples of the above networks include, but are not limited to, the Internet, an enterprise intranet, a local area network, a mobile communication network, and combinations thereof.
[0148] The embodiments described in the embodiments of the present application are for more clearly illustrating the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application. Those skilled in the art will know that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of the present application are equally applicable to similar technical problems.
[0149] Those skilled in the art can understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than those shown in the figures, or combine certain steps, or different steps.
[0150] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, that is, they may be located in one place, or may be distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0151] Those of ordinary skill in the art can understand that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, and their appropriate combinations.
[0152] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above drawings are used to distinguish similar objects, and do not necessarily need to be used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances, so that the embodiments of the present application described here can be implemented in an order other than those illustrated or described here. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.
[0153] It should be understood that in this application, "at least one (item)" means one or more, and "a plurality" means two or more. "And / or" is used to describe the association relationship of associated objects and indicates that there can be three relationships. For example, "A and / or B" can mean: only A exists, only B exists, and both A and B exist at the same time. Here, A and B can be singular or plural. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. "At least one (item) of the following" or its similar expressions refer to any combination of these items, including any combination of single item (item) or plural items (items). For example, at least one (item) of a, b, or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a, b, and c", where a, b, and c can be single or multiple.
[0154] In several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the above division of units is only a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection to each other can be through some interfaces. The indirect coupling or communication connection of devices or units can be in electrical, mechanical, or other forms.
[0155] The units described above as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0156] In addition, the functional units in each embodiment of this application can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units.
[0157] When the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes multiple instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes: various media that can store programs, such as USB flash drives, mobile hard disks, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs.
[0158] The preferred embodiments of the embodiments of this application have been described above with reference to the accompanying drawings, and this does not limit the scope of the rights of the embodiments of this application. Any modifications, equivalent replacements, and improvements made by those skilled in the art without departing from the scope and essence of the embodiments of this application shall be within the scope of the rights of the embodiments of this application.
Claims
1. A blockchain data processing method, characterized in that, the method is applied to an intermediate node, and the method includes: receiving first transaction identification data and data to be chained sent by a service node, wherein the first transaction identification data is generated by the service node based on the data to be chained and service identification data; signing based on the first transaction identification data to obtain a first signature; sending the first signature to a blockchain node, so that the blockchain node performs chaining processing on the data to be chained after the first signature verification is successful.
2. The method according to claim 1, characterized in that, the signing based on the first transaction identification data to obtain a first signature includes: performing a digest calculation on the first transaction identification data and a first random number based on a preset digest algorithm to obtain a first digest; signing the first digest based on the obtained private key to obtain the first signature.
3. The method according to claim 1, characterized in that, the sending the first signature to a blockchain node, so that the blockchain node performs chaining processing on the data to be chained after the first signature verification is successful, includes: sending the first signature, the data to be chained, the first transaction identification data, the service identification data, and the first random number to the blockchain node, so that the blockchain node verifies the first signature based on the first signature, the data to be chained, the first transaction identification data, the service identification data, and the first random number, and the blockchain node performs chaining processing on the data to be chained after the first signature verification is successful.
4. The method according to any one of claims 1 to 3, characterized in that, before receiving the first transaction identification data and the data to be chained sent by the service node, the method further includes: receiving idle data to be chained sent by the service node, wherein the idle data to be chained is sent by the service node when the system thread occupancy rate is less than a preset occupancy rate; signing based on the idle data to be chained to obtain a second signature; sending the second signature to the blockchain node, so that the blockchain node performs chaining processing on the idle data to be chained after the second signature verification is successful, and the blockchain node sends second transaction identification data after the idle data to be chained is successfully chained.
5. The method according to claim 4, characterized in that, before receiving the first transaction identification data and the data to be chained sent by the service node, the method further includes: receiving a data query request sent by the service node, wherein the data query request carries the second transaction identification data; signing based on the second transaction identification data to obtain a third signature; sending the third signature to the blockchain node, so that the blockchain node performs a data query operation on the idle data to be chained after the third signature verification is successful.
6. A blockchain data processing method, characterized in that, the method is applied to a service node, and the method includes: Generate first transaction identification data based on the data to be chained and business identification data; Send the first transaction identification data and the data to be chained to an intermediate node, so that the intermediate node executes the method according to any one of claims 1 to 5.
7. The method according to claim 6, wherein, The sending the first transaction identification data and the data to be chained to an intermediate node includes: Obtain the system thread occupancy rate; If the system thread occupancy rate is greater than or equal to a preset occupancy rate, send the first transaction identification data and the data to be chained to the intermediate node.
8. A blockchain data processing device, wherein, The device is applied to an intermediate node, and the device includes: A data receiving module, configured to receive first transaction identification data and data to be chained sent by a service node, wherein the first transaction identification data is generated by the service node based on the data to be chained and business identification data; A signature module, configured to perform signature based on the first transaction identification data to obtain a first signature; A signature sending module, configured to send the first signature to a blockchain node, so that the blockchain node performs chaining processing on the data to be chained after the first signature verification is successful.
9. A blockchain data processing system, wherein, The system includes: A service node, configured to send data to be chained, or send the data to be chained and first transaction identification data; An intermediate node, configured to receive the data to be chained sent by the service node, or receive the data to be chained and the first transaction identification data sent by the service node, so as to execute the method according to any one of claims 1 to 5; A blockchain node, configured to perform chaining processing on the data to be chained.
10. An electronic device, wherein, The electronic device includes a memory and a processor, the memory stores a computer program, and when the processor executes the computer program, the method according to any one of claims 1 to 5 is implemented, or the method according to any one of claims 6 to 7 is implemented.
11. A computer-readable storage medium, the computer-readable storage medium stores a computer program, wherein, When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented, or the method according to any one of claims 6 to 7 is implemented.