WO2020233351A1 - Blockchain-oriented data management method, apparatus and device, and storage medium - Google Patents

Blockchain-oriented data management method, apparatus and device, and storage medium Download PDF

Info

Publication number
WO2020233351A1
WO2020233351A1 PCT/CN2020/087135 CN2020087135W WO2020233351A1 WO 2020233351 A1 WO2020233351 A1 WO 2020233351A1 CN 2020087135 W CN2020087135 W CN 2020087135W WO 2020233351 A1 WO2020233351 A1 WO 2020233351A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
state
updated
preset
blockchain
Prior art date
Application number
PCT/CN2020/087135
Other languages
French (fr)
Chinese (zh)
Inventor
闫军
Original Assignee
深圳壹账通智能科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳壹账通智能科技有限公司 filed Critical 深圳壹账通智能科技有限公司
Publication of WO2020233351A1 publication Critical patent/WO2020233351A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2379Updates performed during online database operations; commit processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/389Keeping log of transactions for guaranteeing non-repudiation of a transaction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/03Credit; Loans; Processing thereof

Definitions

  • This application relates to the field of blockchain technology, and in particular, to a blockchain-oriented data management method, device, equipment and storage medium.
  • the blockchain can be understood as a distributed ledger.
  • the blockchain stores data
  • the data of the data structure composed of key-value pairs is stored on the blockchain.
  • the key is the key
  • the value is the value. Since the data stored in this structure cannot be queried according to very complex conditions, currently, relational databases are usually used to store the conditions for querying the data stored on the chain. Therefore, both on the blockchain and a relational database There is a corresponding piece of data, that is, the data needs to be saved in a relational database when the data is on the chain. This situation is likely to cause inconsistent data between the two parties when updating the data in the blockchain and the relational database. problem.
  • the inventor realizes that in the existing solutions for updating the state of the data in the blockchain and the relational database, the state of the data in the relational database is usually updated first, and then the corresponding data and its state are written
  • the chain is used to update the data on the chain to ensure that the state of the data on the chain is updated accordingly when the state of the data is successfully updated in the relational database.
  • the embodiments of the application provide a blockchain-oriented data management method, device, equipment, and storage medium, which can effectively solve the problem of inconsistency between the data of the relational database and the corresponding data on the chain, and avoid the problem of data and Undesirable consequences caused by inconsistent data on the chain.
  • an embodiment of the present application provides a blockchain-oriented data management method, which includes: receiving a second update request sent by a user, wherein each update request includes the first state and the first state of the data to be updated.
  • Two states wherein the first state and the second state are the data states of the data to be updated, and the data state is the state attribute value of the data to be updated; according to the first state, a preset relationship
  • the data to be updated is obtained from the database and the data corresponding to the data to be updated is searched from a preset blockchain, wherein the data to be updated obtained in the relational database is used as the first data, and the block
  • the data corresponding to the data to be updated found on the chain is used as the second data; the first data and the second data are compared to determine whether the first data is consistent with the second data; if the first data is consistent with the second data; If one data is inconsistent with the second data, it is determined whether the first data meets the preset data compensation condition according to the first state and the second state; and if the first
  • an embodiment of the present application also provides a blockchain-oriented data management device, which includes: a first receiving unit, configured to receive a second update request sent by a user, wherein each update request includes a waiting Update the first state and the second state of the data, wherein the first state and the second state are the data state of the data to be updated, and the data state is the state attribute value of the data to be updated; first acquisition Unit for obtaining data to be updated from a preset relational database according to the first state and searching for data corresponding to the data to be updated from a preset blockchain, wherein the relational database is The acquired data to be updated is used as the first data, and the data corresponding to the data to be updated found on the blockchain is used as the second data; the first judgment unit is used to compare the first data with the first data Two data to determine whether the first data and the second data are consistent; a second determining unit, for determining whether the first data and the second data are inconsistent, based on the first state and the second state Whether the first data meets
  • the embodiments of the present application also provide a computer device.
  • the computer device includes a memory, a processor, and a computer program stored on the memory and running on the processor.
  • Implementing a blockchain-oriented data management method includes: receiving a second update request sent by a user, wherein each update request includes a first state and a second state of the data to be updated, wherein the first state And the second state is the data state of the data to be updated, and the data state is the state attribute value of the data to be updated; according to the first state, the data to be updated is obtained from a preset relational database and the data It is assumed that the data corresponding to the data to be updated is searched on the blockchain, wherein the data to be updated obtained in the relational database is used as the first data, and the data searched on the blockchain is corresponding to the data to be updated The data of is used as the second data; the first data is compared with the second data to determine whether the first data is consistent with the second data; if the first data is
  • the embodiments of the present application also provide a computer-readable storage medium with a computer program stored on the computer-readable storage medium, and when the computer program is executed by a processor, a blockchain-oriented data management
  • the method includes: receiving a second update request sent by a user, wherein each update request includes a first state and a second state of the data to be updated, wherein the first state and the second state are the data to be updated
  • the data state is the state attribute value of the data to be updated; the data to be updated is obtained from a preset relational database according to the first state, and the data to be updated is searched on the preset blockchain.
  • Update the data corresponding to the data wherein the data to be updated obtained in the relational database is used as the first data, and the data corresponding to the data to be updated found on the blockchain is used as the second data;
  • the first data and the second data to determine whether the first data is consistent with the second data; if the first data is inconsistent with the second data, according to the first state and the second state Determine whether the first data meets a preset data compensation condition; and if the first data meets the preset data compensation condition, perform data compensation on the first data according to the second state.
  • the embodiments of the present application provide a blockchain-oriented data management method, device, equipment, and storage medium.
  • the embodiments of the present application can effectively solve the problem of inconsistency between the data stored in a relational database and the corresponding data on the chain, and avoid the problem that the data on the chain cannot be updated due to the inconsistency between the data of the relational database and the corresponding data on the chain.
  • This embodiment of the application receives an update request sent by a user, and determines whether data compensation is needed for the data in the relational database according to the update request. If it is determined that data compensation is required for the data in the relational database, it will automatically The data is compensated, and the data repair compensation can be realized automatically without user involvement.
  • the embodiments of the present application can effectively ensure the orderly progress of on-chain transactions and can improve the processing capability of abnormal transactions.
  • FIG. 1 is a schematic flowchart of a blockchain-oriented data management method provided by the first embodiment of the application
  • FIG. 2 is a schematic flowchart of a blockchain-oriented data management method provided by the first embodiment of this application;
  • FIG. 3 is a schematic flowchart of a blockchain-oriented data management method provided by the second embodiment of this application.
  • FIG. 4 is a schematic flowchart of a blockchain-oriented data management method provided by the third embodiment of this application.
  • FIG. 5 is a schematic block diagram of a blockchain-oriented data management device provided by the first embodiment of this application.
  • FIG. 6 is a schematic block diagram of a second judgment unit of a blockchain-oriented data management device provided by the first embodiment of this application;
  • FIG. 7 is a schematic block diagram of a block chain-oriented data management device provided by the second embodiment of this application.
  • FIG. 8 is a schematic block diagram of a block chain-oriented data management device provided by the third embodiment of this application.
  • FIG. 9 is a schematic block diagram of a computer device provided by an embodiment of the application.
  • FIG. 1 is a schematic flowchart of a blockchain-oriented data management method provided by the first embodiment of this application.
  • the blockchain-oriented data management method can be run in a terminal device that provides data on-chain functions.
  • the blockchain-oriented data management method is applied to a user-end system of a terminal device to prevent relational
  • the data in the database is inconsistent with the corresponding data on the blockchain.
  • the terminal device may be an electronic device such as a smart phone, a tablet computer, or a notebook computer configured with a preset blockchain; or an independent server or a server cluster composed of multiple servers; the terminal device may also be configured without a preset blockchain.
  • Set a blockchain but it can interact with other terminal devices that configure the preset blockchain.
  • the method may include steps S101 to S105.
  • each update request includes a first state and a second state of the data to be updated, wherein the first state and the second state are data of the data to be updated State, the data state is the state attribute value of the data to be updated.
  • each update request is specifically a data upload request.
  • the preset client terminal includes a preset personal client terminal, a preset enterprise terminal, and a preset bank terminal.
  • the receiving the second update request sent by the user may be receiving the second update request sent by the preset enterprise end; or may be receiving the second update request sent by the preset bank end; or It can be to receive the second update request sent by the preset personal client.
  • each update request includes a first state and a second state of the data to be updated, wherein the first state and the second state are the data state of the data to be updated, and the data state is the data to be updated
  • the status attribute value of the data to be updated includes multiple attribute values, and the status attribute value is one of the multiple attribute values included therein.
  • the data to be updated is service data
  • the service data is data generated by each preset service in the service system of the preset user end.
  • the preset client terminal includes a preset personal client terminal, a preset enterprise terminal, and a preset bank terminal
  • the preset business includes insurance business, loan business, and financial and wealth management business.
  • the business data may specifically For example, insurance data, loan data, and financial management data.
  • each piece of business data generated corresponding to each preset service includes multiple attribute values, where the multiple attribute values can be used as query conditions for querying the business data.
  • a preset relational database can be used to store a piece of data on the blockchain correspondingly, that is, the data can be correspondingly stored in the relational database while the data is on the chain, so as to save the relational database
  • the multiple attribute values corresponding to a piece of data saved in the data are used as query conditions for searching data on the blockchain.
  • a piece of data correspondingly saved in the relational database includes the key value key and data content value; the data content value includes multiple attribute values.
  • the data is loan data
  • the multiple attribute values may be, for example, the loan company, loan amount, loan date, repayment date, repayment amount, loan type, and loan status.
  • the first state and the second state are the data states of the data to be updated
  • the data state is the state attribute value of the data to be updated
  • the first state and the second state are used to indicate the data to be updated
  • the data state before the update and the updated data state of the data specifically, the first state is the data state before the data to be updated is updated, and the second state is the data state after the data to be updated is updated.
  • the current data state of the data to be updated is the data state of the data to be updated before the update; if the data to be updated has been updated, the data to be updated
  • the current data status of is the data status of the data to be updated after the update, therefore, the current data status of the data to be updated will change with the progress of the preset service.
  • the preset business is a loan business
  • the corresponding business data generated is loan data
  • the data status of the loan data is the loan status.
  • a piece of loan data LOAN will be generated correspondingly.
  • the loan data LOAN includes the key value of the loan data and the data content value, where the data content value includes the loan company, loan amount, loan date, repayment date, and repayment amount. Multiple attribute values such as loan type and loan status. Among them, the loan data LOAN can be found by using multiple attribute values of the loan data. For example, the loan data generated on xx month and xx day can be queried. If the loan time of the loan data LOAN is also xx month xx day, the Loan data will be searched out.
  • the loan status of the loan data LOAN is the data status of the loan data
  • the loan status of the loan data LOAN will change with the progress of the loan business, that is, the loan status of the loan data LOAN specifically includes the first status And the second state, the loan state of the loan data LOAN will be updated from the first state to the second state as the loan business progresses.
  • the current data status of the corresponding piece of loan data is in application by default, that is, the first state of the loan status of the loan data is in application; if the bank is in the bank After seeing this piece of loan data LOAN, you can decide whether to approve the loan business application; if the bank agrees to the loan business application, the loan status of the loan data LOAN will be updated from the application to the approved application, where the The first state of the loan status is the application, and the second state is the application approved; if the application for the loan business is disapproved, the loan status of the loan data LOAN will be updated from the application to the application disapproved, where the loan The first status of the status is the application, and the second status is the application disapproved; if the company enters the stage of preparing for repayment after the loan is completed, the loan status of the loan data LOAN will be updated from loaned to paid, part The status of repayment or overdue payment.
  • the loan status of the loan data LOAN will change with the progress of the loan business, that is, the loan status of the loan data LOAN will be updated from the first status to The second state.
  • the first state is the data state before the update of the data to be updated, and the first state may specifically include application in progress, application cancellation, application approval, application disapproval, loan released, paid, partial repayment, and overdue The state of payment, etc.;
  • the second state is the data state after the update of the data to be updated, and the second state may specifically include application in progress, application cancellation, application approval, application disapproval, loan disbursed, repayment, and partial repayment , Overdue payment and other status.
  • the obtaining data to be updated from a preset relational database according to the first state and searching for data corresponding to the data to be updated from a preset blockchain includes the following sub Steps S102a to S102b, wherein, the step S102a: obtain the to-be-updated data from a preset relational database according to the first state of the to-be-updated data, wherein the to-be-updated data obtained in the relational database is Data as the first data; and step S102b: search for data corresponding to the first data from a preset blockchain according to the first data, wherein the data searched on the blockchain is compared with the first data The data corresponding to one data serves as the second data.
  • a piece of data correspondingly stored in the relational database includes the key value and the data content value; the data content value includes multiple attribute values.
  • the multiple attribute values may be, for example, the loan company, loan amount, loan date, repayment date, repayment amount, loan type, and loan status.
  • step S102a if the data to be updated is loan data, the first state of the loan data is the loan state of the loan data, and the first state of the data to be updated starts from a preset relationship
  • Obtaining the data to be updated in the type database specifically refers to obtaining data whose current loan state is the first state from a preset relational database according to the first state, and the acquired data is the data to be updated. For example, if the first status is application, all loan data whose current loan status is application is obtained from a preset relational database.
  • the step S102b searching for data corresponding to the first data from a preset blockchain according to the first data includes: searching from a preset blockchain according to the key value of the first data and Data with the same key value key of the first data, wherein the data corresponding to the first data found on the blockchain is used as the second data.
  • a piece of data stored in the block chain corresponding to the relational database also includes the key value of the data and the data content value; the data content value includes multiple attribute values.
  • the multiple attribute values may be, for example, the loan company, loan amount, loan date, repayment date, repayment amount, loan type, and loan status.
  • the loan status of the second data corresponding to the first data found on the blockchain is the current data status of the second data.
  • the first data and the second data are completely the same data.
  • the difference is that the first data is stored in a preset relational database, and the second data is written into a preset area.
  • Block chain in the entire process of writing business data to the blockchain, it is necessary to interact with multiple systems through the HTTP protocol.
  • the systems can be, for example, transaction systems and blockchain systems, that is, the client system needs to communicate with the transaction through the HTTP protocol.
  • the system interacts with the blockchain system to achieve data on-chain. Therefore, there are many uncontrollable factors in the process of data on-chain.
  • business data on-chain timeout, return failure, or abnormal execution it will Automatically roll back the updated data in the preset relational database.
  • a failure to return or an abnormal situation does not mean that the business data has failed to be uploaded to the chain. If the business data is successfully uploaded to the chain, and the corresponding updated business data in the preset relational database is rolled back, the data on the chain is different from the data in the preset relational database. For example, when the preset enterprise side submits a business application , Correspondingly generate a piece of business data and save it in a preset relational database and write it on a preset blockchain.
  • the current data status of the business data is in application, and when the preset bank has processed the After the business application, for example, to approve the business application, the current data status of the business data in the preset relational database is updated from the application to the approved application, and the updated business data is written into a preset area
  • the client system does not return success, the updated business data will be automatically rolled back to the update in the preset relational database
  • the previous data status at this time, the data status of the business data in the preset relational database is application, and the application is approved on the preset blockchain. Therefore, the first data and the second data are compared to determine whether the first data and the second data are the same.
  • the step further includes if the first data is consistent with If the second data is consistent, the second update request sent by the user is executed; wherein, the second update request is a data upload request. Specifically, if the first data is consistent with the second data, it indicates that the first data is normal uplink data, and data compensation processing is not required for the first data.
  • S104 If the first data is inconsistent with the second data, determine whether the first data meets a preset data compensation condition according to the first state and the second state.
  • step S104 includes sub-steps S104a to S104d.
  • S104a determining whether the first state of the first data can be transferred to the current data state of the second data according to a preset state transfer rule
  • S104b if the first state of the first data can be transferred to all The current data state of the second data, and determine whether the second state of the first data is consistent with the current data state of the second data
  • S104c if the second state of the first data is the same as the current data state of the second data If the data status is consistent, it is determined that the first data meets the preset data compensation condition
  • S104d if the first status of the first data cannot be transferred to the current data status of the second data or the second data status of the first data The state is inconsistent with the current data state of the second data, and it is determined that the first data does not meet the preset data compensation condition.
  • the preset state transfer rules include a state transferable rule and a state non-transferable rule, wherein the state transferable rule is a preset state that can be updated from one state to another.
  • the state non-circulation rule is a preset rule that cannot be transferred from one state to another state. For example, if a state is in application, the preset state can be transferred to another state.
  • the status is canceled application, approved application, and disapproved application; the other status that cannot be transferred with it is loaned out, repaid, partial repayment, overdue payment; if one status is approved to apply, it can happen with the status
  • the other status of the transfer is already loaned; the other status of the status that cannot be associated with the process is application, disapproval of application, repayment, partial repayment, and overdue payment; that is, a status can be transferred from the application status In order to agree to the application status, it cannot be transferred from the approved application status to the application status.
  • step S104a if the first status of the first data is in application, the current data status of the second data is in application approval, and the data status is in application can be transferred to application approval, then It is determined that the first state of the first data satisfies the preset state transfer rule; if the first state of the first data is an application approved, the current data state of the second data is an application disapproved, wherein the data state is If the approval application cannot be transferred to the disapproval application, it is determined that the first state of the first data does not meet the preset state transfer rule.
  • the second state of the first data is determined according to the second state of the first data. Whether the status is consistent with the current data status of the second data; specifically, for example, if it can be known that the first status of the first data is in application according to the update request, and the second status is the approved application; it can be known from step S102 that the area The current data status of the second data corresponding to the first data found on the block chain is an approved application. Therefore, the second status of the first data is consistent with the current data status of the second data, and both are approved applications.
  • the second state of the first data is consistent with the current data state of the second data, it can be determined that the first data meets the preset data compensation condition, and the corresponding data compensation processing may be performed on the first data.
  • the first data is stored in the preset relational database
  • the second data is stored in the preset blockchain.
  • the data status in the first data is different from the data status in the second data in the process of data uploading, for example, in the process of updating the data status of the data
  • when the current data status of the first data is updated from the application to agree
  • write the updated first data as the second data into the blockchain.
  • the system can For example, the transaction system and the blockchain system, that is, the client system needs to interact with the transaction system and the blockchain system through the HTTP protocol to achieve data on the chain. Therefore, there are many uncontrollable factors in the process of data on the chain.
  • the data status of the first data in the preset relational database is application
  • the data status of the second data corresponding to the first data on the preset blockchain is application approval.
  • the client system When the client system receives the query condition that the data status is application, the first data that was rolled back will be retrieved by query, and then the first data needs to be updated to agree to the application and write again according to the update request sent by the user In the chain, but at this time, the data status of the second data corresponding to the first data on the chain is already in the state of agreeing to apply. Because the data on the chain is unique, the first data cannot be repeatedly written to the On the blockchain, the data on the chain will be abnormal, which may cause more adverse effects. At this time, it is only necessary to compensate the data state of the first data in the preset relational database, so that the first data is not queried.
  • the second state of the first data is consistent with the current data state of the second data. If the second state of the first data is consistent with the current data state of the second data, it indicates that the first data was rolled back in the process of updating the data state to the chain, and the corresponding second data has succeeded On the chain, at this time, only the data state of the first data in the preset relational database needs to be compensated, that is, the data state compensation of the first data in the preset relational database is a consent application to prevent The first data is repeatedly chained to solve the abnormality of the chaining transaction.
  • the data of the first data is performed according to the update request.
  • Compensation wherein the performing data compensation on the first data according to the update request specifically includes: updating and compensating the data state of the first data from the first state to the second state according to the update request.
  • this solution first obtains the first data in a preset relational database according to the update request after receiving the update request submitted by the user, and then finds it on the chain according to the first data The second data corresponding to the first data is then judged whether the first data and the second data are consistent; if the first data is consistent with the second data, the second update request sent by the user is executed; if the first data is consistent If the data is inconsistent with the second data, then it is determined whether the first data meets the preset data compensation conditions, and if so, data compensation is performed on the first data, so as to ensure that the need for data is avoided when the update request is subsequently executed.
  • the compensated first data interferes with the update request, that is, avoids interference with the normal uploading of other data to be updated, which can ensure the normal progress of the user's update request, wherein the update request is a data upload request.
  • the embodiments of the present application can effectively solve the problem of inconsistency between the data stored in a relational database and the corresponding data on the chain, and avoid the problem that the data on the chain cannot be updated due to the inconsistency between the data of the relational database and the corresponding data on the chain.
  • the embodiment of the application can automatically compensate the data to be updated that needs data compensation, and can automatically realize data repair compensation without user involvement.
  • the embodiments of the present application can also effectively ensure the orderly progress of on-chain transactions and can improve the processing capability of the abnormal transaction of the client system.
  • FIG. 3 is a schematic flowchart of a blockchain-oriented data management method provided by the second embodiment of this application. Specifically, as shown in FIG. 3, the method may include steps S201-S207.
  • the steps S201-S205 are similar to the steps S101-S105 in the foregoing embodiment, and will not be repeated here.
  • the steps S206-S207 added in this embodiment will be described in detail below.
  • each update request is a data upload request.
  • step S203 after the step of comparing the first data with the second data to determine whether the first data is consistent with the second data, the method further includes: The first data is consistent with the second data, and the second update request sent by the user is executed; wherein, the second update request is a data upload request.
  • the first data is consistent with the second data, it indicates that the first data is normal on-chain data, and there is no need to perform data compensation processing on the first data, and the data compensation may not be required.
  • the data on the blockchain is to execute the second update request sent by the user, so as to ensure the normal progress of the second update request of the user.
  • the second update request sent by the executing user specifically includes sub-step S206a and sub-step S206b, wherein the sub-step S206a: updating the data to be updated in the relational database; and the sub-step S206b : Write the updated data to be updated on a preset blockchain by calling the update link; wherein the update link is an interface that the blockchain provides to the client to call.
  • step S204 judging whether the first data meets the preset data compensation condition according to the first state and the second state specifically includes: S204a: judging the first data of the first data according to the preset state circulation rule Whether a state can be transferred to the current data state of the second data; and S204b, if the first state of the first data can be transferred to the current data state of the second data, determine the first data state of the first data Whether the second state is consistent with the current data state of the second data; wherein, if the first state of the first data cannot be transferred to the current data state of the second data or the second state of the first data is If the current data state of the data is inconsistent, the first data is abnormal data, which is regarded as an unknown abnormality of the system operation, and data consistency cannot be achieved through automatic system compensation, and an abnormal reminder needs to be issued to the user.
  • the sending an abnormal reminder to the user includes sub-step S207a and sub-step S207b.
  • S207a save the first data in a preset data table
  • S207b send the data table to the user by email to send an abnormal reminder.
  • the data table may be sent to the user by means of instant messaging, text messages, or system alarms to send out abnormal reminders.
  • the ID or serial number of the first data may be written into a preset database table, which is used to store all abnormal data and send email reminders to the relevant person in charge, So that the relevant person in charge can analyze and solve the data problem in time according to the email reminder.
  • this solution first obtains the first data in a preset relational database according to the update request after receiving the update request submitted by the user, and then finds it on the chain according to the first data The second data corresponding to the first data is then judged whether the first data is consistent with the second data; if the first data is consistent with the second data, the second update request sent by the user is executed; if the first data is consistent If the data is inconsistent with the second data, then it is determined whether the first data meets the preset data compensation conditions, and if so, data compensation is performed on the first data, so as to ensure that the need for data is avoided when the update request is subsequently executed.
  • the compensated first data interferes with the update request, that is, avoids interference with the normal uploading of other data to be updated, which can ensure the normal progress of the user's update request, wherein the update request is a data upload request. If it is not satisfied, an abnormal reminder is sent to the user, which can prompt the user in time so that the user can quickly and easily find the abnormal data, and then perform manual repair in time.
  • FIG. 4 is a schematic flowchart of a blockchain-oriented data management method provided by the third embodiment of this application. Specifically, the method is applied to a preset user terminal, and the update request is the second update request. As shown in FIG. 4, the method may include steps S301-S310. Steps S301-S307 are similar to steps S201-S207 in the foregoing embodiment, and will not be repeated here. The steps S308 to S312 added in this embodiment will be described in detail below.
  • the judging whether the data to be updated in the relational database meets the preset state transfer rule according to the first state and the second state of the first update request includes sub-step S308a, wherein the sub-step S308a : Judging whether the data to be updated in the relational database can be updated from the first state to the second state according to the first state and the second state of the first update request and the preset state flow rule; wherein, one update The request includes a first state and a second state of the data to be updated, wherein the first state and the second state are the data state of the data to be updated, and the data state is the state attribute value of the data to be updated; The first state is the data state before the data to be updated is updated, and the second state is the data state after the data to be updated is updated.
  • the preset state transfer rule includes a state transferable rule and a state non-transferable rule, wherein the state transferable rule is a preset rule that can be transferred from one state to another state, and the state cannot be transferred rule It is a pre-set rule that cannot flow from one state to another. Specifically, for example, if the first status of the data to be updated is application and its second status is repaid, then the data to be updated in the relational database does not meet the preset state transfer rules; The first state of the updated data is the application, and the second state is the application approved, then the data to be updated in the relational database meets the preset state circulation rules.
  • the updating the data to be updated specifically includes: updating the data status of the data to be updated in a preset relational database of the user end system.
  • the updating the data state of the data to be updated in a preset relational database of the user-end system specifically includes: updating the data to be updated in a preset relational database of the user-end system from the first state to The second state.
  • the writing of the updated data to be updated on a preset blockchain by calling the update link port is achieved through remote access via HTTP protocol.
  • HTTP protocol it is necessary to remotely access multiple systems through the HTTP protocol.
  • the client system may call the write link port of the transaction server through the HTTP protocol, where the HTTP protocol will return the HTTP return code purposefully, and
  • the HTTP return code can be customized according to the needs of the user's actual application scenario.
  • the HTTP return code indicates a failure, the data saved in the relational database will be automatically rolled back.
  • S311 Receive an HTTP return code and determine whether an update exception occurs according to the HTTP return code.
  • the HTTP return code includes multiple status codes, and the multiple status codes are used to indicate an error that occurs when the server processes the request. Therefore, the received HTTP return code can be used to determine whether it is an update abnormality.
  • the update exception is an error condition that occurs when multiple systems in the process of data uploading are processing requests. That is, the multiple status codes are used to indicate errors that occur when multiple systems used in the data upload process process requests. These errors may be errors in the server itself, rather than errors in the request.
  • the multiple status codes can be, for example, 500 (server internal error), 501 (not yet implemented), 502 (error gateway), 503 (service unavailable), 504 (gateway timeout), 505 (HTTP version is not supported), etc. .
  • the time required for the entire process of writing data to the chain can be set to 15 seconds in advance. If the entire process of writing data to the chain takes more than 15 seconds, it is determined that the data entry into the chain has timed out, that is, the If the data fails to enter the chain, an HTTP return code of 504 (gateway timeout) will be returned.
  • the HTTP return code indicates failure
  • the data stored in the relational database will be automatically rolled back.
  • step S307-step S309 are necessary steps to execute the second update request sent by the user, that is, the second update request can be realized by executing the above step S307-step S309, that is, the data upload request is completed,
  • the data to be updated does not exist in the preset relational database and on the preset blockchain, that is, there is no data in the preset relational database and the preset
  • the problem of data inconsistency on the blockchain when the user sends the first update request, the data to be updated does not exist in the preset relational database and on the preset blockchain, that is, there is no data in the preset relational database and the preset
  • the problem of data inconsistency on the blockchain when the user sends the first update request, the data to be updated does not exist in the preset relational database and on the preset blockchain, that is, there is no data in the preset relational database and the preset The problem of data inconsistency on the blockchain.
  • the first update request is executed, there may be a problem that
  • FIG. 5 is a schematic block diagram of a blockchain-oriented data management device 100 provided by the first embodiment of the application.
  • the blockchain-oriented data management device 100 corresponds to the blockchain-oriented data management method shown in FIG.
  • the blockchain-oriented data management device 100 includes a unit for executing the above-mentioned blockchain-oriented data management method.
  • the blockchain-oriented data management device 100 can be configured in a terminal device that provides data on-chain functions, Specifically, the blockchain-oriented data management device 100 is applied in a client system of a terminal device to prevent data in a relational database from being inconsistent with corresponding data on the blockchain.
  • the terminal device may be an electronic device such as a smart phone, a tablet computer, or a notebook computer configured with a preset blockchain; or an independent server or a server cluster composed of multiple servers; the terminal device may also be configured without a preset blockchain.
  • Set a blockchain but it can interact with other terminal devices that configure the preset blockchain.
  • the blockchain-oriented data management device 100 includes a first receiving unit 101, a first acquiring unit 102, a first determining unit 103, a second determining unit 104, and a first compensation unit 105.
  • the first receiving unit 101 is configured to receive a second update request sent by a user, where each update request includes a first state and a second state of the data to be updated, wherein the first state and the second state are The data state of the data to be updated, where the data state is the state attribute value of the data to be updated.
  • the first obtaining unit 102 is configured to obtain data to be updated from a preset relational database according to the first state and search for data corresponding to the data to be updated from a preset blockchain, wherein The data to be updated obtained in the relational database is used as the first data, and the data corresponding to the data to be updated found on the blockchain is used as the second data.
  • the first obtaining unit 102 includes: a first obtaining subunit 102a and a second obtaining subunit 102b.
  • the first obtaining subunit 102a is configured to obtain the data to be updated from a preset relational database according to the first state of the data to be updated, wherein the data to be updated obtained from the relational database is Update data as first data
  • the second acquiring subunit 102b is configured to search for data corresponding to the first data from a preset blockchain according to the first data, wherein the area is The data corresponding to the first data found on the block chain is used as the second data.
  • the first determining unit 103 is configured to compare the first data with the second data to determine whether the first data is consistent with the second data.
  • the second determining unit 104 is configured to determine whether the first data meets a preset data compensation condition according to the first state and the second state if the first data is inconsistent with the second data.
  • the second judgment unit 104 includes: a first judgment subunit 104a, a second judgment subunit 104b, a first judgment unit 104c, and a second judgment unit 104d.
  • the first determining subunit 104a is configured to determine whether the first state of the first data can be transferred to the current data state of the second data according to a preset state transfer rule; the second determining subunit 102b, configured to determine whether the second state of the first data is consistent with the current data state of the second data if the first state of the first data can be transferred to the current data state of the second data;
  • the first determining unit 104c is configured to determine that the first data meets a preset data compensation condition if the second state of the first data is consistent with the current data state of the second data; and the second determining unit 104d, configured to determine if the first state of the first data cannot be transferred to the current data state of the second data or the second state of the first data is inconsistent with the current data state of the second data.
  • the first compensation unit 105 is configured to perform data compensation on the first data according to the second state if the first data meets a preset data compensation condition.
  • FIG. 7 is a schematic block diagram of a block chain-oriented data management device 200 provided by the second embodiment of the application.
  • the block chain-oriented data management device 200 provided by the second embodiment of the present application adds a first execution unit 206 and a first reminder unit 207 on the basis of the above-mentioned embodiment.
  • the device 200 includes a second receiving unit 201, a second acquiring unit 202, a third determining unit 203, a fourth determining unit 204, a second compensating unit 205, a first executing unit 206, and a first reminding unit 207.
  • the second receiving unit 201, the second acquiring unit 202, the third determining unit 203, the fourth determining unit 204, and the second compensating unit 205 are the same as the first receiving unit 101, the first acquiring unit 102, The first judging unit 103, the second judging unit 104, and the first compensation unit 105 are similar, and since their application process and corresponding functions are similar to the corresponding units in the foregoing embodiment, they will not be repeated here.
  • the first execution unit 206 is configured to execute a second update request sent by the user if the first data is consistent with the second data; wherein, each update request is a data upload request.
  • the first execution unit 206 includes a first execution sub-unit 206a and a second execution sub-unit 206b.
  • the first execution sub-unit 206a is used to update the data to be updated in the relational database; and the second execution sub-unit 206b is used to write the updated data to be updated into a file by calling the update link port.
  • the update link port is an interface that the blockchain provides to the client to call.
  • the first reminder unit 207 is configured to send an abnormal reminder to the user if the first data does not meet the preset data compensation condition.
  • the first reminder unit 207 includes a first storage unit 207a and a first reminder subunit 207b.
  • the first storage unit 207a is used to store the first data in a preset data table; and the first reminder sub-unit 207b is used to send the data table to the user by email for sending Exception reminder.
  • the data table may be sent to the user by means of instant messaging, text messages, or system alarms to send out abnormal reminders.
  • FIG. 8 is a schematic block diagram of a blockchain-oriented data management device 300 provided by the third embodiment of the application.
  • a blockchain-oriented data management device 300 provided by the third embodiment of the present application adds a rule determination unit 308, an update unit 309, an update chain unit 310, and a return Code judgment unit 311 and rollback unit 312, that is, the device 300 includes a third receiving unit 301, a third acquisition unit 302, a fifth judgment unit 303, a sixth judgment unit 304, a third compensation unit 305, and a second execution unit 306, a second reminder unit 307, a rule determination unit 308, an update unit 308, an update chain unit 310, a return code determination unit 311, and a rollback unit 312.
  • the third receiving unit 301, the third acquiring unit 302, the fifth determining unit 303, the sixth determining unit 304, the third compensating unit 305, the second executing unit 306, and the second reminding unit 307 are the same as those in the foregoing embodiment
  • the second receiving unit 201, the second acquiring unit 202, the third judging unit 203, the fourth judging unit 204, the second compensation unit 205, the first executing unit 206, and the first reminding unit 207 are similar, due to their application process and corresponding functions It is similar to the corresponding units in the above-mentioned embodiment, and will not be repeated here.
  • the rule determination unit 308 is configured to, if the first update request sent by the user is received, determine whether the to-be-updated data in the relational database meets the predetermined requirements according to the first state and the second state of the first update request. Set state transfer rules. Wherein, the rule determination unit 308 is specifically configured to determine the relationship type according to the first state and second state of the first update request and a preset state transfer rule if the first update request sent by the user is received. Whether the data to be updated in the database can be updated from the first state to the second state.
  • the updating unit 309 is configured to update the data to be updated if the data to be updated in the relational database meets a preset state circulation rule.
  • the update chain unit 310 is used to write the updated data to be updated on a preset blockchain by calling an update link; wherein, the update link is provided by the blockchain for the client to call Interface.
  • the return code judgment unit 311 is configured to receive an HTTP return code and judge whether an update abnormality occurs according to the HTTP return code.
  • the rollback unit 312 is configured to roll back the updated data to be updated in the relational database if an abnormal update occurs.
  • the above-mentioned apparatus may be implemented in the form of a computer program, and the computer program may run on the computer device as shown in FIG. 9.
  • the computer device 600 may be a terminal or a server, where the terminal may be an electronic device supporting data on-chain transactions such as a smart phone, a tablet computer, a notebook computer, a desktop computer, and a personal digital assistant.
  • the server is a server that supports data on-chain transactions, and the server may be an independent server or a server cluster composed of multiple servers.
  • the computer device 600 includes a processor 602, a memory, and a network interface 605 connected through a system bus 601, where the memory may include a non-volatile storage medium 603 and an internal memory 604.
  • the non-volatile storage medium 603 can store an operating system 6031 and a computer program 6032.
  • the computer program 6032 includes program instructions.
  • the processor 602 can execute a blockchain-oriented data management method.
  • the processor 602 is used to provide calculation and control capabilities to support the operation of the entire computer device 600.
  • the internal memory 604 provides an environment for the operation of the computer program 6032 in the non-volatile storage medium 603.
  • the processor 602 can execute a blockchain-oriented data management method.
  • the network interface 605 is used for network communication with other devices.
  • the structure shown in FIG. 9 is only a block diagram of part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device 600 to which the solution of the present application is applied.
  • the specific computer device 600 may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
  • the processor 602 is configured to run a computer program 6032 stored in the memory to implement the following steps: receiving a second update request sent by the user, wherein each update request includes the first state of the data to be updated and the first state of the data to be updated. Two states, wherein the first state and the second state are the data states of the data to be updated, and the data state is the state attribute value of the data to be updated; according to the first state, a preset relationship
  • the data to be updated is obtained from the database and the data corresponding to the data to be updated is searched from a preset blockchain, wherein the data to be updated obtained in the relational database is used as the first data, and the block
  • the data corresponding to the data to be updated found on the chain is used as the second data; the first data and the second data are compared to determine whether the first data is consistent with the second data; if the first data is consistent with the second data; If one data is inconsistent with the second data, it is determined whether the first data meets the preset data compensation condition according to the first state and
  • the blockchain-oriented data management method is applied to a preset user terminal, and the processor 602 further implements the following specifically before implementing the step of receiving the second update request sent by the user Step: if the first update request sent by the user is received, determine whether the data to be updated in the relational database meets the preset state transfer rule according to the first state and the second state of the first update request; if The data to be updated in the relational database meets the preset state circulation rules, and the data to be updated is updated; the updated data to be updated is written to a preset blockchain by calling the update link port; wherein, the The update link port is the interface that the blockchain provides to the client to call; receives the HTTP return code and judges whether an update exception occurs according to the HTTP return code; and if an update exception occurs, rolls back to the relational database The updated data to be updated.
  • the processor 602 when the processor 602 implements the step of judging whether the data to be updated in the relational database meets a preset state transfer rule according to the first state and the second state of the first update request ,
  • the specific implementation is as follows: judging whether the data to be updated in the relational database can be updated from the first state to the second state according to the first state and the second state of the first update request and the preset state transfer rule .
  • the processor 602 implements the process of obtaining the data to be updated from a preset relational database according to the first state and searching the data corresponding to the data to be updated from the preset blockchain.
  • the following steps are specifically implemented: obtaining the data to be updated from a preset relational database according to the first state of the data to be updated, wherein the data to be updated obtained in the relational database is used as the first Data; and searching for data corresponding to the first data from a preset blockchain according to the first data, wherein the data corresponding to the first data searched on the blockchain is taken as the first Two data.
  • the processor 602 when the processor 602 implements the step of judging whether the first data meets the preset data compensation condition based on the first state and the second state, the processor 602 specifically implements the following steps: The rule determines whether the first state of the first data can be transferred to the current data state of the second data; if the first state of the first data can be transferred to the current data state of the second data, it is determined Whether the second state of the first data is consistent with the current data state of the second data; if the second state of the first data is consistent with the current data state of the second data, it is determined that the first data meets the preset Data compensation conditions; and if the first state of the first data cannot be transferred to the current data state of the second data or the second state of the first data is inconsistent with the current data state of the second data, it is determined The first data does not meet the preset data compensation condition.
  • the processor 602 after the processor 602 implements the step of judging whether the first data meets the preset data compensation condition according to the first state and the second state, the processor 602 specifically implements the following steps: One data does not meet the preset data compensation conditions, and an abnormal reminder is issued to the user.
  • the processor 602 when the processor 602 implements the step of sending an abnormal reminder to the user, it specifically implements the following steps: save the first data in a preset data table; and pass the data table through The email is sent to the user to alert the user of the exception.
  • the processor 602 may be a central processing unit (Central Processing Unit, CPU), and the processor 602 may also be other general-purpose processors, digital signal processors (DSP), Application Specific Integrated Circuit (ASIC), Field-Programmable Gate Array (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 the processor may also be any conventional processor.
  • the computer program includes program instructions, and the computer program can be stored in a storage medium, which is a storage medium.
  • the program instructions are executed by at least one processor in the computer system to implement the process steps of the foregoing method embodiments.
  • this application also provides a computer-readable storage medium.
  • the computer-readable storage medium stores a computer program, where the computer program includes program instructions.
  • the processor executes the blockchain-oriented data management method as described above.
  • the computer-readable storage medium may be non-volatile or volatile.
  • the storage medium may be a U disk, a mobile hard disk, a read-only memory (Read-Only Memory, ROM), a magnetic disk, or an optical disk, etc., which can store program codes.
  • the steps in the method of the embodiment of the present application can be adjusted, merged, and deleted in order according to actual needs.
  • the units in the system of the embodiment of the present application may be combined, divided, and deleted according to actual needs.
  • the functional units in the various embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium.
  • the technical solution of this application is essentially or the part that contributes to the existing technology, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium It includes several instructions to make a computer device (which may be a personal computer, a terminal, or a network device, etc.) execute all or part of the steps of the method described in each embodiment of the present application.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Business, Economics & Management (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Strategic Management (AREA)
  • General Business, Economics & Management (AREA)
  • Development Economics (AREA)
  • Technology Law (AREA)
  • Marketing (AREA)
  • Economics (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

Disclosed are a blockchain-oriented data management method, apparatus and device, and a storage medium. The method comprises: receiving a second update request sent by a user, wherein each update request comprises a first state and a second state of to-be-updated data (S101); obtaining to-be-updated data from a preset relational database according to the first state and searching data corresponding to the to-be-updated data from a preset blockchain, wherein the to-be-updated data which is obtained from the relational database is considered as first data, and the data corresponding to the to-be-updated data which is searched from the blockchain is considered as second data (S102); comparing the first data with the second data to determine whether the first data is consistent with the second data (S103); if the first data is not consistent with the second data, determining whether the first data meets a preset data compensation condition according to the first state and the second state (S104); and if the first data meets a preset data compensation condition, performing data compensation on the first data according to the second state (S105). The method can effectively ensure the orderly implementation of business on the chain and improve the abnormal business processing capability.

Description

面向区块链的数据管理方法、装置、设备及存储介质Block chain-oriented data management method, device, equipment and storage medium
本申请要求于2019年5月22日提交中国专利局、申请号为201910428728.7,发明名称为“面向区块链的数据管理方法、装置、设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application filed with the Chinese Patent Office on May 22, 2019, the application number is 201910428728.7, and the invention title is "Blockchain-oriented data management methods, devices, equipment and storage media". All of them The content is incorporated in this application by reference.
技术领域Technical field
本申请涉及区块链技术领域,尤其涉及一种面向区块链的数据管理方法、装置、设备及存储介质。This application relates to the field of blockchain technology, and in particular, to a blockchain-oriented data management method, device, equipment and storage medium.
背景技术Background technique
区块链可以理解为分布式账本,在区块链保存数据的应用场景中,具体地,在区块链上保存由key-value键值对组成的数据结构的数据。其中,该key是键,value是值。由于这种结构保存的数据无法按照很复杂的条件来查询,目前,通常采用关系型数据库来保存用于查询链上所保存的数据的条件,因此,在区块链上以及一关系型数据库均存在相对应的一条数据,即在数据上链时需要将该数据也对应保存到一关系型数据库中,这种情况容易导致在更新区块链以及关系型数据库中的数据时双方的数据不一致的问题。发明人意识到,现有更新区块链以及关系型数据库中的数据的状态的方案中,通常采用先更新该关系型数据库中的数据的状态,再将与其相对应的数据及其状态写入链以更新该链上数据,进而保证在关系型数据库中成功更新该数据的状态的情况下再对应更新链上该数据的状态,然而,可能存在链上该数据的状态更新成功但没有返回或者返回失败的情况,导致该关系型数据库中已更新的数据的状态被回滚,从而导致该关系型数据库的数据与链上对应的数据不一致的问题,进而容易导致该链上的数据变成垃圾数据,且永久地保留在该链上。The blockchain can be understood as a distributed ledger. In the application scenario where the blockchain stores data, specifically, the data of the data structure composed of key-value pairs is stored on the blockchain. Among them, the key is the key and the value is the value. Since the data stored in this structure cannot be queried according to very complex conditions, currently, relational databases are usually used to store the conditions for querying the data stored on the chain. Therefore, both on the blockchain and a relational database There is a corresponding piece of data, that is, the data needs to be saved in a relational database when the data is on the chain. This situation is likely to cause inconsistent data between the two parties when updating the data in the blockchain and the relational database. problem. The inventor realizes that in the existing solutions for updating the state of the data in the blockchain and the relational database, the state of the data in the relational database is usually updated first, and then the corresponding data and its state are written The chain is used to update the data on the chain to ensure that the state of the data on the chain is updated accordingly when the state of the data is successfully updated in the relational database. However, there may be a state of the data on the chain that is successfully updated but not returned or The failure to return causes the state of the updated data in the relational database to be rolled back, which leads to the problem of inconsistency between the data in the relational database and the corresponding data on the chain, which can easily cause the data on the chain to become garbage Data, and remain permanently on the chain.
发明内容Summary of the invention
本申请实施例提供了一种面向区块链的数据管理方法、装置、设备及存储介质,可以有效解决该关系型数据库的数据与链上对应的数据不一致问题,避免因关系型数据库的数据与链上对应的数据不一致而导致的不良后果。The embodiments of the application provide a blockchain-oriented data management method, device, equipment, and storage medium, which can effectively solve the problem of inconsistency between the data of the relational database and the corresponding data on the chain, and avoid the problem of data and Undesirable consequences caused by inconsistent data on the chain.
第一方面,本申请实施例提供了一种面向区块链的数据管理方法,其包括:接收用户发送的第二次更新请求,其中,每一次更新请求包括待更新数据的第一状态以及第二状态,其中,所述第一状态以及第二状态为所述待更新数据的数据状态,所述数据状态为所述待更新数据的状态属性值;根据所述第一状态从一预设关系型数据库中获取待更新数据以及从预设区块链上查找与所述待更新数据对应的数据,其中,将所述关系型数据库中获取的待更新数据作为第一数据,将所述区块链上查找的与该待更新数据对应的数据作为第二数据;比对所述第一数据与所述第二数据以判断所述第一数据与所述第二数据是否一致;若所述第一数据与所述第二数据不一致,根据所述第一状态以及第二状态判断所述第一数据是否满足预设数据补偿条件;以及若所述第一数据满足预设数据补偿条件,根据所述第二状态对所述第一数据进行数据补偿。In the first aspect, an embodiment of the present application provides a blockchain-oriented data management method, which includes: receiving a second update request sent by a user, wherein each update request includes the first state and the first state of the data to be updated. Two states, wherein the first state and the second state are the data states of the data to be updated, and the data state is the state attribute value of the data to be updated; according to the first state, a preset relationship The data to be updated is obtained from the database and the data corresponding to the data to be updated is searched from a preset blockchain, wherein the data to be updated obtained in the relational database is used as the first data, and the block The data corresponding to the data to be updated found on the chain is used as the second data; the first data and the second data are compared to determine whether the first data is consistent with the second data; if the first data is consistent with the second data; If one data is inconsistent with the second data, it is determined whether the first data meets the preset data compensation condition according to the first state and the second state; and if the first data meets the preset data compensation condition, according to the The second state performs data compensation on the first data.
第二方面,本申请实施例还提供了一种面向区块链的数据管理装置,其包括:第一接收单元,用于接收用户发送的第二次更新请求,其中,每一次更新请求包括待更新数据的第一状态以及第二状态,其中,所述第一状态以及第二状态为所述待更新数据的数据状态,所述数据状态为所述待更新数据的状态属性值;第一获取单元,用于根据所述第一状态从一预设关系型数据库中获取待更新数据以及从预设区块链上查找与所述待更新数据对应的数据,其中,将所述关系型数据库中获取的待更新数据作为第一数据,将所述区块链上查找的与该待更新数据对应的数据作为第二数据;第一判断单元,用于比对所述第一数据与所述第二数据以判断所述第一数据与所述第二数据是否一致;第二判断单元,用于若所述第一数据与所述第二数据不一致,根据所述第一状态以及第二状态判断所述第一数据是否满足预设数据补偿条件;以及第一补偿单元,用于若所述第一数据满足预设数据补偿条件,根据所述第二状态 对所述第一数据进行数据补偿。In a second aspect, an embodiment of the present application also provides a blockchain-oriented data management device, which includes: a first receiving unit, configured to receive a second update request sent by a user, wherein each update request includes a waiting Update the first state and the second state of the data, wherein the first state and the second state are the data state of the data to be updated, and the data state is the state attribute value of the data to be updated; first acquisition Unit for obtaining data to be updated from a preset relational database according to the first state and searching for data corresponding to the data to be updated from a preset blockchain, wherein the relational database is The acquired data to be updated is used as the first data, and the data corresponding to the data to be updated found on the blockchain is used as the second data; the first judgment unit is used to compare the first data with the first data Two data to determine whether the first data and the second data are consistent; a second determining unit, for determining whether the first data and the second data are inconsistent, based on the first state and the second state Whether the first data meets a preset data compensation condition; and the first compensation unit is configured to perform data compensation on the first data according to the second state if the first data meets the preset data compensation condition.
第三方面,本申请实施例还提供了一种计算机设备,所述计算机设备包括存储器、处理器以及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述程序时实现一种面向区块链的数据管理方法,包括:接收用户发送的第二次更新请求,其中,每一次更新请求包括待更新数据的第一状态以及第二状态,其中,所述第一状态以及第二状态为所述待更新数据的数据状态,所述数据状态为所述待更新数据的状态属性值;根据所述第一状态从一预设关系型数据库中获取待更新数据以及从预设区块链上查找与所述待更新数据对应的数据,其中,将所述关系型数据库中获取的待更新数据作为第一数据,将所述区块链上查找的与该待更新数据对应的数据作为第二数据;比对所述第一数据与所述第二数据以判断所述第一数据与所述第二数据是否一致;若所述第一数据与所述第二数据不一致,根据所述第一状态以及第二状态判断所述第一数据是否满足预设数据补偿条件;以及若所述第一数据满足预设数据补偿条件,根据所述第二状态对所述第一数据进行数据补偿。In the third aspect, the embodiments of the present application also provide a computer device. The computer device includes a memory, a processor, and a computer program stored on the memory and running on the processor. When the processor executes the program, Implementing a blockchain-oriented data management method includes: receiving a second update request sent by a user, wherein each update request includes a first state and a second state of the data to be updated, wherein the first state And the second state is the data state of the data to be updated, and the data state is the state attribute value of the data to be updated; according to the first state, the data to be updated is obtained from a preset relational database and the data It is assumed that the data corresponding to the data to be updated is searched on the blockchain, wherein the data to be updated obtained in the relational database is used as the first data, and the data searched on the blockchain is corresponding to the data to be updated The data of is used as the second data; the first data is compared with the second data to determine whether the first data is consistent with the second data; if the first data is inconsistent with the second data, According to the first state and the second state, it is determined whether the first data meets the preset data compensation condition; and if the first data meets the preset data compensation condition, the first data is processed according to the second state Perform data compensation.
第四方面,本申请实施例还提供了一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,该计算机程序被处理器执行时实现一种面向区块链的数据管理方法,包括:接收用户发送的第二次更新请求,其中,每一次更新请求包括待更新数据的第一状态以及第二状态,其中,所述第一状态以及第二状态为所述待更新数据的数据状态,所述数据状态为所述待更新数据的状态属性值;根据所述第一状态从一预设关系型数据库中获取待更新数据以及从预设区块链上查找与所述待更新数据对应的数据,其中,将所述关系型数据库中获取的待更新数据作为第一数据,将所述区块链上查找的与该待更新数据对应的数据作为第二数据;比对所述第一数据与所述第二数据以判断所述第一数据与所述第二数据是否一致;若所述第一数据与所述第二数据不一致,根据所述第一状态以及第二状态判断所述第一数据是否满足预设数据补偿条件;以及若所述第一数据满足预设数据补偿条件,根据所述第二状态对所述第一数据进行数据补偿。In a fourth aspect, the embodiments of the present application also provide a computer-readable storage medium with a computer program stored on the computer-readable storage medium, and when the computer program is executed by a processor, a blockchain-oriented data management The method includes: receiving a second update request sent by a user, wherein each update request includes a first state and a second state of the data to be updated, wherein the first state and the second state are the data to be updated The data state is the state attribute value of the data to be updated; the data to be updated is obtained from a preset relational database according to the first state, and the data to be updated is searched on the preset blockchain. Update the data corresponding to the data, wherein the data to be updated obtained in the relational database is used as the first data, and the data corresponding to the data to be updated found on the blockchain is used as the second data; The first data and the second data to determine whether the first data is consistent with the second data; if the first data is inconsistent with the second data, according to the first state and the second state Determine whether the first data meets a preset data compensation condition; and if the first data meets the preset data compensation condition, perform data compensation on the first data according to the second state.
本申请实施例提供了一种面向区块链的数据管理方法、装置、设备及存储介质。本申请实施例能够有效解决保存在一关系型数据库中的数据与链上对应的数据不一致问题,避免因关系型数据库的数据与链上对应的数据不一致而无法更新链上数据的问题。本申请实施例通过接收用户发送的更新请求,并根据该更新请求来判断是否需要对该关系型数据库中的数据进行数据补偿,若判定需要对该关系型数据库中的数据进行数据补偿,则自动对该数据进行补偿,无须用户参与即可自动实现数据修复补偿。本申请实施例可以有效保证上链事务的有序进行以及可以提高异常事务的处理能力。The embodiments of the present application provide a blockchain-oriented data management method, device, equipment, and storage medium. The embodiments of the present application can effectively solve the problem of inconsistency between the data stored in a relational database and the corresponding data on the chain, and avoid the problem that the data on the chain cannot be updated due to the inconsistency between the data of the relational database and the corresponding data on the chain. This embodiment of the application receives an update request sent by a user, and determines whether data compensation is needed for the data in the relational database according to the update request. If it is determined that data compensation is required for the data in the relational database, it will automatically The data is compensated, and the data repair compensation can be realized automatically without user involvement. The embodiments of the present application can effectively ensure the orderly progress of on-chain transactions and can improve the processing capability of abnormal transactions.
附图说明Description of the drawings
图1为本申请第一实施例提供的一种面向区块链的数据管理方法的流程示意图;FIG. 1 is a schematic flowchart of a blockchain-oriented data management method provided by the first embodiment of the application;
图2为本申请第一实施例提供的一种面向区块链的数据管理方法的一流程示意图;2 is a schematic flowchart of a blockchain-oriented data management method provided by the first embodiment of this application;
图3为本申请第二实施例提供的一种面向区块链的数据管理方法的流程示意图;FIG. 3 is a schematic flowchart of a blockchain-oriented data management method provided by the second embodiment of this application;
图4为本申请第三实施例提供的一种面向区块链的数据管理方法的流程示意图;4 is a schematic flowchart of a blockchain-oriented data management method provided by the third embodiment of this application;
图5为本申请第一实施例提供的一种面向区块链的数据管理装置的示意性框图;FIG. 5 is a schematic block diagram of a blockchain-oriented data management device provided by the first embodiment of this application;
图6为本申请第一实施例提供的一种面向区块链的数据管理装置的第二判断单元的示意性框图;6 is a schematic block diagram of a second judgment unit of a blockchain-oriented data management device provided by the first embodiment of this application;
图7为本申请第二实施例提供的一种面向区块链的数据管理装置的示意性框图;FIG. 7 is a schematic block diagram of a block chain-oriented data management device provided by the second embodiment of this application;
图8为本申请第三实施例提供的一种面向区块链的数据管理装置的示意性框图;以及FIG. 8 is a schematic block diagram of a block chain-oriented data management device provided by the third embodiment of this application; and
图9为本申请实施例提供的一种计算机设备的示意性框图。FIG. 9 is a schematic block diagram of a computer device provided by an embodiment of the application.
具体实施方式Detailed ways
请参阅图1,其为本申请第一实施例提供的一种面向区块链的数据管理方法的示意性流程图。该面向区块链的数据管理方法可以运行在提供数据上链功能的终端设备中,具体地,该面向区块链的数据管理方法应用于一终端设备的用户端系统内,用于防止关系型数据库的数据与区块链上对应的数据不一致。其中,该终端设备可以为配置一预设区块链的智能手机、 平板电脑或笔记本电脑等电子设备;或者独立的服务器或者多个服务器组成的服务器集群;该终端设备也可以为未配置一预设区块链,但可以与配置该预设区块链的其他终端设备进行交互。该方法可包括步骤S101至S105。Please refer to FIG. 1, which is a schematic flowchart of a blockchain-oriented data management method provided by the first embodiment of this application. The blockchain-oriented data management method can be run in a terminal device that provides data on-chain functions. Specifically, the blockchain-oriented data management method is applied to a user-end system of a terminal device to prevent relational The data in the database is inconsistent with the corresponding data on the blockchain. Among them, the terminal device may be an electronic device such as a smart phone, a tablet computer, or a notebook computer configured with a preset blockchain; or an independent server or a server cluster composed of multiple servers; the terminal device may also be configured without a preset blockchain. Set a blockchain, but it can interact with other terminal devices that configure the preset blockchain. The method may include steps S101 to S105.
S101、接收用户发送的第二次更新请求,其中,每一次更新请求包括待更新数据的第一状态以及第二状态,其中,所述第一状态以及第二状态为所述待更新数据的数据状态,所述数据状态为所述待更新数据的状态属性值。S101. Receive a second update request sent by a user, where each update request includes a first state and a second state of the data to be updated, wherein the first state and the second state are data of the data to be updated State, the data state is the state attribute value of the data to be updated.
具体地,每一次更新请求具体为数据上链请求。所述预设用户端包括预设个人用户端、预设企业端以及预设银行端。在一实施例中,所述接收用户发送的第二次更新请求可以为接收预设企业端发送的第二次更新请求;或者可以为接收预设银行端发送的第二次更新请求;亦或者可以为接收预设个人用户端发送的第二次更新请求。其中,每一次更新请求包括待更新数据的第一状态以及第二状态,其中,所述第一状态以及第二状态为所述待更新数据的数据状态,所述数据状态为所述待更新数据的状态属性值,其中,所述待更新数据包括多个属性值,该状态属性值为其所包括的多个属性值之一。Specifically, each update request is specifically a data upload request. The preset client terminal includes a preset personal client terminal, a preset enterprise terminal, and a preset bank terminal. In an embodiment, the receiving the second update request sent by the user may be receiving the second update request sent by the preset enterprise end; or may be receiving the second update request sent by the preset bank end; or It can be to receive the second update request sent by the preset personal client. Wherein, each update request includes a first state and a second state of the data to be updated, wherein the first state and the second state are the data state of the data to be updated, and the data state is the data to be updated The status attribute value of the data to be updated includes multiple attribute values, and the status attribute value is one of the multiple attribute values included therein.
在一实施例中,例如本实施例中,所述待更新数据为业务数据,该业务数据为所述预设用户端的业务系统中的每一预设业务所产生的数据。其中,所述预设用户端包括预设个人用户端、预设企业端以及预设银行端,所述预设业务包括保险业务、贷款业务以及金融理财业务等业务,则所述业务数据具体可例如为保险数据、贷款数据以及金融理财数据等。其中,每一预设业务所对应产生的每条业务数据均包括多个属性值,其中,该多个属性值可以作为查询所述业务数据的查询条件。具体地,由于区块链上数据以key-value键值对这一数据结构保存,无法按照很复杂的查询条件来查找该链上的数据。其中,该key是键,value是值。因此,可以采用在一预设的关系型数据库中对应保存一条区块链上的数据,即在数据上链的同时将该数据对应保存到所述关系型数据库中,以将所述关系型数据库中对应保存的一条数据的多个属性值作为用于查找该区块链上数据的查询条件。其中,该关系型数据库中对应保存的一条数据包括该键值key以及数据内容value;所述数据内容value包括多个属性值。若所述数据为贷款数据,则所述多个属性值可例如为贷款企业,贷款金额,贷款日期,还款日期,还款金额,贷款类型以及贷款状态。In an embodiment, for example, in this embodiment, the data to be updated is service data, and the service data is data generated by each preset service in the service system of the preset user end. Wherein, the preset client terminal includes a preset personal client terminal, a preset enterprise terminal, and a preset bank terminal, and the preset business includes insurance business, loan business, and financial and wealth management business. Then the business data may specifically For example, insurance data, loan data, and financial management data. Wherein, each piece of business data generated corresponding to each preset service includes multiple attribute values, where the multiple attribute values can be used as query conditions for querying the business data. Specifically, since the data on the blockchain is stored in a data structure of key-value pairs, it is impossible to find the data on the chain according to very complicated query conditions. Among them, the key is the key and the value is the value. Therefore, a preset relational database can be used to store a piece of data on the blockchain correspondingly, that is, the data can be correspondingly stored in the relational database while the data is on the chain, so as to save the relational database The multiple attribute values corresponding to a piece of data saved in the data are used as query conditions for searching data on the blockchain. Wherein, a piece of data correspondingly saved in the relational database includes the key value key and data content value; the data content value includes multiple attribute values. If the data is loan data, the multiple attribute values may be, for example, the loan company, loan amount, loan date, repayment date, repayment amount, loan type, and loan status.
其中,所述第一状态以及第二状态为所述待更新数据的数据状态,所述数据状态为待更新数据的状态属性值,所述第一状态以及第二状态用于表示所述待更新数据的更新前的数据状态以及更新后的数据状态,具体地,所述第一状态为待更新数据更新前的数据状态,所述第二状态为待更新数据更新后的数据状态。具体地,若未对该待更新数据进行更新,则该待更新数据的当前数据状态为所述待更新数据在更新以前的数据状态;若已对该待更新数据进行更新,则该待更新数据的当前数据状态为所述待更新数据在更新以后的数据状态,因此,所述待更新数据的当前数据状态会跟随着该预设业务的进行而发生变化。例如,若该预设业务为贷款业务,其对应产生的业务数据为贷款数据,所述贷款数据的数据状态为贷款状态,具体地,用户在预设企业端的业务系统上申请了一贷款业务时会对应产生一条贷款数据LOAN,该贷款数据LOAN包括该贷款数据的键值key以及数据内容value,其中,所述数据内容value包括贷款企业,贷款金额,贷款日期,还款日期,还款金额,贷款类型以及贷款状态等多个属性值。其中,可以利用贷款数据的多个属性值查找到该贷款数据LOAN,例如,可以查询在xx月xx日所产生的贷款数据,若该贷款数据LOAN的贷款时间也为xx月xx日,则该贷款数据会被查找出来。另外,由于该贷款数据LOAN的贷款状态为该贷款数据的数据状态,该贷款数据LOAN的贷款状态会随着该贷款业务的进行而发生变化,即该贷款数据LOAN的贷款状态具体包括第一状态以及第二状态,该贷款数据LOAN的贷款状态会随着该贷款业务的进行从第一状态更新为第二状态。例如,当企业在企业端申请了一贷款业务时,其所对应产生的一条贷款数据的当前数据状态默认为申请中,即该贷款数据的贷款状态的第一状态为申请中;若银行在银行端看到这条贷款数据LOAN后,可决定是否同意该贷款业务的申请;若银行同意该贷款业务的申请,则该贷款数据LOAN的贷款状态将会从申请中更新 为同意申请,其中,该贷款状态的第一状态为申请中,其第二状态为同意申请;若不同意该贷款业务的申请,则该贷款数据LOAN的贷款状态将会从申请中更新为不同意申请,其中,该贷款状态的第一状态为申请中,其第二状态为不同意申请;若企业贷完款后进入准备还款阶段,则该贷款数据LOAN的贷款状态将会从已放款更新为已还款,部分还款或者逾期未还款等状态,在这个过程中,该贷款数据LOAN的贷款状态会随着该贷款业务的进行而发生变化,即该贷款数据LOAN的贷款状态将会从第一状态更新为第二状态。所述第一状态为该待更新数据更新前的数据状态,该第一状态具体可包括申请中、取消申请、同意申请、不同意申请、已放款、已还款、部分还款、逾期未还款等状态;所述第二状态为该待更新数据更新后的数据状态,该第二状态具体可包括申请中、取消申请、同意申请、不同意申请、已放款、已还款、部分还款、逾期未还款等状态。Wherein, the first state and the second state are the data states of the data to be updated, the data state is the state attribute value of the data to be updated, and the first state and the second state are used to indicate the data to be updated The data state before the update and the updated data state of the data, specifically, the first state is the data state before the data to be updated is updated, and the second state is the data state after the data to be updated is updated. Specifically, if the data to be updated is not updated, the current data state of the data to be updated is the data state of the data to be updated before the update; if the data to be updated has been updated, the data to be updated The current data status of is the data status of the data to be updated after the update, therefore, the current data status of the data to be updated will change with the progress of the preset service. For example, if the preset business is a loan business, the corresponding business data generated is loan data, and the data status of the loan data is the loan status. Specifically, when the user applies for a loan business on the business system of the preset enterprise side A piece of loan data LOAN will be generated correspondingly. The loan data LOAN includes the key value of the loan data and the data content value, where the data content value includes the loan company, loan amount, loan date, repayment date, and repayment amount. Multiple attribute values such as loan type and loan status. Among them, the loan data LOAN can be found by using multiple attribute values of the loan data. For example, the loan data generated on xx month and xx day can be queried. If the loan time of the loan data LOAN is also xx month xx day, the Loan data will be searched out. In addition, since the loan status of the loan data LOAN is the data status of the loan data, the loan status of the loan data LOAN will change with the progress of the loan business, that is, the loan status of the loan data LOAN specifically includes the first status And the second state, the loan state of the loan data LOAN will be updated from the first state to the second state as the loan business progresses. For example, when an enterprise applies for a loan business on the enterprise side, the current data status of the corresponding piece of loan data is in application by default, that is, the first state of the loan status of the loan data is in application; if the bank is in the bank After seeing this piece of loan data LOAN, you can decide whether to approve the loan business application; if the bank agrees to the loan business application, the loan status of the loan data LOAN will be updated from the application to the approved application, where the The first state of the loan status is the application, and the second state is the application approved; if the application for the loan business is disapproved, the loan status of the loan data LOAN will be updated from the application to the application disapproved, where the loan The first status of the status is the application, and the second status is the application disapproved; if the company enters the stage of preparing for repayment after the loan is completed, the loan status of the loan data LOAN will be updated from loaned to paid, part The status of repayment or overdue payment. During this process, the loan status of the loan data LOAN will change with the progress of the loan business, that is, the loan status of the loan data LOAN will be updated from the first status to The second state. The first state is the data state before the update of the data to be updated, and the first state may specifically include application in progress, application cancellation, application approval, application disapproval, loan released, paid, partial repayment, and overdue The state of payment, etc.; the second state is the data state after the update of the data to be updated, and the second state may specifically include application in progress, application cancellation, application approval, application disapproval, loan disbursed, repayment, and partial repayment , Overdue payment and other status.
S102、根据所述第一状态从一预设关系型数据库中获取待更新数据以及从预设区块链上查找与所述待更新数据对应的数据,其中,将所述关系型数据库中获取的待更新数据作为第一数据,将所述区块链上查找的与该待更新数据对应的数据作为第二数据。S102. Acquire data to be updated from a preset relational database according to the first state and search for data corresponding to the data to be updated from a preset blockchain, wherein the data obtained from the relational database The data to be updated is used as the first data, and the data corresponding to the data to be updated found on the blockchain is used as the second data.
具体地,在一实施例中,所述根据所述第一状态从一预设关系型数据库中获取待更新数据以及从预设区块链上查找与所述待更新数据对应的数据包括如下子步骤S102a至S102b,其中,所述步骤S102a:根据所述待更新数据的第一状态从一预设关系型数据库中获取所述待更新数据,其中,将所述关系型数据库中获取的待更新数据作为第一数据;以及步骤S102b:根据所述第一数据从一预设区块链上查找与所述第一数据对应的数据,其中,将所述区块链上查找的与所述第一数据对应的数据作为第二数据。Specifically, in an embodiment, the obtaining data to be updated from a preset relational database according to the first state and searching for data corresponding to the data to be updated from a preset blockchain includes the following sub Steps S102a to S102b, wherein, the step S102a: obtain the to-be-updated data from a preset relational database according to the first state of the to-be-updated data, wherein the to-be-updated data obtained in the relational database is Data as the first data; and step S102b: search for data corresponding to the first data from a preset blockchain according to the first data, wherein the data searched on the blockchain is compared with the first data The data corresponding to one data serves as the second data.
具体地,由步骤S101可知,该关系型数据库中对应保存的一条数据包括该键值key以及数据内容value;所述数据内容value包括多个属性值。例如,在一实施例中,若所述数据为贷款数据,则所述多个属性值可例如为贷款企业,贷款金额,贷款日期,还款日期,还款金额,贷款类型以及贷款状态。具体地,在步骤S102a中,若待更新数据为贷款数据,所述贷款数据的第一状态为所述贷款数据的贷款状态,所述根据所述待更新数据的第一状态从一预设关系型数据库中获取所述待更新数据具体为根据所述第一状态从一预设关系型数据库中获取当前贷款状态为第一状态的数据,该被获取的数据则为待更新数据。例如,若第一状态为申请中,则从一预设关系型数据库中获取当前贷款状态为申请中的所有贷款数据。所述步骤S102b根据所述第一数据从一预设区块链上查找与所述第一数据对应的数据包括:根据所述第一数据的键值key从一预设区块链上查找与所述第一数据的键值key相同的数据,其中,将所述区块链上查找的与所述第一数据对应的数据作为第二数据。具体地,该区块链中对应该关系型数据库保存的一条数据同样包括该数据的键值key以及数据内容value;所述数据内容value包括多个属性值。例如,在一实施例中,若所述数据为贷款数据,则所述多个属性值可例如为贷款企业,贷款金额,贷款日期,还款日期,还款金额,贷款类型以及贷款状态。此时,从区块链上查找的与所述第一数据对应的第二数据的贷款状态为所述第二数据的当前数据状态。Specifically, it can be known from step S101 that a piece of data correspondingly stored in the relational database includes the key value and the data content value; the data content value includes multiple attribute values. For example, in one embodiment, if the data is loan data, the multiple attribute values may be, for example, the loan company, loan amount, loan date, repayment date, repayment amount, loan type, and loan status. Specifically, in step S102a, if the data to be updated is loan data, the first state of the loan data is the loan state of the loan data, and the first state of the data to be updated starts from a preset relationship Obtaining the data to be updated in the type database specifically refers to obtaining data whose current loan state is the first state from a preset relational database according to the first state, and the acquired data is the data to be updated. For example, if the first status is application, all loan data whose current loan status is application is obtained from a preset relational database. The step S102b searching for data corresponding to the first data from a preset blockchain according to the first data includes: searching from a preset blockchain according to the key value of the first data and Data with the same key value key of the first data, wherein the data corresponding to the first data found on the blockchain is used as the second data. Specifically, a piece of data stored in the block chain corresponding to the relational database also includes the key value of the data and the data content value; the data content value includes multiple attribute values. For example, in one embodiment, if the data is loan data, the multiple attribute values may be, for example, the loan company, loan amount, loan date, repayment date, repayment amount, loan type, and loan status. At this time, the loan status of the second data corresponding to the first data found on the blockchain is the current data status of the second data.
S103、比对所述第一数据与所述第二数据以判断所述第一数据与所述第二数据是否一致。S103. Compare the first data with the second data to determine whether the first data is consistent with the second data.
具体地,通常该第一数据与该第二数据为完全相同的数据,其区别在于,所述第一数据存储于一预设关系型数据库中,所述第二数据写入一预设的区块链上。然而,在业务数据写入区块链的整个过程中,需要通过HTTP协议与多个系统进行交互,所述系统可例如为交易系统以及区块链系统,即用户端系统需要通过HTTP协议与交易系统以及区块链系统进行交互以实现数据上链,因此,在数据上链过程中存在较多不可控制的因素,当出现业务数据上链超时或者返回失败亦或者执行异常等情况时,将会自动回滚该预设关系型数据库中已更新的数据,然而,返回失败或者出现异常情况并不能表示该业务数据上链失败。若该业务数据上链成功,而在预设关系型数据库中对应更新的业务数据被回滚,导致链上数据与预设关系型数据库中数据不同,例如,当预设企业端提交一业务申请,对应产生一条业务数据保存在一预设关系型数据库中,并写入一预设区块链上,此时,该业务数据的当前数据状态为申请 中,而当预设银行端处理了该业务申请后,可例如为同意该业务申请,则将该业务数据在预设关系型数据库中的当前数据状态从申请中更新为同意申请,并将该更新后的业务数据写入一预设区块链上,但是,可能存在该更新后的业务数据成功写入链后,用户端系统却没有返回成功,则该更新后的业务数据在该预设关系型数据库中将会自动回滚到更新以前的数据状态,此时,该业务数据在预设关系型数据库中的数据状态为申请中,而在预设区块链上为同意申请。因此,比对所述第一数据与所述第二数据以判断所述第一数据与所述第二数据是否相同。Specifically, usually the first data and the second data are completely the same data. The difference is that the first data is stored in a preset relational database, and the second data is written into a preset area. Block chain. However, in the entire process of writing business data to the blockchain, it is necessary to interact with multiple systems through the HTTP protocol. The systems can be, for example, transaction systems and blockchain systems, that is, the client system needs to communicate with the transaction through the HTTP protocol. The system interacts with the blockchain system to achieve data on-chain. Therefore, there are many uncontrollable factors in the process of data on-chain. When business data on-chain timeout, return failure, or abnormal execution, it will Automatically roll back the updated data in the preset relational database. However, a failure to return or an abnormal situation does not mean that the business data has failed to be uploaded to the chain. If the business data is successfully uploaded to the chain, and the corresponding updated business data in the preset relational database is rolled back, the data on the chain is different from the data in the preset relational database. For example, when the preset enterprise side submits a business application , Correspondingly generate a piece of business data and save it in a preset relational database and write it on a preset blockchain. At this time, the current data status of the business data is in application, and when the preset bank has processed the After the business application, for example, to approve the business application, the current data status of the business data in the preset relational database is updated from the application to the approved application, and the updated business data is written into a preset area On the block chain, however, there may be that after the updated business data is successfully written into the chain, but the client system does not return success, the updated business data will be automatically rolled back to the update in the preset relational database The previous data status, at this time, the data status of the business data in the preset relational database is application, and the application is approved on the preset blockchain. Therefore, the first data and the second data are compared to determine whether the first data and the second data are the same.
其中,在一实施例中,所述比对所述第一数据与所述第二数据以判断所述第一数据与所述第二数据是否一致的步骤之后还包括若所述第一数据与所述第二数据一致,执行用户发送的第二次更新请求;其中,所述第二次更新请求为数据上链请求。具体地,若所述第一数据与所述第二数据一致,则表明该第一数据为正常上链数据,不需要对该第一数据进行数据补偿处理。Wherein, in one embodiment, after the step of comparing the first data with the second data to determine whether the first data is consistent with the second data, the step further includes if the first data is consistent with If the second data is consistent, the second update request sent by the user is executed; wherein, the second update request is a data upload request. Specifically, if the first data is consistent with the second data, it indicates that the first data is normal uplink data, and data compensation processing is not required for the first data.
S104、若所述第一数据与所述第二数据不一致,根据所述第一状态以及第二状态判断所述第一数据是否满足预设数据补偿条件。S104: If the first data is inconsistent with the second data, determine whether the first data meets a preset data compensation condition according to the first state and the second state.
具体地,在一实施例中,当所述第一数据与所述第二数据不一致时,所述根据所述第一状态以及第二状态判断所述第一数据是否满足预设数据补偿条件包括数据补偿判断方法。该数据补偿判断方法,如图2所示,即步骤S104包括子步骤S104a至S104d。其中,S104a、根据预设状态流转规则判断所述第一数据的第一状态是否可流转为所述第二数据的当前数据状态;S104b、若所述第一数据的第一状态可流转为所述第二数据的当前数据状态,判断所述第一数据的第二状态是否与所述第二数据当前数据状态一致;S104c、若所述第一数据的第二状态与所述第二数据当前数据状态一致,判定所述第一数据满足预设数据补偿条件;S104d、若所述第一数据的第一状态不可流转为所述第二数据的当前数据状态或者所述第一数据的第二状态与所述第二数据当前数据状态不一致,判定所述第一数据不满足预设数据补偿条件。Specifically, in an embodiment, when the first data is inconsistent with the second data, the judging whether the first data meets a preset data compensation condition according to the first state and the second state includes Data compensation judgment method. The data compensation judgment method is shown in FIG. 2, that is, step S104 includes sub-steps S104a to S104d. Wherein, S104a, determining whether the first state of the first data can be transferred to the current data state of the second data according to a preset state transfer rule; S104b, if the first state of the first data can be transferred to all The current data state of the second data, and determine whether the second state of the first data is consistent with the current data state of the second data; S104c, if the second state of the first data is the same as the current data state of the second data If the data status is consistent, it is determined that the first data meets the preset data compensation condition; S104d, if the first status of the first data cannot be transferred to the current data status of the second data or the second data status of the first data The state is inconsistent with the current data state of the second data, and it is determined that the first data does not meet the preset data compensation condition.
具体地,在所述步骤S104a中,所述预设状态流转规则包括状态可流转规则以及状态不可流转规则,其中,所述状态可流转规则为预先设定的可从一状态流转更新为另一状态的规则,所述状态不可流转规则为预先设定的不可从一状态流转为另一状态的规则,例如,若一状态为申请中,则预设设定的可与其发生状态流转的另一状态为取消申请、同意申请以及不同意申请;不可与其发生状态流转的另一状态为已放款、已还款、部分还款、逾期未还款;若一状态为同意申请,则可与其发生状态流转的另一状态为已放款;不可与其发生状态流程的另一状态则为申请中、不同意申请、已还款、已部分还款以及逾期未还款;即一状态可以从申请中状态流转为同意申请状态,却不可从同意申请状态流转为申请中状态。因此,在所述步骤S104a中,若所述第一数据的第一状态为申请中,所述第二数据的当前数据状态为同意申请,其中,数据状态为申请中可流转为同意申请,则判定所述第一数据的第一状态满足预设状态流转规则;若所述第一数据的第一状态为同意申请,所述第二数据的当前数据状态为不同意申请,其中,数据状态为同意申请不可流转为不同意申请,则判定所述第一数据的第一状态不满足预设状态流转规则。Specifically, in the step S104a, the preset state transfer rules include a state transferable rule and a state non-transferable rule, wherein the state transferable rule is a preset state that can be updated from one state to another. State rules, the state non-circulation rule is a preset rule that cannot be transferred from one state to another state. For example, if a state is in application, the preset state can be transferred to another state. The status is canceled application, approved application, and disapproved application; the other status that cannot be transferred with it is loaned out, repaid, partial repayment, overdue payment; if one status is approved to apply, it can happen with the status The other status of the transfer is already loaned; the other status of the status that cannot be associated with the process is application, disapproval of application, repayment, partial repayment, and overdue payment; that is, a status can be transferred from the application status In order to agree to the application status, it cannot be transferred from the approved application status to the application status. Therefore, in the step S104a, if the first status of the first data is in application, the current data status of the second data is in application approval, and the data status is in application can be transferred to application approval, then It is determined that the first state of the first data satisfies the preset state transfer rule; if the first state of the first data is an application approved, the current data state of the second data is an application disapproved, wherein the data state is If the approval application cannot be transferred to the disapproval application, it is determined that the first state of the first data does not meet the preset state transfer rule.
在所述步骤S104b中,若所述第一数据的第一状态可流转为所述第二数据的当前数据状态,则根据所述第一数据的第二状态判断所述第一数据的第二状态是否与所述第二数据的当前数据状态一致;具体可例如为,若根据所述更新请求可知该第一数据第一状态为申请中,第二状态为同意申请;从步骤S102可知该区块链上查找到的与该第一数据对应的第二数据当前数据状态为同意申请,因此,该第一数据第二状态与第二数据当前数据状态一致,均为同意申请,则可判定该第一数据第二状态与该第二数据当前数据状态一致,即可判断该第一数据满足预设数据补偿条件,对该第一数据进行相应的数据补偿处理即可。其中,该第一数据存储于该预设关系型数据库中,该第二数据存储于该预设区块链上。In the step S104b, if the first state of the first data can be transferred to the current data state of the second data, the second state of the first data is determined according to the second state of the first data. Whether the status is consistent with the current data status of the second data; specifically, for example, if it can be known that the first status of the first data is in application according to the update request, and the second status is the approved application; it can be known from step S102 that the area The current data status of the second data corresponding to the first data found on the block chain is an approved application. Therefore, the second status of the first data is consistent with the current data status of the second data, and both are approved applications. If the second state of the first data is consistent with the current data state of the second data, it can be determined that the first data meets the preset data compensation condition, and the corresponding data compensation processing may be performed on the first data. Wherein, the first data is stored in the preset relational database, and the second data is stored in the preset blockchain.
由于在数据上链的过程中,可能导致该第一数据与第二数据中的数据状态不同,例如,在更新数据的数据状态的过程中,当第一数据当前数据状态从申请中更新为同意申请时,再 将该更新后第一数据作为第二数据写入区块链中,当该第二数据成功写入链后,但是由于需要通过HTTP协议与多个系统进行交互,所述系统可例如为交易系统以及区块链系统,即用户端系统需要通过HTTP协议与交易系统以及区块链系统进行交互以实现数据上链,因此,在数据上链过程中存在较多不可控制的因素,因此,容易出现返回异常或上链超时等情况,进而导致该第一数据在预设关系型数据库中的数据状态将从第二状态自动回滚到第一状态,即从同意申请状态回滚到申请中状态。此时,该预设关系型数据库中的第一数据的数据状态为申请中,而该预设区块链上与该第一数据对应的第二数据的数据状态为同意申请。当用户端系统接收到查询条件为数据状态为申请中时,该被回滚的第一数据将会被查询获取到,进而根据用户发送的更新请求需要将该第一数据更新为同意申请再写入链上,但此时,该第一数据对应的第二数据在链上的数据状态已经是同意申请状态,由于链上的数据具备唯一性,因此该更新后第一数据无法重复写入该区块链上,进而导致数据上链过程异常,可能会造成更多不良影响。此时,只需对该第一数据在预设关系型数据库中的数据状态进行补偿,以使该第一数据不被查询出来。因此,需要判断所述第一数据的第二状态是否与所述第二数据当前数据状态一致。若所述第一数据的第二状态与所述第二数据当前数据状态一致,则表明该第一数据在更新数据状态以上链的过程中被回滚了,而其对应的第二数据已成功上链,此时,只需对该第一数据在预设关系型数据库中的数据状态进行补偿即可,即将该第一数据在预设关系型数据库中的数据状态补偿为同意申请,以防止该第一数据重复上链,解决上链事务异常。Because the data status in the first data is different from the data status in the second data in the process of data uploading, for example, in the process of updating the data status of the data, when the current data status of the first data is updated from the application to agree When applying, write the updated first data as the second data into the blockchain. When the second data is successfully written into the chain, but due to the need to interact with multiple systems through the HTTP protocol, the system can For example, the transaction system and the blockchain system, that is, the client system needs to interact with the transaction system and the blockchain system through the HTTP protocol to achieve data on the chain. Therefore, there are many uncontrollable factors in the process of data on the chain. Therefore, it is easy to return abnormalities or timeout on the chain, which will cause the data state of the first data in the preset relational database to automatically roll back from the second state to the first state, that is, roll back from the agreed application state to Application status. At this time, the data status of the first data in the preset relational database is application, and the data status of the second data corresponding to the first data on the preset blockchain is application approval. When the client system receives the query condition that the data status is application, the first data that was rolled back will be retrieved by query, and then the first data needs to be updated to agree to the application and write again according to the update request sent by the user In the chain, but at this time, the data status of the second data corresponding to the first data on the chain is already in the state of agreeing to apply. Because the data on the chain is unique, the first data cannot be repeatedly written to the On the blockchain, the data on the chain will be abnormal, which may cause more adverse effects. At this time, it is only necessary to compensate the data state of the first data in the preset relational database, so that the first data is not queried. Therefore, it is necessary to determine whether the second state of the first data is consistent with the current data state of the second data. If the second state of the first data is consistent with the current data state of the second data, it indicates that the first data was rolled back in the process of updating the data state to the chain, and the corresponding second data has succeeded On the chain, at this time, only the data state of the first data in the preset relational database needs to be compensated, that is, the data state compensation of the first data in the preset relational database is a consent application to prevent The first data is repeatedly chained to solve the abnormality of the chaining transaction.
S105、若所述第一数据满足预设数据补偿条件,根据所述第二状态对所述第一数据进行数据补偿。S105: If the first data meets a preset data compensation condition, perform data compensation on the first data according to the second state.
具体地,若所述第一数据的第二状态与该第二数据当前数据状态一致,即判定所述第一数据满足预设数据补偿条件,则根据所述更新请求对该第一数据进行数据补偿,其中,所述根据所述更新请求对该第一数据进行数据补偿具体包括:根据所述更新请求将所述第一数据的数据状态从第一状态更新补偿为第二状态。Specifically, if the second state of the first data is consistent with the current data state of the second data, that is, it is determined that the first data satisfies the preset data compensation condition, then the data of the first data is performed according to the update request. Compensation, wherein the performing data compensation on the first data according to the update request specifically includes: updating and compensating the data state of the first data from the first state to the second state according to the update request.
在上述实施例中,本方案通过在接收到用户提交的更新请求后,先根据所述更新请求获取一预设关系型数据库中的第一数据,再根据所述第一数据到链上查找到与该第一数据对应的第二数据,再判断该第一数据以及第二数据是否一致;若该第一数据与第二数据一致,则执行用户发送的第二次更新请求;若该第一数据与第二数据不一致,则再判断该第一数据是否满足预设数据补偿条件,若满足,则对该第一数据进行数据补偿,进而保证在后续执行该更新请求时,避免该需进行数据补偿的第一数据对该更新请求的干扰,即避免干扰其他待更新数据的正常上链,可以保证用户的更新请求的正常进行,其中,所述更新请求为数据上链请求。本申请实施例能够有效解决保存在一关系型数据库中的数据与链上对应的数据不一致问题,避免因关系型数据库的数据与链上对应的数据不一致而无法更新链上数据的问题。本申请实施例可以自动对需进行数据补偿的待更新数据进行补偿,无须用户参与即可自动实现数据修复补偿。本申请实施例还可以有效保证上链事务的有序进行以及可以提高用户端系统的异常事务的处理能力。In the above embodiment, this solution first obtains the first data in a preset relational database according to the update request after receiving the update request submitted by the user, and then finds it on the chain according to the first data The second data corresponding to the first data is then judged whether the first data and the second data are consistent; if the first data is consistent with the second data, the second update request sent by the user is executed; if the first data is consistent If the data is inconsistent with the second data, then it is determined whether the first data meets the preset data compensation conditions, and if so, data compensation is performed on the first data, so as to ensure that the need for data is avoided when the update request is subsequently executed. The compensated first data interferes with the update request, that is, avoids interference with the normal uploading of other data to be updated, which can ensure the normal progress of the user's update request, wherein the update request is a data upload request. The embodiments of the present application can effectively solve the problem of inconsistency between the data stored in a relational database and the corresponding data on the chain, and avoid the problem that the data on the chain cannot be updated due to the inconsistency between the data of the relational database and the corresponding data on the chain. The embodiment of the application can automatically compensate the data to be updated that needs data compensation, and can automatically realize data repair compensation without user involvement. The embodiments of the present application can also effectively ensure the orderly progress of on-chain transactions and can improve the processing capability of the abnormal transaction of the client system.
请参阅图3,其为本申请第二实施例提供的一种面向区块链的数据管理方法的流程示意图。具体地,如图3所示,该方法可包括步骤S201-S207。其中步骤S201-S205与上述实施例中的步骤S101-S105类似,在此不再赘述。下面详细说明本实施例中所增加的步骤S206-S207。Please refer to FIG. 3, which is a schematic flowchart of a blockchain-oriented data management method provided by the second embodiment of this application. Specifically, as shown in FIG. 3, the method may include steps S201-S207. The steps S201-S205 are similar to the steps S101-S105 in the foregoing embodiment, and will not be repeated here. The steps S206-S207 added in this embodiment will be described in detail below.
S206、若所述第一数据与所述第二数据一致,执行用户发送的第二次更新请求;其中,每一次更新请求为数据上链请求。S206. If the first data is consistent with the second data, execute a second update request sent by the user; wherein, each update request is a data upload request.
其中,在一实施例中,由步骤S203可知,所述比对所述第一数据与所述第二数据以判断所述第一数据与所述第二数据是否一致的步骤之后还包括:若所述第一数据与所述第二数据一致,执行用户发送的第二次更新请求;其中,所述第二次更新请求为数据上链请求。Wherein, in one embodiment, it can be seen from step S203 that after the step of comparing the first data with the second data to determine whether the first data is consistent with the second data, the method further includes: The first data is consistent with the second data, and the second update request sent by the user is executed; wherein, the second update request is a data upload request.
具体地,若所述第一数据与所述第二数据一致,则表明该第一数据为正常上链数据,不需要对该第一数据进行数据补偿处理,则可以将该不需进行数据补偿的数据上区块链,即执 行用户发送的第二次更新请求,从而可以保证用户的第二次更新请求的正常进行。具体地,所述执行用户发送的第二次更新请求具体包括子步骤S206a以及子步骤S206b,其中,所述子步骤S206a:更新所述关系型数据库中的待更新数据;以及所述子步骤S206b:通过调用更新链接口将更新后的待更新数据写入一预设区块链上;其中,所述更新链接口为所述区块链提供给所述用户端调用的接口。Specifically, if the first data is consistent with the second data, it indicates that the first data is normal on-chain data, and there is no need to perform data compensation processing on the first data, and the data compensation may not be required. The data on the blockchain is to execute the second update request sent by the user, so as to ensure the normal progress of the second update request of the user. Specifically, the second update request sent by the executing user specifically includes sub-step S206a and sub-step S206b, wherein the sub-step S206a: updating the data to be updated in the relational database; and the sub-step S206b : Write the updated data to be updated on a preset blockchain by calling the update link; wherein the update link is an interface that the blockchain provides to the client to call.
S207、若所述第一数据不满足预设数据补偿条件,向用户发出异常提醒。S207: If the first data does not meet the preset data compensation condition, send an abnormal reminder to the user.
具体地,由步骤S204可知,根据所述第一状态以及第二状态判断所述第一数据是否满足预设数据补偿条件具体包括:S204a、根据预设状态流转规则判断所述第一数据的第一状态是否可流转为所述第二数据的当前数据状态;以及S204b、若所述第一数据的第一状态可流转为所述第二数据的当前数据状态,判断所述第一数据的第二状态是否与所述第二数据当前数据状态一致;其中,若所述第一数据的第一状态不可流转为所述第二数据的当前数据状态或者该第一数据第二状态与该第二数据当前数据状态不一致,则所述第一数据为异常数据,则将其视为系统运行的未知异常,无法通过系统自动补偿来达到数据一致性,需要向用户发出异常提醒。Specifically, it can be known from step S204 that judging whether the first data meets the preset data compensation condition according to the first state and the second state specifically includes: S204a: judging the first data of the first data according to the preset state circulation rule Whether a state can be transferred to the current data state of the second data; and S204b, if the first state of the first data can be transferred to the current data state of the second data, determine the first data state of the first data Whether the second state is consistent with the current data state of the second data; wherein, if the first state of the first data cannot be transferred to the current data state of the second data or the second state of the first data is If the current data state of the data is inconsistent, the first data is abnormal data, which is regarded as an unknown abnormality of the system operation, and data consistency cannot be achieved through automatic system compensation, and an abnormal reminder needs to be issued to the user.
具体地,在一实施例中,当所述第一数据不满足预设数据补偿条件时,所述向用户发出异常提醒包括子步骤S207a以及子步骤S207b。其中,S207a、将所述第一数据保存到一预设的数据表内;S207b、将所述数据表通过邮件发送给用户以发出异常提醒。当然在其他实施例方式,可以通过即时通讯方式或者短信亦或者系统报警等方式将所述数据表发送给用户以发出异常提醒。具体地,在一实施例中,可以将该第一数据的ID或者编号写入到一预设数据库表中,该预设数据库表用于存储所有异常数据,并发出邮件提醒到相关负责人,以使该相关负责人可以根据该邮件提醒及时分析并解决该数据问题。Specifically, in an embodiment, when the first data does not meet the preset data compensation condition, the sending an abnormal reminder to the user includes sub-step S207a and sub-step S207b. Wherein, S207a, save the first data in a preset data table; S207b, send the data table to the user by email to send an abnormal reminder. Of course, in other embodiments, the data table may be sent to the user by means of instant messaging, text messages, or system alarms to send out abnormal reminders. Specifically, in an embodiment, the ID or serial number of the first data may be written into a preset database table, which is used to store all abnormal data and send email reminders to the relevant person in charge, So that the relevant person in charge can analyze and solve the data problem in time according to the email reminder.
在上述实施例中,本方案通过在接收到用户提交的更新请求后,先根据所述更新请求获取一预设关系型数据库中的第一数据,再根据所述第一数据到链上查找到与该第一数据对应的第二数据,再判断该第一数据与第二数据是否一致;若该第一数据与第二数据一致,则执行用户发送的第二次更新请求;若该第一数据与第二数据不一致,则再判断该第一数据是否满足预设数据补偿条件,若满足,则对该第一数据进行数据补偿,进而保证在后续执行该更新请求时,避免该需进行数据补偿的第一数据对该更新请求的干扰,即避免干扰其他待更新数据的正常上链,可以保证用户的更新请求的正常进行,其中,所述更新请求为数据上链请求。若不满足,向用户发出异常提醒,可以及时提醒用户,以使用户可以方便快捷发现异常数据,进而及时进行人工修复。In the above embodiment, this solution first obtains the first data in a preset relational database according to the update request after receiving the update request submitted by the user, and then finds it on the chain according to the first data The second data corresponding to the first data is then judged whether the first data is consistent with the second data; if the first data is consistent with the second data, the second update request sent by the user is executed; if the first data is consistent If the data is inconsistent with the second data, then it is determined whether the first data meets the preset data compensation conditions, and if so, data compensation is performed on the first data, so as to ensure that the need for data is avoided when the update request is subsequently executed. The compensated first data interferes with the update request, that is, avoids interference with the normal uploading of other data to be updated, which can ensure the normal progress of the user's update request, wherein the update request is a data upload request. If it is not satisfied, an abnormal reminder is sent to the user, which can prompt the user in time so that the user can quickly and easily find the abnormal data, and then perform manual repair in time.
请参阅图4,其为本申请第三实施例提供的一种面向区块链的数据管理方法的流程示意图。具体地,所述方法应用于一预设用户端,所述更新请求为第二次更新请求,其中,如图4所示,该方法可包括步骤S301-S310。其中步骤S301-S307与上述实施例中的步骤S201-S207类似,在此不再赘述。下面详细说明本实施例中所增加的步骤S308-步骤S312。Please refer to FIG. 4, which is a schematic flowchart of a blockchain-oriented data management method provided by the third embodiment of this application. Specifically, the method is applied to a preset user terminal, and the update request is the second update request. As shown in FIG. 4, the method may include steps S301-S310. Steps S301-S307 are similar to steps S201-S207 in the foregoing embodiment, and will not be repeated here. The steps S308 to S312 added in this embodiment will be described in detail below.
S308、若接收到用户发送的第一次更新请求,根据所述第一次更新请求的第一状态以及第二状态判断所述关系型数据库中的待更新数据是否满足预设状态流转规则。S308: If the first update request sent by the user is received, determine whether the data to be updated in the relational database meets a preset state transfer rule according to the first state and the second state of the first update request.
具体地,所述根据所述第一次更新请求的第一状态以及第二状态判断所述关系型数据库中的待更新数据是否满足预设状态流转规则包括子步骤S308a,其中所述子步骤S308a:根据所述第一次更新请求的第一状态以及第二状态以及预设状态流转规则判断所述关系型数据库中的待更新数据是否可从第一状态更新为第二状态;其中,一次更新请求包括待更新数据的第一状态以及第二状态,其中,所述第一状态以及第二状态为所述待更新数据的数据状态,所述数据状态为所述待更新数据的状态属性值;所述第一状态为待更新数据更新以前的数据状态,所述第二状态为待更新数据更新以后的数据状态。所述预设状态流转规则包括状态可流转规则以及状态不可流转规则,其中,所述状态可流转规则为预先设定的可从一状态流转更新为另一状态的规则,所述状态不可流转规则为预先设定的不可从一状态流转为另一状态的规则。具体可例如为,若所述待更新数据第一状态为申请中,其第二状态为已还款,则所 述关系型数据库中的待更新数据不满足预设状态流转规则;若所述待更新数据第一状态为申请中,其第二状态为同意申请,则所述关系型数据库中的待更新数据满足预设状态流转规则。Specifically, the judging whether the data to be updated in the relational database meets the preset state transfer rule according to the first state and the second state of the first update request includes sub-step S308a, wherein the sub-step S308a : Judging whether the data to be updated in the relational database can be updated from the first state to the second state according to the first state and the second state of the first update request and the preset state flow rule; wherein, one update The request includes a first state and a second state of the data to be updated, wherein the first state and the second state are the data state of the data to be updated, and the data state is the state attribute value of the data to be updated; The first state is the data state before the data to be updated is updated, and the second state is the data state after the data to be updated is updated. The preset state transfer rule includes a state transferable rule and a state non-transferable rule, wherein the state transferable rule is a preset rule that can be transferred from one state to another state, and the state cannot be transferred rule It is a pre-set rule that cannot flow from one state to another. Specifically, for example, if the first status of the data to be updated is application and its second status is repaid, then the data to be updated in the relational database does not meet the preset state transfer rules; The first state of the updated data is the application, and the second state is the application approved, then the data to be updated in the relational database meets the preset state circulation rules.
S309、若所述关系型数据库中的待更新数据满足预设状态流转规则,更新所述待更新数据。S309: If the data to be updated in the relational database meets the preset state circulation rule, update the data to be updated.
具体地,所述更新所述待更新数据具体包括:更新所述用户端系统的一预设关系型数据库中的待更新数据的数据状态。所述更新所述用户端系统的一预设关系型数据库中的待更新数据的数据状态具体为:将所述用户端系统的一预设关系型数据库中的待更新数据从第一状态更新为第二状态。Specifically, the updating the data to be updated specifically includes: updating the data status of the data to be updated in a preset relational database of the user end system. The updating the data state of the data to be updated in a preset relational database of the user-end system specifically includes: updating the data to be updated in a preset relational database of the user-end system from the first state to The second state.
S310、通过调用更新链接口将更新后的待更新数据写入一预设区块链上;其中,所述更新链接口为所述区块链提供给所述用户端调用的接口。S310. Write the updated data to be updated on a preset blockchain by calling the update link; wherein the update link is an interface that the blockchain provides to the client to call.
具体地,所述通过调用更新链接口将更新后的待更新数据写入一预设区块链上是通过HTTP协议远程访问实现的。具体地,需要通过HTTP协议远程访问多个系统实现的,可例如为所述用户端系统通过HTTP协议调用交易服务器的写入链接口,其中,该HTTP协议将有目的地返回HTTP返回码,并且该HTTP返回码可以根据用户实际应用场景的需求进行自定义设置,当该HTTP返回码表示失败时,保存在该关系型数据库中的数据将会自动回滚。Specifically, the writing of the updated data to be updated on a preset blockchain by calling the update link port is achieved through remote access via HTTP protocol. Specifically, it is necessary to remotely access multiple systems through the HTTP protocol. For example, the client system may call the write link port of the transaction server through the HTTP protocol, where the HTTP protocol will return the HTTP return code purposefully, and The HTTP return code can be customized according to the needs of the user's actual application scenario. When the HTTP return code indicates a failure, the data saved in the relational database will be automatically rolled back.
S311、接收HTTP返回码并根据所述HTTP返回码判断是否出现更新异常。S311. Receive an HTTP return code and determine whether an update exception occurs according to the HTTP return code.
其中,所述HTTP返回码包括多个状态码,该多个状态码用于表示服务器在处理请求时发生的错误,因此,通过接收到的HTTP返回码可以判断确定是否为更新异常,其中,所述更新异常为数据上链过程的多个系统在处理请求时发生的错误情况。即该多个状态码用于表示用于数据上链过程的多个系统在处理请求时发生的错误。这些错误可能是服务器本身的错误,而不是请求出错。所述多个状态码可例如为500(服务器内部错误)、501(尚未实施)、502(错误网关)、503(服务不可用)、504(网关超时)以及505(HTTP版本不受支持)等。其中,在一实施例中,可以事先设置数据写入链的整个过程所需时间为15秒,若数据写入链的整个过程所花费时间超过15秒,则判定该数据入链超时,即该数据入链失败,将会返回504(网关超时)这一HTTP返回码。Wherein, the HTTP return code includes multiple status codes, and the multiple status codes are used to indicate an error that occurs when the server processes the request. Therefore, the received HTTP return code can be used to determine whether it is an update abnormality. The update exception is an error condition that occurs when multiple systems in the process of data uploading are processing requests. That is, the multiple status codes are used to indicate errors that occur when multiple systems used in the data upload process process requests. These errors may be errors in the server itself, rather than errors in the request. The multiple status codes can be, for example, 500 (server internal error), 501 (not yet implemented), 502 (error gateway), 503 (service unavailable), 504 (gateway timeout), 505 (HTTP version is not supported), etc. . Among them, in one embodiment, the time required for the entire process of writing data to the chain can be set to 15 seconds in advance. If the entire process of writing data to the chain takes more than 15 seconds, it is determined that the data entry into the chain has timed out, that is, the If the data fails to enter the chain, an HTTP return code of 504 (gateway timeout) will be returned.
S312、若出现更新异常,回滚所述关系型数据库中更新后的待更新数据。S312: If an abnormal update occurs, roll back the updated data to be updated in the relational database.
具体地,当该HTTP返回码表示失败时,保存在该关系型数据库中的数据将会自动回滚。Specifically, when the HTTP return code indicates failure, the data stored in the relational database will be automatically rolled back.
具体地,上述步骤S307-步骤S309为执行用户发送的第二次更新请求的必要步骤,即通过执行上述步骤S307-步骤S309即可实现所述第二次更新请求,即完成数据上链请求,其中,当用户发送第一次更新请求时,在预设关系型数据库中以及预设区块链上均不存在所述待更新数据,即也不存在预设关系型数据库中的数据与预设区块链上数据不一致的问题,然而在执行第一次更新请求之后,可能存在该预设关系型数据库中的数据与预设区块链上数据不一致的问题,因此,应当判断识别出该需要进行数据补偿的数据,以及对该预设关系型数据库中需进行数据补偿的数据进行补偿,进而保证在后续执行该更新请求时,避免该需进行数据补偿的第一数据对该更新请求的干扰,即避免干扰其他待更新数据的正常上链,可以保证用户的更新请求的正常进行,其中,每一次更新请求为数据上链请求。Specifically, the above step S307-step S309 are necessary steps to execute the second update request sent by the user, that is, the second update request can be realized by executing the above step S307-step S309, that is, the data upload request is completed, Among them, when the user sends the first update request, the data to be updated does not exist in the preset relational database and on the preset blockchain, that is, there is no data in the preset relational database and the preset The problem of data inconsistency on the blockchain. However, after the first update request is executed, there may be a problem that the data in the preset relational database is inconsistent with the data on the preset blockchain. Therefore, it should be judged and identified. Data for data compensation, and compensation for data in the preset relational database that needs data compensation, thereby ensuring that when the update request is subsequently executed, the interference of the first data that needs data compensation on the update request is avoided , That is, to avoid interference with the normal uploading of other data to be updated, which can ensure the normal progress of the user's update request, where each update request is a data upload request.
请参阅图5,其为本申请第一实施例提供的一种面向区块链的数据管理装置100的示意性框图。如图5所示,该面向区块链的数据管理装置100对应于图1所示的面向区块链的数据管理方法。该面向区块链的数据管理装置100包括用于执行上述面向区块链的数据管理方法的单元,该面向区块链的数据管理装置100可以被配置于提供数据上链功能的终端设备中,具体地,该面向区块链的数据管理装置100应用于一终端设备的用户端系统内,用于防止关系型数据库的数据与区块链上对应的数据不一致。其中,该终端设备可以为配置一预设区块链的智能手机、平板电脑或笔记本电脑等电子设备;或者独立的服务器或者多个服务器组成的服务器集群;该终端设备也可以为未配置一预设区块链,但可以与配置该预设区块链的其他终端设备进行交互。具体地,请参阅图5,该面向区块链的数据管理装置100包括第一接收单元101、第一获取单元102、第一判断单元103、第二判断单元104以及第一补偿单元105。Please refer to FIG. 5, which is a schematic block diagram of a blockchain-oriented data management device 100 provided by the first embodiment of the application. As shown in FIG. 5, the blockchain-oriented data management device 100 corresponds to the blockchain-oriented data management method shown in FIG. The blockchain-oriented data management device 100 includes a unit for executing the above-mentioned blockchain-oriented data management method. The blockchain-oriented data management device 100 can be configured in a terminal device that provides data on-chain functions, Specifically, the blockchain-oriented data management device 100 is applied in a client system of a terminal device to prevent data in a relational database from being inconsistent with corresponding data on the blockchain. Among them, the terminal device may be an electronic device such as a smart phone, a tablet computer, or a notebook computer configured with a preset blockchain; or an independent server or a server cluster composed of multiple servers; the terminal device may also be configured without a preset blockchain. Set a blockchain, but it can interact with other terminal devices that configure the preset blockchain. Specifically, referring to FIG. 5, the blockchain-oriented data management device 100 includes a first receiving unit 101, a first acquiring unit 102, a first determining unit 103, a second determining unit 104, and a first compensation unit 105.
所述第一接收单元101用于接收用户发送的第二次更新请求,其中,每一次更新请求包括待更新数据的第一状态以及第二状态,其中,所述第一状态以及第二状态为所述待更新数据的数据状态,所述数据状态为所述待更新数据的状态属性值。The first receiving unit 101 is configured to receive a second update request sent by a user, where each update request includes a first state and a second state of the data to be updated, wherein the first state and the second state are The data state of the data to be updated, where the data state is the state attribute value of the data to be updated.
所述第一获取单元102用于根据所述第一状态从一预设关系型数据库中获取待更新数据以及从预设区块链上查找与所述待更新数据对应的数据,其中,将所述关系型数据库中获取的待更新数据作为第一数据,将所述区块链上查找的与该待更新数据对应的数据作为第二数据。The first obtaining unit 102 is configured to obtain data to be updated from a preset relational database according to the first state and search for data corresponding to the data to be updated from a preset blockchain, wherein The data to be updated obtained in the relational database is used as the first data, and the data corresponding to the data to be updated found on the blockchain is used as the second data.
在一实施例中,第一获取单元102包括:第一获取子单元102a以及第二获取子单元102b。其中,所述第一获取子单元102a,用于根据所述待更新数据的第一状态从一预设关系型数据库中获取所述待更新数据,其中,将所述关系型数据库中获取的待更新数据作为第一数据;以及所述第二获取子单元102b,用于根据所述第一数据从一预设区块链上查找与所述第一数据对应的数据,其中,将所述区块链上查找的与所述第一数据对应的数据作为第二数据。In an embodiment, the first obtaining unit 102 includes: a first obtaining subunit 102a and a second obtaining subunit 102b. Wherein, the first obtaining subunit 102a is configured to obtain the data to be updated from a preset relational database according to the first state of the data to be updated, wherein the data to be updated obtained from the relational database is Update data as first data; and the second acquiring subunit 102b is configured to search for data corresponding to the first data from a preset blockchain according to the first data, wherein the area is The data corresponding to the first data found on the block chain is used as the second data.
所述第一判断单元103用于比对所述第一数据与所述第二数据以判断所述第一数据与所述第二数据是否一致。The first determining unit 103 is configured to compare the first data with the second data to determine whether the first data is consistent with the second data.
所述第二判断单元104用于若所述第一数据与所述第二数据不一致,根据所述第一状态以及第二状态判断所述第一数据是否满足预设数据补偿条件。The second determining unit 104 is configured to determine whether the first data meets a preset data compensation condition according to the first state and the second state if the first data is inconsistent with the second data.
在一实施例中,如图6所示,所述第二判断单元104包括:第一判断子单元104a、第二判断子单元104b、第一判定单元104c以及第二判定单元104d。其中,所述第一判断子单元104a,用于根据预设状态流转规则判断所述第一数据的第一状态是否可流转为所述第二数据的当前数据状态;所述第二判断子单元102b,用于若所述第一数据的第一状态可流转为所述第二数据的当前数据状态,判断所述第一数据的第二状态是否与所述第二数据当前数据状态一致;所述第一判定单元104c,用于若所述第一数据的第二状态与所述第二数据当前数据状态一致,判定所述第一数据满足预设数据补偿条件;以及所述第二判定单元104d,用于若所述第一数据的第一状态不可流转为所述第二数据的当前数据状态或者所述第一数据的第二状态与所述第二数据当前数据状态不一致,判定所述第一数据不满足预设数据补偿条件。In an embodiment, as shown in FIG. 6, the second judgment unit 104 includes: a first judgment subunit 104a, a second judgment subunit 104b, a first judgment unit 104c, and a second judgment unit 104d. The first determining subunit 104a is configured to determine whether the first state of the first data can be transferred to the current data state of the second data according to a preset state transfer rule; the second determining subunit 102b, configured to determine whether the second state of the first data is consistent with the current data state of the second data if the first state of the first data can be transferred to the current data state of the second data; The first determining unit 104c is configured to determine that the first data meets a preset data compensation condition if the second state of the first data is consistent with the current data state of the second data; and the second determining unit 104d, configured to determine if the first state of the first data cannot be transferred to the current data state of the second data or the second state of the first data is inconsistent with the current data state of the second data The first data does not meet the preset data compensation condition.
所述第一补偿单元105用于若所述第一数据满足预设数据补偿条件,根据所述第二状态对所述第一数据进行数据补偿。The first compensation unit 105 is configured to perform data compensation on the first data according to the second state if the first data meets a preset data compensation condition.
需要说明的是,所属领域的技术人员可以清楚地了解到,上述面向区块链的数据管理装置100和各单元的具体实现过程以及效果,可以参考前述方法实施例中的相应描述,为了描述的方便和简洁,在此不再赘述。It should be noted that those skilled in the art can clearly understand that the above-mentioned blockchain-oriented data management device 100 and the specific implementation process and effects of each unit can refer to the corresponding description in the foregoing method embodiment, for the purpose of description Convenient and concise, I won’t repeat it here.
请参阅图7,其为本申请第二实施例提供的一种面向区块链的数据管理装置200的示意性框图。如图7所示,本申请第二实施例提供的一种面向区块链的数据管理装置200是在上述实施例的基础上增加了第一执行单元206以及第一提醒单元207,即所述装置200包括第二接收单元201、第二获取单元202、第三判断单元203、第四判断单元204、第二补偿单元205、第一执行单元206以及第一提醒单元207。其中,该第二接收单元201、第二获取单元202、第三判断单元203、第四判断单元204以及第二补偿单元205与上述实施例中的第一接收单元101、第一获取单元102、第一判断单元103、第二判断单元104以及第一补偿单元105类似,由于其应用过程以及相应功能与上述实施例中所对应的单元类似,在此不再赘述。Please refer to FIG. 7, which is a schematic block diagram of a block chain-oriented data management device 200 provided by the second embodiment of the application. As shown in FIG. 7, the block chain-oriented data management device 200 provided by the second embodiment of the present application adds a first execution unit 206 and a first reminder unit 207 on the basis of the above-mentioned embodiment. The device 200 includes a second receiving unit 201, a second acquiring unit 202, a third determining unit 203, a fourth determining unit 204, a second compensating unit 205, a first executing unit 206, and a first reminding unit 207. Among them, the second receiving unit 201, the second acquiring unit 202, the third determining unit 203, the fourth determining unit 204, and the second compensating unit 205 are the same as the first receiving unit 101, the first acquiring unit 102, The first judging unit 103, the second judging unit 104, and the first compensation unit 105 are similar, and since their application process and corresponding functions are similar to the corresponding units in the foregoing embodiment, they will not be repeated here.
所述第一执行单元206用于若所述第一数据与所述第二数据一致,执行用户发送的第二次更新请求;其中,每一次更新请求为数据上链请求。The first execution unit 206 is configured to execute a second update request sent by the user if the first data is consistent with the second data; wherein, each update request is a data upload request.
具体地,在一实施例中,所述第一执行单元206包括第一执行子单元206a以及第二执行子单元206b。其中,所述第一执行子单元206a用于更新所述关系型数据库中的待更新数据;以及所述第二执行子单元206b用于通过调用更新链接口将更新后的待更新数据写入一预设区块链上;其中,所述更新链接口为所述区块链提供给所述用户端调用的接口。Specifically, in an embodiment, the first execution unit 206 includes a first execution sub-unit 206a and a second execution sub-unit 206b. Wherein, the first execution sub-unit 206a is used to update the data to be updated in the relational database; and the second execution sub-unit 206b is used to write the updated data to be updated into a file by calling the update link port. On a preset blockchain; wherein, the update link port is an interface that the blockchain provides to the client to call.
所述第一提醒单元207用于若所述第一数据不满足预设数据补偿条件,向用户发出异常提醒。The first reminder unit 207 is configured to send an abnormal reminder to the user if the first data does not meet the preset data compensation condition.
具体地,在一实施例中,所述第一提醒单元207包括第一保存单元207a以及第一提醒子单元207b。其中,所述第一保存单元207a用于将所述第一数据保存到一预设的数据表内;以及所述第一提醒子单元207b用于将所述数据表通过邮件发送给用户以发出异常提醒。当然在其他实施例方式,可以通过即时通讯方式或者短信亦或者系统报警等方式将所述数据表发送给用户以发出异常提醒。Specifically, in an embodiment, the first reminder unit 207 includes a first storage unit 207a and a first reminder subunit 207b. Wherein, the first storage unit 207a is used to store the first data in a preset data table; and the first reminder sub-unit 207b is used to send the data table to the user by email for sending Exception reminder. Of course, in other embodiments, the data table may be sent to the user by means of instant messaging, text messages, or system alarms to send out abnormal reminders.
需要说明的是,所属领域的技术人员可以清楚地了解到,上述装置200和各单元的具体实现过程以及效果,可以参考前述方法实施例中的相应描述,为了描述的方便和简洁,在此不再赘述。It should be noted that those skilled in the art can clearly understand that for the specific implementation process and effects of the above-mentioned device 200 and each unit, reference may be made to the corresponding description in the foregoing method embodiment. For the convenience and brevity of the description, it is not here. Repeat it again.
请参阅图8,其为本申请第三实施例提供的一种面向区块链的数据管理装置300的示意性框图。如图8所示,本申请第三实施例提供的一种面向区块链的数据管理装置300是在上述实施例的基础上增加了规则判断单元308、更新单元309、更新链单元310、返回码判断单元311以及回滚单元312,即所述装置300包括第三接收单元301、第三获取单元302、第五判断单元303、第六判断单元304、第三补偿单元305、第二执行单元306、第二提醒单元307、规则判断单元308、更新单元308、更新链单元310、返回码判断单元311以及回滚单元312。其中,该第三接收单元301、第三获取单元302、第五判断单元303、第六判断单元304、第三补偿单元305、第二执行单元306以及第二提醒单元307与上述实施例中的第二接收单元201、第二获取单元202、第三判断单元203、第四判断单元204、第二补偿单元205、第一执行单元206以及第一提醒单元207类似,由于其应用过程以及相应功能与上述实施例中所对应的单元类似,在此不再赘述。Please refer to FIG. 8, which is a schematic block diagram of a blockchain-oriented data management device 300 provided by the third embodiment of the application. As shown in FIG. 8, a blockchain-oriented data management device 300 provided by the third embodiment of the present application adds a rule determination unit 308, an update unit 309, an update chain unit 310, and a return Code judgment unit 311 and rollback unit 312, that is, the device 300 includes a third receiving unit 301, a third acquisition unit 302, a fifth judgment unit 303, a sixth judgment unit 304, a third compensation unit 305, and a second execution unit 306, a second reminder unit 307, a rule determination unit 308, an update unit 308, an update chain unit 310, a return code determination unit 311, and a rollback unit 312. Among them, the third receiving unit 301, the third acquiring unit 302, the fifth determining unit 303, the sixth determining unit 304, the third compensating unit 305, the second executing unit 306, and the second reminding unit 307 are the same as those in the foregoing embodiment The second receiving unit 201, the second acquiring unit 202, the third judging unit 203, the fourth judging unit 204, the second compensation unit 205, the first executing unit 206, and the first reminding unit 207 are similar, due to their application process and corresponding functions It is similar to the corresponding units in the above-mentioned embodiment, and will not be repeated here.
所述规则判断单元308用于若接收到用户发送的第一次更新请求,根据所述第一次更新请求的第一状态以及第二状态判断所述关系型数据库中的待更新数据是否满足预设状态流转规则。其中,所述规则判断单元308具体用于若接收到用户发送的第一次更新请求,根据所述第一次更新请求的第一状态以及第二状态以及预设状态流转规则判断所述关系型数据库中的待更新数据是否可从第一状态更新为第二状态。The rule determination unit 308 is configured to, if the first update request sent by the user is received, determine whether the to-be-updated data in the relational database meets the predetermined requirements according to the first state and the second state of the first update request. Set state transfer rules. Wherein, the rule determination unit 308 is specifically configured to determine the relationship type according to the first state and second state of the first update request and a preset state transfer rule if the first update request sent by the user is received. Whether the data to be updated in the database can be updated from the first state to the second state.
所述更新单元309用于若所述关系型数据库中的待更新数据满足预设状态流转规则,更新所述待更新数据。The updating unit 309 is configured to update the data to be updated if the data to be updated in the relational database meets a preset state circulation rule.
所述更新链单元310用于通过调用更新链接口将更新后的待更新数据写入一预设区块链上;其中,所述更新链接口为所述区块链提供给所述用户端调用的接口。The update chain unit 310 is used to write the updated data to be updated on a preset blockchain by calling an update link; wherein, the update link is provided by the blockchain for the client to call Interface.
所述返回码判断单元311用于接收HTTP返回码并根据所述HTTP返回码判断是否出现更新异常。The return code judgment unit 311 is configured to receive an HTTP return code and judge whether an update abnormality occurs according to the HTTP return code.
所述回滚单元312用于若出现更新异常,回滚所述关系型数据库中更新后的待更新数据。The rollback unit 312 is configured to roll back the updated data to be updated in the relational database if an abnormal update occurs.
需要说明的是,所属领域的技术人员可以清楚地了解到,上述装置300和各单元的具体实现过程以及效果,可以参考前述方法实施例中的相应描述,为了描述的方便和简洁,在此不再赘述。It should be noted that those skilled in the art can clearly understand that for the specific implementation process and effects of the foregoing device 300 and each unit, reference may be made to the corresponding description in the foregoing method embodiment. For the convenience and brevity of the description, it is not here. Repeat it again.
上述装置可以实现为一种计算机程序的形式,该计算机程序可以在如图9所示的计算机设备上运行。The above-mentioned apparatus may be implemented in the form of a computer program, and the computer program may run on the computer device as shown in FIG. 9.
请参阅图9,其为本申请实施例提供的一种计算机设备的示意性框图。该计算机设备600可以是终端,也可以是服务器,其中,终端可以是智能手机、平板电脑、笔记本电脑、台式电脑和个人数字助理等支持数据上链事务的电子设备。服务器为支持数据上链事务的服务器,该服务器可以是独立的服务器,也可以是多个服务器组成的服务器集群。Please refer to FIG. 9, which is a schematic block diagram of a computer device according to an embodiment of the application. The computer device 600 may be a terminal or a server, where the terminal may be an electronic device supporting data on-chain transactions such as a smart phone, a tablet computer, a notebook computer, a desktop computer, and a personal digital assistant. The server is a server that supports data on-chain transactions, and the server may be an independent server or a server cluster composed of multiple servers.
参阅图9,该计算机设备600包括通过系统总线601连接的处理器602、存储器以及网络接口605,其中,存储器可以包括非易失性存储介质603和内存储器604。Referring to FIG. 9, the computer device 600 includes a processor 602, a memory, and a network interface 605 connected through a system bus 601, where the memory may include a non-volatile storage medium 603 and an internal memory 604.
该非易失性存储介质603可存储操作系统6031和计算机程序6032。该计算机程序6032包括程序指令,该程序指令被执行时,可使得处理器602执行一种面向区块链的数据管理方法。The non-volatile storage medium 603 can store an operating system 6031 and a computer program 6032. The computer program 6032 includes program instructions. When the program instructions are executed, the processor 602 can execute a blockchain-oriented data management method.
该处理器602用于提供计算和控制能力,以支撑整个计算机设备600的运行。The processor 602 is used to provide calculation and control capabilities to support the operation of the entire computer device 600.
该内存储器604为非易失性存储介质603中的计算机程序6032的运行提供环境,该计算机程序6032被处理器602执行时,可使得处理器602执行一种面向区块链的数据管理方法。The internal memory 604 provides an environment for the operation of the computer program 6032 in the non-volatile storage medium 603. When the computer program 6032 is executed by the processor 602, the processor 602 can execute a blockchain-oriented data management method.
该网络接口605用于与其它设备进行网络通信。本领域技术人员可以理解,图9中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备600的限定,具体的计算机设备600可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。The network interface 605 is used for network communication with other devices. Those skilled in the art can understand that the structure shown in FIG. 9 is only a block diagram of part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device 600 to which the solution of the present application is applied. The specific computer device 600 may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
其中,所述处理器602用于运行存储在存储器中的计算机程序6032,以实现如下步骤:接收用户发送的第二次更新请求,其中,每一次更新请求包括待更新数据的第一状态以及第二状态,其中,所述第一状态以及第二状态为所述待更新数据的数据状态,所述数据状态为所述待更新数据的状态属性值;根据所述第一状态从一预设关系型数据库中获取待更新数据以及从预设区块链上查找与所述待更新数据对应的数据,其中,将所述关系型数据库中获取的待更新数据作为第一数据,将所述区块链上查找的与该待更新数据对应的数据作为第二数据;比对所述第一数据与所述第二数据以判断所述第一数据与所述第二数据是否一致;若所述第一数据与所述第二数据不一致,根据所述第一状态以及第二状态判断所述第一数据是否满足预设数据补偿条件;以及若所述第一数据满足预设数据补偿条件,根据所述第二状态对所述第一数据进行数据补偿。The processor 602 is configured to run a computer program 6032 stored in the memory to implement the following steps: receiving a second update request sent by the user, wherein each update request includes the first state of the data to be updated and the first state of the data to be updated. Two states, wherein the first state and the second state are the data states of the data to be updated, and the data state is the state attribute value of the data to be updated; according to the first state, a preset relationship The data to be updated is obtained from the database and the data corresponding to the data to be updated is searched from a preset blockchain, wherein the data to be updated obtained in the relational database is used as the first data, and the block The data corresponding to the data to be updated found on the chain is used as the second data; the first data and the second data are compared to determine whether the first data is consistent with the second data; if the first data is consistent with the second data; If one data is inconsistent with the second data, it is determined whether the first data meets the preset data compensation condition according to the first state and the second state; and if the first data meets the preset data compensation condition, according to the The second state performs data compensation on the first data.
在一实施例中,所述面向区块链的数据管理方法应用于一预设用户端,所述处理器602在实现所述接收用户发送的第二次更新请求的步骤之前,具体还实现如下步骤:若接收到用户发送的第一次更新请求,根据所述第一次更新请求的第一状态以及第二状态判断所述关系型数据库中的待更新数据是否满足预设状态流转规则;若所述关系型数据库中的待更新数据满足预设状态流转规则,更新所述待更新数据;通过调用更新链接口将更新后的待更新数据写入一预设区块链上;其中,所述更新链接口为所述区块链提供给所述用户端调用的接口;接收HTTP返回码并根据所述HTTP返回码判断是否出现更新异常;以及若出现更新异常,回滚所述关系型数据库中更新后的待更新数据。In an embodiment, the blockchain-oriented data management method is applied to a preset user terminal, and the processor 602 further implements the following specifically before implementing the step of receiving the second update request sent by the user Step: if the first update request sent by the user is received, determine whether the data to be updated in the relational database meets the preset state transfer rule according to the first state and the second state of the first update request; if The data to be updated in the relational database meets the preset state circulation rules, and the data to be updated is updated; the updated data to be updated is written to a preset blockchain by calling the update link port; wherein, the The update link port is the interface that the blockchain provides to the client to call; receives the HTTP return code and judges whether an update exception occurs according to the HTTP return code; and if an update exception occurs, rolls back to the relational database The updated data to be updated.
在一实施例中,处理器602在实现所述根据所述第一次更新请求的第一状态以及第二状态判断所述关系型数据库中的待更新数据是否满足预设状态流转规则的步骤时,具体实现如下步骤:根据所述第一次更新请求的第一状态以及第二状态以及预设状态流转规则判断所述关系型数据库中的待更新数据是否可从第一状态更新为第二状态。In an embodiment, when the processor 602 implements the step of judging whether the data to be updated in the relational database meets a preset state transfer rule according to the first state and the second state of the first update request , The specific implementation is as follows: judging whether the data to be updated in the relational database can be updated from the first state to the second state according to the first state and the second state of the first update request and the preset state transfer rule .
在一实施例中,处理器602在实现所述根据所述第一状态从一预设关系型数据库中获取待更新数据以及从预设区块链上查找与所述待更新数据对应的数据的步骤时,具体实现如下步骤:根据所述待更新数据的第一状态从一预设关系型数据库中获取所述待更新数据,其中,将所述关系型数据库中获取的待更新数据作为第一数据;以及根据所述第一数据从一预设区块链上查找与所述第一数据对应的数据,其中,将所述区块链上查找的与所述第一数据对应的数据作为第二数据。In an embodiment, the processor 602 implements the process of obtaining the data to be updated from a preset relational database according to the first state and searching the data corresponding to the data to be updated from the preset blockchain. In the step, the following steps are specifically implemented: obtaining the data to be updated from a preset relational database according to the first state of the data to be updated, wherein the data to be updated obtained in the relational database is used as the first Data; and searching for data corresponding to the first data from a preset blockchain according to the first data, wherein the data corresponding to the first data searched on the blockchain is taken as the first Two data.
在一实施例中,处理器602在实现所述根据所述第一状态以及第二状态判断所述第一数据是否满足预设数据补偿条件的步骤时,具体实现如下步骤:根据预设状态流转规则判断所述第一数据的第一状态是否可流转为所述第二数据的当前数据状态;若所述第一数据的第一状态可流转为所述第二数据的当前数据状态,判断所述第一数据的第二状态是否与所述第二数据当前数据状态一致;若所述第一数据的第二状态与所述第二数据当前数据状态一致,判定所述第一数据满足预设数据补偿条件;以及若所述第一数据的第一状态不可流转为所述第二数据的当前数据状态或者所述第一数据的第二状态与所述第二数据当前数据状态不一致,判定所述第一数据不满足预设数据补偿条件。In one embodiment, when the processor 602 implements the step of judging whether the first data meets the preset data compensation condition based on the first state and the second state, the processor 602 specifically implements the following steps: The rule determines whether the first state of the first data can be transferred to the current data state of the second data; if the first state of the first data can be transferred to the current data state of the second data, it is determined Whether the second state of the first data is consistent with the current data state of the second data; if the second state of the first data is consistent with the current data state of the second data, it is determined that the first data meets the preset Data compensation conditions; and if the first state of the first data cannot be transferred to the current data state of the second data or the second state of the first data is inconsistent with the current data state of the second data, it is determined The first data does not meet the preset data compensation condition.
在一实施例中,处理器602在实现所述根据所述第一状态以及第二状态判断所述第一数据是否满足预设数据补偿条件的步骤之后,具体还实现如下步骤:若所述第一数据不满足预设数据补偿条件,向用户发出异常提醒。In one embodiment, after the processor 602 implements the step of judging whether the first data meets the preset data compensation condition according to the first state and the second state, the processor 602 specifically implements the following steps: One data does not meet the preset data compensation conditions, and an abnormal reminder is issued to the user.
在一实施例中,处理器602在实现所述向用户发出异常提醒的步骤时,具体实现如下步 骤:将所述第一数据保存到一预设的数据表内;以及将所述数据表通过邮件发送给用户以发出异常提醒。In one embodiment, when the processor 602 implements the step of sending an abnormal reminder to the user, it specifically implements the following steps: save the first data in a preset data table; and pass the data table through The email is sent to the user to alert the user of the exception.
应当理解,在本申请实施例中,处理器602可以是中央处理单元(Central Processing Unit,CPU),该处理器602还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。其中,通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。It should be understood that in this embodiment of the application, the processor 602 may be a central processing unit (Central Processing Unit, CPU), and the processor 602 may also be other general-purpose processors, digital signal processors (DSP), Application Specific Integrated Circuit (ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor.
本领域普通技术人员可以理解的是实现上述实施例的方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成。该计算机程序包括程序指令,计算机程序可存储于一存储介质中,该存储介质为存储介质。该程序指令被该计算机系统中的至少一个处理器执行,以实现上述方法的实施例的流程步骤。Those of ordinary skill in the art can understand that all or part of the processes in the methods of the foregoing embodiments can be implemented by computer programs instructing relevant hardware. The computer program includes program instructions, and the computer program can be stored in a storage medium, which is a storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the foregoing method embodiments.
因此,本申请还提供一种计算机可读存储介质。该计算机可读存储介质存储有计算机程序,其中计算机程序包括程序指令。该程序指令被处理器执行时使处理器执行如上所述的面向区块链的数据管理方法。Therefore, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, where the computer program includes program instructions. When the program instructions are executed by the processor, the processor executes the blockchain-oriented data management method as described above.
计算机可读存储介质可以是非易失性,也可以是易失性。所述存储介质可以是U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、磁碟或者光盘等各种可以存储程序代码的存储介质。The computer-readable storage medium may be non-volatile or volatile. The storage medium may be a U disk, a mobile hard disk, a read-only memory (Read-Only Memory, ROM), a magnetic disk, or an optical disk, etc., which can store program codes.
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。A person of ordinary skill in the art may realize that the units and algorithm steps of the examples described in the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two, in order to clearly illustrate the hardware and software Interchangeability. In the above description, the composition and steps of each example have been generally described in terms of function. Whether these functions are executed by hardware or software depends on the specific application and design constraint conditions of the technical solution. Professionals and technicians can use different methods for each specific application to implement the described functions, but such implementation should not be considered beyond the scope of this application.
在本申请所提供的几个实施例中,应该理解到,所揭露的系统和方法,可以通过其它的方式实现。例如,以上所描述的系统实施例仅仅是示意性的。例如,各个单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。In the several embodiments provided in this application, it should be understood that the disclosed system and method may be implemented in other ways. For example, the system embodiment described above is only illustrative. For example, the division of each unit is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be omitted or not implemented.
本申请实施例方法中的步骤可以根据实际需要进行顺序调整、合并和删减。本申请实施例系统中的单元可以根据实际需要进行合并、划分和删减。另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以是两个或两个以上单元集成在一个单元中。The steps in the method of the embodiment of the present application can be adjusted, merged, and deleted in order according to actual needs. The units in the system of the embodiment of the present application may be combined, divided, and deleted according to actual needs. In addition, the functional units in the various embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
该集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分,或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,终端,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of this application is essentially or the part that contributes to the existing technology, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium It includes several instructions to make a computer device (which may be a personal computer, a terminal, or a network device, etc.) execute all or part of the steps of the method described in each embodiment of the present application.

Claims (20)

  1. 一种面向区块链的数据管理方法,包括:A blockchain-oriented data management method, including:
    接收用户发送的第二次更新请求,其中,每一次更新请求包括待更新数据的第一状态以及第二状态,其中,所述第一状态以及第二状态为所述待更新数据的数据状态,所述数据状态为所述待更新数据的状态属性值;Receiving a second update request sent by the user, where each update request includes a first state and a second state of the data to be updated, wherein the first state and the second state are the data states of the data to be updated, The data status is the status attribute value of the data to be updated;
    根据所述第一状态从一预设关系型数据库中获取待更新数据以及从预设区块链上查找与所述待更新数据对应的数据,其中,将所述关系型数据库中获取的待更新数据作为第一数据,将所述区块链上查找的与该待更新数据对应的数据作为第二数据;According to the first state, the data to be updated is obtained from a preset relational database and the data corresponding to the data to be updated is searched on the preset blockchain, wherein the data to be updated obtained in the relational database is Data as the first data, and the data corresponding to the data to be updated found on the blockchain as the second data;
    比对所述第一数据与所述第二数据以判断所述第一数据与所述第二数据是否一致;Comparing the first data with the second data to determine whether the first data is consistent with the second data;
    若所述第一数据与所述第二数据不一致,根据所述第一状态以及第二状态判断所述第一数据是否满足预设数据补偿条件;以及If the first data is inconsistent with the second data, judging whether the first data meets a preset data compensation condition according to the first state and the second state; and
    若所述第一数据满足预设数据补偿条件,根据所述第二状态对所述第一数据进行数据补偿。If the first data meets a preset data compensation condition, perform data compensation on the first data according to the second state.
  2. 根据权利要求1所述的面向区块链的数据管理方法,所述方法应用于一预设用户端,所述接收用户发送的第二次更新请求的步骤之前,还包括:The blockchain-oriented data management method according to claim 1, wherein the method is applied to a preset user terminal, and before the step of receiving the second update request sent by the user, the method further comprises:
    若接收到用户发送的第一次更新请求,根据所述第一次更新请求的第一状态以及第二状态判断所述关系型数据库中的待更新数据是否满足预设状态流转规则;If the first update request sent by the user is received, judging whether the data to be updated in the relational database meets the preset state transfer rule according to the first state and the second state of the first update request;
    若所述关系型数据库中的待更新数据满足预设状态流转规则,更新所述待更新数据;If the data to be updated in the relational database meets the preset state circulation rule, update the data to be updated;
    通过调用更新链接口将更新后的待更新数据写入一预设区块链上;其中,所述更新链接口为所述区块链提供给所述用户端调用的接口;Write the updated data to be updated on a preset blockchain by calling the update link; wherein, the update link is an interface that the blockchain provides to the client to call;
    接收HTTP返回码并根据所述HTTP返回码判断是否出现更新异常;以及Receiving an HTTP return code and judging whether an update exception occurs according to the HTTP return code; and
    若出现更新异常,回滚所述关系型数据库中更新后的待更新数据。If an update exception occurs, roll back the updated data to be updated in the relational database.
  3. 根据权利要求2所述的面向区块链的数据管理方法,所述根据所述第一次更新请求的第一状态以及第二状态判断所述关系型数据库中的待更新数据是否满足预设状态流转规则,包括:The blockchain-oriented data management method according to claim 2, wherein said determining whether the data to be updated in the relational database meets a preset state according to the first state and the second state of the first update request Circulation rules, including:
    根据所述第一次更新请求的第一状态以及第二状态以及预设状态流转规则判断所述关系型数据库中的待更新数据是否可从第一状态更新为第二状态。Determine whether the data to be updated in the relational database can be updated from the first state to the second state according to the first state and the second state of the first update request and a preset state circulation rule.
  4. 根据权利要求1所述的面向区块链的数据管理方法,所述根据所述第一状态从一预设关系型数据库中获取待更新数据以及从预设区块链上查找与所述待更新数据对应的数据,包括:The blockchain-oriented data management method according to claim 1, wherein the data to be updated is obtained from a preset relational database according to the first state, and the data to be updated is searched from the preset blockchain. Data corresponding to the data, including:
    根据所述待更新数据的第一状态从一预设关系型数据库中获取所述待更新数据,其中,将所述关系型数据库中获取的待更新数据作为第一数据;以及Acquiring the data to be updated from a preset relational database according to the first state of the data to be updated, wherein the data to be updated acquired in the relational database is used as the first data; and
    根据所述第一数据从一预设区块链上查找与所述第一数据对应的数据,其中,将所述区块链上查找的与所述第一数据对应的数据作为第二数据。Searching for data corresponding to the first data from a preset blockchain according to the first data, wherein the data corresponding to the first data searched on the blockchain is used as the second data.
  5. 根据权利要求1所述的面向区块链的数据管理方法,所述根据所述第一状态以及第二状态判断所述第一数据是否满足预设数据补偿条件,包括:The blockchain-oriented data management method according to claim 1, wherein the judging whether the first data meets a preset data compensation condition according to the first state and the second state comprises:
    根据预设状态流转规则判断所述第一数据的第一状态是否可流转为所述第二数据的当前数据状态;Judging whether the first state of the first data can be transferred to the current data state of the second data according to a preset state transfer rule;
    若所述第一数据的第一状态可流转为所述第二数据的当前数据状态,判断所述第一数据的第二状态是否与所述第二数据当前数据状态一致;If the first state of the first data can be transferred to the current data state of the second data, determining whether the second state of the first data is consistent with the current data state of the second data;
    若所述第一数据的第二状态与所述第二数据当前数据状态一致,判定所述第一数据满足预设数据补偿条件;以及If the second state of the first data is consistent with the current data state of the second data, determining that the first data meets the preset data compensation condition; and
    若所述第一数据的第一状态不可流转为所述第二数据的当前数据状态或者所述第一数据的第二状态与所述第二数据当前数据状态不一致,判定所述第一数据不满足预设数据补偿条件。If the first state of the first data cannot be transferred to the current data state of the second data or the second state of the first data is inconsistent with the current data state of the second data, it is determined that the first data is not Meet the preset data compensation conditions.
  6. 根据权利要求1所述的面向区块链的数据管理方法,所述根据所述第一状态以及第二 状态判断所述第一数据是否满足预设数据补偿条件的步骤之后,还包括:The blockchain-oriented data management method according to claim 1, after the step of judging whether the first data meets a preset data compensation condition according to the first state and the second state, further comprising:
    若所述第一数据不满足预设数据补偿条件,向用户发出异常提醒。If the first data does not meet the preset data compensation condition, an abnormal reminder is issued to the user.
  7. 根据权利要求6所述的面向区块链的数据管理方法,所述向用户发出异常提醒,包括:According to the blockchain-oriented data management method of claim 6, the sending an abnormal reminder to the user includes:
    将所述第一数据保存到一预设的数据表内;以及Save the first data in a preset data table; and
    将所述数据表通过邮件发送给用户以发出异常提醒。The data table is sent to the user by mail to send out an abnormal reminder.
  8. 一种面向区块链的数据管理装置,包括:A block chain-oriented data management device includes:
    第一接收单元,用于接收用户发送的第二次更新请求,其中,每一次更新请求包括待更新数据的第一状态以及第二状态,其中,所述第一状态以及第二状态为所述待更新数据的数据状态,所述数据状态为所述待更新数据的状态属性值;The first receiving unit is configured to receive a second update request sent by a user, wherein each update request includes a first state and a second state of the data to be updated, wherein the first state and the second state are the The data state of the data to be updated, where the data state is the state attribute value of the data to be updated;
    第一获取单元,用于根据所述第一状态从一预设关系型数据库中获取待更新数据以及从预设区块链上查找与所述待更新数据对应的数据,其中,将所述关系型数据库中获取的待更新数据作为第一数据,将所述区块链上查找的与该待更新数据对应的数据作为第二数据;The first obtaining unit is configured to obtain data to be updated from a preset relational database according to the first state and search for data corresponding to the data to be updated from a preset blockchain, wherein the relationship is The data to be updated obtained in the type database is used as the first data, and the data corresponding to the data to be updated found on the blockchain is used as the second data;
    第一判断单元,用于比对所述第一数据与所述第二数据以判断所述第一数据与所述第二数据是否一致;A first judging unit, configured to compare the first data with the second data to judge whether the first data is consistent with the second data;
    第二判断单元,用于若所述第一数据与所述第二数据不一致,根据所述第一状态以及第二状态判断所述第一数据是否满足预设数据补偿条件;以及A second judgment unit, configured to judge whether the first data meets a preset data compensation condition according to the first state and the second state if the first data is inconsistent with the second data; and
    第一补偿单元,用于若所述第一数据满足预设数据补偿条件,根据所述第二状态对所述第一数据进行数据补偿。The first compensation unit is configured to perform data compensation on the first data according to the second state if the first data meets a preset data compensation condition.
  9. 一种计算机设备,所述计算机设备包括存储器、处理器以及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述程序时实现一种面向区块链的数据管理方法,包括:A computer device that includes a memory, a processor, and a computer program stored in the memory and capable of running on the processor. The processor implements a blockchain-oriented data management method when the processor executes the program ,include:
    接收用户发送的第二次更新请求,其中,每一次更新请求包括待更新数据的第一状态以及第二状态,其中,所述第一状态以及第二状态为所述待更新数据的数据状态,所述数据状态为所述待更新数据的状态属性值;Receiving a second update request sent by the user, where each update request includes a first state and a second state of the data to be updated, wherein the first state and the second state are the data states of the data to be updated, The data status is the status attribute value of the data to be updated;
    根据所述第一状态从一预设关系型数据库中获取待更新数据以及从预设区块链上查找与所述待更新数据对应的数据,其中,将所述关系型数据库中获取的待更新数据作为第一数据,将所述区块链上查找的与该待更新数据对应的数据作为第二数据;According to the first state, the data to be updated is obtained from a preset relational database and the data corresponding to the data to be updated is searched on the preset blockchain, wherein the data to be updated obtained in the relational database is Data as the first data, and the data corresponding to the data to be updated found on the blockchain as the second data;
    比对所述第一数据与所述第二数据以判断所述第一数据与所述第二数据是否一致;Comparing the first data with the second data to determine whether the first data is consistent with the second data;
    若所述第一数据与所述第二数据不一致,根据所述第一状态以及第二状态判断所述第一数据是否满足预设数据补偿条件;以及If the first data is inconsistent with the second data, judging whether the first data meets a preset data compensation condition according to the first state and the second state; and
    若所述第一数据满足预设数据补偿条件,根据所述第二状态对所述第一数据进行数据补偿。If the first data meets a preset data compensation condition, perform data compensation on the first data according to the second state.
  10. 根据权利要求9所述的计算机设备,所述方法应用于一预设用户端,所述接收用户发送的第二次更新请求的步骤之前,还包括:The computer device according to claim 9, wherein the method is applied to a preset user terminal, and before the step of receiving the second update request sent by the user, the method further comprises:
    若接收到用户发送的第一次更新请求,根据所述第一次更新请求的第一状态以及第二状态判断所述关系型数据库中的待更新数据是否满足预设状态流转规则;If the first update request sent by the user is received, judging whether the data to be updated in the relational database meets the preset state transfer rule according to the first state and the second state of the first update request;
    若所述关系型数据库中的待更新数据满足预设状态流转规则,更新所述待更新数据;If the data to be updated in the relational database meets the preset state circulation rule, update the data to be updated;
    通过调用更新链接口将更新后的待更新数据写入一预设区块链上;其中,所述更新链接口为所述区块链提供给所述用户端调用的接口;Write the updated data to be updated on a preset blockchain by calling the update link; wherein, the update link is an interface that the blockchain provides to the client to call;
    接收HTTP返回码并根据所述HTTP返回码判断是否出现更新异常;以及Receiving an HTTP return code and judging whether an update exception occurs according to the HTTP return code; and
    若出现更新异常,回滚所述关系型数据库中更新后的待更新数据。If an update exception occurs, roll back the updated data to be updated in the relational database.
  11. 根据权利要求10所述的计算机设备,所述根据所述第一次更新请求的第一状态以及第二状态判断所述关系型数据库中的待更新数据是否满足预设状态流转规则,包括:The computer device according to claim 10, wherein the judging whether the data to be updated in the relational database meets a preset state transfer rule according to the first state and the second state of the first update request comprises:
    根据所述第一次更新请求的第一状态以及第二状态以及预设状态流转规则判断所述关系型数据库中的待更新数据是否可从第一状态更新为第二状态。Determine whether the data to be updated in the relational database can be updated from the first state to the second state according to the first state and the second state of the first update request and a preset state circulation rule.
  12. 根据权利要求9所述的计算机设备,所述根据所述第一状态从一预设关系型数据库中获取待更新数据以及从预设区块链上查找与所述待更新数据对应的数据,包括:The computer device according to claim 9, wherein the obtaining data to be updated from a preset relational database according to the first state and searching for data corresponding to the data to be updated from a preset blockchain comprises :
    根据所述待更新数据的第一状态从一预设关系型数据库中获取所述待更新数据,其中,将所述关系型数据库中获取的待更新数据作为第一数据;以及Acquiring the data to be updated from a preset relational database according to the first state of the data to be updated, wherein the data to be updated acquired in the relational database is used as the first data; and
    根据所述第一数据从一预设区块链上查找与所述第一数据对应的数据,其中,将所述区块链上查找的与所述第一数据对应的数据作为第二数据。Searching for data corresponding to the first data from a preset blockchain according to the first data, wherein the data corresponding to the first data searched on the blockchain is used as the second data.
  13. 根据权利要求9所述的计算机设备,所述根据所述第一状态以及第二状态判断所述第一数据是否满足预设数据补偿条件,包括:9. The computer device according to claim 9, wherein the judging whether the first data meets a preset data compensation condition according to the first state and the second state comprises:
    根据预设状态流转规则判断所述第一数据的第一状态是否可流转为所述第二数据的当前数据状态;Judging whether the first state of the first data can be transferred to the current data state of the second data according to a preset state transfer rule;
    若所述第一数据的第一状态可流转为所述第二数据的当前数据状态,判断所述第一数据的第二状态是否与所述第二数据当前数据状态一致;If the first state of the first data can be transferred to the current data state of the second data, determining whether the second state of the first data is consistent with the current data state of the second data;
    若所述第一数据的第二状态与所述第二数据当前数据状态一致,判定所述第一数据满足预设数据补偿条件;以及If the second state of the first data is consistent with the current data state of the second data, determining that the first data meets the preset data compensation condition; and
    若所述第一数据的第一状态不可流转为所述第二数据的当前数据状态或者所述第一数据的第二状态与所述第二数据当前数据状态不一致,判定所述第一数据不满足预设数据补偿条件。If the first state of the first data cannot be transferred to the current data state of the second data or the second state of the first data is inconsistent with the current data state of the second data, it is determined that the first data is not Meet the preset data compensation conditions.
  14. 根据权利要求9所述的计算机设备,所述根据所述第一状态以及第二状态判断所述第一数据是否满足预设数据补偿条件的步骤之后,还包括:8. The computer device according to claim 9, after the step of judging whether the first data meets a preset data compensation condition according to the first state and the second state, further comprising:
    若所述第一数据不满足预设数据补偿条件,向用户发出异常提醒。If the first data does not meet the preset data compensation condition, an abnormal reminder is issued to the user.
  15. 根据权利要求13所述的计算机设备,所述向用户发出异常提醒,包括:The computer device according to claim 13, wherein the sending an abnormal reminder to the user comprises:
    将所述第一数据保存到一预设的数据表内;以及Save the first data in a preset data table; and
    将所述数据表通过邮件发送给用户以发出异常提醒。The data table is sent to the user by mail to send out an abnormal reminder.
  16. 一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,该计算机程序被处理器执行时实现一种面向区块链的数据管理方法,包括:A computer-readable storage medium having a computer program stored on the computer-readable storage medium, and when the computer program is executed by a processor, realizes a blockchain-oriented data management method, including:
    接收用户发送的第二次更新请求,其中,每一次更新请求包括待更新数据的第一状态以及第二状态,其中,所述第一状态以及第二状态为所述待更新数据的数据状态,所述数据状态为所述待更新数据的状态属性值;Receiving a second update request sent by the user, where each update request includes a first state and a second state of the data to be updated, wherein the first state and the second state are the data states of the data to be updated, The data status is the status attribute value of the data to be updated;
    根据所述第一状态从一预设关系型数据库中获取待更新数据以及从预设区块链上查找与所述待更新数据对应的数据,其中,将所述关系型数据库中获取的待更新数据作为第一数据,将所述区块链上查找的与该待更新数据对应的数据作为第二数据;According to the first state, the data to be updated is obtained from a preset relational database and the data corresponding to the data to be updated is searched on the preset blockchain, wherein the data to be updated obtained in the relational database is Data as the first data, and the data corresponding to the data to be updated found on the blockchain as the second data;
    比对所述第一数据与所述第二数据以判断所述第一数据与所述第二数据是否一致;Comparing the first data with the second data to determine whether the first data is consistent with the second data;
    若所述第一数据与所述第二数据不一致,根据所述第一状态以及第二状态判断所述第一数据是否满足预设数据补偿条件;以及If the first data is inconsistent with the second data, judging whether the first data meets a preset data compensation condition according to the first state and the second state; and
    若所述第一数据满足预设数据补偿条件,根据所述第二状态对所述第一数据进行数据补偿。If the first data meets a preset data compensation condition, perform data compensation on the first data according to the second state.
  17. 根据权利要求16所述的计算机可读存储介质,所述方法应用于一预设用户端,所述接收用户发送的第二次更新请求的步骤之前,还包括:The computer-readable storage medium according to claim 16, wherein the method is applied to a preset user terminal, and before the step of receiving the second update request sent by the user, the method further comprises:
    若接收到用户发送的第一次更新请求,根据所述第一次更新请求的第一状态以及第二状态判断所述关系型数据库中的待更新数据是否满足预设状态流转规则;If the first update request sent by the user is received, judging whether the data to be updated in the relational database meets the preset state transfer rule according to the first state and the second state of the first update request;
    若所述关系型数据库中的待更新数据满足预设状态流转规则,更新所述待更新数据;If the data to be updated in the relational database meets the preset state circulation rule, update the data to be updated;
    通过调用更新链接口将更新后的待更新数据写入一预设区块链上;其中,所述更新链接口为所述区块链提供给所述用户端调用的接口;Write the updated data to be updated on a preset blockchain by calling the update link; wherein, the update link is an interface that the blockchain provides to the client to call;
    接收HTTP返回码并根据所述HTTP返回码判断是否出现更新异常;以及Receiving an HTTP return code and judging whether an update exception occurs according to the HTTP return code; and
    若出现更新异常,回滚所述关系型数据库中更新后的待更新数据。If an update exception occurs, roll back the updated data to be updated in the relational database.
  18. 根据权利要求17所述的计算机可读存储介质,所述根据所述第一次更新请求的第一状态以及第二状态判断所述关系型数据库中的待更新数据是否满足预设状态流转规则,包括:18. The computer-readable storage medium according to claim 17, wherein said determining whether the data to be updated in the relational database meets a preset state transfer rule according to the first state and the second state of the first update request, include:
    根据所述第一次更新请求的第一状态以及第二状态以及预设状态流转规则判断所述关系型数据库中的待更新数据是否可从第一状态更新为第二状态。Determine whether the data to be updated in the relational database can be updated from the first state to the second state according to the first state and the second state of the first update request and a preset state circulation rule.
  19. 根据权利要求16所述的计算机可读存储介质,所述根据所述第一状态从一预设关系型数据库中获取待更新数据以及从预设区块链上查找与所述待更新数据对应的数据,包括:The computer-readable storage medium according to claim 16, wherein the data to be updated is obtained from a preset relational database according to the first state and the data corresponding to the data to be updated is searched from a preset blockchain Data, including:
    根据所述待更新数据的第一状态从一预设关系型数据库中获取所述待更新数据,其中,将所述关系型数据库中获取的待更新数据作为第一数据;以及Acquiring the data to be updated from a preset relational database according to the first state of the data to be updated, wherein the data to be updated acquired in the relational database is used as the first data; and
    根据所述第一数据从一预设区块链上查找与所述第一数据对应的数据,其中,将所述区块链上查找的与所述第一数据对应的数据作为第二数据。Searching for data corresponding to the first data from a preset blockchain according to the first data, wherein the data corresponding to the first data searched on the blockchain is used as the second data.
  20. 根据权利要求16所述的计算机可读存储介质,所述根据所述第一状态以及第二状态判断所述第一数据是否满足预设数据补偿条件,包括:15. The computer-readable storage medium according to claim 16, wherein the judging whether the first data meets a preset data compensation condition according to the first state and the second state comprises:
    根据预设状态流转规则判断所述第一数据的第一状态是否可流转为所述第二数据的当前数据状态;Judging whether the first state of the first data can be transferred to the current data state of the second data according to a preset state transfer rule;
    若所述第一数据的第一状态可流转为所述第二数据的当前数据状态,判断所述第一数据的第二状态是否与所述第二数据当前数据状态一致;If the first state of the first data can be transferred to the current data state of the second data, determining whether the second state of the first data is consistent with the current data state of the second data;
    若所述第一数据的第二状态与所述第二数据当前数据状态一致,判定所述第一数据满足预设数据补偿条件;以及If the second state of the first data is consistent with the current data state of the second data, determining that the first data meets the preset data compensation condition; and
    若所述第一数据的第一状态不可流转为所述第二数据的当前数据状态或者所述第一数据的第二状态与所述第二数据当前数据状态不一致,判定所述第一数据不满足预设数据补偿条件。If the first state of the first data cannot be transferred to the current data state of the second data or the second state of the first data is inconsistent with the current data state of the second data, it is determined that the first data is not Meet the preset data compensation conditions.
PCT/CN2020/087135 2019-05-22 2020-04-27 Blockchain-oriented data management method, apparatus and device, and storage medium WO2020233351A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910428728.7A CN110275892B (en) 2019-05-22 2019-05-22 Block chain-oriented data management method, device, equipment and storage medium
CN201910428728.7 2019-05-22

Publications (1)

Publication Number Publication Date
WO2020233351A1 true WO2020233351A1 (en) 2020-11-26

Family

ID=67960255

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/087135 WO2020233351A1 (en) 2019-05-22 2020-04-27 Blockchain-oriented data management method, apparatus and device, and storage medium

Country Status (2)

Country Link
CN (1) CN110275892B (en)
WO (1) WO2020233351A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113726519A (en) * 2021-08-16 2021-11-30 山东伏羲智库互联网研究院 Digital identity management method and device, electronic equipment and storage medium
CN116560896A (en) * 2023-07-11 2023-08-08 智慧眼科技股份有限公司 Abnormality compensation method, device, equipment and storage medium

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110275892B (en) * 2019-05-22 2022-08-19 深圳壹账通智能科技有限公司 Block chain-oriented data management method, device, equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017136527A1 (en) * 2016-02-05 2017-08-10 Manifold Technology, Inc. Blockchain-enhanced database
CN107273455A (en) * 2017-05-31 2017-10-20 深圳前海微众银行股份有限公司 Block chain data access method and device
CN109523385A (en) * 2018-12-07 2019-03-26 深圳市智税链科技有限公司 Method, accounting nodes and the medium of Transaction Information are inquired in block chain network
CN109634679A (en) * 2018-10-16 2019-04-16 平安科技(深圳)有限公司 Block chain configures update method, device, equipment and storage medium
CN110275892A (en) * 2019-05-22 2019-09-24 深圳壹账通智能科技有限公司 Data managing method, device, equipment and storage medium towards block chain

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107704196B (en) * 2017-03-09 2020-03-27 深圳壹账通智能科技有限公司 Block chain data storage system and method
CN107562775B (en) * 2017-07-14 2020-04-24 创新先进技术有限公司 Data processing method and device based on block chain
US10565192B2 (en) * 2017-08-01 2020-02-18 International Business Machines Corporation Optimizing queries and other retrieve operations in a blockchain
CN109558411A (en) * 2017-09-26 2019-04-02 浙江华信区块链科技服务有限公司 A kind of lower chain synchronous method and device based on block chain data
CN110378694B (en) * 2018-05-21 2021-01-12 腾讯科技(深圳)有限公司 Block chain data processing method and device, computer equipment and storage medium
CN109542918A (en) * 2018-10-19 2019-03-29 平安普惠企业管理有限公司 Guarantee method, system, computer equipment and the storage medium of data consistency

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017136527A1 (en) * 2016-02-05 2017-08-10 Manifold Technology, Inc. Blockchain-enhanced database
CN107273455A (en) * 2017-05-31 2017-10-20 深圳前海微众银行股份有限公司 Block chain data access method and device
CN109634679A (en) * 2018-10-16 2019-04-16 平安科技(深圳)有限公司 Block chain configures update method, device, equipment and storage medium
CN109523385A (en) * 2018-12-07 2019-03-26 深圳市智税链科技有限公司 Method, accounting nodes and the medium of Transaction Information are inquired in block chain network
CN110275892A (en) * 2019-05-22 2019-09-24 深圳壹账通智能科技有限公司 Data managing method, device, equipment and storage medium towards block chain

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113726519A (en) * 2021-08-16 2021-11-30 山东伏羲智库互联网研究院 Digital identity management method and device, electronic equipment and storage medium
CN116560896A (en) * 2023-07-11 2023-08-08 智慧眼科技股份有限公司 Abnormality compensation method, device, equipment and storage medium
CN116560896B (en) * 2023-07-11 2023-10-10 智慧眼科技股份有限公司 Abnormality compensation method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN110275892A (en) 2019-09-24
CN110275892B (en) 2022-08-19

Similar Documents

Publication Publication Date Title
WO2020233351A1 (en) Blockchain-oriented data management method, apparatus and device, and storage medium
US20190340166A1 (en) Conflict resolution for multi-master distributed databases
US10917520B1 (en) Automated self-service callback for proactive and dynamic user assistance
US20100299664A1 (en) System, method and computer program product for pushing an application update between tenants of a multi-tenant on-demand database service
US20070156690A1 (en) Systems and methods of accessing and updating recorded data via an inter-object proxy
US20090234906A1 (en) Computer processing system for realizing data upgrade and a data upgrading method
US10762109B2 (en) Asynchronous deletion in non-relational databases
CN110544097A (en) Intelligent contract version control, calling and upgrading method, equipment and storage medium
CN103370695B (en) database update notification method
EP2416246A1 (en) Extensibility of business process and application logic
US10509716B2 (en) Automated recovery of flighted features based on service requests
US20130024472A1 (en) Extensibility of business process and application logic
WO2020232892A1 (en) Method and apparatus for key management for blockchain, device, and storage medium
CN112202834A (en) Data processing method, data processing device and node server
US20120124097A1 (en) Reusing system configuration information and metadata for related operations
US11243979B1 (en) Asynchronous propagation of database events
CN112632093A (en) Work order processing method, device, system, storage medium and program product
CN110263305B (en) Configuration file comparison method, device, equipment and storage medium
CN111638885A (en) Plug-in issuing method and device, electronic equipment and storage medium
US7680838B1 (en) Maintaining data synchronization in a file-sharing environment
US20150234866A1 (en) Data Distribution System
CN114020368A (en) Information processing method and device based on state machine and storage medium
CN114896337A (en) Data uplink method, system, equipment and computer readable storage medium
JP5621465B2 (en) Database system
CN117785900A (en) Data updating method, device, computer equipment and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20809192

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20809192

Country of ref document: EP

Kind code of ref document: A1

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 18/03/2022)

122 Ep: pct application non-entry in european phase

Ref document number: 20809192

Country of ref document: EP

Kind code of ref document: A1