Blockchain-based Data Processing Method, Apparatus, Electronic Device, and Storage Medium

By carrying block height information in the data subscription request and combining blockchain technology to automatically determine the data subscription type, the problem of single existing data subscription methods is solved, and an efficient and convenient data subscription process is achieved.

CN113591130BActive Publication Date: 2025-06-20TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202110946121.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-17
Publication Date
2025-06-20
Estimated Expiration
2041-08-17

AI Technical Summary

Technical Problem

The existing data subscription method is single, making it difficult for users to subscribe to real-time data and historical data at the same time, resulting in inefficient subscriptions.

Method used

By carrying the first block height and the second block height in the data subscription request, combining blockchain technology, the data subscription type is automatically determined, and the corresponding subscription data is obtained from the business blockchain.

Benefits of technology

It has realized the automation of various data subscription methods, improved the convenience and efficiency of data subscription, and enhanced the ability to obtain subscription data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113591130B_ABST
    Figure CN113591130B_ABST
Patent Text Reader

Abstract

An embodiment of the present application discloses a blockchain-based data processing method, apparatus, electronic device, and storage medium, which are applied to the field of computer technology. The method includes: obtaining a data subscription request sent by a service client, where the data subscription request carries a first block height and a second block height, determining a data subscription type according to the first block height and the second block height, obtaining a target service block from a service blockchain according to the data subscription type, and obtaining subscription data of the service client from the service data included in the target service block. By adopting the embodiment of the present application, the subscription method of subscription data can be enriched, and the subscription efficiency for subscription data can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular, to a data processing method, apparatus, electronic device, and storage medium based on a blockchain. Background Art

[0002] Currently, when a user wants to subscribe to required service data, a data subscription request can be sent to the device storing the service data, and the device provides a subscription service according to the indication of the data subscription request. The obtained subscription data can be real-time data or historical data. Therefore, the subscription type corresponding to the subscription service requested by the user can be a real-time data subscription type or a historical data subscription type. In the existing data subscription, usually the user independently selects the subscription type to be either the real-time data subscription type or the historical data subscription type. If the user wants to subscribe to both the real-time data subscription type and the historical data subscription type, the user needs to separately subscribe to the real-time data subscription type and the historical data subscription type. It can be seen that the way of data subscription by the user is single, and the data subscription method is not convenient enough, resulting in low efficiency of data subscription. Summary of the Invention

[0003] Embodiments of this application provide a data processing method, apparatus, electronic device, and storage medium based on a blockchain, which can enrich the subscription method of subscription data and improve the subscription efficiency for the subscription data.

[0004] On the one hand, embodiments of this application provide a data processing method based on a blockchain. The method includes:

[0005] Obtain a data subscription request sent by a service client; the data subscription request carries a first block height and a second block height; the first block height is less than or equal to the second block height;

[0006] Determine a data subscription type according to the first block height and the second block height;

[0007] Obtain a target service block from the service blockchain according to the data subscription type;

[0008] Obtain the subscription data of the service client from the service data included in the target service block.

[0009] On the one hand, embodiments of this application provide a data processing apparatus based on a blockchain. The apparatus includes:

[0010] An obtaining module, configured to obtain a data subscription request sent by a service client; the data subscription request carries a first block height and a second block height; the first block height is less than or equal to the second block height;

[0011] A determination module, configured to determine a data subscription type according to a first block height and a second block height;

[0012] An acquisition module, further configured to obtain a target business block from a business blockchain according to the data subscription type;

[0013] An acquisition module, further configured to obtain subscription data of a business client from the business data included in the target business block.

[0014] On the one hand, an embodiment of the present application provides an electronic device, which includes a processor and a memory. The memory is used to store a computer program, and the computer program includes program instructions. The processor is configured to call the program instructions to execute some or all of the steps in the above method.

[0015] On the one hand, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. The computer program includes program instructions. When the program instructions are executed by a processor, they are used to execute some or all of the steps in the above method.

[0016] Correspondingly, according to an aspect of the present application, there is provided a computer program product or a computer program. The computer program product or the computer program includes program instructions, and the program instructions are stored in a computer-readable storage medium. A processor of a computer device reads the program instructions from the computer-readable storage medium, and the processor executes the program instructions, so that the computer device executes the above-provided data processing method based on a blockchain.

[0017] In an embodiment of the present application, a data subscription request sent by a business client can be obtained. The data subscription request carries a first block height and a second block height. The data subscription type is determined according to the first block height and the second block height. The target business block is obtained from the business blockchain according to the data subscription type, and the subscription data of the business client is obtained from the business data included in the target business block. By implementing the above-proposed method, the automated acquisition of the data subscription type required by the user can be realized by specifying the block height, thereby enriching the subscription method during data subscription, improving the convenience of data subscription, and further improving the subscription efficiency for subscription data in combination with the blockchain. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0019] Figure 1 A schematic diagram of an application architecture provided by an embodiment of the present application;

[0020] Figure 2 A schematic flowchart of a data processing method based on a blockchain provided by an embodiment of the present application;

[0021] Figure 3 A schematic diagram of a scenario for generating a data subscription request provided by an embodiment of the present application;

[0022] Figure 4 A schematic diagram of a scenario for generating a data subscription request provided by an embodiment of the present application;

[0023] Figure 5 A schematic flowchart of a data processing method based on a blockchain provided by an embodiment of the present application;

[0024] Figure 6a A schematic diagram of a scenario for determining a target service block provided by an embodiment of the present application;

[0025] Figure 6b A schematic diagram of a scenario for obtaining subscribed data provided by an embodiment of the present application;

[0026] Figure 7 A schematic diagram of a scenario for data subscription provided by an embodiment of the present application;

[0027] Figure 8a A schematic diagram of an interaction for data subscription provided by an embodiment of the present application;

[0028] Figure 8b A schematic diagram of an interaction for data subscription provided by an embodiment of the present application;

[0029] Figure 8c A schematic diagram of an interaction for data subscription provided by an embodiment of the present application;

[0030] Figure 8d A schematic diagram of an interaction for data subscription provided by an embodiment of the present application;

[0031] Figure 9 A schematic diagram of the structure of a data processing device based on a blockchain provided by an embodiment of the present application;

[0032] Figure 10 A schematic diagram of the structure of an electronic device provided by an embodiment of the present application. Detailed implementation manners

[0033] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application.

[0034] The data processing method based on blockchain proposed in the embodiments of this application can be implemented on an electronic device, which can be a server or a terminal device. Among them, the server can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server. The terminal device can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, a vehicle-mounted terminal, etc., but is not limited thereto.

