A data processing method and device based on blockchain
By processing transaction data in the blockchain network, parsing and processing the data of the latest block, and obtaining the original data of the transaction data, the problems of long business processes and easy errors in key checkpoints caused by the dispersion of transaction data in the existing technology are solved, and efficient processing of transaction data and fast transactions are achieved.
Patent Information
- Application Number
- CN202210652869.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-10
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2042-06-10
AI Technical Summary
In the existing technology, due to the dispersion of transaction data, the business process is long and key checkpoints are prone to errors.
By building a blockchain network, blockchain information is obtained according to a preset time period, the data of the latest block is parsed and processed, the hash value of the transaction data is extracted, the original data corresponding to the transaction data is obtained based on the hash value, and distributed to the business system for processing.
It achieves efficient processing of transaction data, ensures normal and rapid transaction processing, and avoids errors at key checkpoints caused by long business processes due to the dispersion of transaction data.
Smart Images

Figure CN115099813B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technologies, and in particular to a data processing method and device based on blockchain. Background Art
[0002] Under existing technical solutions, communication between multiple systems is mainly through Remote Procedure Call (RPC) or application program interface services. With the popularity of microservice architecture and fine-grained business segmentation, a request often needs to involve multiple services, and the services are interdependent. At the same time, service performance monitoring and troubleshooting have become very complex. An error in any node or intermediate link may cause the entire request to fail.
[0003] Taking the order relationship synchronization business scenario as an example, Figure 1 It is a flowchart of ordering relationship in the prior art, such as Figure 1 As shown, the existing process is initiated by the Business & Operation Support System (BOSS). BOSS uses the application program interface to synchronize user subscription relationship data to the main system in batches to activate benefits. The mesh network system forwards this information to the main system. After receiving the synchronized user data, the main system performs corresponding processing and informs the BOSS of the processing results.
[0004] by Figure 1 Taking the ordering relationship synchronization business in as an example, the BOSS generates the ordering relationship, synchronizes it to the mesh network system, and then forwards it to the main system through the mesh network routing. Since the ordering relationship is scattered among multiple BOSSes, the transaction data is scattered, the business process is long and has many links, and the checkpoints are prone to errors. Summary of the Invention
[0005] In view of the above problems, the present invention is proposed to provide a blockchain-based data processing method and device that overcomes the above-mentioned problems of long business processes and easy errors in key checkpoints due to the dispersion of transaction data.
[0006] According to one aspect of the present invention, a data processing method based on blockchain is provided, comprising:
[0007] Obtaining current blockchain information according to a preset time period, and parsing the current blockchain information to determine the latest block;
[0008] Determine whether the latest block has been processed; if not, parse the data of the latest block and process the data of the latest block to obtain transaction data;
[0009] Extract the hash value of the transaction data, obtain the original data corresponding to the transaction data based on the hash value, and distribute it to the business system for processing.
[0010] According to another aspect of the present invention, a data processing device based on blockchain is provided, comprising:
[0011] An information acquisition module, configured to acquire current blockchain information according to a preset time period and parse the current blockchain information to determine the latest block;
[0012] A judgment module, used to judge whether the latest block has been processed;
[0013] a parsing module, configured to parse data of the latest block and process the data of the latest block to obtain transaction data if the latest block has not been processed;
[0014] The processing module is used to extract the hash value of the transaction data, obtain the original data corresponding to the transaction data according to the hash value, and distribute it to the business system for processing.
[0015] According to another aspect of the present invention, there is provided a computing device, comprising: a processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other via the communication bus;
[0016] The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform operations corresponding to the above-mentioned blockchain-based data processing method.
[0017] According to another aspect of the present invention, a computer storage medium is provided, wherein the storage medium stores at least one executable instruction, and the executable instruction causes a processor to perform operations corresponding to the above-mentioned blockchain-based data processing method.
[0018] According to the present invention, a blockchain-based data processing method and device obtains current blockchain information according to a preset time period, parses the current blockchain information to determine the latest block; determines whether the latest block has been processed; if not, parses the data of the latest block and processes the data of the latest block to obtain transaction data; extracts the hash value of the transaction data, obtains the original data corresponding to the transaction data based on the hash value, and distributes it to the business system for processing. The present invention obtains blockchain information from the blockchain network according to a preset period, monitors the transaction data corresponding to the latest block in real time, thereby processing the transaction data, and obtains the original data corresponding to the transaction data based on the hash value of the transaction data, ensuring that transactions proceed normally and quickly, and avoiding the problem of key checkpoint errors caused by long business processes due to the dispersion of transaction data.
[0019] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are specifically listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Various other advantages and benefits will become apparent to those skilled in the art upon reading the detailed description of the preferred embodiment below. The accompanying drawings are for illustration purposes only and are not to be considered as limiting the present invention. The same reference symbols are used throughout the drawings to represent the same components. In the drawings:
[0021] Figure 1 Shows an order relationship flow chart in the prior art;
[0022] Figure 2 A flowchart of a blockchain-based data processing method provided by an embodiment of the present invention is shown;
[0023] Figure 3 A schematic diagram of a blockchain provided by an embodiment of the present invention is shown;
[0024] Figure 4 A schematic diagram of the blockchain and IPFS interaction process provided by an embodiment of the present invention is shown;
[0025] Figure 5 A schematic diagram of the structure of a blockchain-based data processing device provided by an embodiment of the present invention is shown;
[0026] Figure 6 A schematic structural diagram of a computing device provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0027] Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of the present invention and to fully convey the scope of the present invention to those skilled in the art.
[0028] Blockchain is a decentralized, distributed architecture where all nodes in the network fully record all data on the chain, ensuring data security and reliability. If one party loses data, the complete data can be quickly restored, reducing the long process chain of data calls and improving the efficiency of data sharing and circulation. In this invention, a blockchain network is constructed, and the data uploader and data downloader self-build nodes to join the blockchain network. On this basis, in order to be able to process transaction data on the blockchain network in real time, by monitoring each block of the blockchain network in real time and using smart contract event-driven notifications, it can achieve automatic distribution and processing of transaction data, solving the problem of high-concurrency and real-time processing of transaction data on the blockchain.
[0029] Figure 2 The flowchart of an embodiment of a data processing method based on blockchain of the present invention is shown. The method is applied to the data downloader. In this embodiment, the data uploader can be the transaction initiator in the blockchain network; the data downloader can be the transaction receiver in the blockchain network; Figure 2 As shown, the method includes the following steps:
[0030] Step S210: Obtain the current blockchain information according to a preset time period, and parse the current blockchain information to determine the latest block.
[0031] Specifically, the data downloader can obtain the current blockchain information according to a preset time period and parse the current blockchain information to determine the latest block; wherein, the preset time period can be set according to the actual application scenario, for example, the data downloader can obtain the current blockchain information from the blockchain every 0.5 seconds.
[0032] In this embodiment, the data uploader can construct transaction data and save it to the InterPlanetary File System, obtain the hash value of the transaction data, write the hash value to the local blockchain node through the smart contract, and the local blockchain node synchronizes the hash value to other blockchain nodes.
[0033] Figure 3 A schematic diagram of a blockchain provided by an embodiment of the present invention is shown in FIG. Figure 3As shown, the data uploader and the data downloader each establish a local blockchain node and join the blockchain network, wherein the data uploader and the data downloader can upload or download transaction data through the Software Development Kit (SDK) or the Application Programming Interface (API); specifically, when the data uploader writes the transaction data to the blockchain, the data will be automatically synchronized on each node of the entire blockchain network, so that each blockchain node will participate in recording the transaction data; when the data uploader constructs the transaction data and saves it to the file management system, it obtains the hash value of the transaction data and calls the smart contract on the blockchain to synchronize the hash value to other blockchain nodes. Based on the data consensus of the blockchain, the transaction data of the nodes in the entire network are automatically synchronized, and the blockchain node of the data downloader will also record the hash value of the transaction.
[0034] This embodiment uses the blockchain network as an example of a blockchain operating system (Enterprise Operation System, EOS) designed for distributed applications to process transaction data on the chain; and uses the InterPlanetary File System (IPFS) as an example of a file management system to store the original data corresponding to the transaction data. Figure 4 The following is a schematic diagram of the interaction process between blockchain and IPFS provided by an embodiment of the present invention. Figure 4 As shown in the figure, the process of obtaining IPFS data operation credentials is as follows: the data uploader obtains the blockchain common account and account private key; constructs a token request structure for obtaining IPFS data upload; the IPFS gateway verifies the user information (account and account private key, etc.) entered by the data uploader; if the verification is successful, the token data is generated and returned to the data uploader.
[0035] The data transmission process in IPFS is as follows: the data uploader prepares the data to be transmitted, where the data to be transmitted can be the transaction data to be transmitted by the data uploader; organizes the Hypertext Transfer Protocol (HTTP) message based on the data to be transmitted, and uploads the data to be transmitted with a token; the IPFS gateway verifies the token message, and after the verification passes, forwards the data operation request to the IPFS file system; the IPFS file system saves the data and returns the corresponding hash value of the data to be transmitted.
[0036] The data downloader obtains the hash value corresponding to the data from the blockchain; organizes and obtains the data HTTP information based on the hash value; and carries the token to obtain the data to be transmitted; the IPFS gateway verifies the token information, and after the verification is passed, the IPFS file system returns the data to be transmitted to the data downloader.
[0037] The data transmission process on the blockchain is as follows: the data uploader prepares the hash value corresponding to the data, calls the smart contract (DAPP) based on the hash value to upload the data to the chain; the blockchain system conducts data consensus.
[0038] The data downloader obtains the hash value corresponding to the data through DAPP, and obtains the original data corresponding to the data from the IPFS file system based on the hash value; if the data to be transmitted prepared by the data uploader is transaction data to be transmitted, the original data corresponding to the transaction data transmitted by the data uploader is obtained from the IPFS file system based on the hash value.
[0039] In an optional manner, step S210 further includes: parsing the current blockchain information to obtain the latest block number; setting the current block number, and cyclically determining whether the current block number is less than the latest block number; if so, pulling the latest block from the blockchain, where the block number of the latest block is the current block number plus one.
[0040] Specifically, use EOS's chain / get_info interface to obtain the current blockchain information and parse the latest block number head_block_num from it; initialize the monitoring of the current block information, set the current block number start_block_num, DAPP account and the name of the smart contract action; among them, the current block refers to the block from which block data is obtained in sequence and which DAPP accounts and smart contract action names in the monitoring block are selected.
[0041] Taking the preset time period of 0.5 seconds as an example, in this step, the current blockchain information is obtained every 0.5 seconds, the current blockchain information is parsed to determine the latest block, and a loop is started to monitor and process the transaction data on the blockchain in real time. Specifically, the current block number current_block_num is initialized to start_block_number-1, and a loop is used to determine whether the current block number current_block_num is less than the latest block number head_block_num; if so, the latest block is pulled from the blockchain, and the block with the current block number plus one (i.e., current_block_num+1) is pulled once through the chain / get_block interface of EOS and recorded as the latest block new_block.
[0042] It should be noted that if the current block number is greater than or equal to the latest block number, after continuing to wait for a preset time period, step S210 is repeated to determine the latest block.
[0043] Step S220: Determine whether the latest block has been processed; if so, return to step S210; if not, execute step S230.
[0044] In an optional manner, step S220 further includes: obtaining the block number of the last processed block, and determining whether the block number of the last processed block is equal to the block number of the latest block; if so, determining that the latest block has been processed; if not, determining that the latest block has not been processed.
[0045] In an optional manner, after parsing the current blockchain information to determine the latest block and before determining whether the latest block has been processed, that is, after step S210 and before step S220, the method further includes: performing a hash check on the latest block to determine whether the latest block is an irreversible block; wherein, if the check passes, the latest block is determined to be an irreversible block.
[0046] It should be noted that if the latest block is a reversible block, the transaction data on the corresponding blockchain may be in an intermediate state, resulting in a fork in the transaction data. In this case, the transaction data pointed to by the latest block is not accurate. Therefore, after obtaining the latest block, it is necessary to first perform a hash check on the latest block to confirm that the latest block is the latest irreversible block of the blockchain main chain. In an optional method, performing a hash check on the latest block further includes steps 1-3:
[0047] Step 1: Get the hash value of the previous block saved in the latest block and the hash value of the current block corresponding to the current block number; determine whether the hash value of the previous block is equal to the hash value of the current block; if so, execute step 2; if not, jump to step 3.
[0048] Specifically, the characteristic of blockchain is an ordered chain. Each block saves the hash value of the previous block. According to the latest block new_block obtained in step S210, the hash value privious_block_hash pointing to the previous block is taken out from this latest block. Then, according to the current block current_block obtained by the last current block number current_block_num, the hash value block_hash of the current block itself is taken out. It is determined whether privious_block_hash is equal to block_hash; if so, execute step 2; if not, jump to step 3.
[0049] Step 2: Confirm that the hash of the latest block passes verification, update the current block to the latest block, and store the hash value of the current block in the historical block record.
[0050] If privious_block_hash is equal to block_hash, it means that the latest block new_block is the main chain data. The hash verification of the latest block is confirmed to be passed, and the current block current_block is updated to the latest block new_block. The hash value of the updated current block current_block is stored in the historical block record block_history.
[0051] Step 3: Roll back the data. Search for a historical block whose hash value is equal to the hash value of the previous block based on the historical block records. Replace the historical block with the current block, delete the on-chain data after the current block, and update the current blockchain information.
[0052] If privious_block_hash is not equal to block_hash, it means that the chain has forked, and the data is rolled back. According to the historical block record block_history, a historical block with a hash value equal to the hash value of the previous block is searched, and the historical block is replaced with the current block current_block. The on-chain data after the current block current_block is deleted, the current blockchain information is updated, and the block number corresponding to the unforked data is relocated to head_block_num.
[0053] In an optional manner, after the hash check is passed on the latest block new_block, it is determined whether the latest block new_block has been processed; specifically, the block number last_processed_block_Num of the last processed block is obtained, and it is determined whether the last processed block number last_processed_block_Num is equal to the block number current_block_num of the current block; if they are equal, it is determined that the latest block new_block has been processed, and the process returns to step S210 to wait for the next block polling; if they are not equal, it is determined that the latest block new_block has not been processed, and the process repositions to the block number of the last processed block plus last_processed_block_Num+1, and the process returns to step S210 to wait for the next block polling.
[0054] Step S230: Parse the data of the latest block and process the data of the latest block to obtain transaction data.
[0055] In this step, if it is determined that the latest block new_block has not been processed, the data of the latest block new_block is parsed and multi-threaded processing is performed on the data of the latest block new_block to obtain transaction data.
[0056] In an optional manner, step S230 further includes: parsing the latest block to obtain the action array of the latest block, searching for action data matching the smart contract by traversing the action array; and concurrently processing the action data by multi-threading to obtain transaction data.
[0057] Specifically, the latest block is parsed to obtain its action array (actions array), which is then looped through to find each action data matching the smart contract. Multithreading (disruptor) concurrently processes the action data to obtain transaction data. Action data can include data such as the hash value and timestamp corresponding to the transaction data. Each transaction data item is matched to a single thread. This approach enables real-time processing of massive amounts of transaction data under high-concurrency conditions on the chain.
[0058] Step S240: extract the hash value of the transaction data, obtain the original data corresponding to the transaction data based on the hash value, and distribute it to the business system for processing.
[0059] Taking the IPFS system as an example, the hash value of transaction data in the blockchain network can point to the original data corresponding to the transaction data corresponding to the hash value of the transaction data in the IPFS. Therefore, in this step, according to each transaction data, the hash value of the transaction data is extracted, and the IPFS interface is called according to the hash value to obtain the original data corresponding to the transaction data, and the original data corresponding to the transaction data is distributed to the back-end business system to process the original data according to its respective business logic; specifically, the original data corresponding to the transaction data includes data such as messages generated by the transaction data; after all transaction data is processed, the block data has been processed, and the block number last_processed_block_Num of the last processed block is updated to the current block number, and the process returns to step S210 to wait for the scheduling of the next block.
[0060] In an optional embodiment, the method further includes: saving the block number of the processed block to a database; when a failure occurs, retrieving the block number of the last processed block from the database; and monitoring and obtaining current blockchain information based on the block number of the last processed block.
[0061] Specifically, the processed block number can be saved to the database. In order to support more hash types, the Remote Dictionary Server (Redis) database is preferred to ensure that if there is an abnormal situation, the latest block data of the current blockchain information can be processed from this block number.
[0062] by Figure 1 The sub-BOSS system generates approximately 6 million transactions per day, and the sub-BOSS system concurrently writes the transaction data into the blockchain. The main system monitors the block chain in real time, and processes the transaction data on the blockchain in real time to enable subscription services for users. The blockchain ensures strong consistency in the subscription relationship between the sub-BOSS system and the main system, and enables real-time and high-concurrency processing of transaction data on the blockchain.
[0063] The method of this embodiment obtains current blockchain information according to a preset time period, parses the current blockchain information to determine the latest block; after the latest block passes the hash check, it is determined whether the latest block has been processed; if not, the data of the latest block is parsed and multi-threaded processing is performed on the data of the latest block to obtain transaction data; the hash value of the transaction data is extracted, the original data corresponding to the transaction data is obtained based on the hash value, and the original data is distributed to the business system for processing. This method builds a blockchain network and adds transaction data to the blockchain network, so that each blockchain node will participate in recording the transaction data, avoiding the problem of key checkpoint errors caused by the long business process due to the dispersion of transaction data; the method monitors each block in real time based on EOS and IPFS, obtains blockchain information from the blockchain network according to a preset period, monitors the transaction data corresponding to the latest block in real time, and then processes the transaction data in multiple threads. The original data is obtained from the InterPlanetary File System based on the hash value of the transaction data, realizing real-time multi-threaded processing of transaction data under high concurrency, ensuring normal and rapid transaction processing.
[0064] Figure 5 The following is a schematic diagram showing the structure of an embodiment of a data processing device based on blockchain according to the present invention. Figure 5 As shown, the device includes: an information acquisition module 510, a verification module 520, a judgment module 530, an analysis module 540 and a processing module 550.
[0065] The information acquisition module 510 is used to obtain the current blockchain information according to a preset time period and parse the current blockchain information to determine the latest block.
[0066] In an optional manner, the information acquisition module 510 is further used to: parse the current blockchain information to obtain the latest block number; set the current block number, and cyclically determine whether the current block number is less than the latest block number; if so, pull the latest block from the blockchain, and the block number of the latest block is the current block number plus one.
[0067] In an optional manner, the device further includes a verification module 520 for performing a hash verification on the latest block; if the verification passes, the latest block is determined to be an irreversible block.
[0068] In an optional manner, the verification module 520 is further used to: obtain the hash value of the previous block saved in the latest block and the hash value of the current block corresponding to the current block number; determine whether the hash value of the previous block is equal to the hash value of the current block; if so, determine that the hash verification of the latest block passes.
[0069] In an optional manner, the verification module 520 is further used to: if the hash value of the previous block is equal to the hash value of the current block, then update the current block to the latest block, and store the hash value of the current block in the historical block record; if the hash value of the previous block is not equal to the hash value of the current block, then roll back the data, search for a historical block with a hash value equal to the hash value of the previous block according to the historical block record, replace the historical block with the current block, delete the on-chain data after the current block, and update the current blockchain information.
[0070] The judgment module 530 is used to judge whether the latest block has been processed after the hash check is passed on the latest block.
[0071] In an optional manner, the judgment module 530 is further used to: obtain the block number of the last processed block, and determine whether the block number of the last processed block is equal to the block number of the latest block; if so, it is determined that the latest block has been processed; if not, it is determined that the latest block has not been processed.
[0072] The parsing module 540 is configured to parse the data of the latest block and process the data of the latest block to obtain transaction data if the latest block has not been processed.
[0073] In an optional manner, the parsing module 540 is further used to: parse the latest block to obtain the action array of the latest block, search for action data matching the smart contract by traversing the action array; and concurrently process the action data through multiple threads to obtain transaction data.
[0074] The processing module 550 is used to extract the hash value of the transaction data, obtain the original data corresponding to the transaction data based on the hash value, and distribute it to the business system for processing.
[0075] In an optional manner, the device may also include a transaction data chain module, which is used to construct transaction data and save it to the interstellar file system, obtain the hash value of the transaction data, write the hash value to the local blockchain node through the smart contract, and the local blockchain node synchronizes the hash value to other blockchain nodes.
[0076] In an optional manner, the processing module 550 is further used to: save the block number of the processed block to a database; the information acquisition module 510 is further used to: retrieve the block number of the last processed block from the database when a failure occurs; and monitor and obtain current blockchain information based on the block number of the last processed block.
[0077] The device of this embodiment obtains current blockchain information at a preset time interval, parses the information, and determines the latest block. After the latest block passes a hash check, it determines whether it has been processed. If not, it parses the data of the latest block and processes it in a multi-threaded manner to obtain transaction data. It then extracts the hash value of the transaction data, obtains the original data corresponding to the transaction data based on the hash value, and distributes it to the business system for processing. This device builds a blockchain network and adds transaction data to the blockchain network, ensuring that every blockchain node participates in recording the transaction data.
[0078] An embodiment of the present invention provides a non-volatile computer storage medium, which stores at least one executable instruction. The computer executable instruction can execute a blockchain-based data processing method in any of the above method embodiments.
[0079] The executable instructions can be used to cause the processor to perform the following operations:
[0080] Obtain the current blockchain information according to the preset time period, and parse the current blockchain information to determine the latest block;
[0081] Determine whether the latest block has been processed; if not, parse the data of the latest block and process the data of the latest block to obtain transaction data;
[0082] Extract the hash value of the transaction data, obtain the original data corresponding to the transaction data based on the hash value, and distribute it to the business system for processing.
[0083] Figure 6 The schematic diagram of the structure of the computing device embodiment of the present invention is shown. The specific embodiment of the present invention does not limit the specific implementation of the computing device.
[0084] like Figure 6 As shown, the computing device may include:
[0085] Processor, Communications Interface, Memory, and Communication Bus.
[0086] The processor, communication interface, and memory communicate with each other via a communication bus. The communication interface is used to communicate with other devices, such as clients or other server network elements. The processor is used to execute programs, specifically the steps described in the aforementioned embodiment of a blockchain-based data processing method.
[0087] Specifically, the program may include program codes including computer operation instructions.
[0088] The processor may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention. The one or more processors included in the server may be processors of the same type, such as one or more CPUs, or processors of different types, such as one or more CPUs and one or more ASICs.
[0089] Memory is used to store programs. The memory may include high-speed RAM memory, and may also include non-volatile memory (non-volatile memory), such as at least one disk storage.
[0090] The program can be specifically used to cause the processor to perform the following operations:
[0091] Obtain the current blockchain information according to the preset time period, and parse the current blockchain information to determine the latest block;
[0092] Determine whether the latest block has been processed; if not, parse the data of the latest block and process the data of the latest block to obtain transaction data;
[0093] Extract the hash value of the transaction data, obtain the original data corresponding to the transaction data based on the hash value, and distribute it to the business system for processing.
[0094] In an optional manner, the program can be further used to enable the processor to execute other steps of a blockchain-based data processing method in the above embodiment.
[0095] The algorithm or demonstration provided herein are not inherently relevant to any particular computer, virtual system or other equipment. Various general-purpose systems may also be used together with the teachings based on this. According to the above description, it is apparent that the structure required for constructing this type of system. In addition, the embodiment of the present invention is not directed to any specific programming language yet. It should be understood that various programming languages can be utilized to realize the content of the present invention described herein, and the above description of specific languages is for the purpose of disclosing the best mode of the present invention.
[0096] In the description provided herein, numerous specific details are described. However, it is understood that embodiments of the present invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques are not shown in detail so as not to obscure the understanding of this description.
[0097] Similarly, it should be understood that in order to streamline the present invention and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the invention, various features of the embodiments of the invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, this disclosed method should not be interpreted as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim. Rather, as reflected in the claims below, inventive aspects lie in less than all the features of the individual embodiments disclosed above. Accordingly, the claims that follow the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of the invention.
[0098] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and in addition may be divided into multiple submodules or subunits or subcomponents. All features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed herein may be combined in any combination, except that at least some of such features and / or processes or units are mutually exclusive. Unless expressly stated otherwise, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.
[0099] Furthermore, those skilled in the art will appreciate that although some embodiments herein include certain features included in other embodiments but not other features, combinations of features from different embodiments are intended to be within the scope of the present invention and to form different embodiments. For example, in the claims below, any of the claimed embodiments may be used in any combination.
[0100] The various component embodiments of the present invention can be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It will be appreciated by those skilled in the art that a microprocessor or digital signal processor (DSP) can be used in practice to implement some or all of the functions of some or all of the components according to an embodiment of the present invention. The present invention can also be implemented as a device or apparatus program (e.g., a computer program and a computer program product) for executing a part or all of the methods described herein. Such a program implementing the present invention can be stored on a computer-readable medium, or can have the form of one or more signals. Such a signal can be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.
[0101] It should be noted that the above embodiments illustrate rather than limit the invention, and that alternative embodiments may be devised by a person skilled in the art without departing from the scope of the appended claims. In the claims, any reference signs placed between brackets should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention may be implemented by means of hardware comprising several different elements and by means of appropriately programmed computers. In a unit claim enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third etc. does not indicate any order. These words may be interpreted as names. The steps in the above embodiments should not be understood as limiting the order of execution unless otherwise specified.
Claims
1. A data processing method based on blockchain, characterized in that: include: Obtaining current blockchain information according to a preset time period, and parsing the current blockchain information to obtain the latest block number; Set the current block number and cyclically determine whether the current block number is less than the latest block number; If yes, then pull the latest block from the blockchain, where the block number of the latest block is the current block number plus one; Obtaining the hash value of the previous block stored in the latest block and the hash value of the current block corresponding to the current block number; Determine whether the hash value of the previous block is equal to the hash value of the current block; If so, determine that the hash check of the latest block passes, update the current block to the latest block, determine that the latest block is an irreversible block, and store the hash value of the current block in the historical block record; If not, perform a data rollback, search for a historical block with a hash value equal to the hash value of the previous block based on the historical block record, replace the historical block with the current block, delete the on-chain data after the current block, and update the current blockchain information; Determine whether the latest block has been processed; if not, parse the data of the latest block and process the data of the latest block to obtain transaction data; Extract the hash value of the transaction data, obtain the original data corresponding to the transaction data based on the hash value, and distribute it to the business system for processing.
2. The method according to claim 1, characterized in that Determining whether the latest block has been processed further includes: Obtaining the block number of the last processed block, and determining whether the block number of the last processed block is equal to the block number of the latest block; If so, it is determined that the latest block has been processed; if not, it is determined that the latest block has not been processed.
3. The method according to any one of claims 1 to 2, characterized in that The parsing of the data of the latest block and processing the data of the latest block to obtain transaction data further includes: Parsing the latest block to obtain an action array of the latest block, and searching for action data matching the smart contract by traversing the action array; The action data is processed by concurrent multi-threading to obtain transaction data.
4. A data processing device based on blockchain, characterized in that: include: An information acquisition module is used to obtain current blockchain information according to a preset time period and parse the current blockchain information to obtain the latest block number; Set the current block number and cyclically determine whether the current block number is less than the latest block number; If yes, then pull the latest block from the blockchain, where the block number of the latest block is the current block number plus one; Obtaining the hash value of the previous block stored in the latest block and the hash value of the current block corresponding to the current block number; Determine whether the hash value of the previous block is equal to the hash value of the current block; If so, determine that the hash check of the latest block passes, update the current block to the latest block, determine that the latest block is an irreversible block, and store the hash value of the current block in the historical block record; If not, perform a data rollback, search for a historical block with a hash value equal to the hash value of the previous block based on the historical block record, replace the historical block with the current block, delete the on-chain data after the current block, and update the current blockchain information; A judgment module, used to judge whether the latest block has been processed; a parsing module, configured to parse data of the latest block and process the data of the latest block to obtain transaction data if the latest block has not been processed; The processing module is used to extract the hash value of the transaction data, obtain the original data corresponding to the transaction data according to the hash value, and distribute it to the business system for processing.
5. A computing device, characterized in that include: A processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform an operation corresponding to the blockchain-based data processing method according to any one of claims 1 to 3.
6. A computer storage medium, characterized in that The storage medium stores at least one executable instruction, and the executable instruction enables the processor to perform an operation corresponding to the blockchain-based data processing method as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Block chain transaction storage method and device, electronic equipment and readable storage medium
CN114238500A