Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth such as the particular system architecture, techniques, etc., in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
It should be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It is also to be understood that the terminology used in the description of the application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in the present specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
As used in this specification and the appended claims, the term "if" may be interpreted as "when..once" or "in response to a determination" or "in response to detection" depending on the context. Similarly, the phrase "if a determination" or "if a [ described condition or event ] is detected" may be interpreted in the context of meaning "upon determination" or "in response to determination" or "upon detection of a [ described condition or event ]" or "in response to detection of a [ described condition or event ]".
In particular implementations, the terminals described in embodiments of the application include, but are not limited to, other portable devices such as mobile phones, laptop computers, or tablet computers having a touch-sensitive surface (e.g., a touch screen display and/or a touch pad). It should also be appreciated that in some embodiments, the device is not a portable communication device, but a desktop computer having a touch-sensitive surface (e.g., a touch screen display and/or a touch pad).
In the following discussion, a terminal including a display and a touch sensitive surface is described. However, it should be understood that the terminal may include one or more other physical user interface devices such as a physical keyboard, mouse, and/or joystick.
The terminal supports various applications such as one or more of a drawing application, a presentation application, a word processing application, a website creation application, a disk burning application, a spreadsheet application, a game application, a telephone application, a video conferencing application, an email application, an instant messaging application, an exercise support application, a photograph 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.
Various applications that may be executed on the terminal may 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 terminal may be adjusted and/or changed between applications and/or within the corresponding applications. In this way, the common physical architecture (e.g., touch-sensitive surface) of the terminal may support various applications with user interfaces that are intuitive and transparent to the user.
It should be understood that, the sequence number of each step in this embodiment does not mean the execution sequence, and the execution sequence of each process should be determined by its function and internal logic, and should not limit the implementation process of the embodiment of the present application in any way.
In order to illustrate the technical scheme of the application, the following description is made by specific examples.
Referring to fig. 1, fig. 1 is a flowchart of a data consistency processing method according to an embodiment of the present application. As shown in fig. 1, a data consistency processing method includes the following steps:
and step 101, acquiring a service data uplink request.
The service data uplink request is used to indicate that service data to be uplink is written to the blockchain.
In the embodiment of the application, the execution main body of the data consistency processing method is a service end. The service end is, for example, a personal computer equipped with a service system, a user mobile phone, etc. The business system is, for example, a transaction system, a transfer system, etc.
Correspondingly, in step 101, the business data is transaction data, transfer data, etc., and more specifically includes information such as account information of both sides of the transaction, transaction amount, account information of both sides of the transfer, transfer amount, etc.
And 102, when detecting that the business data to be uplink is written into the blockchain and is abnormal, extracting a target data uplink request record with a flag bit as a first value from a system database.
The system database stores service data, a data uplink request record corresponding to the service data uplink request and a flag bit for indicating the processing state of the service data uplink request.
The service end needs to store service data, and the service data needs to have data consistency with the service data stored on the block chain.
Specifically, when service data is generated in the service end, the service data to be uplink needs to be written into the blockchain based on a corresponding triggered service data uplink request, if the service data to be uplink is successfully written into the blockchain, the service end obtains feedback information of the blockchain, analyzes and obtains data parameters corresponding to the data to be uplink based on the feedback information, performs data synchronization on the service end based on the data parameters, and specifically needs to synchronize the data parameters corresponding to the data to be uplink into the service data of the system database, so that the service end data and the on-chain data are kept synchronous.
The data uplink request record stored in the system database is generated corresponding to each service data uplink request. Different data uplink request records form a service data uplink request record table in a system database.
The data uplink request record may include request information such as request time and request identifier corresponding to each service data uplink request. Each data uplink request record corresponds to a flag bit, and the initial value of the flag bit is a first value.
The system database is also provided with a flag bit for indicating the processing state of the service data uplink request, and different values of the flag bit can indicate whether the service data uplink request is normally processed on a data link. Here, when the uplink result feedback information sent by the data link based on the service data uplink request is normally received, the service data uplink request can be considered to be normally processed on the data link (the flag bit is set to the second value at this time), and the uplink result feedback information can be uplink success or uplink failure. When no feedback information of the uplink result sent by the data link based on the service data uplink request is received, it can be considered that the service data uplink request is processed on the data link to be abnormal (i.e. it is determined that the service data to be uplink is written into the blockchain to be abnormal, and at this time, the value of the flag bit is still the first value).
The failure to receive the feedback information of the uplink result sent by the data link based on the service data uplink request may be caused by service restart or network congestion, which results in failure to receive the feedback information of the uplink result sent by the data link based on the service data uplink request within a set duration.
Therefore, when it is detected that the writing of the service data to be uplink into the blockchain is abnormal, a target data uplink request record with the flag bit as a first value needs to be extracted from the system database so as to determine the service data uplink request which is not normally processed based on the service data uplink request record table.
And step 103, searching target data matched with the target data uplink request record from the blockchain.
Under the condition that the service data to be uplink is written into the block chain to be abnormal is detected, and the target data uplink request record corresponding to the service data uplink request which is not normally processed is determined from the system database of the service end, the target data matched with the target data uplink request record is required to be pulled from the block chain.
In one embodiment, the target data uplink request record includes a request time of the service data uplink request.
Correspondingly, searching the target data matched with the target data uplink request record from the blockchain comprises the following steps:
And based on the target data uplink request record, extracting uplink data which is within a set duration range from the request time from the blockchain as the target data.
Typically, the service end sends the service data uplink request to the blockchain immediately after acquiring the service data uplink request. And if the block chain receives the service data uplink request and carries out uplink processing on the data to be uplink indicated by the service data uplink request, and if the uplink is successful, the block chain stores corresponding uplink data. The uplink time of the uplink data meets the requirement that the request time from the service data uplink request is within the set duration range.
And searching target data matched with the target data uplink request record from the block chain according to the request time of the business data uplink request recorded in the target data uplink request record.
And 104, based on the target data, when the service data in the system database and the uplink data in the blockchain are consistent, setting the mark position corresponding to the target data uplink request record as a second value.
The flag bit is used as a judging basis for judging whether the abnormal state of the block chain is recovered when the service data to be uplink is written into the block chain.
Wherein the first value of the flag bit is, for example, 0 and the second value is, for example, 1.
And determining whether the service data in the system database and the uplink data in the block chain have consistency or not based on the target data.
Here, when the service data to be uplink indicated by the service data uplink request is not written into the blockchain (i.e. the data uplink fails), it can be determined that the data in the blockchain has not been changed, and at this time, it can be determined that the service data in the system database has consistency with the uplink data in the blockchain. Or when the service data to be uplink indicated by the service data uplink request is written into the blockchain (namely, the data uplink is successful), the data in the blockchain can be determined to be changed, then the data to be uplink is required to be synchronized into the service data of the system database, the data of the service end is updated, the service data of the updated system database is consistent with the data of the blockchain, and at the moment, the consistency of the service data in the system database and the uplink data in the blockchain can be determined.
Specifically, in one embodiment, the target data uplink request record includes a request identifier of a service data uplink request, and the determining that the service data in the system database has consistency with the uplink data in the blockchain includes:
And determining that the data in the system has consistency with the data in the blockchain when the target data does not contain the target uplink data corresponding to the request identifier based on the request identifier in the target data uplink request record.
And when the target data does not contain the target uplink data corresponding to the request identification, the processing state of the service data uplink request is considered to be data uplink failure.
Specifically, in another embodiment, the target data uplink request record includes a request identifier of a service data uplink request, and the determining that the service data in the system database has consistency with the uplink data in the blockchain includes:
And synchronizing the data to be uplink to the service data of the system database when determining that the target data contains target uplink data corresponding to the request identifier based on the request identifier in the target data uplink request record, and determining that the service data in the system database has consistency with the uplink data in the block chain.
And when the target data contains target uplink data corresponding to the request identification of the service data uplink request, the processing state of the service data uplink request is considered to be successful in data uplink.
In the above process, when abnormal conditions such as network timeout and external hanging of service are met, data uplink feedback information sent by a blockchain based on a service data uplink request cannot be obtained, at this time, it is determined that the abnormality occurs when service data to be uplink is written into the blockchain, at this time, the service end to be uplink data is submitted, and the service end does not know the data uplink result, so that consistency between the service data and the link needs to be ensured through a compensation mechanism.
Specifically, all abnormal data with a flag bit of 0 (i.e., a first value) is required to be pulled from a system database, the generation time of each piece of data is taken as a parameter, all transaction data in a set time period is pulled up by a deblocking chain, after the transaction data is unpacked, a request number (requestId) corresponding to a service data uplink request is compared with requestId of the unpacked uplink data, if the target uplink data with the same request number is not matched, it is determined that target uplink data corresponding to a request identifier of the service data uplink request is not contained in target data stored in the block chain, and at the moment, the data uplink is considered to be failed, and local compensation data at a service end is not required. If the target uplink data with the consistent request number is matched, determining that the target data stored in the blockchain contains target uplink data corresponding to the request identifier of the service data uplink request, and considering that the data uplink is successful at the moment, determining that the service data in the local system database and the uplink data in the blockchain are in a state of no consistency at the moment, unpacking the target uplink data to obtain corresponding uplink parameters (such as transfer amount, account, transfer balance, transfer contract and the like), executing service logic at the service end to re-warehouse to complete data compensation of the service data at the service end, enabling the service data in the system database to have consistency with the uplink data in the blockchain, and enabling the mark position corresponding to the target data uplink request record to be 1 (namely a second value).
In the processing process, when the consistency of the data is maintained, the adopted scheme is not full pulling, or active pulling triggered by a user, but when the occurrence of uplink abnormality of the data to be uplink is detected, the data uplink request record with the flag bit as a first value is extracted from the system database of the service end, the target data corresponding to the record is obtained from the block chain, when the data content corresponding to the data to be uplink is matched from the target data, the data synchronization is locally carried out at the service end, the consistency of the data between the service end and the block chain is maintained, the value of the flag bit of the data uplink request record is changed, and the value of the flag bit is set as a second value, so that the effective marking of the processing state of the data uplink request is realized.
In the embodiment of the application, the record information of the service data uplink request is formed at the service end, and the mark of the processing state of the service data uplink request is realized by means of the adjustment of the value of the flag bit, so that when the condition that the service data to be uplink is written into the blockchain and is abnormal is detected, the target data matched with the record of the target data uplink request is searched from the blockchain based on the record information of the service data uplink request and the corresponding flag bit, and further the consistency between the service data in the service end and the data in the blockchain is determined, the service pressure of a service party and a blockchain server is reduced, and the timeliness of data synchronization is ensured.
Different implementation manners of the data consistency processing method are also provided in the embodiment of the application.
Referring to fig. 2, fig. 2 is a flowchart second of a data consistency processing method according to an embodiment of the present application. As shown in fig. 2, a data consistency processing method includes the following steps:
Step 201, a service data uplink request is acquired.
The service data uplink request is used to indicate that service data to be uplink is written to the blockchain.
The implementation process of this step is the same as that of step 101 in the foregoing embodiment, and will not be described here again.
Step 202, storing the request information of the service data uplink request into the system database, obtaining a data uplink request record corresponding to the service data uplink request, and setting the flag position corresponding to the data uplink request record as the first value.
The request information specifically includes information such as request time and request identification of the service data uplink request.
And 203, when the fact that the to-be-uplinked service data is successfully written in the block chain is detected, synchronizing the to-be-uplinked data into the service data of the system database, wherein the mark position corresponding to the data uplink request record is the second value.
And if the feedback information of successful data uplink sent by the block chain based on the service data uplink request is received, determining that the service data to be uplink is successfully written in the block chain.
At this time, it can be determined that the data in the blockchain is changed, and then the data to be uplink needs to be synchronized to the service data of the system database, the service end data is updated, and the service data of the updated system database is consistent with the data of the blockchain.
And 204, when the fact that the writing of the business data to be uplinked in the block chain fails is detected, setting the mark position corresponding to the data uplink request record as the second value, and outputting prompt information of data processing failure.
And if the feedback information of the data uplink failure sent by the block chain based on the service data uplink request is received, determining that the writing failure of the service data to be uplink in the block chain is detected.
When the writing of the service data to be uplink in the block chain fails, the prompting information of the data processing failure needs to be output to the user at the service end.
And step 205, when detecting that the abnormality occurs in writing the business data to be uplink into the blockchain, extracting a target data uplink request record with a flag bit as a first value from a system database.
The system database stores service data, a data uplink request record corresponding to the service data uplink request and a flag bit for indicating the processing state of the service data uplink request.
The implementation process of this step is the same as that of step 102 in the foregoing embodiment, and will not be described here again.
And step 206, searching the target data matched with the target data uplink request record from the blockchain.
The implementation process of this step is the same as that of step 103 in the foregoing embodiment, and will not be described here again.
Step 207, based on the target data, when it is determined that the service data in the system database has consistency with the uplink data in the blockchain, the flag position corresponding to the target data uplink request record is set to be a second value.
The implementation process of this step is the same as that of step 104 in the foregoing embodiment, and will not be described here again.
In the embodiment of the application, the record information of the service data uplink request is formed at the service end, and the mark of the processing state of the service data uplink request is realized by means of the adjustment of the value of the flag bit, so that when the condition that the service data to be uplink is written into the blockchain is detected to be abnormal, the target data matched with the record of the target data uplink request is searched from the blockchain based on the record information of the service data uplink request and the corresponding flag bit, and further, the consistency between the service data in the service end and the data in the blockchain is determined, and when the condition that the service data to be uplink is written into the blockchain fails or is written into the blockchain successfully is detected, different processing measures are respectively adopted, the consistency between the service data in the service end and the data in the blockchain is ensured, the service pressure of a service party and a blockchain server is reduced, and the timeliness of data synchronization is ensured.
Referring to fig. 3, fig. 3 is a block diagram of a data consistency processing apparatus according to an embodiment of the present application, and for convenience of explanation, only a portion related to the embodiment of the present application is shown.
The data consistency processing apparatus 300 includes:
An obtaining module 301, configured to obtain a service data uplink request, where the service data uplink request is used to indicate writing service data to be uplink to a blockchain;
The extraction module 302 is configured to extract, when it is detected that an abnormality occurs in writing the service data to be uplink to the blockchain, a target data uplink request record with a flag bit as a first value from a system database, where the system database stores service data, a data uplink request record corresponding to the service data uplink request, and a flag bit for indicating a processing state of the service data uplink request;
a searching module 303, configured to search the blockchain for target data matching the target data uplink request record;
And the state value setting module 304 is configured to, based on the target data, set the flag position corresponding to the target data uplink request record to a second value when it is determined that the service data in the system database has consistency with the uplink data in the blockchain.
Wherein, the state value setting module 304 is further configured to:
storing the request information of the service data uplink request into the system database to obtain a data uplink request record corresponding to the service data uplink request;
and taking the mark position corresponding to the data uplink request record as the first value.
Wherein, the state value setting module 304 is further configured to:
And when the fact that the business data to be uplink is successfully written in the block chain is detected, the mark position corresponding to the data uplink request record is the second value, and the business data to be uplink is synchronized to the business data of the system database.
Wherein, the state value setting module 304 is further configured to:
When the fact that the writing of the business data to be uplinked in the block chain fails is detected, the mark position corresponding to the data uplink request record is taken as the second value, and prompt information of data processing failure is output.
The target data uplink request record comprises the request time of a service data uplink request; the searching module 303 is specifically configured to:
And based on the target data uplink request record, extracting uplink data which is within a set duration range from the request time from the blockchain as the target data.
The target data uplink request record includes a request identifier of a service data uplink request, and the state value setting module 304 is specifically configured to:
And determining that the data in the system has consistency with the data in the blockchain when the target data does not contain the target uplink data corresponding to the request identifier based on the request identifier in the target data uplink request record.
The target data uplink request record includes a request identifier of a service data uplink request, and the state value setting module 304 is further specifically configured to:
And synchronizing the data to be uplink to the service data of the system database when determining that the target data contains target uplink data corresponding to the request identifier based on the request identifier in the target data uplink request record, and determining that the service data in the system database has consistency with the uplink data in the block chain.
The data consistency processing device provided by the embodiment of the application can realize the processes of the embodiment of the data consistency processing method and achieve the same technical effects, and is not repeated here for avoiding repetition.
Fig. 4 is a block diagram of a terminal according to an embodiment of the present application. As shown in this figure, the terminal 4 of this embodiment comprises at least one processor 40 (only one is shown in fig. 4), a memory 41 and a computer program 42 stored in said memory 41 and executable on said at least one processor 40, said processor 40 implementing the steps of any of the various method embodiments described above when executing said computer program 42.
The terminal 4 may be a computing device such as a desktop computer, a notebook computer, a palm computer, a cloud server, etc. The terminal 4 may include, but is not limited to, a processor 40, a memory 41. It will be appreciated by those skilled in the art that fig. 4 is merely an example of the terminal 4 and is not limiting of the terminal 4, and may include more or fewer components than shown, or may combine some components, or different components, e.g., the terminal may further include input and output devices, network access devices, buses, etc.
The Processor 40 may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (DIGITAL SIGNAL Processor, DSP), application SPECIFIC INTEGRATED Circuit (ASIC), field-Programmable gate array (Field-Programmable GATE ARRAY, FPGA) or other Programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 41 may be an internal storage unit of the terminal 4, such as a hard disk or a memory of the terminal 4. The memory 41 may also be an external storage device of the terminal 4, such as a plug-in hard disk, a smart memory card (SMART MEDIA CARD, SMC), a Secure Digital (SD) card, a flash memory card (FLASH CARD) or the like, which are provided on the terminal 4. Further, the memory 41 may also include both an internal storage unit and an external storage device of the terminal 4. The memory 41 is used for storing the computer program as well as other programs and data required by the terminal. The memory 41 may also be used for temporarily storing data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions. The functional units and modules in the embodiment may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit, where the integrated units may be implemented in a form of hardware or a form of a software functional unit. In addition, the specific names of the functional units and modules are only for distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working process of the units and modules in the above system may refer to the corresponding process in the foregoing method embodiment, which is not described herein again.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and in part, not described or illustrated in any particular embodiment, reference is made to the related descriptions of other embodiments.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/terminal and method may be implemented in other manners. For example, the apparatus/terminal embodiments described above are merely illustrative, e.g., the division of the modules or units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection via interfaces, devices or units, which may be in electrical, mechanical or other forms.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated modules/units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the present application may implement all or part of the flow of the method of the above embodiment, or may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, and when the computer program is executed by a processor, the computer program may implement the steps of each of the method embodiments described above. Wherein the computer program comprises computer program code which may be in source code form, object code form, executable file or some intermediate form etc. The computer readable medium may include any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), an electrical carrier signal, a telecommunications signal, a software distribution medium, and so forth. It should be noted that the computer readable medium contains content that can be appropriately scaled according to the requirements of jurisdictions in which such content is subject to legislation and patent practice, such as in certain jurisdictions in which such content is subject to legislation and patent practice, the computer readable medium does not include electrical carrier signals and telecommunication signals.
The present application may also be implemented as a computer program product for implementing all or part of the procedures of the methods of the above embodiments, which when run on a terminal causes the terminal to perform the steps of the method embodiments described above.
The foregoing embodiments are merely illustrative of the technical solutions of the present application, and not restrictive, and although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those skilled in the art that modifications may still be made to the technical solutions described in the foregoing embodiments or equivalent substitutions of some technical features thereof, and that such modifications or substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application.