[0035] In some embodiments, please refer to Figure 1 , Figure 1 which is a schematic diagram of an application architecture provided by the embodiments of this application. The data processing method based on blockchain proposed in this application can be executed through this application architecture. As Figure 1 shown, Figure 1 it may include an electronic device and the device where the service client is located. Among them, a service blockchain for storing service data is deployed in the electronic device. The service blockchain may include one or more service blocks. The device where the service client is located is used to subscribe to the service data in the service blockchain. When the electronic device receives a data subscription request sent by the service client, the electronic device can perform a service operation of obtaining subscription data from the service blockchain according to the first block height and the second block height carried in the data subscription request. Optionally, the device where the service client is located can be a server or a terminal device.

[0036] It can be understood that Figure 1 this is only an exemplary representation of the possible application architecture of the technical solution of this application, and does not limit the specific architecture of the technical solution of this application. That is, the technical solution of this application can also provide other forms of application architectures.

[0037] Optionally, in some embodiments, the electronic device may execute the blockchain-based data processing method according to actual service requirements to improve the acquisition efficiency of subscribed data in the blockchain. The technical solution of the present application can be applied to any scenario of subscribing to data from a business blockchain. For example, it can be applied to the scenario of subscribing to data from a business blockchain to achieve business data synchronization of the business blockchain. The electronic device can implement the technical solution of the present application to determine the data subscription type when obtaining a data subscription request, based on the first block height and the second block height carried in the data subscription request, and obtain the subscribed data (such as financial transaction-related data, etc.) from the business data included in the target business block in a corresponding subscribed data acquisition manner according to the data subscription type. Then, the electronic device can send the subscribed data to the business client, and the device where the business client is located can store the received subscribed data to achieve data synchronization in the business blockchain. Through the technical solution of the present application, the acquisition efficiency of the subscribed data can be improved, which in turn helps to improve the overall efficiency in the scenario of synchronizing business data from the business blockchain.

[0038] Optionally, data involved in the present application, such as business data, etc., can be stored in a database or can be stored in a blockchain, such as through a blockchain distributed system. The present application does not make any limitations.

[0039] Among them, the blockchain is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, and encryption algorithms. The blockchain, in essence, is a decentralized database, a string of data blocks generated by using cryptographic methods. Each data block contains information about a batch of network transactions, which is used to verify the validity of the information (anti-counterfeiting) and generate the next block. The blockchain can include the blockchain underlying platform, the platform product service layer, and the application service layer.

[0040] The underlying blockchain platform may include processing modules such as user management, basic services, smart contracts, and operation monitoring. Among them, the user management module is responsible for managing the identity information of all blockchain participants, including maintaining the generation of public and private keys (account management), key management, and maintaining the correspondence between the real identity of the user and the blockchain address (permission management). And under authorization, it supervises and audits the transaction situations of certain real identities, and provides rule configuration for risk control (risk control audit); the basic service module is deployed on all blockchain node devices to verify the validity of business requests, and after reaching a consensus on valid requests, records them in storage. For a new business request, the basic service first performs interface adaptation parsing and authentication processing (interface adaptation), then encrypts the business information through a consensus algorithm (consensus management), and after encryption, transmits it to the shared ledger completely and consistently (network communication), and records and stores it; the smart contract module is responsible for the registration and issuance of contracts, as well as contract triggering and contract execution. Developers can define contract logic through a certain programming language, publish it to the blockchain (contract registration), trigger the execution by calling keys or other events according to the logic of the contract terms, complete the contract logic, and at the same time provide functions for contract upgrade and cancellation; the operation monitoring module is mainly responsible for the deployment, configuration modification, contract setting, cloud adaptation during the product release process, and visual output of the real-time state during product operation, such as: alarming, monitoring network conditions, monitoring the health status of node devices, etc.

[0041] The platform product service layer provides the basic capabilities and implementation frameworks of typical applications. Developers can build on these basic capabilities and overlay the characteristics of the business to complete the blockchain implementation of the business logic. The application service layer provides application services based on the blockchain solution for business participants to use. For example, in this application, data storage functions can be provided through the blockchain, and subscribed data can be obtained.

[0042] It can be understood that the above scenarios are only examples and do not constitute a limitation on the application scenarios of the technical solutions provided by the embodiments of this application. The technical solutions of this application can also be applied to other scenarios. For example, as is known to those of ordinary skill in the art, with the evolution of the system architecture and the emergence of new business scenarios, the technical solutions provided by the embodiments of this application are equally applicable to similar technical problems.

[0043] Based on the above description, the embodiments of this application propose a blockchain-based data processing method, which can be executed by the above-mentioned electronic device. Please refer to Figure 2 , Figure 2 which is a schematic flowchart of a blockchain-based data processing method provided by the embodiments of this application. As Figure 2 shown, the process of the blockchain-based data processing method of the embodiments of this application may include the following:

[0044] S201. Obtain a data subscription request sent by a service client; the data subscription request carries a first block height and a second block height.

[0045] Among them, the business blockchain contains one or more business blocks, and each business block corresponds to a block height. The electronic device can determine the data subscription type and the target business block by combining the first block height and the second block height carried in the data subscription request with the block height of each business block in the business blockchain. The block height can be set sequentially according to the generation time of the business block. For example, the block height of the business block can be 10, 11, 12,.... And, the first block height can be less than or equal to the second block height.

[0046] In a possible implementation manner, the service client is an application client or a web client. The service client can include a setting interface for the data subscription request. Relevant business personnel can specify the first block height and the second block height through this setting interface, and the service client generates a corresponding data subscription request based on the specified first block height and second block height and sends it to the electronic device. For example, as Figure 3 shown, Figure 3 FIG. is a schematic diagram of a scenario for generating a data subscription request provided by an embodiment of the present application. Among them, the user can specify the first block height and the second block height through the "request setting" interface of the service client, and trigger the "submit" control to enable the service client to generate a data subscription request based on the first block height and the second block height specified by the user; and optionally, the service client can provide a "block height" interface to query the block height situation of the business blocks in the business blockchain, such as the maximum block height at the query time, etc. Optionally, the target data type of the subscribed data can also be specified in the setting interface, and the service client generates a corresponding data subscription request based on the specified first block height, second block height, and target data type and sends it to the electronic device.

[0047] Another example, as Figure 4 shown, Figure 4A schematic diagram of a scenario for generating a data subscription request provided by an embodiment of the present application. Herein, a user can specify a first block height, a second block height, and a target data type through the "request setting" interface of the service client, and trigger the "submit" control to enable the service client to generate a data subscription request based on the first block height, the second block height, and the target data type specified by the user. Optionally, the service client can provide a "data type" interface to view the set of data types corresponding to the service data included in the service blocks in the service blockchain, and select the target data type from this set of data types. The target data type is the type of data that the user wants to subscribe to. Subsequently, the electronic device can determine the subscribed data from the service data included in the service blockchain based on the target data type.

[0048] S202. Determine the data subscription type according to the first block height and the second block height.

[0049] In a possible implementation manner, the electronic device can determine the data subscription type according to the first block height and the second block height. The data subscription type can include a historical data subscription type and a real-time data subscription type. Therefore, different data subscription types can be determined by uniformly specifying the block height, and then the acquisition of the subscribed data can be realized based on different data subscription types to improve the flexibility of the acquisition of the subscribed data. The data subscription type can be used to determine the target service block. The determination methods of the target service blocks corresponding to different data subscription types are different, and the acquisition methods of the corresponding subscribed data are also different. The subscribed data is the data finally subscribed by the user.

[0050] Among them, when the electronic device obtains the data subscription request, the service blockchain has a target block height, which is the block height of the service block with the largest block height in the service blockchain, that is, the block height of the service block with the latest generation time in the service blockchain. It can be understood that when the electronic device obtains the data subscription request, it takes the largest block height in the service blockchain at this time as the target block height corresponding to this data subscription request. If there are new service blocks in the service blockchain after the data subscription request is obtained, that is, when the corresponding largest block height changes, the target block height corresponding to this data subscription request remains unchanged. For example, the electronic device obtains the data subscription request at time X, and the largest block height at this time is 100, then the target block height of this data subscription request is 100. If at time X+1, there are new service blocks in the service blockchain, and the largest block height in the service blockchain at this time is 120, but the target block height of this data subscription request remains unchanged and is still 100.

[0051] Therefore, the specific way for the electronic device to determine that the data subscription type is the historical data subscription type can be that if both the first block height and the second block height are less than or equal to the target block height, it is determined that the data subscription type is the historical data subscription type, which means that the data subscription request indicates that the corresponding data subscription type is the historical data subscription type, and subsequently, the target business block is obtained from the business blockchain based on the target business block determination method corresponding to the historical data subscription type; and the specific way for the electronic device to determine that the data subscription type is the real-time data subscription type can be that if both the first block height and the second block height are greater than the target block height, it is determined that the data subscription type is the real-time data subscription type, which means that the data subscription request indicates that the corresponding data subscription type is the real-time data subscription type, and subsequently, the target business block is obtained from the business blockchain based on the target business block determination method corresponding to the real-time data subscription type.

[0052] For example, when the electronic device obtains a data subscription data request, the target block height is 100. If the first block height is 10 and the second block height is 20, then at this time it is the historical data subscription type; if the first block height is 110 and the second block height is 120, then at this time it is the real-time data subscription type.

[0053] S203. Obtain the target business block from the business blockchain according to the data subscription type.

[0054] In a possible implementation manner, if the data subscription type is the historical data subscription type, the specific way for the electronic device to obtain the target business block from the business blockchain according to the data subscription type can be to determine the first block height interval according to the first block height and the second block height, and obtain the business block on the business blockchain whose corresponding block height is within the first block height interval as the target business block. At this time, the target business block can also be called the historical business block, and the subscription data obtained from the business data of the historical business block can also be called the historical data, corresponding to the historical data subscription type. For example, if the first block height is 10 and the second block height is 20, then the first block height interval at this time is 10 to 20 (including 10 and 20), so the business block on the business blockchain with a height block between 10 and 20 is used as the target business block at this time.

[0055] Moreover, if the data subscription type is a real-time data subscription type, the electronic device obtains the target business block from the business blockchain according to the data subscription type. Specifically, the second block height interval is determined according to the first block height and the second block height. When a business block whose corresponding block height in the business blockchain is within the second block height interval is generated, the generated business block is synchronously determined as the target business block. The target business block at this time can also be called a real-time business block, and the subscription data obtained from the business data of the real-time business block can also be called real-time data, corresponding to the real-time data subscription type. For example, at this time, the target block height is 100, the first block height is 101, and the second block height is 120. Then the second block height interval at this time is 101 to 120 (including 101 and 120). Therefore, when a new business block is generated on the business blockchain and the block height of the new business block (such as 101) is within the second block height interval, the generated business block is synchronously determined as the target business block.

[0056] S204. Obtain the subscription data of the business client from the business data included in the target business block.

[0057] In a possible implementation manner, when the data subscription type is a historical data subscription type, the electronic device directly reads the included business data from the target business block in the business blockchain in sequence, uses the read business data as the subscription data subscribed by the business client, sends the subscription data to the business client, and after the sending is completed, the electronic device disconnects the connection with the device where the business client is located. Among them, the electronic device can send to the business client while reading the business data from the target business block, or can send all the business data to the business client after reading all the business data in the target business block.

[0058] In a possible implementation manner, when the data subscription type is a real-time data subscription type, when the electronic device detects that a business block is generated in the business blockchain and the block height corresponding to the business block is within the second block height interval, the business data being written into the business block is synchronously used as the subscription data and sent to the business client in real time. Among them, for the target business block determined at this time, when the electronic device detects that business data is written into the target business block and the business data is successfully written, the business data is read from the target business block, so as to continuously send the business data in the target business block to the business client based on the connection with the device where the business client is located, so as to realize the real-time sending of the subscribed data.

[0059] Optionally, in some embodiments, if the data subscription request further includes a target data type for the subscribed data, when the electronic device reads the service data in the target service block, the subscribed data of the service client can be obtained from the service data included in the target service block. Specifically, the service data belonging to the target data type can be obtained from the service data included in the target service block as the subscribed data, and the subscribed data is sent to the service client. That is, the service data in the service block can include different data types, and the different data types can be determined according to the actual service scenario. Therefore, when it is necessary to obtain the service data of a specified data type from the service blockchain, when the target service block is determined and the included service data is read from the target service block, the service data belonging to the target data type can be obtained from the service data according to the specified target data type and used as the subscribed data to implement a custom subscription scheme for obtaining service data in the service blockchain.

[0060] In the embodiments of the present application, a data subscription request sent by a service client can be obtained. The data subscription request carries a first block height and a second block height. The data subscription type is determined according to the first block height and the second block height. The subscribed data of the service client is obtained from the service data included in the target service block. By implementing the method proposed in the embodiments of the present application, the data subscription type required by the user can be automatically obtained by specifying the block height, thereby enriching the subscription method during data subscription, improving the convenience of data subscription, and further improving the subscription efficiency for the subscribed data in combination with the blockchain.

[0061] Please refer to Figure 5 , Figure 5 is a schematic flowchart of a data processing method based on a blockchain provided by an embodiment of the present application. This method can be executed by the above-mentioned electronic device. As Figure 5 shown, the process of the data processing method based on the blockchain in the embodiments of the present application can include the following:

[0062] S501. Obtain a data subscription request sent by a service client; the data subscription request carries a first block height and a second block height. Among them, the specific implementation manner of step S501 can refer to the relevant description of step S201 above, and will not be elaborated here.

[0063] S502. Obtain the target block height in the service blockchain.

[0064] Among them, when the electronic device obtains the data subscription request sent by the service client, it can obtain the target block height in the service blockchain. The target block height is the block height indicated by the service block with the largest block height in the service blockchain at this time.

[0065] S503. Determine the data subscription type according to the first block height, the second block height, and the target block height.

[0066] Among them, the electronic device can determine that the data subscription type is a historical data subscription type, a real-time data subscription type, or a mixed data type that includes both a historical data subscription type and a real-time data subscription type according to the first block height, the second block height, and the target block height.

[0067] In some embodiments, for the specific implementation of the electronic device determining that the data subscription type is a historical data subscription type or a real-time data subscription type according to the first block height, the second block height, and the target block height, reference may be made to the relevant description in step S202 above, and details are not described herein again.

[0068] In a possible implementation, the specific way for the electronic device to determine that the data subscription type is a mixed data subscription type according to the first block height, the second block height, and the target block height may be that if the first block height is less than the target block height and the second block height is greater than the target block height, then determine that the data subscription type is a mixed data subscription type; this mixed data subscription type includes a historical data subscription type and a real-time data subscription type. That is, it indicates that the data subscription request indicates a data subscription type that includes both a historical data subscription type and a real-time data subscription type. The historical data subscription type, the real-time data subscription type, and the mixed data subscription type can meet the different needs of the service client for obtaining subscription data, that is, the needs of the service client are to subscribe to historical data, real-time data, or a mixed data that includes historical data and real-time data. For example, when the electronic device receives a data subscription data request, if the target block height is 100, the first block height is 10, and the second block height is 120, then this is a mixed data subscription type at this time.

[0069] S504. Obtain the target service block from the business blockchain according to the data subscription type.

[0070] Optionally, when the data subscription type is a historical data subscription type or a real-time data subscription type, for the specific implementation of obtaining the target service block from the business blockchain according to the data subscription type, reference may be made to the relevant description in step S203 above, and details are not described herein again.

[0071] In a possible implementation, when the data subscription type is a hybrid data subscription type, the specific method for the electronic device to obtain the target business block from the business blockchain according to the data subscription type may be to determine the historical block height range and the real-time block height range based on the first block height and the second block height. At the first moment after obtaining the data subscription request, obtain the business blocks on the business blockchain whose corresponding block heights are within the historical block height range as the target business blocks. And, at the second moment after obtaining the data subscription request, if a business block with a block height within the real-time block height range is generated on the business blockchain, synchronously determine the generated business block as the target business block, where the first moment is earlier than the second moment; wherein, the lower limit of the historical block height range is the first block height, the upper limit of the historical block height range is the target block height, the upper limit of the real-time block height range is the second block height, the lower limit of the real-time block height range is the target block height, and the real-time block height range does not include the target block height. The first moment may be the moment after obtaining the data subscription request and determining the historical block height range and the real-time block height range, and the second moment may be the moment pointed to when all the business blocks within the historical block height range have been read, that is, the moment when the business block corresponding to the target block height has been read completely.

[0072] And, the business blocks within the historical block height range may obtain subscription data in the acquisition manner corresponding to the historical data subscription type, and the business blocks within the real-time block height range may obtain subscription data in the acquisition manner corresponding to the historical data subscription type or in the acquisition manner corresponding to the real-time data subscription type.

[0073] It can be understood that the target block height is included between the first block height and the second block height, and the target block height is the maximum block height in the business blockchain when the electronic device obtains the data subscription request. Optionally, the height range that can be determined by the first block height and the target block height may be called the historical block height range, that is, the business blocks in the business blockchain with block heights within this historical block height range may be called the historical business blocks corresponding to this data subscription request, and the subscription data obtained from the business data included in this historical business block may be called historical data; the height range that can be determined by the target block height and the second block height may be called the real-time block height range, that is, the business blocks generated on the business blockchain with block heights within this real-time block height range may be called the real-time business blocks corresponding to this data subscription request, and the subscription data obtained from the business data included in this real-time business block may be called real-time data. Since the historical block height range includes the target block height, the real-time block height range does not include the target block height.

[0074] For example, when the electronic device receives a data subscription request, the target block height is 100, the carried first block height is 10, and the second block height is 200. Therefore, the historical block height range is 10 to 100 (including 10 and 100), and the real-time block height range is 100 - 200 (including 200 but not including 100). Therefore, the business blocks in the business blockchain with block heights between 10 and 100 are the historical business blocks corresponding to the data subscription request, and the newly generated business blocks in the business blockchain with block heights between 101 and 200 are the real-time business blocks corresponding to the data subscription request. The first moment can be when the historical block height range and the real-time block height range are determined and ready to read the business block pointed to by the lower limit of the historical block height range from the business blockchain, that is, when ready to read the business block with a block height of 10 from the business blockchain. The second moment can be when the business block pointed to by the upper limit of the historical block height range is read, that is, when the business block with a block height of 100 is read.

[0075] Optionally, in a possible implementation manner, the representation forms of the first block height and the second block height can be not only specific block heights but also set special characters, which can be used to quickly read the specified business block and obtain the subscribed data. For example, it is agreed that the special character for the real-time business block is -1. When the first block height is -1, it means directly reading the business block generated after the business block with the current maximum block height (also known as the real-time business block). That is, if the business client wants to specify reading the real-time business block, it can be achieved by setting the first block height and the second block height to -1. For example, if the first block height is -1 and the second block height is -1, it means continuously reading the real-time business block and continuously pushing the business data in the real-time business block; if the first block height is -1 and the second block height is 500, it means continuously reading the real-time business block until the block height of the real-time business block reaches 500; if the first block height is 10 and the second block height is 500, it means starting to read from the historical business block with a block height of 10 until the historical business block with the target block height, and then continuing to read the subsequent business blocks in the way of reading the real-time business block until the block height of the real-time business block reaches 500; if the first block height is 10 and the second block height is -1, it means starting to read from the historical business block with a block height of 10 until the historical business block with the target block height, and then continuously reading the subsequently generated real-time business blocks in the way of reading the real-time business block and continuously pushing the business data in the real-time business block.

[0076] S505. Obtain the subscribed data of the business client from the business data included in the target business block.

[0077] Optionally, when the data subscription type is a historical data subscription type or a real-time data subscription type, the specific implementation of obtaining the subscription data of the service client from the service data included in the target service block may refer to the relevant description in step S204 above, which will not be elaborated here.

