CN111639309B - Data processing method and device, node equipment and storage medium - Google Patents

Data processing method and device, node equipment and storage medium Download PDF

Info

Publication number
CN111639309B
CN111639309B CN202010454293.6A CN202010454293A CN111639309B CN 111639309 B CN111639309 B CN 111639309B CN 202010454293 A CN202010454293 A CN 202010454293A CN 111639309 B CN111639309 B CN 111639309B
Authority
CN
China
Prior art keywords
program
atomic operation
target
node
service
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN202010454293.6A
Other languages
Chinese (zh)
Other versions
CN111639309A (en
Inventor
郑罗海
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202010454293.6A priority Critical patent/CN111639309B/en
Publication of CN111639309A publication Critical patent/CN111639309A/en
Application granted granted Critical
Publication of CN111639309B publication Critical patent/CN111639309B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/10Protecting distributed programs or content, e.g. vending or licensing of copyrighted material ; Digital rights management [DRM]
    • G06F21/12Protecting executable software
    • G06F21/121Restricting unauthorised execution of programs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/30Authentication, i.e. establishing the identity or authorisation of security principals
    • G06F21/31User authentication
    • 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
    • G06Q30/00Commerce
    • G06Q30/04Billing or invoicing

Abstract

The embodiment of the application discloses a data processing method, a data processing device, node equipment and a storage medium, which are suitable for the field of data storage in big data, and the method comprises the following steps: acquiring an atomic operation interface associated with the K programs, calling the atomic operation interface to execute atomic operation on each program in the K programs, and obtaining an atomic operation result of each program participating in competition of the distributed lock; acquiring a target atomic operation result with a first parameter value from the atomic operation result of each program, and determining the program corresponding to the target atomic operation result as a target program; locking the target program through the distributed lock so that the target program after locking accesses the shared resource; executing the billing service in the target program after the locking processing based on the shared resource; and when the billing service is finished, unlocking the target program after the locking process is performed to release the distributed lock. By adopting the embodiment of the application, the accuracy of data reading can be improved.

Description

Data processing method and device, node equipment and storage medium
Technical Field
The present application relates to the field of block chain technologies, and in particular, to a data processing method and apparatus, a node device, and a storage medium.
Background
Currently, when a certain program executes an invoicing service, a CPU (Central Processing Unit) can generate an electronic ticket associated with the invoicing service based on a target ticket number read from a database. However, when a plurality of programs (for example, the program a and the program B) are executed in parallel, due to a sudden power failure or a drop in the line, the CPU may interrupt the program a if the execution of the program a is not completed, so that the program executed by the CPU jumps from the program a to the program B.
For example, if the CPU reads a target ticket number (for example, ticket number 1) from the database during the execution of the program a to generate the electronic ticket a, when the CPU reads the ticket number 1 and does not generate the electronic ticket a, the program a is interrupted due to a power failure, a line drop, or the like, and the CPU jumps to the program B. At this time, the CPU still has a possibility of acquiring the ticket number 1, which has been read by the program 1, from the database in the process of executing the program B to generate the electronic ticket B, and can generate the electronic ticket B based on the ticket number 1. However, when the CPU resumes executing the program 1, the electronic ticket a is still synchronously generated based on the read ticket number 1, which may cause an abnormality in the service data result. Therefore, due to program interruption, errors occur in data reading of the program, and the accuracy of data reading is further reduced.
Disclosure of Invention
The embodiment of the application provides a data processing method, a data processing device, a node device and a storage medium, which can improve the accuracy of data reading.
An embodiment of the present application provides a data processing method, including:
acquiring an atomic operation interface associated with the K programs, calling the atomic operation interface to execute atomic operation on each program in the K programs, and obtaining an atomic operation result of each program participating in competition of the distributed lock; k is a positive integer; the distributed lock is used for accessing a shared resource associated with the billing service in the block chain;
acquiring a target atomic operation result with a first parameter value from the atomic operation result of each program, and determining the program corresponding to the target atomic operation result as a target program;
locking the target program through the distributed lock so that the target program after locking accesses the shared resource;
executing the billing service in the target program after the locking processing based on the shared resource;
and when the billing service is finished, unlocking the target program after the locking process is performed to release the distributed lock.
An aspect of an embodiment of the present application provides a data processing apparatus, including:
the first acquisition module is used for acquiring the atomic operation interfaces associated with the K programs, calling the atomic operation interfaces to execute the atomic operation on each program in the K programs, and obtaining the atomic operation result of each program participating in competition of the distributed lock; k is a positive integer; the distributed lock is used for accessing a shared resource associated with the billing service in the block chain;
the first determining module is used for acquiring a target atomic operation result with a first parameter value from the atomic operation result of each program and determining the program corresponding to the target atomic operation result as a target program;
the locking processing module is used for locking the target program through the distributed lock so that the target program after locking accesses the shared resource;
the service execution module is used for executing the billing service in the target program after the locking processing based on the shared resource;
and the unlocking processing module is used for executing unlocking processing on the target program after locking processing when the billing service is finished so as to release the distributed lock.
The first acquisition module is also used for receiving a service processing request which is sent by the user terminal and is associated with the invoicing service; and when the service processing request is determined to be a legal request, acquiring K programs associated with the billing service, executing to acquire atomic operation interfaces associated with the K programs, calling the atomic operation interfaces to execute atomic operation on each program in the K programs, and obtaining the lock state parameters of each program participating in competition of the distributed lock.
The service processing request comprises service key information and user signature information submitted by a bill request user corresponding to the user terminal; the user signature information is obtained after the user terminal requests a user private key of a user to sign the service key information through the bill;
the device also includes:
the second acquisition module is used for acquiring a user public key corresponding to the user private key, and checking the signature of the user signature information based on the user public key to obtain a signature checking result;
the second determining module is used for determining that the bill requesting user is a legal user and determining the service processing request initiated by the user terminal as a legal request if the signature verification result indicates that the verification is successful;
and the third determining module is used for determining the bill requesting user as an illegal user and determining the service processing request initiated by the user terminal as an illegal request if the signature verification result indicates that the verification fails.
Wherein, this first acquisition module includes:
the system comprises a first acquisition unit, a second acquisition unit and a third acquisition unit, wherein the first acquisition unit is used for acquiring atomic operation interfaces associated with K programs under the billing service and determining the default values of the default parameters associated with the K programs; the K programs include a first program and a second program;
the first calling unit is used for calling an atomic replacement function associated with the atomic operation interface and respectively executing the atomic operation on the first program and the second program;
a first replacing unit, configured to replace an initial value of a lock state parameter of the first program with a default value, replace the default value of the default parameter of the first program with an initial value, and use the default parameter with the initial value returned by the first program after the atomic operation is performed as a first operation result of the first program;
a first updating unit, configured to update an initial value of a lock state parameter of a second program according to the lock state parameter of the first program having a predetermined value, to obtain an updated value of the lock state parameter of the second program;
a second replacing unit, configured to replace an updated value of the lock status parameter of the second program with a default value, replace the default value of the default parameter of the second program with an updated value, and use the default parameter with the updated value, which is returned after the atomic operation is performed by the second program, as a second operation result of the second program;
and a result determination unit for regarding the first operation result and the second operation result as an atomic operation result of each program participating in the competition for the distributed lock.
The atomic operation result of each program comprises an atomic operation result corresponding to a first parameter value and an atomic operation result corresponding to a second parameter value; the first parameter value and the second parameter value are both the values of the appointed parameters of each program after the atomic operation is executed; the first parameter value is used for indicating the corresponding program to successfully acquire the distributed lock; the second parameter value is used to indicate that the corresponding program has not acquired the distributed lock temporarily.
Wherein, the device still includes:
the detection module is used for detecting the programs which do not acquire the distributed lock temporarily in the K programs and determining the programs which do not acquire the distributed lock temporarily as the programs to be processed;
and the atomic operation execution module is used for executing the atomic operation on the program to be processed until the atomic operation result of the program to be processed is the first parameter value, and locking the program to be processed through the distributed lock so that the locked program to be processed accesses the shared resource.
Wherein, the device still includes:
the system comprises a first request sending module, a first contract calling module and a first contract calling module, wherein the first contract calling module is used for obtaining a first contract calling address of a first intelligent contract related to an invoicing service, calling the first intelligent contract based on the first contract calling address, and sending a bill application request to a tax node in a block chain; the bill application request is used for indicating the tax node to configure a bill number section corresponding to a bill code;
the first receiving module is used for receiving a bill number section corresponding to the bill code returned by the tax node and taking the bill code and M bill numbers in the bill number section as shared resources; m is a positive integer.
Wherein, the device still includes:
the third obtaining module is used for obtaining a second contract calling address of a second intelligent contract related to the invoicing service when a bill application request is sent to the tax node in the block chain, calling the second intelligent contract based on the second contract calling address, and obtaining enterprise user information corresponding to the N enterprise users; n is a positive integer;
the second request sending module is used for sending an enterprise information synchronization request to the tax node based on the enterprise user information; the enterprise information synchronization request is used for indicating the tax node to search enterprise updating information which is not matched with the enterprise user information in the enterprise information database, and using the searched enterprise updating information as enterprise information to be synchronized of the corresponding enterprise user;
and the second receiving module is used for receiving the enterprise information to be synchronized returned by the tax node and updating the shared resources according to the enterprise information to be synchronized.
Wherein, the service execution module comprises:
the selecting unit is used for selecting a target bill number aiming at a target user terminal associated with the target program after the locking processing from the bill number section in the shared resource; the target bill number is one bill number in the bill number section;
the deleting unit is used for deleting the target bill number in the shared resource and carrying out decrement processing on the number of the bill numbers in the bill number section;
and the generating unit is used for generating an electronic bill associated with the target user terminal based on the bill code, the target bill number and the service key information and returning the electronic bill to the target user terminal.
Wherein, should select the unit to include:
the access subunit is used for accessing the shared resource based on the target program after the locking processing, and determining the matching between the enterprise user information in the shared resource and the bill request user information in the business key information sent by the target user terminal; the target user terminal is a user terminal associated with the target program after the locking processing;
the generating subunit is used for generating modification prompt information based on the enterprise user information if the enterprise user information is not matched with the bill requesting user information so as to inform the target user terminal of modifying the bill requesting user information;
and the selecting subunit is used for selecting the target bill number from the bill number section in the shared resource aiming at the target user terminal if the enterprise user information is matched with the bill request user information.
Wherein, the device still includes:
the packaging processing module is used for packaging the service data information associated with the electronic bill to obtain a to-be-verified block to be written into the block chain;
the broadcast module is used for broadcasting the to-be-verified block to the consensus node on the block chain so that the consensus node can perform consensus on the acquired to-be-verified block to obtain a consensus result;
and the writing module is used for determining that the block chain nodes on the block chain achieve consensus and writing the block to be verified into the block chain as a target block if the consensus result exceeding 1/2 in the consensus results returned by the consensus nodes indicates that the consensus is successful.
Wherein, this unblock processing module includes:
the second calling unit is used for calling an atomic unlocking function associated with the atomic operation interface when the billing service is finished, executing unlocking processing on the target program after locking processing to release the distributed lock, and restoring to obtain the target program;
and the second updating unit is used for updating the target atomic operation result of the target program from the first parameter value to a second parameter value while releasing the distributed lock so as to complete the release of the distributed lock.
One aspect of the present application provides a node device, including: a processor, a memory, a network interface;
the processor is connected to a memory and a network interface, wherein the network interface is used for providing a data communication function, the memory is used for storing a computer program, and the processor is used for calling the computer program to execute the method in the above aspect in the embodiment of the present application.
An aspect of the present application provides a computer-readable storage medium storing a computer program comprising program instructions that, when executed by a processor, perform the method of the above-mentioned aspect of the embodiments of the present application.
In the embodiment of the application, when the K programs are executed in parallel, the billing node in the blockchain network may acquire an atomic operation interface associated with the K programs, and may further call the atomic operation interface to perform an atomic operation on each program in the K programs, so that an atomic operation result of each program participating in competition for the distributed lock may be obtained, and based on the atomic operation result of each program, a target program capable of acquiring the distributed lock is determined in the K programs. It should be understood that the billing node may determine a program corresponding to the target atomic operation result with the first parameter value as a target program, and then may perform locking processing on the target program through a distributed lock for accessing the shared resource associated with the blockchain, so that the target program after the locking processing may safely access the shared resource stored by the billing node. Further, the billing node may execute a billing service associated with the blockchain in the target program after the locking process based on the accessed shared resource, and when the billing service is completed in the target program, the billing node may perform an unlocking process on the target program after the locking process to release the distributed lock. Therefore, the billing node is based on the atomic operation, so that the target program realizes the acquisition of the distributed lock, and the shared resource accessed by the target program cannot be interrupted by other programs in the process of executing the billing service by the target program, so that the problem of safe access of the target program to the shared resource can be solved, the completeness operation of the billing service in the target program is ensured, and the accuracy of reading the data of the shared resource by the target program can be improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic diagram of a blockchain network structure according to an embodiment of the present disclosure;
FIG. 2 is a schematic diagram of a data interaction scenario provided by an embodiment of the present application;
fig. 3 is a schematic flowchart of a data processing method according to an embodiment of the present application;
fig. 4 is a schematic view of a scenario for verifying validity of a service processing request according to an embodiment of the present application;
FIG. 5 is a schematic diagram of a scenario for performing an atomic operation on a program according to an embodiment of the present application;
fig. 6 is a schematic view of a scenario for acquiring a shared resource according to an embodiment of the present application;
FIG. 7 is a schematic diagram of a scenario for updating a shared resource according to an embodiment of the present application;
fig. 8 is a schematic view of a scenario for executing an invoicing service according to an embodiment of the present application;
fig. 9 is a schematic flowchart of a data processing method according to an embodiment of the present application;
fig. 10 is a schematic diagram of an uplink scenario provided in an embodiment of the present application;
fig. 11 is a schematic flowchart of a data processing method according to an embodiment of the present application;
fig. 12 is a schematic structural diagram of a data processing apparatus according to an embodiment of the present application;
fig. 13 is a schematic diagram of a node device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The embodiment of the application can store the shared resources in the billing nodes based on the cloud technology, and is suitable for the field of data storage in big data.
The Cloud technology (Cloud technology) is a hosting technology for unifying series resources such as hardware, software, network and the like in a wide area network or a local area network to realize calculation, storage, processing and sharing of data.
Cloud technology (Cloud technology) is based on a general term of network technology, information technology, integration technology, management platform technology, application technology and the like applied in a Cloud computing business model, can form a resource pool, is used as required, and is flexible and convenient. Cloud computing technology will become an important support. Background services of the technical network system require a large amount of computing and storage resources, such as video websites, picture-like websites and more web portals. With the high development and application of the internet industry, each article may have its own identification mark and needs to be transmitted to a background system for logic processing, data in different levels are processed separately, and various industrial data need strong system background support and can only be realized through cloud computing.
The Big data (Big data) refers to a data set which cannot be captured, managed and processed by a conventional software tool within a certain time range, and is a massive, high-growth-rate and diversified information asset which can have stronger decision-making power, insight discovery power and flow optimization capability only by a new processing mode. With the advent of the cloud era, big data has attracted more and more attention, and the big data needs special technology to effectively process a large amount of data within a tolerance elapsed time. The method is suitable for the technology of big data, and comprises a large-scale parallel processing database, data mining, a distributed file system, a distributed database, a cloud computing platform, the Internet and an extensible storage system.
It can be understood that, in the embodiment of the present application, the invoicing node in the blockchain network may store, based on the cloud storage, the shared resource acquired from the tax node in the blockchain network to which the invoicing node belongs in the local shared memory of the invoicing node.
The distributed cloud storage system (hereinafter referred to as a storage system) refers to a storage system which integrates a large number of storage devices (storage devices are also referred to as storage nodes) of various types in a network through application software or application interfaces to cooperatively work through functions such as cluster application, grid technology, distributed storage file system and the like, and provides data storage and service access functions to the outside.
In the embodiment of the application, the enterprise data information base associated with the tax node may store enterprise user information corresponding to each of a plurality of enterprise users, so as to update the enterprise user information stored in the local shared memory of the invoicing node according to the stored enterprise user information. The enterprise data information base may be referred to as a Database (Database), which may be regarded as an electronic file cabinet, in short, a place for storing electronic files, and a user may perform operations such as adding, querying, updating, and deleting on data in the files. A "database" is a collection of data that is stored together in a manner that can be shared by multiple users, has as little redundancy as possible, and is independent of the application.
Please refer to fig. 1, which is a block chain network structure according to an embodiment of the present disclosure. The blockchain network structure shown in fig. 1 may be applied to a blockchain system, which may be a distributed system formed by a plurality of nodes connected by a form of network communication. As shown in fig. 1, the blockchain system may include a plurality of nodes, which may specifically include node 10A, node 10B, node 10C, …, and node 10N. The user terminal cluster shown in fig. 1 may include a plurality of user terminals, and as shown in fig. 1, the plurality of user terminals may specifically include a user terminal 100a, a user terminal 100b, a user terminal 100c, …, and a user terminal 100 n.
Herein, each node (e.g., node 10A, node 10B, node 10C, …, and node 10N) in the blockchain network may be collectively referred to as a blockchain node in the present embodiment. It should be understood that these block chain nodes may be used To maintain the same block chain, and any two block chain nodes in the block chain network may form a point-To-point (P2P, Peer To Peer) network, and the point-To-point network may adopt a P2P Protocol, where the P2P Protocol is an application layer Protocol operating on top of a Transmission Control Protocol (TCP). In a distributed system, any device such as a server, a terminal, etc. may be added to form a blockchain node, where each blockchain node may include a hardware layer, an intermediate layer, an operating system layer, and an application layer.
Each block chain node in the block chain system has a node identifier corresponding thereto, and each block chain node in the block chain system may store other node identifiers having a network connection relationship with the current block chain node, so that the generated block is broadcast to other block chain nodes in the block chain system according to the node identifiers of the other block chain nodes in the following. Each block chain node can maintain a node identification list as shown in the following table, and the node name and the node identification are correspondingly stored in the node identification list. The node identifier may be an IP (Internet Protocol) address and any other information that can be used to identify the node, and table 1 only illustrates the IP address as an example.
TABLE 1
Node name Node identification
Node
1 117.114.151.174
Node 2 117.116.189.145
Node N 119.123.789.258
For convenience of understanding, in the embodiment of the present application, a blockchain node may be selected in the blockchain system shown in fig. 1 as a blockchain node having an invoicing service function in the blockchain network. The embodiment of the application can call the blockchain node with the billing service function in the blockchain network as the billing node. It can be understood that the billing node may be a server accessing the blockchain network, or may be a user terminal accessing the blockchain network, and a specific form of the billing node is not limited herein.
For example, the node 10A in the blockchain system may be used as an invoicing node in the embodiment of the present application. The node 10A may be directly or indirectly connected with each user terminal in the user terminal cluster through a wired or wireless communication manner to perform service data interaction, which is not limited herein in this embodiment of the application. The node 10A may be a server, which may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a network service, cloud communication, middleware service, a domain name service, a security service, a CDN, a big data and artificial intelligence platform, and the like.
Wherein, each ue in the ue cluster may include: smart terminals such as smart phones, tablet computers, notebook computers, desktop computers, and the like. It is understood that the embodiment of the present application may select one user terminal from the plurality of user terminals of the user terminal cluster shown in fig. 1 as the target user terminal associated with the billing node (e.g., node 10A). For example, in the embodiment of the present application, the user terminal 100a in the user terminal cluster may be referred to as a target user terminal.
The node 10A in this embodiment of the present application may perform an atomic operation on a plurality of programs, so as to obtain a distributed lock for a program (target program) corresponding to a target atomic operation result, so that the target program may quickly solve a problem of secure access to a shared memory resource, and thus, efficiency and accuracy of executing an invoicing service in the target program may be ensured. So-called atomic operations are indivisible, i.e., are not interrupted by any other task or event until execution is complete. The distributed lock in embodiments of the present application may be used to access shared resources associated with a blockchain corresponding to a blockchain network.
It should be appreciated that the result of an atomic operation performed by a program after the atomic operation is performed may be used to indicate the task state of the program to acquire the distributed lock. The atomic operation result of each program obtained by the node 10A may include an atomic operation result corresponding to the first parameter value and an atomic operation result corresponding to the second parameter value. It will be appreciated that the first parameter value and the second parameter value may each be values of the default parameter after each program has performed the atomic operation. Wherein the first parameter value (e.g., 0) may be used to indicate that the corresponding program successfully acquires the distributed lock; the second parameter value (e.g., 1) may be used to indicate that the corresponding program has not acquired the distributed lock temporarily.
For easy understanding, please refer to fig. 2, which is a schematic view of a data interaction scenario provided in an embodiment of the present application. As shown in fig. 2, the billing node in the embodiment of the present application may be the billing node in the block chain network shown in fig. 1, for example, the node 10A.
It should be understood that the service scenario of the embodiment of the present application may be an electronic ticket scenario, so as to illustrate a process that the billing node performs the billing service in the target program (i.e., the program that acquires the distributed lock) by performing an atomic operation on each of the K programs when the K programs shown in fig. 2 are executed in parallel. Wherein K is a positive integer.
The electronic bill obtained by executing the billing service in the embodiment of the application can be an electronic bill in a certain game scene. For example, a game user (e.g., user 1) may purchase a collection of property equipment (e.g., armor for defensive properties, broadsword for offensive properties, wings for speed properties, etc.) for a game character in a certain game a using virtual assets such as game gold or game diamonds. At this time, the facilitator (i.e., the ticket requesting user) corresponding to the game a may send a service processing request to the billing node through the user terminal 1, so that the billing node may issue an electronic ticket associated with the purchased attribute equipment with the user 1 as a purchaser and the facilitator (i.e., the enterprise user) corresponding to the game a as a seller.
Optionally, the electronic ticket obtained by executing the billing service in the embodiment of the present application may also be an electronic ticket in a certain financial scenario. For example, a dining user (e.g., user 2) may have a meal at a certain restaurant, and after the meal is finished, a service provider (i.e., a ticket requesting user) corresponding to the restaurant may send a service processing request to the billing node through the user terminal 2, so that the billing node may use the unit or business where the user 2 is located as a purchaser, and the service provider (i.e., a business user) corresponding to the restaurant as a seller, and issue an electronic ticket associated with a meal fee. The electronic ticket obtained by executing the billing service in the embodiment of the present application may also be an electronic ticket in other scenarios, which is not limited herein.
It will be appreciated that the billing node may determine the validity of a received transaction request for obtaining an electronic ticket. The number of legal requests which can be determined by the billing node in the service processing request can be K, and each legal request can correspond to one program. The program may be a process or a thread, and is not limited herein. The K service processing requests may specifically include service processing request 1, service processing request 2, …, and service processing request K. The billing service corresponding to the service processing request 1 may be the billing service executed in the program 1; the invoicing service corresponding to the service processing request 2 may be the invoicing service executed in the program 2; by analogy, the billing service corresponding to the service processing request K may be the billing service executed in the program K.
As shown in fig. 2, the billing node in the embodiment of the present application may obtain the atomic operation interfaces associated with the K programs, and may further call the atomic operation interfaces to perform an atomic operation on each program in the K programs, so that an atomic operation result of each program participating in the competition for the distributed lock may be obtained. Wherein the distributed lock may be used to access a shared resource associated with the blockchain. It is to be understood that the atomic operation result of each program may include an atomic operation result corresponding to a first parameter value (e.g., 0) and an atomic operation result corresponding to a second parameter value (e.g., 1). It will be appreciated that the first parameter value and the second parameter value may each be values of the default parameter after each program has performed the atomic operation.
It should be understood that the billing node may obtain a target atomic operation result having the first parameter value in the atomic operation result of each program, and determine a program (e.g., program 2 shown in fig. 2) corresponding to the target atomic operation result as the target program. For example, after the invoicing node performs an atomic operation on the K programs (for example, 4 programs) shown in fig. 2, the result of the atomic operation of each program participating in the competition for the distributed lock is obtained. For example, the result of the atomic operation of procedure 1 may be 1, the result of the atomic operation of procedure 2 may be 0, the result of the atomic operation of procedure 3 may be 1, and the result of the atomic operation of procedure 4 may be 1. At this time, the billing node may acquire an atomic operation result having a first parameter value (e.g., 0) as a target atomic operation result among the atomic operation results of the 4 programs, and determine a program corresponding to the target atomic operation result (i.e., program 2 shown in fig. 2) as the target program.
Further, the billing node may perform locking processing on the program 2 through a distributed lock, so that the program 2 after the locking processing accesses the shared resource in the shared memory locally stored by the billing node. The shared resource can be acquired by calling an intelligent contract in a block chain corresponding to a block chain network to which the billing node belongs. Wherein the smart contracts may include a first smart contract and a second smart contract. It can be understood that the billing node can obtain the bill number segment corresponding to the bill code stored in the local shared memory of the billing node based on the first intelligent contract; the billing node can update the enterprise user information in the local shared memory of the billing node based on the second intelligent contract.
At this time, the billing node may execute the billing service associated with the blockchain in the locked program 2 based on the shared resource. In other words, the billing node may execute the billing service associated with the service processing request 2, so that the electronic ticket B as shown in fig. 2 may be obtained, and the electronic ticket B may be returned to the user terminal that originated the service processing request 2. When the billing service is completed, the billing node can execute unlocking processing on the program 2 after locking processing, so that the distributed lock can be released, and the program 2 can be recovered. While releasing the distributed lock, the target atomic operation result of program 2 may be updated from the first parameter value (i.e., 0) to the second parameter value (e.g., 1). Therefore, in the embodiment of the application, since the program 2 acquires the distributed lock, the program 2 is not interrupted by any other program in the process of executing the target service in the program 2, so that the problem of safe access to the shared resource can be quickly solved, the accuracy of reading the data of the shared resource can be improved as much as possible, and the abnormality of the issued electronic bill can be avoided as much as possible.
The specific implementation manner of releasing the distributed lock when the target program that acquires the distributed lock completes the invoicing service based on the acquired shared resource may be as shown in the following embodiments corresponding to fig. 3 to 11.
Further, please refer to fig. 3, which is a flowchart illustrating a data processing method according to an embodiment of the present application. As shown in fig. 3, the method may be performed by an invoicing node in the blockchain network, where the invoicing node may be a user terminal accessing to the blockchain network or a server accessing to the blockchain network, and is not limited herein. For convenience of understanding, the billing node in the embodiment of the present application may take an example of accessing to a server in a blockchain network (e.g., the node 10A in the blockchain network shown in fig. 1). The method may comprise at least the following steps S101-S105:
step S101, obtaining the atomic operation interfaces associated with the K programs, calling the atomic operation interfaces to execute the atomic operation on each program in the K programs, and obtaining the atomic operation result of each program participating in competition of the distributed lock.
It should be understood that, before performing step S101, an invoicing node in the blockchain network may receive a service processing request associated with an invoicing service, which is sent by a user terminal having a network connection relationship with the invoicing node, and then, when determining that the service processing request is a legal request, the invoicing node may obtain atomic operation interfaces associated with K programs under the invoicing service, and then, may determine an agreed value of an agreed parameter associated with the K programs. The initial value of the lock status parameter of each of the K programs may be a value (e.g., 0) obtained by initializing the lock status parameter, and the default value of the default parameter may be the same value (e.g., 1). Where K is a positive integer, the K programs may include a first program and a second program. It will be appreciated that the billing node may call an atomic replacement function associated with the atomic operation interface to perform an atomic operation on the first program and the second program, respectively. It should be appreciated that the billing node may replace the initial value of the lock status parameter of the first program with the default value and replace the default value of the default parameter of the first program with the initial value, and may further replace the default parameter with the initial value returned by the first program after the atomic operation is performed as the first operation result (i.e., 0) of the first program. Further, the billing node may further update the initial value of the lock state parameter of the second program according to the lock state parameter of the first program having the default value, so as to obtain an updated value (i.e. 1) of the lock state parameter of the second program. At this time, the invoicing node may replace the updated value of the lock status parameter of the second program with the default value, and replace the default value of the default parameter of the second program with the updated value, and then may use the default parameter with the updated value returned by the second program after the atomic operation is performed as the second operation result (i.e. 1) of the second program. Further, the billing node may treat the first operation result and the second operation result as an atomic operation result of each program participating in the competition for the distributed lock.
It should be understood that the billing node may receive a service processing request associated with the billing service sent by a user terminal having a network connection with the billing node. The ue may be any one of the ue clusters shown in fig. 1, for example, the ue 100 a. Wherein, the user corresponding to the user terminal may be referred to as a ticket requesting user. The ticket requesting user may be an enterprise user or an individual user, which is not limited herein. It can be understood that the user terminal can request the user private key of the user through the ticket to sign the service key information, so that the user signature information can be obtained. The business key information may include information of the ticket requesting user (i.e. basic information of the seller), basic information of the purchaser, basic information of the taxable item, etc. The ticket user request information may include a seller's name, address, contact address, etc., the purchaser's basic information may include a purchaser's name, address, contact address, etc., and the taxable items may include taxable services, quantity, unit price, amount, etc. At this time, the user terminal may generate a service processing request for acquiring the electronic ticket based on the user signature information and the user public key, and send the service processing request to the billing node.
When receiving a service processing request from a user terminal, the billing node may determine the validity of the service processing request. It should be understood that the billing node may obtain the user public key of the user requesting the ticket, and verify the user signature information based on the user public key, so as to obtain the corresponding signature verification result. If the result of the signature verification indicates that the verification is successful, the billing node can determine that the bill requesting user corresponding to the user terminal is a legal user and determine the service processing request initiated by the user terminal as a legal request; if the result of the signature verification indicates that the verification fails, the billing node can determine that the ticket requesting user corresponding to the user terminal is an illegal user, and determine that the service processing request initiated by the user terminal is an illegal request.
For easy understanding, please refer to fig. 4, which is a schematic diagram illustrating a scenario that verifies the validity of a service processing request according to an embodiment of the present application. As shown in fig. 4, the ue a may be any ue in the ue cluster in the embodiment corresponding to fig. 1, for example, the ue 100 a. The user corresponding to the user terminal a may request the user 1 for the ticket. Node B may be an invoicing node in the blockchain network in the embodiment corresponding to fig. 1, for example, node 10A.
As shown in fig. 4, the user terminal a may sign the service key information submitted by the ticket requesting user 1 based on the user private key of the ticket requesting user 1, so as to obtain the user signature information. The service key information may include information of a ticket requesting user 1 (e.g., a business name of the ticket requesting user 1, a user name of the ticket requesting user 1, a contact address of the ticket requesting user 1, a user public key of the ticket requesting user 1, etc.), basic information of a purchaser, basic information of a taxable item, etc. The user terminal a may perform hash calculation on the service key information, so as to obtain summary information h of the service key information, and digitally sign the summary information h based on a user private key of the ticket request user 1, so as to obtain user signature information. Wherein, the user signature information includes the digital signature and the service key information.
Further, the user terminal a may generate a service processing request for sending to the node B based on the user signature information, the service key information, and the user public key corresponding to the user private key, so that the node B may obtain the user public key of the ticket requesting user 1 carried by the service processing request, and check the signature for the user signature information based on the user public key, thereby obtaining a signature checking result. It can be understood that the node B may check the digital signature based on the user public key of the ticket requesting user 1 to obtain the digest information H of the service key information, and perform hash calculation on the service key information by using the same hash algorithm as that of the user terminal a, so as to obtain the digest information H of the service key information. Further, the node B may compare the digest information H obtained after the signature verification with the digest information H obtained by performing hash calculation to obtain a signature verification result.
If the summary information H is different from the summary information H, it can be understood that the signature verification result obtained by the node B indicates that signature verification fails, and at this time, the node B may determine the ticket requesting user 1 as an illegal user, and may determine the service processing request initiated by the user terminal a as an illegal request. If the summary information H is the same as the summary information H, it can be understood that the signature verification result obtained by the node B indicates that the signature verification is successful, and at this time, the node B may determine the ticket requesting user 1 as a valid user, and may determine the service processing request initiated by the user terminal a as a valid request.
It should be understood that the billing node may execute step S101 when determining that the service processing request initiated by the user terminal a is a legal request. Wherein the atomic operation interface can be implemented by assembly language, for example, atomic _ swap (a, B) (an atomic replacement function). It is understood that a herein can be understood as a lock status parameter in a program, and B herein can be understood as a contract parameter in a program. The billing node may refer to a value obtained by initializing the lock state parameter in the program as an initial value (e.g., 0) of the lock state parameter. The invoicing node may pre-agree the agreed upon values in the agreed upon parameters in each program to the same value (e.g., 1).
For easy understanding, please refer to fig. 5, which is a schematic view illustrating a scenario in which an atomic operation is performed on a program according to an embodiment of the present application. Procedure 1 as shown in fig. 5 may be a procedure of participating in a distributed lock competition in an invoicing node, the value of the lock status parameter a in procedure 1 may be an initial value (e.g., 0), and the value of the commitment parameter B in procedure 1 may be a default value (e.g., 1). The billing node may be the billing node in the embodiment corresponding to fig. 1, for example, the node 10A.
It should be understood that the billing node may acquire an atomic operation interface, and perform an atomic operation on the program 1 through the above atomic replacement function, so that the initial value of the lock state parameter a in the program 1 may be replaced with the default value, and the default value of the default parameter B in the program 1 may be replaced with the initial value. For example, after the invoicing node performs the atomic operation on the program 1, the lock status parameter a in the program 1 may be 1, and the contract parameter B may be 0. At this time, the invoicing node may take the value (i.e., initial value) in the contract parameter B of the program 1 after the atomic operation is performed as the atomic operation result of the program 1, that is, the atomic operation result of the program 1 may be 0.
It can be understood that there may be K legal requests (for example, 3) determined by the billing node in the service processing request, and each legal request may correspond to one program. The program may be a process or a thread, and is not limited herein. The 3 service processing requests may specifically include a service processing request 1, a service processing request 2, and a service processing request 3. The billing service corresponding to the service processing request 1 may be the billing service executed in the program 1; the invoicing service corresponding to the service processing request 2 may be the invoicing service executed in the program 2; the billing service corresponding to the service processing request 3 may be the billing service executed in the program 3.
Further, the billing node may obtain the atomic operation interfaces associated with the 3 programs. It will be appreciated that the billing node may execute 3 programs, program 1, program 2, and program 3, in parallel, to compete for the distributed lock. In this embodiment, the time when the program 1, the program 2, and the program 3 compete for the distributed lock may be referred to as time T1. It should be understood that at time T1, the invoicing node may obtain the atomic operation interfaces associated with these 3 programs under the invoicing service, and thus may determine that the default value of the default parameter of program 1 is 1, the default value of the default parameter of program 2 is 1, and the default value of the default parameter in program 3 is 1.
At this time, the billing node may call the atomic operation interface to perform the atomic operation on program 1, program 2, and program 3, respectively. It will be appreciated that the invoicing node may replace the initial values of the lock status parameters in procedure 1 with default values and the default values of the default parameters in procedure 1 with initial values. That is, the billing node may replace the lock status parameter in program 1 with 1 and the contract parameter in program 1 with 0 by performing an atomic operation on program 1. At this time, the invoicing node may take the contract parameter with the initial value returned by the program 1 after the atomic operation is executed as the operation result of the program 1, that is, the operation result of the program 1 is 0.
Further, the billing node may update the initial value of the lock state parameter of program 2 based on the lock state parameter of program 1 (i.e., 1) having the agreed value, so that an updated value (i.e., a first updated value) of the lock state parameter of program 2 may be obtained. In other words, the first updated value of the lock status parameter of procedure 2 may be 1. It should be appreciated that the billing node may replace the first updated value of the lock status parameter in procedure 2 with the default value and the default value of the commitment parameter in procedure 2 with the first updated value. That is, the billing node may replace the lock status parameter in program 2 with 1 and the contract parameter in program 2 with 1 by performing an atomic operation on program 2. At this time, the invoicing node may take the contract parameter with the first updated value returned by the program 2 after the atomic operation is executed as the operation result of the program 2, that is, the operation result of the program 2 is 1.
Further, the billing node may update the initial value of the lock state parameter of program 3 based on the lock state parameter of program 1 (i.e., 1) having the first updated value, so that an updated value of the lock state parameter of program 3 (i.e., the second updated value) may be obtained. In other words, the second updated value of the lock status parameter of procedure 3 may be 1. It should be appreciated that the billing node may replace the second updated value of the lock status parameter in procedure 3 with the default value and the default value of the default parameter in procedure 3 with the second updated value. That is, the billing node may replace the lock status parameter in program 3 with 1 and the contract parameter in program 3 with 1 by performing an atomic operation on program 3. At this time, the invoicing node may take the contract parameter with the second updated value returned by the program 3 after the atomic operation is executed as the operation result of the program 3, that is, the operation result of the program 3 is 1.
At this time, the billing node may take the operation result of program 1 (i.e., 0), the operation result of program 2 (i.e., 1), and the operation result of program 3 (i.e., 1) as the atomic operation result of each program participating in the competition for the distributed lock.
It is understood that the atomic operation result in each program may include an atomic operation result corresponding to a first parameter value (e.g., 0) and an atomic operation result corresponding to a second parameter value (e.g., 1). The first parameter value may be used to indicate that the corresponding program successfully acquires the distributed lock, and the second parameter value may be used to indicate that the corresponding program temporarily does not acquire the distributed lock. For example, in the above 3 programs, it may be understood that the program 1 may successfully acquire the distributed lock, and the program 2 and the program 3 may not acquire the distributed lock temporarily.
At this time, the billing node may detect a program that has not acquired the distributed lock temporarily among the K programs, and may determine the program that has not acquired the distributed lock temporarily as the program to be processed. Further, the billing node may perform an atomic operation on the to-be-processed program until the atomic operation result of the to-be-processed program is the first parameter value, and lock the to-be-processed program through the distributed lock, so that the locked to-be-processed program accesses the shared resource.
For example, in the above 3 programs, the billing node may detect that the program 2 and the program 3 have not acquired the distributed lock temporarily, and at this time, the billing node may determine the program 2 and the program 3 as the to-be-processed program. It will be appreciated that the billing node may perform an atomic operation on the program to be processed, thereby entering a loop wait state. Optionally, the to-be-processed program may synchronously process other services associated with the to-be-processed program in the process of circular waiting, so that the processing efficiency of the service data may be improved.
After the billing service is executed in the program 1 after the locking process, the program 1 after the locking process is unlocked, so that the distributed lock can be released, and at this time, the program 2 and the program 3 will continue to compete for the distributed lock. In this embodiment, the time when the program 2 and the program 3 continue to compete for the distributed lock may be referred to as time T2. At time T2, the billing node may continue to call the atomic operation interface, so as to perform the atomic operation on program 2 and program 3, respectively, and obtain the atomic operation result of program 2 and program 3. For example, the result of the atomic operation of program 2 may be 0, and the result of the atomic operation of program 3 may be 1, at which point the billing node may determine that program 2 may acquire a distributed lock to perform the billing service of program 2.
When the program 2 after the locking process finishes the billing service, the program 3 can continue to compete for the distributed lock when the distributed lock can be released by unlocking the program 2 after the locking process. In this embodiment, the time when the program 3 continues to compete for the distributed program may be referred to as time T3. At time T3, the billing node may continue to call the atomic operation interface to perform an atomic operation on program 3, resulting in an atomic operation result for program 3 (i.e., 0). At this time, the billing node may determine that the program 3 may acquire the distributed lock to execute the billing service of the program 3, and after the billing service is executed by the program 3 after the locking process, the program 3 after the locking process is unlocked to release the distributed lock.
Step S102, obtaining a target atomic operation result with a first parameter value in the atomic operation result of each program, and determining the program corresponding to the target atomic operation result as the target program.
Specifically, the atomic operation result of each program may include an atomic operation result corresponding to a first parameter value (e.g., 0) and an atomic operation result corresponding to a second parameter value (e.g., 1). At this time, the billing node acquires the atomic operation result having the first parameter value among the atomic operation results of each program. In this embodiment, the atomic operation result with the first parameter value may be referred to as a target atomic operation result. Further, the billing node may determine the program corresponding to the target atomic operation result as the target program.
For example, in step S101, the programs participating in the competition for the distributed lock at time T1 may be program 1, program 2, and program 3. And the billing node executes the atomic operation on the 3 programs respectively by calling the atomic operation interface, so as to obtain the atomic operation results corresponding to the 3 programs respectively. That is, the result of the atomic operation of the program 1 may be 0, the result of the atomic operation of the program 2 may be 1, and the result of the atomic operation of the program 3 may be 1. At this time, the billing node may obtain the target atomic operation result with the first parameter value (i.e., 0), and may further determine the program corresponding to the target atomic operation result (i.e., program 1) as the target program.
And step S103, locking the target program through the distributed lock so that the target program after locking accesses the shared resource.
Specifically, the billing node may perform locking processing on the object program through the distributed lock to obtain the object program after the locking processing, and further may enable the object program after the locking processing to access the shared resource stored in the local shared memory of the billing node. The shared resource is obtained by calling an intelligent contract in a block chain corresponding to the billing node by the billing node. It is to be understood that smart contracts may be understood as computerized agreements that may execute the terms of a certain contract, implemented by code deployed on a shared ledger for execution when certain conditions are met, for completing automated transactions according to actual business requirement code. For example, the billing node may obtain the shared resource stored in the local shared memory of the billing node based on the intelligent contracts (e.g., the first intelligent contract and the second intelligent contract).
It should be appreciated that the invoicing node may obtain a first contract invocation address of a first intelligent contract associated with the invoicing service, and may in turn invoke the first intelligent contract based on the first contract invocation address to send a ticket application request to the tax node in the block chain. The first intelligent contract can be used for sending a bill application request to the tax nodes in the blockchain, and the bill application request can be used for indicating the tax nodes to configure bill number sections corresponding to the bill codes. Furthermore, the billing node can receive a bill number section corresponding to the bill code returned by the tax node, and the bill code and M bill numbers in the bill number section are used as shared resources, so as to store the shared resources in the local memory of the billing node; m is a positive integer.
For easy understanding, please refer to fig. 6, which is a schematic view of a scenario for acquiring a shared resource according to an embodiment of the present application. As shown in fig. 6, the billing node a in the embodiment of the present application may be the billing node in the block chain network shown in fig. 1, for example, the node 10A. The tax node B in this embodiment may be a tax node in a block chain network to which the billing node a belongs, and the tax node B may be a tax node in the block chain network shown in fig. 1, for example, a node 10B.
It should be appreciated that the invoicing node a may obtain a first contract invocation address of a first intelligent contract associated with the invoicing service, and may invoke the intelligent contract based on the first contract invocation address, such that a request for a ticket application may be sent to the tax node B. When the tax node B receives the ticket application request, the ticket number segment corresponding to the ticket code may be configured based on the ticket application request. As shown in fig. 6, the ticket number segment may include M ticket numbers, and the M ticket numbers may specifically include ticket number 1, ticket number 2, …, ticket number M, and the like. Wherein M is a positive integer.
Further, the tax node B may return the ticket number segment corresponding to the ticket code to the billing node a, and at this time, the billing node a may use the ticket code and the M ticket numbers in the ticket number segment as shared resources, and further may store the shared resources in a shared memory local to the billing node a.
In addition, when the billing node sends a bill application request to the tax node in the block chain, the billing node may obtain a second contract calling address of a second intelligent contract associated with the billing service, and may further call the second intelligent contract based on the second contract calling address to obtain user information corresponding to the N users. The N users may include enterprise users or individual users, which is not limited herein. Wherein N may be a positive integer. The second intelligent contract may be used to update user information (e.g., enterprise user information) in the shared resource.
Further, the billing node a may send an enterprise information synchronization request to the tax node based on the enterprise user information. The enterprise information synchronization request can be used for indicating the tax node to search enterprise updating information which is unmatched with the enterprise user information in the enterprise information database, and then the tax node can take the searched enterprise updating information as the enterprise information to be synchronized of the corresponding enterprise user. Furthermore, the billing node can receive the enterprise information to be synchronized returned by the tax node, and update the shared resource according to the enterprise information to be synchronized.
For easy understanding, please refer to fig. 7, which is a schematic view of a scenario for updating a shared resource according to an embodiment of the present application. As shown in fig. 7, the billing node a in the embodiment of the present application may be the billing node in the block chain network shown in fig. 1, for example, the node 10A. The tax node B in this embodiment may be a tax node in a block chain network to which the billing node a belongs, and the tax node B may be a tax node in the block chain network shown in fig. 1, for example, a node 10B.
The enterprise information database associated with the tax node B may store user information corresponding to N users, where the user may be an individual user or an enterprise user, and is not limited herein. In the embodiment of the present application, enterprise user information corresponding to 3 enterprise users is taken as an example, and specifically, the enterprise user information corresponding to enterprise user 1, enterprise user information corresponding to enterprise user 2, and enterprise user information corresponding to enterprise user 3 may be included.
As shown in fig. 7, the invoicing node a may obtain a second contract invoking address of a second intelligent contract associated with the invoicing service, and may further invoke the second intelligent contract based on the second contract invoking address, so as to obtain enterprise user information corresponding to 3 enterprise users from the local shared memory. For example, the billing node a may obtain the enterprise user information corresponding to the 3 enterprise users from the enterprise user information table 1 stored in the local shared memory, and the enterprise user information table 1 may be established based on the enterprise users and the enterprise user information corresponding to the enterprise users. The enterprise user information corresponding to the enterprise user 1 may be enterprise user information 10a, the enterprise user information corresponding to the enterprise user 2 may be enterprise user information 20a, and the enterprise user information corresponding to the enterprise user 3 may be enterprise user information 30 a.
The billing node a may send an enterprise information synchronization request to the tax node B based on the 3 enterprise user information. At this time, the tax node B may search for enterprise update information that does not match the enterprise user information stored in the invoicing node, i.e., the enterprise user information 10B corresponding to the enterprise user 1 and the enterprise user information 30B corresponding to the enterprise user 3, in the enterprise user information table 3 in the enterprise information database associated with the tax node B based on the enterprise information synchronization request.
Further, the tax node B may use the enterprise user information 10B and the enterprise user information 30B as the enterprise information to be synchronized, and may further send the enterprise information to be synchronized to the billing node a. At this time, the billing node a may update the enterprise user information corresponding to the enterprise user 1 from the enterprise user information 10a to the enterprise user information 10b and update the enterprise user information corresponding to the enterprise user 3 from the enterprise user information 30a to the enterprise user information 30b based on the enterprise information to be synchronized. That is, the enterprise user information table in the shared memory of the billing node a may be updated from the enterprise user information table 1 to the enterprise user information table 2. It is understood that the contents of the enterprise user information table 2 and the enterprise user information table 3 may be the same.
And step S104, executing the billing service in the target program after the locking processing based on the shared resource.
Specifically, the billing node may select a target ticket number for a target user terminal associated with the target program after the locking process from the ticket number segment in the shared resource. Wherein, the target bill number can be a bill number in the bill number section. Further, the billing node may delete the target ticket number in the shared resource, and perform decremental processing on the number of ticket numbers in the ticket number segment. It should be appreciated that the billing node may generate an electronic ticket associated with the target user terminal based on the ticket code, the target ticket number, and the business critical information, and return the electronic ticket to the target user terminal.
It should be understood that the billing node may access the shared resource based on the target program after the locking process, and may further determine the matching between the enterprise user information in the shared resource and the ticket request user information in the business key information sent by the target user terminal. The target user terminal may be a user terminal associated with the target program after the locking process. It is understood that, if the enterprise user information does not match the ticket requesting user information, the billing node may generate a modification prompt message to notify the target user terminal of modifying the ticket requesting user information based on the enterprise user information, where the modification prompt message may be "your user information does not match the submitted information, ask you to modify the user information, or update the user information". If the enterprise user information is matched with the bill request user information, the billing node can select a target bill number from the bill number section in the shared resource aiming at the target user terminal.
Further, the billing node may delete the target ticket number in the shared memory, and perform decremental processing on the number of ticket numbers in the ticket number segment. Meanwhile, the billing node may generate an electronic ticket associated with the target user terminal based on the ticket code, the target ticket number, and the service key information, and return the electronic ticket to the target user terminal. It can be understood that the billing node can count the number (count, denoted as C) of the ticket numbers in the shared resource, and when the billing node executes a billing service once and generates an electronic ticket, the billing node can decrement the number of the ticket numbers through the assignment function. Wherein, the valuation function can be C ═ C-1. For example, when the billing service is not executed, the number of the ticket numbers in the shared memory of the billing node may be 10, after the billing service is executed once, the billing node may perform decremental processing on the number of the ticket numbers through the assignment function, and at this time, the number of the ticket numbers in the shared memory may be 9. When the number of the bill numbers stored in the local shared memory of the billing node is 0, the billing node can send a bill application request to the tax node in the block chain network to which the billing node belongs by calling a first intelligent contract, so that the tax node can configure a new bill number section corresponding to the bill code based on the bill application request, further receive the new bill number section, and store the new bill number section as a shared resource in the shared memory. The specific implementation of the billing node obtaining the ticket number segment corresponding to the ticket code may refer to the description in the embodiment corresponding to fig. 6, which is not described herein again.
For easy understanding, please refer to fig. 8, which is a schematic view of a scenario for executing an invoicing service according to an embodiment of the present application. The node B in the embodiment of the present application may be an invoicing node in the block chain network shown in fig. 1, for example, the node 10A. The user terminal a in this embodiment may be any one of the user terminals in the user terminal cluster shown in fig. 1, for example, the user terminal 100 a. The user terminal a may be a user terminal associated with the target program after the locking process.
As shown in fig. 8, a user corresponding to the user terminal a may be a ticket requesting user 1 (i.e., a seller, such as an enterprise user), for example, in a financial scenario, the ticket requesting user 1 may issue an electronic ticket associated with a certain purchase for a certain customer through the user terminal a after the certain customer purchases a certain material. It will be appreciated that the user terminal a may send a service processing request for acquiring an electronic ticket to the node B based on the service critical information submitted by the ticket requesting user 1. At this time, the node B may determine the validity of the service processing request when receiving the service processing request. Further, when it is determined that the service processing request is a legal request, the node B may call an atomic operation interface, and perform an atomic operation on a program (e.g., program 1) corresponding to the service processing request, so as to obtain an atomic operation result of the program 1. When the atomic operation result of the program 1 is the first parameter value, the node B may determine the atomic operation result of the program 1 as a target atomic operation result, and use the program 1 as a target program, and further may perform locking processing on the program 1 through a distributed lock, to obtain the program 1 after the locking processing, and at this time, the node B may access the shared resource in the shared memory in the node B through the program 1 after the locking processing.
As shown in fig. 8, the shared resource in the shared memory locally stored by the node B may include enterprise user information, a ticket code, and a ticket number segment. The number C of the ticket numbers in the shared memory may be M, and the M ticket numbers may specifically include ticket number 1, ticket number 2, …, ticket number M, and the like. Wherein M is a positive integer. It can be understood that the service processing request sent by the user terminal a may carry service key information associated with the ticket requesting user 1, and the service key information 1 may include ticket requesting user information of the ticket requesting user 1, for example, a user name of the ticket requesting user 1, a business name of the ticket requesting user 1, a contact address of the ticket requesting user 1, and the like. At this time, the node B may access the enterprise user information in the shared resource based on the program 1 after the locking process, so that the matching between the enterprise user information corresponding to the ticket requesting user 1 in the shared memory and the ticket requesting user information submitted by the ticket requesting user 1 in the service key information may be determined.
When it is determined that the enterprise user information corresponding to the ticket requesting user 1 in the shared memory matches the ticket requesting user information submitted by the ticket requesting user 1 in the service key information, the node B may select a target ticket number (e.g., ticket number 1) associated with the ticketing service from the ticket number segment in the shared resource. Further, the node B may delete the ticket number 1 in the shared memory, and may perform decremental processing on the number of ticket numbers stored in the shared memory through the above-mentioned assignment function, thereby obtaining the number C of ticket numbers in the shared memory. For example, after the deleted ticket number 1, the number C of ticket numbers in the shared memory may be M-1. The M-1 ticket numbers may specifically include ticket number 2, ticket number 3, …, and ticket number M.
Meanwhile, the node B may generate the electronic ticket 700 associated with the user terminal a based on the ticket code, the ticket number 1, and the service key information in the shared memory. At this point, node B may return the electronic ticket 700 to user terminal a. In the embodiment of the application, because the program 1 corresponding to the service processing request is locked, the node B can safely access the shared resource in the shared memory without being interrupted by any other program in the process of processing the billing service associated with the user terminal a, so that the accuracy of the electronic bill corresponding to the billing service is improved.
And step S105, when the billing service is completed, unlocking the target program after the locking process is performed so as to release the distributed lock.
Specifically, the billing node may call an atomic unlocking function associated with the atomic operation interface when completing the billing service, so as to perform unlocking processing on the target program after the locking processing, and thus, the distributed lock may be released, and the target program is restored. Furthermore, the billing node can update the target atomic operation result of the target program from the first parameter value to the second parameter value while releasing the distributed lock, and further can complete the release of the distributed lock.
It is understood that, in the above step S101, the programs participating in the competition for the distributed lock at the time T1 may be program 1, program 2, and program 3. The target program determined by the billing node may be program 1. At this time, when the billing service corresponding to the program 1 is completed, the billing node may call an atomic unlocking function associated with the atomic operation interface, so that the unlocking process may be performed on the locked program 1, the distributed lock may be released, and the program 1 may be obtained by restoring. At the same time when the billing node releases the distributed lock, the result of the atomic operation of the program 1 may be updated from the first parameter value (e.g., 0) to the second parameter value (e.g., 1), and the release of the distributed lock may be completed.
In the embodiment of the application, when the K programs are executed in parallel, the billing node in the blockchain network may acquire an atomic operation interface associated with the K programs, and may further call the atomic operation interface to perform an atomic operation on each program in the K programs, so that an atomic operation result of each program participating in competition for the distributed lock may be obtained, and based on the atomic operation result of each program, a target program capable of acquiring the distributed lock is determined in the K programs. It should be understood that the billing node may determine a program corresponding to the target atomic operation result with the first parameter value as a target program, and then may perform locking processing on the target program through a distributed lock for accessing the shared resource associated with the blockchain, so that the target program after the locking processing may safely access the shared resource stored by the billing node. Further, the billing node may execute a billing service associated with the blockchain in the target program after the locking process based on the accessed shared resource, and when the billing service is completed in the target program, the billing node may perform an unlocking process on the target program after the locking process to release the distributed lock. Therefore, the billing node is based on the atomic operation, so that the target program realizes the acquisition of the distributed lock, and the shared resource accessed by the target program cannot be interrupted by other programs in the process of executing the billing service by the target program, so that the problem of safe access of the target program to the shared resource can be solved, the completeness operation of the billing service in the target program is ensured, and the accuracy of reading the data of the shared resource by the target program can be improved.
Further, please refer to fig. 9, which is a flowchart illustrating a data processing method according to an embodiment of the present application. As shown in fig. 9, the method may be performed by an invoicing node in the blockchain network, where the invoicing node may be a user terminal accessing to the blockchain network or a server accessing to the blockchain network, and is not limited herein. For convenience of understanding, the billing node in the embodiment of the present application may take an example of accessing to a server in a blockchain network (e.g., the node 10A in the blockchain network shown in fig. 1). The method may comprise at least the following steps S201-S208:
step S201, obtaining the atomic operation interfaces associated with the K programs, and calling the atomic operation interfaces to perform atomic operation on each of the K programs, so as to obtain an atomic operation result of each program participating in competition for the distributed lock.
Step S202, obtaining a target atomic operation result with a first parameter value from the atomic operation results of each program, and determining the program corresponding to the target atomic operation result as the target program.
And step S203, locking the target program through the distributed lock so that the target program after locking accesses the shared resource.
And step S204, executing the billing service in the target program after the locking processing based on the shared resource.
And step S205, when the billing service is completed, unlocking the target program after the locking process is performed to release the distributed lock.
For specific implementation of steps S201 to S205, reference may be made to the description of steps S101 to S105 in the embodiment corresponding to fig. 3, which will not be described herein again.
Step S206, the business data information associated with the electronic bill is packaged to obtain the to-be-verified block to be written into the block chain.
Specifically, the billing node may obtain the block with the largest generation timestamp from the block chain in the block chain network corresponding to the billing node. Furthermore, the billing node can perform packaging processing on the service data information associated with the electronic bill, so that a to-be-verified block to be written into the block chain to which the billing node belongs can be obtained.
Step S207, broadcasting the to-be-verified block to the consensus node on the block chain, so that the consensus node performs consensus on the acquired to-be-verified block to obtain a consensus result.
Specifically, the billing node may broadcast the to-be-verified block to the consensus node on the block chain, so that the consensus node performs consensus on the acquired to-be-verified block, thereby obtaining a consensus result. The consensus node may be a block chain node in a consensus network in a block chain network to which the billing node belongs.
In step S208, if the consensus result exceeding 1/2 in the consensus results returned by the consensus nodes indicates successful consensus, it is determined that the block chain nodes on the block chain achieve consensus, and the block to be verified is written into the block chain as the target block.
Specifically, if the consensus result exceeding 1/2 in the consensus result returned by the consensus node indicates that the consensus is successful, the billing node may determine that the block link points on the blockchain achieve the consensus, and further may use the block to be verified as the target block, and write the target block into the blockchain, that is, use the block to be verified as the next block of the block with the largest generation timestamp, so as to write the service data information into the blockchain in the blockchain network corresponding to the billing node.
The specific implementation of steps S206 to S208 can be referred to the following description in the embodiment corresponding to fig. 10. Further, please refer to fig. 10, which is a schematic diagram of an uplink scenario provided in an embodiment of the present application. As shown in fig. 10, the node 900 in this embodiment may be an invoicing node of the blockchain network in the embodiment corresponding to fig. 1, for example, the node 10A. Each of the consensus nodes 910 and 900 in the consensus network may belong to the same blockchain network.
The blockchain 9 shown in fig. 10 may be a blockchain in a blockchain network corresponding to the blockchain system in fig. 1, where the blockchain 9 may be an identical blockchain shared by each node in the blockchain network to which the node 900 belongs, and each node may obtain information stored in the blockchain 9. The blockchain 9 includes a block 90a, blocks 90b, …, a block 90n, and a target block, and the block 90a can be referred to as a created block of the blockchain 9. The target tile in the blockchain 9 may contain business data information associated with an electronic ticket (e.g., associated with an electronic ticket 700 as shown in fig. 8).
The node 900 can write the service data information into the blockchain 9 in the blockchain network corresponding to the node 900. In other words, the node 900 can obtain the chunk 90n with the largest generation timestamp from the blockchain 9. Further, the node 900 may perform a packing process on the service data information, so as to obtain a to-be-verified block to be written into the block chain 9 to which the node 900 belongs. At this time, the node 900 may broadcast the to-be-verified block to the consensus node 910 on the block chain, so that the consensus node 910 performs consensus on the obtained to-be-verified block to obtain a consensus result. If the consensus result exceeding 1/2 in the consensus result returned by the consensus node 910 indicates that the consensus is successful, the node 900 may determine that the blockchain link points on the blockchain achieve consensus, and may further use the block to be verified as the target block and write the target block into the blockchain 9, that is, use the block to be verified as the next block of the block 90n, so that the service data information may be written into the blockchain 9 in the blockchain network corresponding to the node 900.
Further, please refer to fig. 11, which is a flowchart illustrating a data processing method according to an embodiment of the present application. As shown in fig. 11, the method may be performed by an invoicing node in the blockchain network, where the invoicing node may be a user terminal accessing to the blockchain network or a server accessing to the blockchain network, and is not limited herein. For convenience of understanding, the billing node in the embodiment of the present application may take an example of accessing to a server in a blockchain network (e.g., the node 10A in the blockchain network shown in fig. 1). The method may comprise at least the following steps S301-S307:
in step S301, atomic operation interfaces associated with the K programs are acquired.
Specifically, before executing step S301, the billing node in the blockchain network may receive a service processing request associated with the billing service and sent by a user terminal having a network connection relationship with the billing node, and then when determining that the service processing request is a legal request, the billing node may obtain atomic operation interfaces associated with K programs under the billing service, and further may determine an agreed value of an agreed parameter associated with the K programs. The initial value of the lock status parameter of each of the K programs may be a value (e.g., 0) obtained by initializing the lock status parameter, and the default value of the default parameter may be the same value (e.g., 1). Wherein K is a positive integer.
Step S302, an atomic operation interface is called to execute atomic operation on each program in the K programs, and an atomic operation result of each program participating in competition of the distributed lock is obtained.
It should be understood that the K programs may include a first program and a second program. It will be appreciated that the billing node may call an atomic replacement function associated with the atomic operation interface to perform an atomic operation on the first program and the second program, respectively. It should be appreciated that the billing node may replace the initial value of the lock status parameter of the first program with the default value and replace the default value of the default parameter of the first program with the initial value, and may further replace the default parameter with the initial value returned by the first program after the atomic operation is performed as the first operation result (i.e., 0) of the first program. Further, the billing node may further update the initial value of the lock state parameter of the second program according to the lock state parameter of the first program having the default value, so as to obtain an updated value (i.e. 1) of the lock state parameter of the second program. At this time, the invoicing node may replace the updated value of the lock status parameter of the second program with the default value, and replace the default value of the default parameter of the second program with the updated value, and then may use the default parameter with the updated value returned by the second program after the atomic operation is performed as the second operation result (i.e. 1) of the second program. Further, the billing node may treat the first operation result and the second operation result as an atomic operation result of each program participating in the competition for the distributed lock.
Step S303, detecting whether the atomic operation result of each program is a first parameter value;
specifically, the atomic operation result of each program may include an atomic operation result corresponding to a first parameter value (e.g., 0) and an atomic operation result corresponding to a second parameter value (e.g., 1). At this time, the billing node may detect whether the atomic operation result of each program is the first parameter value.
Step S304, if the detected atomic operation result of the program is the second parameter value, determining the program corresponding to the atomic operation result with the second parameter value as the program to be processed, and performing the atomic operation on the program to be processed until the atomic operation result of the program to be processed is the first parameter value.
Specifically, if the atomic operation result of the program detected by the invoicing node is the atomic operation result with the second parameter value, the invoicing node may determine the program corresponding to the atomic operation result with the second parameter value as the program to be processed, and may further continue to perform the atomic operation on the program to be processed until the atomic operation result of the program to be processed is the first parameter value. Optionally, the billing node may execute other services in the to-be-processed program synchronously, so as to improve the efficiency of the billing node.
Step S305, if the detected program atomic operation result is the first parameter value, determining the program target atomic operation result corresponding to the atomic operation result with the second parameter value as the target program, and locking the target program through the distributed lock so that the locked target program accesses the shared resource;
specifically, if the atomic operation result of the program detected by the billing node is the atomic operation result with the first parameter value, the billing node may perform a program target atomic operation result corresponding to the atomic operation result with the second parameter value, and determine the program corresponding to the target atomic operation result as the target program.
Step S306, executing billing service in the target program after locking processing based on the shared resource;
and step S307, when the billing service is finished, unlocking the target program after the locking process is performed to release the distributed lock.
For a specific implementation of the processes in steps S301 to S307 in this embodiment of the application, reference may be made to the descriptions of steps S101 to S105 in the embodiment corresponding to fig. 3 and steps S201 to S208 in the embodiment corresponding to fig. 9, and details will not be further described here.
In the embodiment of the application, when the K programs are executed in parallel, the billing node in the blockchain network may acquire an atomic operation interface associated with the K programs, and may further call the atomic operation interface to perform an atomic operation on each program in the K programs, so that an atomic operation result of each program participating in competition for the distributed lock may be obtained, and based on the atomic operation result of each program, a target program capable of acquiring the distributed lock is determined in the K programs. It should be understood that the billing node may determine a program corresponding to the target atomic operation result with the first parameter value as a target program, and then may perform locking processing on the target program through a distributed lock for accessing the shared resource associated with the blockchain, so that the target program after the locking processing may safely access the shared resource stored by the billing node. Further, the billing node may execute a billing service associated with the blockchain in the target program after the locking process based on the accessed shared resource, and when the billing service is completed in the target program, the billing node may perform an unlocking process on the target program after the locking process to release the distributed lock. Therefore, the billing node is based on the atomic operation, so that the target program realizes the acquisition of the distributed lock, and the shared resource accessed by the target program cannot be interrupted by other programs in the process of executing the billing service by the target program, so that the problem of safe access of the target program to the shared resource can be solved, the completeness operation of the billing service in the target program is ensured, and the accuracy of reading the data of the shared resource by the target program can be improved.
Further, please refer to fig. 12, which is a schematic structural diagram of a data processing apparatus according to an embodiment of the present application. As shown in fig. 12, the data processing apparatus 1 may be a computer program (including program code) running in a node device, for example, the data processing apparatus 1 is an application software; the data processing device 1 may be configured to perform corresponding steps in the method provided by the embodiment of the present application. As shown in fig. 12, the data processing apparatus 1 may operate as an invoicing node in a blockchain network, and the invoicing node may be the invoicing node in the embodiment corresponding to fig. 1, for example, the node 10A. The data processing apparatus 1 may include: the system comprises a first obtaining module 11, a first determining module 12, a locking processing module 13, a service executing module 14, an unlocking processing module 15, a second obtaining module 16, a second determining module 17, a third determining module 18, a detecting module 19, an atomic operation executing module 20, a first request sending module 21, a first receiving module 22, a third obtaining module 23, a second request sending module 24, a second receiving module 25, a packaging processing module 26, a broadcasting module 27 and a writing module 28.
The first obtaining module 11 is configured to obtain an atomic operation interface associated with the K programs, and call the atomic operation interface to perform an atomic operation on each of the K programs to obtain an atomic operation result of each program participating in the competition for the distributed lock; k is a positive integer; the distributed lock is used to access shared resources associated with invoicing traffic in the blockchain.
Wherein, the first obtaining module 11 includes: a first obtaining unit 111, a first calling unit 112, a first replacing unit 113, a first updating unit 114, a second replacing unit 115 and a result determining unit 116.
The first obtaining unit 111 is configured to obtain atomic operation interfaces associated with K programs under the billing service, and determine default values of default parameters associated with the K programs; the K programs include a first program and a second program;
the first calling unit 112 is configured to call an atomic replacement function associated with an atomic operation interface, and perform an atomic operation on the first program and the second program respectively;
the first replacing unit 113 is configured to replace the initial value of the lock status parameter of the first program with a default value, replace the default value of the default parameter of the first program with an initial value, and use the default parameter with the initial value returned by the first program after the atomic operation is performed as the first operation result of the first program;
the first updating unit 114 is configured to update the initial value of the lock state parameter of the second program according to the lock state parameter of the first program having the default value, so as to obtain an updated value of the lock state parameter of the second program;
the second replacing unit 115 is configured to replace the updated value of the lock status parameter of the second program with the default value, replace the default value of the default parameter of the second program with the updated value, and use the default parameter with the updated value returned by the second program after the atomic operation is performed as the second operation result of the second program;
the result determination unit 116 is configured to use the first operation result and the second operation result as an atomic operation result of each program participating in the competition for the distributed lock.
For specific implementation manners of the first obtaining unit 111, the first calling unit 112, the first replacing unit 113, the first updating unit 114, the second replacing unit 115, and the result determining unit 116, reference may be made to the description of step S101 in the embodiment corresponding to fig. 3, and details will not be further described here.
The first obtaining module 11 is further configured to receive a service processing request associated with the invoicing service and sent by the user terminal; and when the service processing request is determined to be a legal request, acquiring K programs associated with the billing service, executing to acquire atomic operation interfaces associated with the K programs, calling the atomic operation interfaces to execute atomic operation on each program in the K programs, and obtaining the lock state parameters of each program participating in competition of the distributed lock.
The first determining module 12 is configured to obtain a target atomic operation result with a first parameter value from the atomic operation result of each program, and determine a program corresponding to the target atomic operation result as a target program;
the locking processing module 13 is configured to perform locking processing on the target program through a distributed lock, so that the target program after the locking processing accesses the shared resource;
the service execution module 14 is configured to execute an invoicing service in the locked object program based on the shared resource.
Wherein, the service execution module 14 includes: an extracting unit 141, a deleting unit 142 and a generating unit 143.
The selecting unit 141 is configured to select a target ticket number from the ticket number segments in the shared resource, for the target user terminal associated with the target program after the locking process; the target bill number is one bill number in the bill number section.
Wherein, the selecting unit 141 includes: access sub-cell 1411, generate sub-cell 1412, and select sub-cell 1413.
The access subunit 1411 is configured to access the shared resource based on the target program after the locking process, and determine matching between the enterprise user information in the shared resource and the ticket request user information in the service key information sent by the target user terminal; the target user terminal is a user terminal associated with the target program after the locking processing;
the generating subunit 1412, configured to generate modification prompt information based on the enterprise user information if the enterprise user information does not match the ticket request user information, so as to notify the target user terminal of modifying the ticket request user information;
the selecting sub-unit 1413 is configured to select a target ticket number for the target user terminal from the ticket number segment in the shared resource if the enterprise user information matches the ticket requesting user information.
For specific implementation manners of the accessing sub-unit 1411, the generating sub-unit 1412 and the selecting sub-unit 1413, reference may be made to the description of the target ticket number in the embodiment corresponding to fig. 8, and details will not be further described here.
The deleting unit 142 is configured to delete the target ticket number in the shared resource, and perform decremental processing on the number of ticket numbers in the ticket number segment;
the generating unit 143 is configured to generate an electronic ticket associated with the target user terminal based on the ticket code, the target ticket number, and the service key information, and return the electronic ticket to the target user terminal.
For specific implementation manners of the selecting unit 141, the deleting unit 142 and the generating unit 143, reference may be made to the description of step S104 in the embodiment corresponding to fig. 3, and details will not be further described here.
The unlocking processing module 15 is configured to, when the billing service is completed, execute unlocking processing on the target program after the locking processing, so as to release the distributed lock.
Wherein, the unlocking processing module 15 includes: a second calling unit 151 and a second updating unit 152.
The second calling unit 151 is configured to, when the billing service is completed, call an atomic unlocking function associated with an atomic operation interface, perform unlocking processing on the target program subjected to locking processing to release the distributed lock, and restore the target program to obtain a target program;
the second updating unit 152 is configured to update the target atomic operation result of the target program from the first parameter value to the second parameter value while releasing the distributed lock, so as to complete releasing the distributed lock.
For specific implementation of the second calling unit 151 and the second updating unit 152, reference may be made to the description of step S105 in the embodiment corresponding to fig. 3, and details will not be further described here.
The service processing request comprises service key information and user signature information submitted by a bill request user corresponding to the user terminal; the user signature information is obtained after the user terminal requests a user private key of a user to sign the service key information through the bill;
the second obtaining module 16 is configured to obtain a user public key corresponding to the user private key, and perform signature verification on the user signature information based on the user public key to obtain a signature verification result;
the second determining module 17 is configured to determine that the ticket requesting user is a valid user and determine the service processing request initiated by the user terminal as a valid request if the signature verification result indicates that the verification is successful;
the third determining module 18 is configured to determine that the ticket requesting user is an illegal user and determine the service processing request initiated by the user terminal as an illegal request if the signature verification result indicates that the verification fails.
The atomic operation result of each program comprises an atomic operation result corresponding to a first parameter value and an atomic operation result corresponding to a second parameter value; the first parameter value and the second parameter value are both the values of the appointed parameters of each program after the atomic operation is executed; the first parameter value is used for indicating the corresponding program to successfully acquire the distributed lock; the second parameter value is used to indicate that the corresponding program has not acquired the distributed lock temporarily.
The detection module 19 is configured to detect a program that has not acquired the distributed lock temporarily among the K programs, and determine the program that has not acquired the distributed lock temporarily as a program to be processed;
the atomic operation execution module 20 is configured to execute an atomic operation on the to-be-processed program, and lock the to-be-processed program through the distributed lock until the atomic operation result of the to-be-processed program is the first parameter value, so that the to-be-processed program after being locked accesses the shared resource.
The first request sending module 21 is configured to obtain a first contract invoking address of a first intelligent contract associated with an invoicing service, invoke the first intelligent contract based on the first contract invoking address, and send a bill application request to a tax node in a block chain; the bill application request is used for indicating the tax node to configure a bill number section corresponding to a bill code;
the first receiving module 22 is configured to receive a bill number segment corresponding to a bill code returned by the tax node, and use the bill code and M bill numbers in the bill number segment as shared resources; m is a positive integer.
The third obtaining module 23 is configured to, when a request for applying a bill is sent to a tax node in a block chain, obtain a second contract invoking address of a second intelligent contract associated with an invoicing service, invoke the second intelligent contract based on the second contract invoking address, and obtain enterprise user information corresponding to N enterprise users; n is a positive integer;
the second request sending module 24 is configured to send an enterprise information synchronization request to the tax node based on the enterprise user information; the enterprise information synchronization request is used for indicating the tax node to search enterprise updating information which is not matched with the enterprise user information in the enterprise information database, and using the searched enterprise updating information as enterprise information to be synchronized of the corresponding enterprise user;
the second receiving module 25 is configured to receive the enterprise information to be synchronized returned by the tax node, and update the shared resource according to the enterprise information to be synchronized.
The packaging processing module 26 is configured to package service data information associated with the electronic ticket to obtain a to-be-verified block to be written in the block chain;
the broadcasting module 27 is configured to broadcast the to-be-verified block to the consensus node on the block chain, so that the consensus node performs consensus on the acquired to-be-verified block to obtain a consensus result;
the writing module 28 is configured to determine that the blockchain nodes on the blockchain achieve consensus and write the to-be-verified block into the blockchain as the target block if the consensus result exceeding 1/2 in the consensus results returned by the consensus nodes indicates that the consensus is successful.
For specific implementation manners of the first obtaining module 11, the first determining module 12, the locking processing module 13, the service executing module 14, the unlocking processing module 15, the second obtaining module 16, the second determining module 17, the third determining module 18, the detecting module 19, the atomic operation executing module 20, the first request sending module 21, the first receiving module 22, the third obtaining module 23, the second request sending module 24, the second receiving module 25, the packing processing module 26, the broadcasting module 27, and the writing module 28, reference may be made to the description of step S201 to step S208 in the embodiment corresponding to fig. 9, and further description will not be repeated here. In addition, the beneficial effects of the same method are not described in detail.
Further, please refer to fig. 13, which is a schematic diagram of a node device according to an embodiment of the present application. As shown in fig. 13, the node device 1000 may be an invoicing node in the blockchain network in the corresponding embodiment of fig. 1, for example, the node 10A. The node apparatus 1000 may include: at least one processor 1001, such as a CPU, at least one network interface 1004, a user interface 1003, memory 1005, at least one communication bus 1002. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display (Display) and a Keyboard (Keyboard), and the network interface 1004 may optionally include a standard wired interface and a wireless interface (e.g., WI-FI interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory (non-volatile memory), such as at least one disk memory. The memory 1005 may optionally also be at least one storage device located remotely from the aforementioned processor 1001. As shown in fig. 13, a memory 1005, which is a kind of computer storage medium, may include therein an operating system, a network communication module, a user interface module, and a device control application program.
In the node device 1000 shown in fig. 13, the network interface 1004 is mainly used for network communication with the user terminal and the tax node; the user interface 1003 is an interface for providing a user with input; and the processor 1001 may be used to invoke a device control application stored in the memory 1005 to implement:
acquiring an atomic operation interface associated with the K programs, calling the atomic operation interface to execute atomic operation on each program in the K programs, and obtaining an atomic operation result of each program participating in competition of the distributed lock; k is a positive integer; the distributed lock is used for accessing a shared resource associated with the billing service in the block chain;
acquiring a target atomic operation result with a first parameter value from the atomic operation result of each program, and determining the program corresponding to the target atomic operation result as a target program;
locking the target program through the distributed lock so that the target program after locking accesses the shared resource;
executing the billing service in the target program after the locking processing based on the shared resource;
and when the billing service is finished, unlocking the target program after the locking process is performed to release the distributed lock.
It should be understood that the node device 1000 described in this embodiment may perform the description of the data processing method in the embodiment corresponding to fig. 3 and fig. 9, and may also perform the description of the data processing apparatus 1 in the embodiment corresponding to fig. 12, which is not described herein again. In addition, the beneficial effects of the same method are not described in detail.
Further, here, it is to be noted that: an embodiment of the present application further provides a computer-readable storage medium, where the computer program executed by the aforementioned data processing apparatus 1 is stored in the computer-readable storage medium, and the computer program includes program instructions, and when the processor executes the program instructions, the description of the data processing method in the embodiment corresponding to fig. 3 or fig. 9 can be performed, so that details are not repeated here. In addition, the beneficial effects of the same method are not described in detail. For technical details not disclosed in embodiments of the computer-readable storage medium referred to in the present application, reference is made to the description of embodiments of the method of the present application. As an example, program instructions may be deployed to be executed on one computing device or on multiple computing devices at one site or distributed across multiple sites and interconnected by a communication network, which may comprise a block chain system.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
The above disclosure is only for the purpose of illustrating the preferred embodiments of the present application and is not to be construed as limiting the scope of the present application, so that the present application is not limited thereto, and all equivalent variations and modifications can be made to the present application.

Claims (15)

1. A data processing method, comprising:
acquiring an atomic operation interface associated with K programs, calling the atomic operation interface to execute atomic operation on each program in the K programs, and obtaining an atomic operation result of each program participating in competition of the distributed lock; k is a positive integer; the distributed lock is used for accessing a shared resource associated with an invoicing service in a block chain; the atomic operation means to replace the lock state parameter and the default parameter in each program; the atomic operation result of each program is an agreed parameter returned by each program after the atomic operation is executed;
acquiring a target atomic operation result with a first parameter value from the atomic operation results of each program, and determining the program corresponding to the target atomic operation result as a target program;
locking the target program through the distributed lock so that the target program after locking accesses the shared resource;
executing the billing service in the target program after the locking processing based on the shared resource; the billing service comprises the steps of selecting a target bill number from the bill number section in the shared resource and deleting the target bill number in the shared resource;
and when the billing service is finished, executing unlocking processing on the target program after the locking processing so as to release the distributed lock.
2. The method of claim 1, further comprising:
receiving a service processing request which is sent by a user terminal and is associated with an invoicing service;
and when the service processing request is determined to be a legal request, acquiring K programs associated with the billing service, executing the atomic operation interface associated with the K programs, and calling the atomic operation interface to execute atomic operation on each program in the K programs to obtain the lock state parameters of each program participating in competition of the distributed lock.
3. The method according to claim 2, wherein the service processing request includes service key information and user signature information submitted by a ticket request user corresponding to the user terminal; the user signature information is obtained after the user terminal signs the service key information through a user private key of the bill request user;
the method further comprises the following steps:
acquiring a user public key corresponding to the user private key, and checking the signature of the user signature information based on the user public key to obtain a signature checking result;
if the signature verification result indicates that verification is successful, determining that the bill requesting user is a legal user, and determining that the service processing request initiated by the user terminal is a legal request;
and if the signature verification result indicates that the verification fails, determining that the bill requesting user is an illegal user, and determining the service processing request initiated by the user terminal as an illegal request.
4. The method according to claim 1, wherein the obtaining an atomic operation interface associated with the K programs, and calling the atomic operation interface to perform an atomic operation on each of the K programs, and obtaining an atomic operation result of each of the programs participating in the competition for the distributed lock comprises:
acquiring atomic operation interfaces associated with K programs under the billing service, and determining the default values of the default parameters associated with the K programs; the K programs include a first program and a second program;
calling an atomic replacement function associated with the atomic operation interface to respectively execute atomic operations on the first program and the second program;
replacing the initial value of the lock state parameter of the first program with the default value, replacing the default value of the default parameter of the first program with the initial value, and taking the default parameter with the initial value returned by the first program after the atomic operation is completed as the first operation result of the first program;
updating the initial value of the lock state parameter of the second program according to the lock state parameter of the first program with the default value to obtain an updated value of the lock state parameter of the second program;
replacing the updated value of the lock state parameter of the second program with the default value, replacing the default value of the default parameter of the second program with the updated value, and taking the default parameter with the updated value returned by the second program after the atomic operation is completed as a second operation result of the second program;
and taking the first operation result and the second operation result as the atomic operation result of each program participating in competition for the distributed lock.
5. The method of claim 1, wherein the atomic operation result of each program comprises an atomic operation result corresponding to a first parameter value and an atomic operation result corresponding to a second parameter value; the first parameter value and the second parameter value are both values of an agreed parameter after each program executes atomic operation; the first parameter value is used for indicating a corresponding program to successfully acquire the distributed lock; the second parameter value is used for indicating that the corresponding program does not acquire the distributed lock temporarily.
6. The method of claim 5, further comprising:
detecting a program which does not temporarily acquire the distributed lock in the K programs, and determining the program which does not temporarily acquire the distributed lock as a program to be processed;
and executing the atomic operation on the program to be processed until the atomic operation result of the program to be processed is the first parameter value, and locking the program to be processed through the distributed lock so that the locked program to be processed accesses the shared resource.
7. The method of claim 1, further comprising:
acquiring a first contract calling address of a first intelligent contract associated with an invoicing service, calling the first intelligent contract based on the first contract calling address, and sending a bill application request to a tax node in the block chain; the bill application request is used for indicating the tax node to configure a bill number section corresponding to a bill code;
receiving a bill number section corresponding to the bill code returned by the tax node, and taking the bill code and M bill numbers in the bill number section as the shared resource; m is a positive integer.
8. The method of claim 7, further comprising:
when a bill application request is sent to the tax node in the block chain, acquiring a second contract calling address of a second intelligent contract associated with the invoicing service, calling the second intelligent contract based on the second contract calling address, and acquiring enterprise user information corresponding to N enterprise users; n is a positive integer;
sending an enterprise information synchronization request to the tax node based on the enterprise user information; the enterprise information synchronization request is used for indicating the tax node to search enterprise updating information which is not matched with the enterprise user information in an enterprise information database, and using the searched enterprise updating information as enterprise information to be synchronized of the corresponding enterprise user;
and receiving the enterprise information to be synchronized returned by the tax node, and updating the shared resources according to the enterprise information to be synchronized.
9. The method according to claim 7, wherein the executing the billing service in the target program after the locking process based on the shared resource comprises:
selecting a target bill number from the bill number section in the shared resource aiming at the target user terminal associated with the target program after the locking processing; the target bill number is a bill number in the bill number section;
deleting the target bill number in the shared resource, and decreasing the number of the bill numbers in the bill number section;
and generating an electronic bill associated with the target user terminal based on the bill code, the target bill number and the service key information sent by the target user terminal, and returning the electronic bill to the target user terminal.
10. The method of claim 9, wherein the extracting a target ticket number for a target user terminal associated with the target program after the locking process from the ticket number segment in the shared resource comprises:
based on the target program after locking processing, accessing the shared resource, and determining the matching between the enterprise user information in the shared resource and the bill request user information in the business key information sent by the target user terminal; the target user terminal is a user terminal associated with the target program after the locking processing;
if the enterprise user information is not matched with the bill requesting user information, generating modification prompt information based on the enterprise user information so as to inform the target user terminal to modify the bill requesting user information;
and if the enterprise user information is matched with the bill request user information, selecting a target bill number aiming at the target user terminal from the bill number section in the shared resource.
11. The method of claim 9, further comprising:
packaging the service data information associated with the electronic bill to obtain a to-be-verified block to be written in the block chain;
broadcasting the to-be-verified block to a consensus node on the block chain so that the consensus node performs consensus on the acquired to-be-verified block to obtain a consensus result;
and if the consensus result exceeding 1/2 in the consensus results returned by the consensus nodes indicates successful consensus, determining that the block chain nodes on the block chain achieve consensus, and writing the block to be verified into the block chain as a target block.
12. The method according to claim 1, wherein the performing, when the billing service is completed, an unlocking process on the target program after the locking process includes:
when the billing service is finished, an atomic unlocking function associated with the atomic operation interface is called, and unlocking processing is performed on the target program after locking processing, so that the distributed lock is released, and the target program is obtained through restoration;
and updating the target atomic operation result of the target program from the first parameter value to a second parameter value while releasing the distributed lock so as to complete the release of the distributed lock.
13. A data processing apparatus, comprising:
the first acquisition module is used for acquiring atomic operation interfaces associated with the K programs, calling the atomic operation interfaces to execute atomic operation on each program in the K programs, and obtaining an atomic operation result of each program participating in competition of the distributed lock; k is a positive integer; the distributed lock is used for accessing a shared resource associated with an invoicing service in a block chain; the atomic operation means to replace the lock state parameter and the default parameter in each program; the atomic operation result of each program is an agreed parameter returned by each program after the atomic operation is executed;
a first determining module, configured to obtain a target atomic operation result with a first parameter value from the atomic operation result of each program, and determine a program corresponding to the target atomic operation result as a target program;
the locking processing module is used for locking the target program through the distributed lock so that the target program after locking accesses the shared resource;
the service execution module is used for executing the billing service in the target program after the locking processing based on the shared resource; the billing service comprises the steps of selecting a target bill number from the bill number section in the shared resource and deleting the target bill number in the shared resource;
and the unlocking processing module is used for executing unlocking processing on the target program after the locking processing when the billing service is finished so as to release the distributed lock.
14. A node apparatus, comprising: a processor, a memory, a network interface;
the processor is connected to a memory for providing data communication functions, a network interface for storing a computer program, and a processor for calling the computer program to perform the method according to any one of claims 1 to 12.
15. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program comprising program instructions which, when executed by a processor, perform the method according to any one of claims 1-12.
CN202010454293.6A 2020-05-26 2020-05-26 Data processing method and device, node equipment and storage medium Active CN111639309B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010454293.6A CN111639309B (en) 2020-05-26 2020-05-26 Data processing method and device, node equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010454293.6A CN111639309B (en) 2020-05-26 2020-05-26 Data processing method and device, node equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111639309A CN111639309A (en) 2020-09-08
CN111639309B true CN111639309B (en) 2021-08-24

Family

ID=72329435

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010454293.6A Active CN111639309B (en) 2020-05-26 2020-05-26 Data processing method and device, node equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111639309B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114385761B (en) * 2022-03-23 2022-07-12 支付宝(杭州)信息技术有限公司 Consensus data storage and acquisition method and device based on consensus system
CN115145737B (en) * 2022-08-31 2022-12-30 维塔科技(北京)有限公司 Dynamic locking method, electronic device and computer readable storage medium
CN117151712B (en) * 2023-10-26 2024-03-26 腾讯科技(深圳)有限公司 Blockchain transaction processing method, device, computer equipment and storage medium
CN117520362B (en) * 2024-01-04 2024-04-12 北京佳讯飞鸿电气股份有限公司 Data management system, method, equipment and storage medium based on distributed lock

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102298539A (en) * 2011-06-07 2011-12-28 华东师范大学 Method and system for scheduling shared resources subjected to distributed parallel treatment
CN104657260A (en) * 2013-11-25 2015-05-27 航天信息股份有限公司 Achievement method for distributed locks controlling distributed inter-node accessed shared resources
CN104702655A (en) * 2014-03-21 2015-06-10 杭州海康威视系统技术有限公司 Cloud storage resource distribution method and system
CN104954411A (en) * 2014-03-31 2015-09-30 腾讯科技(深圳)有限公司 Method for sharing network resource by distributed system, terminal thereof and system thereof
CN106060060A (en) * 2016-06-22 2016-10-26 努比亚技术有限公司 Method and system for client to obtain lock
CN106293930A (en) * 2015-06-11 2017-01-04 华为技术有限公司 Method, device and the network system of a kind of signal lock distribution
CN109828847A (en) * 2019-01-25 2019-05-31 平安科技(深圳)有限公司 Lock processing method, device, computer equipment and storage medium based on block chain
CN110008031A (en) * 2018-01-05 2019-07-12 北京金山云网络技术有限公司 Apparatus operation method, group system, electronic equipment and read/write memory medium
CN110113395A (en) * 2019-04-19 2019-08-09 新华三云计算技术有限公司 Shared-file system maintaining method and device
CN110599275A (en) * 2019-09-27 2019-12-20 腾讯科技(深圳)有限公司 Data processing method and device based on block chain network and storage medium
CN112579615A (en) * 2019-09-29 2021-03-30 北京沃东天骏信息技术有限公司 Method and device for realizing distributed lock

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102298539A (en) * 2011-06-07 2011-12-28 华东师范大学 Method and system for scheduling shared resources subjected to distributed parallel treatment
CN104657260A (en) * 2013-11-25 2015-05-27 航天信息股份有限公司 Achievement method for distributed locks controlling distributed inter-node accessed shared resources
CN104702655A (en) * 2014-03-21 2015-06-10 杭州海康威视系统技术有限公司 Cloud storage resource distribution method and system
CN104954411A (en) * 2014-03-31 2015-09-30 腾讯科技(深圳)有限公司 Method for sharing network resource by distributed system, terminal thereof and system thereof
CN106293930A (en) * 2015-06-11 2017-01-04 华为技术有限公司 Method, device and the network system of a kind of signal lock distribution
CN106060060A (en) * 2016-06-22 2016-10-26 努比亚技术有限公司 Method and system for client to obtain lock
CN110008031A (en) * 2018-01-05 2019-07-12 北京金山云网络技术有限公司 Apparatus operation method, group system, electronic equipment and read/write memory medium
CN109828847A (en) * 2019-01-25 2019-05-31 平安科技(深圳)有限公司 Lock processing method, device, computer equipment and storage medium based on block chain
CN110113395A (en) * 2019-04-19 2019-08-09 新华三云计算技术有限公司 Shared-file system maintaining method and device
CN110599275A (en) * 2019-09-27 2019-12-20 腾讯科技(深圳)有限公司 Data processing method and device based on block chain network and storage medium
CN112579615A (en) * 2019-09-29 2021-03-30 北京沃东天骏信息技术有限公司 Method and device for realizing distributed lock

Also Published As

Publication number Publication date
CN111639309A (en) 2020-09-08

Similar Documents

Publication Publication Date Title
CN111639309B (en) Data processing method and device, node equipment and storage medium
US20200348921A1 (en) Microservice update system
CN110995473B (en) Service node control method and related equipment
CN111400112B (en) Writing method and device of storage system of distributed cluster and readable storage medium
CN111213135B (en) System and method for blockchain-based notification
CN111133428B (en) System and method for registering subscribed state in blockchain
US9589153B2 (en) Securing integrity and consistency of a cloud storage service with efficient client operations
CN112513900B (en) System and method for consensus management
JP7157348B2 (en) Blockchain system, approval terminal, smart contract registration method, and smart contract registration program
CN110601896B (en) Data processing method and equipment based on block chain nodes
Beller et al. Blockchain-based software engineering
CN111183444B (en) System and method for registering subscribed sub-states in a blockchain
CN111949531B (en) Block chain network testing method, device, medium and electronic equipment
CN110400217B (en) Rule change processing method and device for intelligent contract
CN112613877B (en) Intelligent contract triggering method and device applied to block chain network and related equipment
CN111899008B (en) Resource transfer method, device, equipment and system
CN112506747A (en) Business process monitoring method and device, electronic equipment and storage medium
CN116155771A (en) Network anomaly test method, device, equipment, storage medium and program
CN114971827A (en) Account checking method and device based on block chain, electronic equipment and storage medium
Gerrits et al. A Blockchain cloud architecture deployment for an industrial IoT use case
CN113011907A (en) Data processing method, device, storage medium and equipment
CN114070847A (en) Current limiting method, device, equipment and storage medium of server
CN116521509A (en) Intelligent contract testing method, device, equipment, storage medium and product
CN113592645A (en) Data verification method and device
CN113806309A (en) Metadata deleting method, system, terminal and storage medium based on distributed lock

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40028926

Country of ref document: HK

SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant