Block information pushing method and device, computer device and storage medium
By carrying the block number in the block information and using checkpoint checks, the problem of inconsistent block information push in the blockchain system is solved, and the orderly and accurate push of block information is achieved.
Patent Information
- Application Number
- CN202211738788.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-30
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2042-12-30
Smart Images

Figure CN116192941B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of blockchain technology, and in particular relates to a method, apparatus, computer equipment, and storage medium for pushing block information. Background Art
[0002] In existing blockchain applications, blockchain systems can push messages to business systems using blockchain message push. Specifically, each time a blockchain node in the blockchain system generates a block, the node's corresponding message push module generates the corresponding block information for push. This triggers the message push module's message push process, pushing the block information to a message queue, which then pushes the information to other business systems.
[0003] During this process, the message push module in the blockchain node generates corresponding push messages based on the generated blocks. Since the push messages are asynchronous with the block generation, it is often the case that the later generated blocks push messages first. Moreover, when a block is rolled back or cut, the same block information will be pushed twice, i.e. a "dirty block" is pushed. Summary of the Invention
[0004] The embodiments of the present application provide a method, apparatus, computer device, and storage medium for pushing block information to solve the problems in the prior art of pushing messages for later-generated blocks first and pushing "dirty blocks" when block information is pushed.
[0005] A first aspect of an embodiment of the present application provides a method for pushing block information, including:
[0006] Every time a block is generated, block information waiting to be pushed is generated, and the block information carries the block number of the block;
[0007] Based on the block information, determining target block information that has passed the checkpoint based on the block number;
[0008] The target block information is output to a target queue in sequence according to the block numbers.
[0009] A second aspect of an embodiment of the present application provides a block information pushing device, including:
[0010] A generation module, configured to generate block information to be pushed each time a block is generated, wherein the block information carries the block number of the block;
[0011] An information determination module, configured to determine, based on the block information, target block information of a checkpoint that has passed the check based on the block number;
[0012] An output module is configured to output the target block information in sequence to a target queue according to the block number.
[0013] A third aspect of the embodiments of the present application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the method according to the first aspect when executing the computer program.
[0014] A fourth aspect of the embodiments of the present application provides a computer readable storage medium, which stores a computer program, and the computer program is executable on a processor to implement the steps of the method according to the first aspect.
[0015] A fifth aspect of the embodiments of the present application provides a computer program product, which, when executed on a computer device, causes the computer device to perform the steps of the method according to the first aspect.
[0016] As can be seen from the above, in the embodiments of the present application, each time a block is generated, block information carrying the block number of the corresponding block is generated, and the target block information that passes the checkpoint based on the block number is determined based on the block information. Finally, the target block information is output in sequence to the target queue according to the block number. In this process, the block number carried in the block information is used to introduce the checkpoint to check the block information based on the block number, so as to screen the case that one block number corresponds to multiple block information, to realize the checking and screening of dirty blocks, and to ensure that the target block information that passes the check is pushed to the message queue based on the block number, so as to realize the ordered pushing of the block information. BRIEF DESCRIPTION OF DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without any creative effort on the basis of these drawings.
[0018] Figure 1 is a flowchart of a block information pushing method provided by the embodiments of the present application Figure 1 ;
[0019] Figure 2 is a flowchart of a block information pushing method provided by the embodiments of the present application Figure 2 ;
[0020] Figure 3 is a structural diagram of a block information pushing device provided by the embodiments of the present application
[0021] Figure 4 This is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0022] In the following description, specific details such as specific system structures and techniques are provided for purposes of illustration rather than limitation to facilitate a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid obscuring the description of the present application with unnecessary detail.
[0023] It will be understood that when used in this specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0024] It should also be understood that the terms used in this specification are for the purpose of describing specific embodiments only and are not intended to limit the present application. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms unless the context clearly indicates otherwise.
[0025] It should be further understood that the term "and / or" used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0026] As used in this specification and the appended claims, the term "if" can be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.
[0027] In specific implementations, the computer devices described in the embodiments of the present application include, but are not limited to, other portable devices such as mobile phones, laptop computers, or tablet computers with touch-sensitive surfaces (e.g., touch screen displays and / or touch pads). It should also be understood that in some embodiments, the device is not a portable communication device, but rather a desktop computer with a touch-sensitive surface (e.g., touch screen displays and / or touch pads).
[0028] In the following discussion, a computer device including a display and a touch-sensitive surface is described. However, it should be understood that a computer device may include one or more other physical user interface devices such as a physical keyboard, mouse, and / or joystick.
[0029] The computer device supports various applications, such as one or more of the following: a drawing application, a presentation application, a word processing application, a website creation application, a disk burning application, a spreadsheet application, a gaming application, a telephony application, a video conferencing application, an email application, an instant messaging application, a workout support application, a photo management application, a digital camera application, a digital video camera application, a web browsing application, a digital music player application, and / or a digital video player application.
[0030] Various applications that can be executed on a computer device can use at least one common physical user interface device, such as a touch-sensitive surface. One or more functions of the touch-sensitive surface and corresponding information displayed on the computer device can be adjusted and / or changed between applications and / or within a respective application. In this way, the common physical architecture of the computer device (e.g., the touch-sensitive surface) can support a variety of applications with user interfaces that are intuitive and transparent to the user.
[0031] It should be understood that the size of the serial numbers of each step in this embodiment does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of this application.
[0032] In order to illustrate the technical solution described in this application, specific embodiments are provided below.
[0033] See also Figure 1 , Figure 1 This is a process of pushing block information provided by an embodiment of the present application. Figure 1 .like Figure 1 As shown, a method for pushing block information includes the following steps:
[0034] Step 101: Every time a block is generated, block information waiting to be pushed is generated.
[0035] The block information carries the block number of the block.
[0036] Here, the generated block information carries the block number of the corresponding block, so that in the subsequent block information inspection and push process to the message queue, the orderly push of block information and the inspection and discovery of dirty blocks can be achieved based on the block number.
[0037] Furthermore, in an optional implementation, the block information may also carry a first block hash of the block and a block hash of the previous block of the block.
[0038] Since blocks are generated sequentially, and the block numbers of sequentially generated blocks increase as they are generated, the previous block here specifically refers to the block that precedes the current block in the block generation order. The block number of this previous block and the block number of the current block are two consecutive increasing block numbers.
[0039] The generated block information is used to record the relevant information of the generated block. In addition to the block number and block hash mentioned above, the block information may also include the transaction information included in the block and other information associated with the transaction information. This is only an example and is not limited to this.
[0040] Step 102: Based on the block information, determine target block information that has passed the checkpoint based on the block number.
[0041] Here, a checkpoint is introduced to check the block information based on the block number carried in the block information, so as to screen out the situation where one block number corresponds to multiple block information, and realize the inspection and screening of dirty blocks. The block information corresponding to the dirty block will not be checked, while the block information of the normal block will be checked.
[0042] Among them, based on the block information, the checkpoint needs to check the generated block information. Specifically, for example, each time a block information is generated, the blockchain system generates a checkpoint to check the block information, or generates a checkpoint after generating a set number of block information to check these block information separately.
[0043] Step 103 : Output the target block information to a target queue in sequence according to the block number.
[0044] Finally, the checked target block information is output to the target queue in order of block number.
[0045] In specific applications, block information is pushed in an orderly manner to the message queue that has subscribed to the corresponding information according to the block generation order, so that business systems or users using blockchain or blockchain-based business systems can obtain the information they need in order, realizing the orderly push of block information.
[0046] In an embodiment of the present application, each time a block is generated, block information waiting to be pushed is generated and carries the block number of the corresponding block. Based on the block information, the target block information that has passed the checkpoint based on the block number is determined. Finally, the target block information is output to the target queue in sequence according to the block number. In this process, the block number carried in the block information is used to introduce a checkpoint to check the block information based on the block number, so as to screen out the situation where one block number corresponds to multiple block information, realize the inspection and screening of dirty blocks, and ensure that in the process of pushing the target block information that has passed the inspection to the message queue, the block information is pushed in an orderly manner based on the block number.
[0047] Furthermore, in one example, Figure 2 As shown, a specific implementation process of the above step 102 of determining the target block information that has passed the checkpoint based on the block number check based on the block information is as follows.
[0048] The block information also carries the first block hash of the block.
[0049] Correspondingly, step 102 determines target block information that has passed the checkpoint check based on the block information, including:
[0050] Step 201: Obtain a first block height and a second block hash corresponding to a checkpoint, use the first block height as a reference block height, and use the second block hash as a reference block hash;
[0051] Step 202: If the reference block height is greater than the second block height of the previous checkpoint, determine whether there is first block information in the block information having the same block number as the reference block height;
[0052] Step 203: If it is determined that the first block information exists in the block information, and the first block hash in the first block information is the same as the reference block hash, the first block information is determined as the target block information.
[0053] After generating a set number of blocks, a checkpoint is generated to check the block information of the generated blocks. At this time, the generated checkpoint corresponds to the block with the latest block number among the set number of blocks, the block height corresponding to the generated checkpoint is the block height of the block with the latest block number among the set number of blocks, and the block hash corresponding to the generated checkpoint is the block hash of the block with the latest block number among the set number of blocks.
[0054] At this time, it is also necessary to introduce the reference block height i and the reference block hash blockHash.
[0055] When checking the block information of the generated block based on the generated checkpoint, it is necessary to update the reference block height i and the reference block hash blockHash in sequence, and on this basis, check the block information of the generated block in sequence.
[0056] In the first round of inspection, the first block height corresponding to the checkpoint is used as the reference block height, and the second block hash corresponding to the checkpoint is used as the reference block hash. In the inspection of other block information, the inspection order is based on the descending block number. The reference block height and reference block hash are updated once for each block information corresponding to the inspection, and the inspection of the block information is carried out based on the updated reference block height and reference block hash.
[0057] Among them, when the reference block height is greater than the second block height of the previous checkpoint, it can be determined that the generation time of the block corresponding to the block information currently to be traversed and checked by the checkpoint is later than the generation time of the block corresponding to the previous checkpoint, that is, the block information currently to be checked by the checkpoint is information that has not been checked by the checkpoint.
[0058] Subsequently, the target block information whose block number is the same as the reference block height and whose block hash is the same as the reference block hash can be further determined from the block information, and the block information determined as the normal block will be checked and passed, thereby realizing the screening of valid blocks based on the block information.
[0059] Furthermore, when the reference block height is greater than the second block height of the last recorded checkpoint, after determining whether there is first block information with the same block number as the reference block height in the block information, the method further includes:
[0060] In step 204, if it is determined that there are at least two pieces of the first block information in the block information, one piece of the first block information in which the first block hash value is the same as the reference block hash value is determined, and the first block information is determined as the target block information; and the other pieces of the first block information in which the first block hash value is different from the reference block hash value is determined, and the first block information is deleted.
[0061] When it is determined from the block information that there are multiple block information with the same block number as the reference block height, it means that there are dirty blocks that have been rolled back before. The block information in which the block hash is the same as the reference block hash value is determined as the block information corresponding to the valid block, and the other block information in which the block hash is different from the reference block hash value is determined as the block information corresponding to the invalid block and deleted, thereby realizing the screening and elimination of the block information corresponding to the dirty blocks.
[0062] Further, in one example, the block information further carries a third block hash of a previous block of the block; after determining the first block information as the target block information, the method further comprises:
[0063] updating the reference block height according to the descending order of the block number, and updating the third block hash in the target block information as the reference block hash;
[0064] If the reference block height is greater than the second block height of the recorded previous checkpoint, the step 202 is returned to judge whether the first block information with the same block number and the reference block height exists in the block information until the updated reference block height is equal to the second block height.
[0065] In the process, after performing the checking operation on the block information once, the reference block height and the reference block hash need to be updated, and the next round of block information checking is performed with the updated reference block height and the reference block hash.
[0066] Further, the method further comprises:
[0067] If the updated reference block height is equal to the second block height, the first block height is recorded as the block height of the previous checkpoint in step 206.
[0068] In a specific implementation process, the block height corresponding to the previous checkpoint is recorded as current, the block height included in the received checkpoint event is recorded as i (i.e. the aforementioned reference block height), and the block hash is recorded as blockHash (i.e. the aforementioned reference block hash). When i>current, the following process is performed in a loop. The purpose is to ensure that all blocks from the previous checkpoint to the current checkpoint are received
[0069] and the block data generated between the previous checkpoint and the current checkpoint is excluded, and it is ensured that there is no "dirty block" information in the block related information pushed out.
[0070] Among them, the block information with the recorded block number i needs to be read based on the value of the current i. There can be multiple block information with the same block number, and when the block chain has a chopping operation or a rollback operation, there can be multiple block information with the same block number.
[0071] It is necessary to judge whether such block information exists, and whether the block hash of the block information is equal to blockHash. If there is no block information with the block number i, the checkpoint event is returned to the step 201.
[0072] The message push module reprocesses the process of receiving external events. In specific applications, it may happen that a checkpoint event is received first, and then the block information generated before the checkpoint is formed is received. In this case, the block information with block number i does not exist. In this case, the processing flow of the current checkpoint event can be terminated. If the block information with block number i exists, proceed to the next step.
[0073] 5 Furthermore, it is necessary to delete the block information whose block number is i and whose block hash is not blockHash and delete the push messages generated based on these blocks.
[0074] Then, the block hash of the previous block is read from the block corresponding to the block information with block number i and block hash blockHash, assigned to blockHash, and i=i-1 is updated. The above processing process is executed in a loop until i=current, and the loop processing flow ends.
[0075] After the 0 loop process is completed, the current value is updated to the block height corresponding to the current checkpoint.
[0076] Further find the queue that subscribes to the checkpoint message in the subscription information, push the block information that has passed the check to the queue, and trigger the sequential push of information.
[0077] In the process of generating block information for push: the block information to be pushed needs to be generated based on the message content, message type, queues to which it needs to be pushed, etc. The block information to be pushed is sorted from small to large according to the block number.
[0078] Among them, since the block information that needs to be pushed is sorted from small to large according to the block number when it is generated, when pushing the block information, it is directly read from small to large and pushed to the queue to ensure that the block information is generated first and pushed first.
[0079] Furthermore, the outputting the target block information to the target queue in sequence according to the block number includes:
[0080] Determine whether the target queue where the target block information is waiting to be pushed is deregistered;
[0081] If it is determined that the block is not deregistered, determining whether the block number corresponding to the target block information is greater than the block height of the checkpoint;
[0082] If the determination result is no, the target block information is output to the target queue in the order of the block numbers.
[0083] Further, when the block information is sequentially output to the target queue, it is also necessary to first determine whether the queue to which the message needs to be pushed is unregistered, and if so, delete the message and continue to traverse the next block information to continue information output to other queues that subscribe to the block information. Otherwise, it is necessary to determine whether the block number corresponding to the current block information is greater than the value of the updated current, i.e., whether it is greater than the block height corresponding to the current checkpoint. If so, skip this message, otherwise output the current block information to the target queue until the block information checked by the checkpoint is traversed. This process ensures that only blocks that have passed the checkpoint check will be pushed out, avoiding the push of "dirty blocks".
[0084] The unregistration process is as follows:
[0085] The unregistration request is received, and the unregistration request carries the queue name to be unregistered. If the unregistered queue name is not included in the registered subscription information, return, otherwise delete the subscription information with the same queue name from the recorded registered subscription information, disconnect the connection with the incoming queue name, and delete the queue, and return a message indicating that the unregistration is successful.
[0086] According to the block number, the target block information is sequentially output to the target queue, and the process further includes:
[0087] The registration request is received, and the registration request carries subscription information, which includes message queue name and message type;
[0088] In response to the registration request, if it is determined that the message queue name is not registered and the message type is a legal message type, a message queue is created according to the subscription information;
[0089] The subscription information and the corresponding relationship between the subscription information and the message queue are stored, and feedback information indicating that the registration is successful is output.
[0090] The message type is, for example, a block information type, a transaction information type, etc. The block contains a plurality of transactions. When the message type is a block information type, the created message queue is used to receive block information corresponding to the block, and when the message type is a transaction information type, the created message queue is used to receive transaction information corresponding to each transaction in the block.
[0091] Specifically, in one example, the registered subscription information is received, and the process is as follows:
[0092] Receive a registration request that carries subscription information, including but not limited to the following: message queue name, subscribed message type; when the message type includes block information, specify whether detailed transaction information is required; when the message type includes transaction information, specify whether to match the transaction's destination address, whether to match the transaction's log content, and other information.
[0093] When creating a queue in response to a registration request, first determine whether the registered message queue name has been registered. If so, return the corresponding prompt information. Otherwise, determine whether the subscribed message type is legal, that is, whether it is a supported message type. If not, return the corresponding prompt information. Otherwise, create a queue based on the registered message queue name, and create a connection to send messages to this queue. Save the registered subscription information and return a successful registration message.
[0094] Furthermore, in one example, when outputting block information, it is necessary to traverse the subscription information and know which queues need information of this message type based on the subscription information.
[0095] If it is determined that the subscription information display of a queue requires information of this message type, then the information that this queue needs this message type is recorded. After traversing the subscription information of all queues, the corresponding block information is generated according to the recorded queues that require information of this message type, and the block number, block hash and the previous block hash of this block are recorded, and the block information is output to the corresponding queue.
[0096] In the above implementation process, the checkpoints introduced are used to traverse the currently generated block information based on the block number of the block information and the block height of the previous checkpoint, and the block information corresponding to different block numbers is screened out to check and filter dirty blocks. In addition, the block information is pushed in an orderly manner based on the block number when the target block information that has passed the check is pushed to the message queue.
[0097] See also Figure 3 , Figure 3 This is a structural diagram of a block information pushing device provided in an embodiment of the present application. For the sake of convenience, only the parts related to the embodiment of the present application are shown.
[0098] The block information pushing device 300 includes:
[0099] The generation module 301 is configured to generate block information to be pushed each time a block is generated, wherein the block information carries the block number of the block;
[0100] An information determination module 302 is configured to determine, based on the block information, target block information of a checkpoint that has passed the check based on the block number;
[0101] The output module 303 is configured to output the target block information to a target queue in sequence according to the block numbers.
[0102] The block information also includes the first block hash of the block.
[0103] The information determination module 302 is specifically configured to:
[0104] Obtain the first block height and second block hash corresponding to the checkpoint, use the first block height as a reference block height, and use the second block hash as a reference block hash;
[0105] If the reference block height is greater than the second block height of the previous checkpoint, determining whether there is first block information in the block information having the same block number as the reference block height;
[0106] If it is determined that there is one piece of the first block information in the block information, and the first block hash in the first block information is the same as the reference block hash, the first block information is determined as the target block information.
[0107] The information determination module 302 is specifically configured to:
[0108] If it is determined that there are at least two first block information in the block information, determining one first block information among the at least two first block information whose first block hash value is the same as the reference block hash value, and determining the first block information as the target block information;
[0109] The method further determines other first block information in at least two pieces of the first block information whose first block hash value is different from the reference block hash value, and deletes the other first block information.
[0110] The block information also includes the third block hash of the previous block of the block. The information determination module 302 is specifically configured to:
[0111] updating the reference block height according to the descending order of the block numbers, and updating the third block hash in the target block information to the reference block hash;
[0112] Return to the step of determining whether there is first block information with the same block number as the reference block height in the block information when the reference block height is greater than the second block height of the last recorded checkpoint, until the updated reference block height is equal to the second block height.
[0113] The information determination module 302 is further specifically configured to:
[0114] When the updated reference block height is equal to the second block height, the first block height is recorded as the block height of the previous checkpoint.
[0115] The output module 303 is specifically configured to:
[0116] Determine whether the target queue where the target block information is waiting to be pushed is deregistered;
[0117] If it is determined that the block is not deregistered, determining whether the block number corresponding to the target block information is greater than the block height of the checkpoint;
[0118] If the determination result is no, the target block information is output to the target queue in the order of the block numbers.
[0119] The device also includes:
[0120] Registration module for:
[0121] Receive a registration request, which carries subscription information including a message queue name and a message type;
[0122] In response to the registration request, if it is determined that the message queue name has not been registered and the message type is a legal message type, creating a message queue according to the subscription information;
[0123] The subscription information and the corresponding relationship between the subscription information and the message queue are stored, and feedback information of successful registration is output.
[0124] The block information pushing device provided in the embodiment of the present application can implement each process of the embodiment of the block information pushing method described above and can achieve the same technical effect. To avoid repetition, it will not be described here.
[0125] Figure 4 4 is a structural diagram of a computer device provided in an embodiment of the present application. As shown in the figure, the computer device 4 of this embodiment includes: at least one processor 40 ( Figure 4 Only one is shown), a memory 41 and a computer program 42 stored in the memory 41 and executable on the at least one processor 40, wherein the processor 40 implements the steps of any of the above-mentioned method embodiments when executing the computer program 42.
[0126] The computer device 4 can be a desktop computer, a notebook computer, a palmtop computer, a cloud server or other computing devices. The computer device 4 can include, but is not limited to, a processor 40 and a memory 41. Those skilled in the art will understand that Figure 4It is only an example of the computer device 4 and does not constitute a limitation of the computer device 4. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the computer device may also include input and output devices, network access devices, buses, etc.
[0127] The processor 40 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0128] The memory 41 may be an internal storage unit of the computer device 4, such as a hard disk or memory of the computer device 4. The memory 41 may also be an external storage device of the computer device 4, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. equipped on the computer device 4. Furthermore, the memory 41 may include both an internal storage unit of the computer device 4 and an external storage device. The memory 41 is used to store the computer program and other programs and data required by the computer device. The memory 41 may also be used to temporarily store data that has been output or is about to be output.
[0129] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above-mentioned division of each functional unit and module is exemplified, and in actual application, the above-mentioned functions can be completed by different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be realized in the form of hardware or software. In addition, the specific names of each functional unit and module are only for easy distinction, and do not limit the protection scope of the present application. The specific working process of the units and modules in the above system can refer to the corresponding process in the foregoing method embodiments, which will not be repeated here.
[0130] In the above embodiments, the description of each embodiment has its own emphasis, and the parts not described or recorded in detail in a certain embodiment can be referred to the related description of other embodiments.
[0131] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized in electronic hardware or a combination of computer software and electronic hardware. Whether the functions are executed in hardware or software depends on the specific application and design constraints of the technical solution. A person skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0132] In the embodiments provided in the present application, it should be understood that the disclosed devices / computer equipment and methods can be implemented in other ways. For example, the device / computer equipment embodiments described above are only schematic, for example, the division of the modules or units is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the shown or discussed each other can be indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0133] The units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, that is, they can be located in one place, or can be distributed on a plurality of network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
[0134] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0135] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the process in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and when the computer program is executed by the processor, it can implement the steps of the above-mentioned various method embodiments. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0136] The present application implements all or part of the processes in the above-mentioned embodiment methods, and may also be implemented through a computer program product. When the computer program product runs on a computer device, the computer device can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0137] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present application, and should all be included in the scope of protection of the present application.
Claims
1. A method for pushing block information, characterized in that: include: Every time a block is generated, block information waiting to be pushed is generated, and the block information carries the block number of the block; After generating a set number of the blocks, generating a checkpoint to check the block information of the generated blocks; wherein the block information of the generated blocks is checked based on the reference block height and the reference block hash, and the reference block height and the reference block hash are updated correspondingly each time the block information corresponding to a block is checked; Based on the block information, determining target block information that has passed the checkpoint based on the block number; the target block information is block information whose block number determined from the block information is the same as the reference block height and whose block hash is the same as the reference block hash; The target block information is output to a target queue in sequence according to the block numbers.
2. The method according to claim 1, characterized in that The block information also carries the first block hash of the block; The step of determining, based on the block information, target block information of a checkpoint based on the block number that has passed the check includes: Obtain the first block height and second block hash corresponding to the checkpoint, use the first block height as a reference block height, and use the second block hash as a reference block hash; If the reference block height is greater than the second block height of the previous checkpoint, determining whether there is first block information in the block information having the same block number as the reference block height; If it is determined that there is one piece of the first block information in the block information, and the first block hash in the first block information is the same as the reference block hash, the first block information is determined as the target block information.
3. The method according to claim 2, characterized in that When the reference block height is greater than the second block height of the last checkpoint recorded, after determining whether there is first block information with the same block number as the reference block height in the block information, the method further includes: If it is determined that there are at least two first block information in the block information, determining one first block information among the at least two first block information whose first block hash value is the same as the reference block hash value, and determining the first block information as the target block information; The method further determines other first block information in at least two pieces of the first block information whose first block hash value is different from the reference block hash value, and deletes the other first block information.
4. The method according to claim 2 or 3, characterized in that The block information also carries the third block hash of the previous block of the block; After determining the first block information as the target block information, the method further includes: updating the reference block height according to the descending order of the block numbers, and updating the third block hash in the target block information to the reference block hash; Return to the step of determining whether there is first block information with the same block number as the reference block height in the block information when the reference block height is greater than the second block height of the last recorded checkpoint, until the updated reference block height is equal to the second block height.
5. The method according to claim 4, characterized in that Also includes: When the updated reference block height is equal to the second block height, the first block height is recorded as the block height of the previous checkpoint.
6. The method according to claim 1, characterized in that Outputting the target block information to the target queue in sequence according to the block number includes: Determine whether the target queue where the target block information is waiting to be pushed is deregistered; If it is determined that the block is not deregistered, determining whether the block number corresponding to the target block information is greater than the block height of the checkpoint; If the determination result is no, the target block information is output to the target queue in the order of the block numbers.
7. The method according to claim 1, characterized in that Before outputting the target block information to the target queue in sequence according to the block number, the method further includes: Receive a registration request, the registration request carrying subscription information, the subscription information including a message queue name and a message type; In response to the registration request, if it is determined that the message queue name has not been registered and the message type is a legal message type, creating a message queue according to the subscription information; The subscription information and the corresponding relationship between the subscription information and the message queue are stored, and feedback information of successful registration is output.
8. A device for pushing block information, characterized in that: include: A generation module, configured to generate block information to be pushed each time a block is generated, wherein the block information carries the block number of the block; After generating a set number of the blocks, generating a checkpoint to check the block information of the generated blocks; wherein the block information of the generated blocks is checked based on a reference block height and a reference block hash, and the reference block height and the reference block hash are updated each time the block information corresponding to a block is checked; an information determination module, configured to determine, based on the block information, target block information that has passed the checkpoint based on the block number; the target block information being block information whose block number, as determined from the block information, is the same as the reference block height and whose block hash is the same as the reference block hash; The output module is used for outputting the target block information to a target queue in sequence according to the block numbers.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Information processing method and device based on block chain, equipment and storage medium
CN110990497A
Method and device for pushing information to service system
CN113709216A