[0078] In a possible implementation, when the data subscription type is a mixed data subscription type, the specific way for the electronic device to obtain the subscription data of the service client from the service data included in the target service block may be that, at the first moment, directly read the target service blocks in the historical block height range in the service blockchain in the way of reading historical service blocks in sequence, and obtain the subscription data of the service client from the service data included in the target service block. At the second moment when the reading of the target service blocks in the historical block height range is completed, if there are service blocks in the target service blocks in the real-time block height range that are generated during the reading of the target service blocks in the historical block height range, this part of service blocks can be read in the way of reading historical service blocks, and then the subscription data can be obtained until there are no generated and unread service blocks in the real-time block height range on the service blockchain. Subsequently, when generating the target service block with the block height in the second block height range, synchronously read the target service block in the way of reading real-time service blocks, and obtain the subscription data.

[0079] Therefore, it can be understood that the first block height carried in the data subscription request can also be referred to as the block start height, and the second block height can also be referred to as the block end height, that is, it means that the electronic device obtains the subscription data from the service block indicated by the block start height until the service block indicated by the block end height.

[0080] For example, the historical block height range is 10 - 100 (including 10 and 100), and the real-time block height range is 100 - 200 (including 200 but not including 100). The electronic device reads the service blocks with the block height in the historical block height range on the service blockchain, that is, reads the service blocks with the block height of 10 - 100 on the service blockchain in the way of historical service blocks and obtains the subscription data. After the reading is completed, if service blocks 101 - 120 in the real-time block height range are generated on the service blockchain and are generated during the reading of the service blocks in the historical block height range, therefore, the service blocks 101 - 120 can be read in the way of historical service blocks. After the reading is completed, at this time, there are no generated and unread service blocks in the real-time block height range on the service blockchain, then the subsequent newly generated service blocks are regarded as real-time service blocks and are read in the way of real-time service blocks until the reading of the service data of the service block with the block height of 200 is completed.

[0081] Another example, please refer toFigure 6a , Figure 6a is a schematic diagram of a scenario for determining a target service block provided by an embodiment of the present application. When a data subscription request is obtained, the target block height is 100, the first block height is 10, and the second block height is 200. Therefore, the historical block height range is 10 - 100, and the real-time block height range is 100 - 200 (excluding 100, which can also be expressed as 101 - 200); please refer to Figure 6b , Figure 6b is a schematic diagram of a scenario for obtaining subscribed data provided by an embodiment of the present application. An electronic device reads service blocks with block heights between 10 and 100 in a service blockchain (the service blocks with block heights between 10 and 100 can be understood as new historical service blocks corresponding to the data subscription request). After the reading is completed, if there is a service block with a block height between 100 and 200 in the service blockchain (assuming service block ① with a block height between 101 and 120) that is generated during the reading of the service blocks with block heights between 10 and 100 (this service block ① can be understood as a new historical service block corresponding to the data subscription request), the reading of service block ① is continued in the same way as the reading of the service blocks with block heights between 10 and 100 in the service blockchain (i.e., the historical service block reading method). After the reading of service block ① is completed, if there is no unread generated service block with a block height between 100 and 200 on the service blockchain, then every time a service block with a block height between 100 and 200 is generated (assuming service block ② with a block height between 121 and 200), this service block ② is synchronously read (i.e., the real-time service block reading method) (this service block ② can be understood as a real-time service block corresponding to the data subscription request).

[0082] It can be understood that the subscription data reading methods for historical service blocks and real-time service blocks are different, and the paths to obtain the subscription data are different. When it is necessary to read historical service blocks to obtain subscription data, the electronic device can directly read the historical service blocks from the service blockchain, obtain the subscription data, and send it to the service client. When it is necessary to read real-time service blocks to obtain subscription data, the electronic device needs to register a target channel (channel, a Go language used to share messages, which is used to share the service data in real-time blocks here) for the service client and use the target channel as a parameter to update the subscriber list. This subscriber list includes the channels registered for multiple service clients. When a new service block is generated, the core module in the electronic device will push the new service block to multiple channels in the subscriber list. For the target channel, if the new service block is the real-time service block corresponding to the data subscription request, the subscriber module in the electronic device can receive the new service block from the target channel and read the new service block to obtain the subscription data. Optionally, the subscription module includes the subscription rules (the first block height, the second block height, and may include the target data type) carried in the data subscription request. When reading the service data in the new service block, the electronic device can, according to the target data type included in the subscription rules, obtain the subscription data belonging to the target data type and send it to the service client.

[0083] In a possible implementation, if the data subscription type is a real-time data subscription type or a mixed data subscription type, the electronic device establishes a long connection with the service client. At this time, when the subscription data is obtained, based on the long connection between the service clients, the subscription data is sent to the service client through the data subscription interface between the electronic device and the service client. Among them, the way for the electronic device to establish a long connection with the service client can be implemented through the stream (grpcstream, which can continuously push data. grpc is a high-performance RPC (Remote Procedure Call) framework. The service client can use this framework to call the data subscription interface of the electronic device to implement the data subscription of this solution). This stream mode is applicable to scenarios that include reading the service data of real-time service blocks. When a new subscribed service block is generated by the publisher (electronic device), the service data in the service block will be pushed to the subscriber (service client) in real-time. Based on the long connection, it can ensure the continuous sending of real-time service data and reduce the connection establishment and disconnection overhead, which can improve the processing performance of the electronic device. Therefore, the electronic device can be represented as an RPC Server, and correspondingly, the device where the service client is located can be represented as an RPC Client.

[0084] For example, please refer to Figure 7 , Figure 7 which is a schematic diagram of a data subscription scenario provided by an embodiment of the present application. Among them, there can be one or more business blockchains (Chain 1 (chain1), Chain 2 (chain2).....), which can be used for business data in business blocks between different independent chains. Accordingly, Chain 1 can correspond to a core engine module 1 and a subscriber list 1. The core engine module 1 is used to send a new business block generated on Chain 1 to multiple channels in the subscriber list 1 when it is detected. And Chain 2 can correspond to a core engine module 2 and a subscriber list 2. Therefore: (1) Sending a data subscription request: The business client sends a data subscription request (1-3). The data subscription request carries subscription rules (the first block height, the second block height, the target data type, the specified business blockchain (Chain 1 or Chain 2)). When the electronic device receives the data subscription request through the data subscription interface, it obtains the subscription rules carried in the data subscription request and stores them in the subscription module; (2) Obtaining subscription data: (a) When the data subscription type corresponding to the data subscription request is a historical data subscription type (data subscription request 1), the electronic device directly obtains the corresponding subscription data from the specified business blockchain and sends it to the business client through the data subscription interface; (b) When the data subscription type is a real-time data subscription type (data subscription request 3), when the core engine module 2 detects that a new business block is generated on the corresponding Chain 2, it sends the new business block to multiple channels in the subscriber list 2 of the corresponding Chain 2. When Channel 3 receives the new business block, the electronic device receives the new business block in Channel 2 through the subscription module, obtains the subscription data in the new business block according to the subscription rules corresponding to the data subscription request 3, and sends it to the business client 3 through the data subscription interface; (c) When the data subscription type corresponding to the data subscription request is a hybrid data subscription type (data subscription request 2), first obtain the corresponding subscription data from the business blockchain in the way of the historical data subscription type. After the historical business blocks are read, obtain the corresponding subscription data in the way of the real-time data subscription type through the core engine module, the subscriber list and the subscription module, and send it to the business client 2 through the data subscription interface; (3) After the electronic device sends the subscription data to the business client according to the data subscription request, the subscription operation corresponding to the data subscription request can be cancelled in the subscription module, that is, the target channel registered for the business client is deleted from the subscriber list.

[0085] For example, please refer to Figures 8a - 8d , Figures 8a - 8d which is an interaction schematic diagram of a data subscription provided by an embodiment of the present application. It is assumed that the target block height is 200 when the data subscription request is obtained:

[0086] (1) When the first block height carried in the data subscription request 1 is 10 and the second block height is 100 (10 - 100), the data subscription type is the historical data subscription type. The electronic device directly reads the target business block that is the historical business block from the business blockchain. After obtaining and sending the subscription data, the electronic device disconnects the connection with the business client;

[0087] (2) When the first block height carried in the data subscription request 2 is 10 and the second block height is -1 (set as a special character indicating the real-time block) (10 - -1), the data subscription type is the mixed data subscription type. The electronic device first reads the target business block that is the historical business block part from the business blockchain, sends the obtained subscription data, and reads the target business block that is the real-time business block part through the subscription module (register a channel for the business client through the subscription module, and use the core engine module to send the newly generated business block to the channel of the subscriber list. The subscription module receives and reads the newly generated business block through the channel). The electronic device continuously monitors and receives the real-time business block, synchronously reads the business data in the real-time business block, and obtains and sends the subscription data;

[0088] (3) When the first block height carried in the data subscription request 3 is 10 and the second block height is 500 (10 - 500), the data subscription type is the mixed data subscription type. The electronic device first reads the target business block that is the historical business block part from the business blockchain, sends the obtained subscription data, and reads the target business block that is the real-time business block part through the subscription module until the block height of the real-time business block reaches 500. After sending the subscription data, the electronic device disconnects the connection with the business client;

[0089] (4) When the first block height carried in the data subscription request 4 is -1 and the second block height is -1 (-1 - -1), the electronic device reads the target business block that is the real-time business block through the subscription module. The electronic device continuously monitors and receives the real-time business block, synchronously reads the business data in the real-time business block, and obtains and sends the subscription data;

[0090] (5) When the first block height carried in the data subscription request 5 is -1 and the second block height is 500 (-1 - 500), the electronic device reads the target business block that is the real-time business block through the subscription module until the block height of the real-time business block reaches 500. After sending the subscription data, the electronic device disconnects the connection with the business client;

[0091] (6) When the first block height carried in the data subscription request 6 is 220 and the second block height is 300 (220 - 300), the subscription module reads the target business block that is a real-time business block with a block height of 220 until the block height of the real-time business block reaches 300, and after sending the subscribed data, the electronic device disconnects the connection with the business client;

[0092] (7) When the first block height carried in the data subscription request 7 is 220 and the second block height is -1, since the second block height indicates the current real-time business block (block height is 201), the first block height is higher than the second block height, so a subscription error prompt message is generated and returned to the business client.

[0093] Among them, the above step (1) corresponds to Figure 8a , steps (2)-(3) correspond to Figure 8b , steps (4)-(5) correspond to Figure 8c , steps (6)-(7) correspond to Figure 8d .

[0094] In the embodiments of the present application, a data subscription request sent by a business client can be obtained. The data subscription request carries a first block height and a second block height. The target block height in the business blockchain is obtained, and the data subscription type is determined according to the first block height, the second block height, and the target block height. The target business block is obtained from the business blockchain according to the data subscription type, and the subscription data of the business client is obtained from the business data included in the target business block. By implementing the method proposed in the embodiments of the present application, the automated acquisition of the data subscription type required by the user can be realized by uniformly specifying the block height. The obtained data subscription type can be a historical data subscription type, a real-time data subscription type, or a mixed data subscription type to meet different requirements of the business client for the subscribed data. Furthermore, the subscription method during data subscription can be enriched, the convenience of data subscription can be improved, and the subscription efficiency for the subscribed data can be further improved by combining with the blockchain.

[0095] Please refer to Figure 9 , Figure 9 which is a schematic structural diagram of a blockchain-based data processing device provided by the present application. It should be noted that, Figure 9 the shown blockchain-based data processing device is used to execute the methods of the embodiments of the present application Figure 2 and Figure 5 shown. For the sake of convenience of description, only the parts related to the embodiments of the present application are shown, and the specific technical details are not disclosed. Refer to the present application Figure 2 and Figure 5The embodiments shown. The blockchain-based data processing apparatus 900 may include: an acquisition module 901 and a determination module 902. Among them:

[0096] The acquisition module 901 is configured to acquire a data subscription request sent by a service client; the data subscription request carries a first block height and a second block height; the first block height is less than or equal to the second block height;

[0097] The determination module 902 is configured to determine a data subscription type according to the first block height and the second block height;

[0098] The acquisition module 901 is further configured to acquire a target service block from the service blockchain according to the data subscription type;

[0099] The acquisition module 901 is further configured to acquire the subscription data of the service client from the service data included in the target service block.

[0100] In a possible implementation manner, when the data subscription request is acquired, the service blockchain has a target block height, and the target block height is the block height of the service block with the largest block height in the service blockchain;

[0101] When the determination module 902 is configured to determine the data subscription type according to the first block height and the second block height, it is specifically configured to:

[0102] If both the first block height and the second block height are less than or equal to the target block height, determine that the data subscription type is a historical data subscription type;

[0103] If both the first block height and the second block height are greater than the target block height, determine that the data subscription type is a real-time data subscription type;

[0104] If the first block height is less than the target block height and the second block height is greater than the target block height, determine that the data subscription type is a mixed data subscription type; the mixed data subscription type includes a historical data subscription type and a real-time data subscription type.

[0105] In a possible implementation manner, when the acquisition module 901 is configured to acquire a target service block from the service blockchain according to the data subscription type, it is specifically configured to:

[0106] If the data subscription type is a historical data subscription type, determine a first block height interval according to the first block height and the second block height;

[0107] Acquire the service blocks corresponding to the block heights in the first block height interval from the service blockchain as the target service blocks.

[0108] In a possible implementation, when the obtaining module 901 is used to obtain a target service block from a service blockchain according to a data subscription type, it is specifically used for:

[0109] If the data subscription type is a real-time data subscription type, determine a second block height interval according to a first block height and a second block height;

[0110] When a service block whose corresponding block height on the service blockchain is within the second block height interval is generated, synchronously determine the generated service block as the target service block.

[0111] In a possible implementation, when the obtaining module 901 is used to obtain a target service block from a service blockchain according to a data subscription type, it is specifically used for:

[0112] If the data subscription type is a hybrid data subscription type, determine a historical block height interval and a real-time block height interval according to a first block height and a second block height; the lower limit of the historical block height interval is the first block height, and the upper limit of the historical block height interval is the target block height; the upper limit of the real-time block height interval is the second block height, and the lower limit of the real-time block height interval is the target block height, and the real-time block height interval does not include the target block height;

[0113] At a first moment after obtaining a data subscription request, obtain a service block on the service blockchain whose corresponding block height is within the historical block height interval as the target service block;

[0114] At a second moment after obtaining the data subscription request, if a service block whose corresponding block height on the service blockchain is within the real-time block height interval is generated, synchronously determine the generated service block as the target service block; the first moment is earlier than the second moment.

[0115] In a possible implementation, the determining module 902 is further used for:

[0116] If the data subscription type is a real-time data subscription type or a hybrid data subscription type, establish a long connection with a service client;

[0117] The obtaining module 901 is further used for:

[0118] Send subscription data to the service client based on the long connection with the service client.

[0119] In a possible implementation, the data subscription request further includes a target data type; when the obtaining module 901 is used to obtain subscription data of a service client from service data included in a target service block, it is specifically used for:

[0120] Obtain the business data belonging to the target data type from the business data included in the target business block as the subscription data;

[0121] Send the subscription data to the business client.

[0122] In the embodiments of the present application, the acquisition module acquires a data subscription request sent by the business client; the data subscription request carries a first block height and a second block height; the first block height is less than or equal to the second block height; the determination module determines the data subscription type according to the first block height and the second block height; the acquisition module acquires the target business block from the business blockchain according to the data subscription type; the acquisition module acquires the subscription data of the business client from the business data included in the target business block. By implementing the above-mentioned device, it is possible to automatically obtain the data subscription type required by the user by specifying the block height, thereby enriching the subscription method during data subscription, improving the convenience of data subscription, and further improving the subscription efficiency for the subscription data in combination with the blockchain.

[0123] In each embodiment of the present application, each functional module can be integrated into one module, or each module can exist physically alone, or two or more modules can be integrated into one module. The above-mentioned integrated module can be implemented in the form of hardware or in the form of a software functional module, which is not limited in the present application.

[0124] Please refer to Figure 10 , Figure 10 which is a schematic structural diagram of an electronic device provided by an embodiment of the present application. As Figure 10 shown, the electronic device 1000 includes: at least one processor 1001 and a memory 1002. Optionally, the electronic device may further include a network interface. Among them, data can be exchanged between the processor 1001, the memory 1002, and the network interface. The network interface is controlled by the processor 1001 for sending and receiving messages. The memory 1002 is used to store a computer program, and the computer program includes program instructions. The processor 1001 is used to execute the program instructions stored in the memory 1002. Among them, the processor 1001 is configured to call the program instructions to execute the above method.

[0125] Among them, the memory 1002 may include a volatile memory, such as a random-access memory (RAM); the memory 1002 may also include a non-volatile memory, such as a flash memory, a solid-state drive (SSD), etc.; the memory 1002 may further include a combination of the above types of memories.

[0126] Among them, the processor 1001 can be a central processing unit (CPU). In one embodiment, the processor 1001 can also be a Graphics Processing Unit (GPU). The processor 1001 can also be a combination of a CPU and a GPU.

[0127] In a possible implementation, the memory 1002 is used to store program instructions, and the processor 1001 can call the program instructions to execute the following steps:

[0128] Obtain a data subscription request sent by a service client; the data subscription request carries a first block height and a second block height; the first block height is less than or equal to the second block height;

[0129] Determine the data subscription type according to the first block height and the second block height;

[0130] Obtain a target service block from the service blockchain according to the data subscription type;

[0131] Obtain the subscription data of the service client from the service data included in the target service block.

[0132] In a possible implementation, when the data subscription request is obtained, the service blockchain has a target block height, which is the block height of the service block with the largest block height in the service blockchain;

[0133] When the processor 1001 is used to determine the data subscription type according to the first block height and the second block height, it is specifically used for:

[0134] If both the first block height and the second block height are less than or equal to the target block height, determine that the data subscription type is a historical data subscription type;

[0135] If both the first block height and the second block height are greater than the target block height, determine that the data subscription type is a real-time data subscription type;

[0136] If the first block height is less than the target block height and the second block height is greater than the target block height, determine that the data subscription type is a mixed data subscription type; the mixed data subscription type includes a historical data subscription type and a real-time data subscription type.

[0137] In a possible implementation, when the processor 1001 is used to obtain a target service block from the service blockchain according to the data subscription type, it is specifically used for:

[0138] If the data subscription type is a historical data subscription type, determine a first block height range according to the first block height and the second block height;

[0139] Obtain business blocks on the business blockchain whose corresponding block heights are within the first block height range as target business blocks.

[0140] In a possible implementation, when the processor 1001 is used to obtain target business blocks from the business blockchain according to the data subscription type, it is specifically used for:

[0141] If the data subscription type is a real-time data subscription type, determine a second block height range according to the first block height and the second block height;

[0142] When a business block whose corresponding block height is within the second block height range is generated on the business blockchain, synchronously determine the generated business block as the target business block.

[0143] In a possible implementation, when the processor 1001 is used to obtain target business blocks from the business blockchain according to the data subscription type, it is specifically used for:

[0144] If the data subscription type is a mixed data subscription type, determine a historical block height range and a real-time block height range according to the first block height and the second block height; the lower limit of the historical block height range is the first block height, and the upper limit of the historical block height range is the target block height; the upper limit of the real-time block height range is the second block height, and the lower limit of the real-time block height range is the target block height, and the real-time block height range does not include the target block height;

[0145] At the first moment after obtaining the data subscription request, obtain business blocks on the business blockchain whose corresponding block heights are within the historical block height range as target business blocks;

[0146] At the second moment after obtaining the data subscription request, if a business block whose corresponding block height is within the real-time block height range is generated on the business blockchain, synchronously determine the generated business block as the target business block; the first moment is earlier than the second moment.

[0147] In a possible implementation, the processor 1001 is further used for:

[0148] If the data subscription type is a real-time data subscription type or a mixed data subscription type, establish a long connection with the business client;

[0149] The processor 1001 is further used for:

[0150] Send the subscribed data to the service client based on a long connection with the service client.

[0151] In a possible implementation, the data subscription request further includes a target data type; when the processor 1001 is used to obtain the subscribed data of the service client from the service data included in the target service block, it is specifically used for:

[0152] Obtain the service data belonging to the target data type from the service data included in the target service block as the subscribed data;

[0153] Send the subscribed data to the service client.

[0154] In a specific implementation, the above-described blockchain-based data processing device 900, processor 1001, memory 1002, etc. can execute the implementation manners described in the above method embodiments, and can also execute the implementation manners described in the embodiments of the present application, which will not be elaborated herein.

[0155] An embodiment of the present application further provides a computer (readable) storage medium. The computer storage medium stores a computer program, and the computer program includes program instructions. When the program instructions are executed by a processor, the processor can execute some or all of the steps executed in the above method embodiments. Optionally, the computer storage medium can be volatile or non-volatile. The computer-readable storage medium mainly includes a program storage area and a data storage area. Among them, the program storage area can store an operating system, application programs required for at least one function, etc.; the data storage area can store data created according to the use of blockchain nodes, etc.

[0156] As used herein, "a plurality of" means two or more. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. The character " / " generally represents an "or" relationship between the associated objects before and after.

[0157] Those of ordinary skill in the art can understand that all or part of the processes of implementing the above method embodiments can be completed by instructing relevant hardware through a computer program. The foregoing program can be stored in a computer storage medium, and the computer storage medium can be a computer-readable storage medium. When the program is executed, it can include the processes of the above method embodiments. Among them, the foregoing storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM), etc.

[0158] The above-disclosed are only some embodiments of the present application. Of course, the scope of rights of the present application cannot be limited thereby. Those of ordinary skill in the art can understand all or part of the processes of implementing the above embodiments, and the equivalent changes made according to the claims of the present application still fall within the scope covered by the present application.

Claims

1. A data processing method based on blockchain, characterized in that, The method includes: Obtaining a data subscription request sent by a service client; the data subscription request carries a first block height and a second block height; the first block height is less than or equal to the second block height; Determining a data subscription type according to the first block height and the second block height; Obtaining a target service block from a service blockchain according to the data subscription type; Obtaining the subscription data of the service client from the service data included in the target service block; Wherein, when the data subscription request is obtained, the service blockchain has a target block height, and the target block height is the maximum block height in the service blockchain; the determining the data subscription type according to the first block height and the second block height includes: If both the first block height and the second block height are less than or equal to the target block height, determining that the data subscription type is a historical data subscription type; If both the first block height and the second block height are greater than the target block height, determining that the data subscription type is a real-time data subscription type; If the first block height is less than the target block height and the second block height is greater than the target block height, determining that the data subscription type is a mixed data subscription type; the mixed data subscription type includes the historical data subscription type and the real-time data subscription type.

2. The method according to claim 1, characterized in that, The obtaining the target service block from the service blockchain according to the data subscription type includes: If the data subscription type is the historical data subscription type, determining a first block height range according to the first block height and the second block height; Obtaining a service block whose corresponding block height is within the first block height range from the service blockchain as the target service block.

3. The method according to claim 1, characterized in that, The obtaining the target service block from the service blockchain according to the data subscription type includes: If the data subscription type is the real-time data subscription type, determining a second block height range according to the first block height and the second block height; When a service block whose corresponding block height is within the second block height range is generated on the service blockchain, synchronously determining the generated service block as the target service block.

4. The method according to claim 1, characterized in that, The obtaining the target service block from the service blockchain according to the data subscription type includes: If the data subscription type is the mixed data subscription type, determining a historical block height range and a real-time block height range according to the first block height and the second block height; the lower limit of the historical block height range is the first block height, and the upper limit of the historical block height range is the target block height; the upper limit of the real-time block height range is the second block height, and the lower limit of the real-time block height range is the target block height, and the real-time block height range does not include the target block height; At a first moment after obtaining the data subscription request, obtain a service block on the service blockchain whose corresponding block height is within the historical block height range as the target service block; At a second moment after obtaining the data subscription request, if a service block whose corresponding block height is within the real-time block height range is generated on the service blockchain, synchronously determine the generated service block as the target service block; the first moment is earlier than the second moment.

5. The method according to claim 1, characterized in that, The method further includes: If the data subscription type is the real-time data subscription type or the hybrid data subscription type, establish a long connection with the service client; The method further includes: Send the subscription data to the service client based on the long connection with the service client.

6. The method according to claim 1, characterized in that, The data subscription request further includes a target data type; obtaining the subscription data of the service client from the service data included in the target service block includes: Obtain service data belonging to the target data type from the service data included in the target service block as the subscription data; Send the subscription data to the service client.

7. A data processing device based on blockchain, characterized in that, The apparatus includes: An obtaining module, configured to obtain a data subscription request sent by a service client; the data subscription request carries a first block height and a second block height; the first block height is less than or equal to the second block height; A determining module, configured to determine a data subscription type according to the first block height and the second block height; The obtaining module is further configured to obtain a target service block from the service blockchain according to the data subscription type; The obtaining module is further configured to obtain the subscription data of the service client from the service data included in the target service block; Wherein, when the data subscription request is obtained, the service blockchain has a target block height, and the target block height is the maximum block height in the service blockchain; determining the data subscription type according to the first block height and the second block height includes: If both the first block height and the second block height are less than or equal to the target block height, determine that the data subscription type is the historical data subscription type; If both the first block height and the second block height are greater than the target block height, determine that the data subscription type is the real-time data subscription type; If the first block height is less than the target block height and the second block height is greater than the target block height, determine that the data subscription type is the hybrid data subscription type; the hybrid data subscription type includes the historical data subscription type and the real-time data subscription type.

8. An electronic device, characterized in that, It includes a processor and a memory, wherein the memory is used to store a computer program, the computer program includes program instructions, and the processor is configured to call the program instructions to execute the method according to any one of claims 1-6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, and the computer program includes program instructions. When the program instructions are executed by a processor, the processor is caused to execute the method according to any one of claims 1-6.

Citation Information

Patent Citations

  • Event publishing and event subscribing method and device based on block chain

    CN110097363A