WO2020224249A1 - 基于区块链的事务处理方法、装置、设备及存储介质 - Google Patents

基于区块链的事务处理方法、装置、设备及存储介质 Download PDF

Info

Publication number
WO2020224249A1
WO2020224249A1 PCT/CN2019/121996 CN2019121996W WO2020224249A1 WO 2020224249 A1 WO2020224249 A1 WO 2020224249A1 CN 2019121996 W CN2019121996 W CN 2019121996W WO 2020224249 A1 WO2020224249 A1 WO 2020224249A1
Authority
WO
WIPO (PCT)
Prior art keywords
service terminal
target keyword
transaction processing
keyword key
transaction
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.)
Ceased
Application number
PCT/CN2019/121996
Other languages
English (en)
French (fr)
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.)
OneConnect Smart Technology Co Ltd
Original Assignee
OneConnect Smart Technology 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 OneConnect Smart Technology Co Ltd filed Critical OneConnect Smart Technology Co Ltd
Publication of WO2020224249A1 publication Critical patent/WO2020224249A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/466Transaction processing
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores
    • G06F9/524Deadlock detection or avoidance

Definitions

  • This application relates to the field of blockchain technology, in particular to a blockchain-based transaction processing method, device, equipment, and computer-readable storage medium.
  • Blockchain can generally be understood as a distributed ledger, and its essence is also a distributed database, and its bottom layer uses a persistent key value Key-Value Database.
  • Key-Value Database a persistent key value
  • the main purpose of this application is to provide a blockchain-based transaction processing method, device, equipment, and computer-readable storage medium, aiming to solve the existing technical problems that are prone to confusion and conflicts of high-concurrency data.
  • this application provides a blockchain-based transaction processing method, wherein the blockchain-based transaction processing method includes the following steps:
  • target keyword Key If the target keyword Key is not in an occupied state, write corresponding transaction data into the blockchain according to the target keyword Key;
  • the corresponding writing success information is returned to the service terminal, and the distributed lock corresponding to the target keyword Key is allocated to the service terminal for the service terminal to pass through The distributed lock executes the corresponding exclusive transaction.
  • the corresponding writing success information is returned to the service terminal, and the distributed lock corresponding to the target keyword Key is allocated to the service terminal for all
  • the step of the service terminal executing the corresponding exclusive transaction through the distributed lock includes:
  • the corresponding write success information is returned to the service terminal, and the distributed lock corresponding to the target keyword Key is allocated to the service terminal for the service terminal to pass through The distributed lock executes the corresponding exclusive transaction.
  • the present application also provides a blockchain-based transaction processing device, which includes: To
  • the status judgment module is configured to determine the corresponding target keyword Key according to the transaction processing request when receiving the transaction processing request sent by the service terminal, and determine whether the target keyword Key is in an occupied state;
  • a data writing module configured to write corresponding transaction data to the blockchain according to the target keyword Key if the target keyword Key is not in an occupied state;
  • the lock allocation module is configured to return the corresponding write success information to the service terminal when the transaction data writing is completed, and allocate the distributed lock corresponding to the target keyword Key to the service terminal to For the service terminal to execute the corresponding exclusive transaction through the distributed lock.
  • this application also provides a blockchain-based transaction processing device.
  • the blockchain-based transaction processing device includes a processor, a memory, and stored on the memory and can be used by the The computer-readable instructions executed by the processor, where the computer-readable instructions, when executed by the processor, implement the steps of the above-mentioned blockchain-based transaction processing method.
  • the present application also provides a computer-readable storage medium having computer-readable instructions stored on the computer-readable storage medium, and when the computer-readable instructions are executed by a processor, the implementation is as described above The steps of a blockchain-based transaction processing method.
  • This application provides a blockchain-based transaction processing method, that is, when a transaction processing request sent by a service terminal is received, the corresponding target keyword Key is determined according to the transaction processing request, and it is determined whether the target keyword Key is in Occupied state; if the target keyword Key is not in an occupied state, write corresponding transaction data to the blockchain according to the target keyword Key; when the transaction data writing is completed, write to the service terminal Return the corresponding write success information, and allocate the distributed lock corresponding to the target keyword Key to the service terminal, so that the service terminal can execute the corresponding exclusive transaction through the distributed lock.
  • the application when the application receives a transaction processing request from a business terminal, it controls and manages the transaction processing process through a distributed lock, so that a certain resource can only be used by one business terminal at the same time under high concurrency.
  • To execute so as to ensure the orderliness of transaction processing and the unity of data, and solve the existing technical problems that are prone to confusion and conflicts of high-concurrency data.
  • FIG. 1 is a schematic diagram of the hardware structure of a blockchain-based transaction processing device involved in the embodiment of the application;
  • FIG. 2 is a schematic flowchart of a first embodiment of a transaction processing method based on blockchain in this application;
  • FIG. 3 is a schematic flowchart of a second embodiment of a blockchain-based transaction processing method according to this application.
  • FIG. 4 is a schematic flowchart of a third embodiment of a transaction processing method based on blockchain in this application.
  • FIG. 5 is a schematic diagram of functional modules of the first embodiment of a transaction processing device based on blockchain in this application.
  • the blockchain-based transaction processing methods involved in the embodiments of this application are mainly applied to blockchain-based transaction processing equipment.
  • the blockchain-based transaction processing equipment may be a PC, a portable computer, a mobile terminal, etc., with display and processing functions device of.
  • FIG. 1 is a schematic diagram of the hardware structure of a blockchain-based transaction processing device involved in the embodiment of the application.
  • a blockchain-based transaction processing device may include a processor 1001 (for example, a CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005.
  • the communication bus 1002 is used to realize the connection and communication between these components;
  • the user interface 1003 may include a display (Display), an input unit such as a keyboard (Keyboard);
  • the network interface 1004 may optionally include a standard wired interface, a wireless interface (Such as WI-FI interface);
  • the memory 1005 can be a high-speed RAM memory or a stable memory (non-volatile memory), such as a disk memory.
  • the memory 1005 may optionally be a storage device independent of the aforementioned processor 1001.
  • Figure 1 does not constitute a limitation on the blockchain-based transaction processing equipment, and may include more or less components than shown in the figure, or combine certain components, or Different component arrangements.
  • the memory 1005 as a computer-readable storage medium in FIG. 1 may include an operating system, a network communication module, and computer-readable instructions.
  • the network communication module is mainly used to connect to the server and perform data communication with the server; and the processor 1001 can call the computer-readable instructions stored in the memory 1005 and execute the blockchain-based transactions provided by the embodiments of the present application Approach.
  • the embodiment of the application provides a transaction processing method based on blockchain.
  • FIG. 2 is a schematic flowchart of a first embodiment of a blockchain-based transaction processing method of this application.
  • the blockchain-based transaction processing method includes the following steps:
  • Step S10 upon receiving the transaction processing request sent by the service terminal, determine the corresponding target keyword Key according to the transaction processing request, and determine whether the target keyword Key is in an occupied state;
  • this application provides a blockchain-based transaction processing method.
  • a transaction processing request from a business terminal is received, the transaction processing process is controlled and managed through a distributed lock, so that a certain resource is high.
  • concurrency it can only be executed by one service terminal at the same time, so as to ensure the orderliness of transaction processing and the unity of data, and thus solve the existing technical problems of confusion and conflicts that easily produce high concurrent data.
  • the transaction processing method based on the blockchain of this application is applied to the blockchain business system (blockchain business platform).
  • the steps of the transaction processing method can be realized through smart contracts.
  • the blockchain business system is preset with smart Contract, smart contract can be understood as a collection of code and data, stored in the blockchain node; smart contract can automatically perform some functions driven by time or events, such as the ability to transfer information between nodes and modify the area The state of the blockchain (account information, etc.), and Turing complete calculations (all things that can be done with Turing machines, in general, all things that can be done by general programming languages), etc.
  • For each business participant of the blockchain business system they can access the corresponding blockchain node through their respective business terminals and send related business operation instructions to the smart contract of the blockchain business system.
  • a business participant when a business participant needs to perform data write operations on the blockchain business system (operate on a certain resource), it can use a certain business terminal (such as PC, laptop, mobile phone, tablet, etc.)
  • the smart contract of the blockchain sends transaction processing requests.
  • For the transaction processing request there are transaction objects that need to be processed.
  • the bottom layer of the blockchain uses a persistent key value Key-Value Database, and the distributed lock used to control the transaction processing flow in this application is set with a keyword (Key), so the transaction object in the transaction processing request may include the target keyword Key.
  • the blockchain business system When the blockchain business system (smart contract) receives the transaction processing request, it will first determine the corresponding target keyword Key according to the transaction processing request, and then query whether the target keyword Key already exists in the blockchain ; If it already exists, it can be considered that the target keyword is occupied, and the corresponding lock acquisition failure prompt can be returned to the service terminal; if it does not exist, it can be considered that the target keyword is not in the occupied state, and you can proceed The next step is to write data.
  • the blockchain business system smart contract
  • Step S20 If the target keyword Key is not in an occupied state, write corresponding transaction data to the blockchain according to the target keyword Key;
  • the blockchain business system when it is determined that the target keyword Key is not in an occupied state, the blockchain business system will write corresponding transaction data into the blockchain according to the target keyword Key. It is worth noting that when it is determined that the target keyword Key is not in the occupied state, the corresponding distributed lock is not immediately assigned to the service terminal, but the data writing operation is first attempted.
  • Step S30 When the transaction data writing is completed, the corresponding writing success information is returned to the service terminal, and the distributed lock corresponding to the target keyword Key is allocated to the service terminal for the service terminal The service terminal executes the corresponding exclusive transaction through the distributed lock.
  • the blockchain business system when the transaction data is written, can determine that the exclusive operation qualification corresponding to the target keyword Key is granted to the business terminal, and the blockchain business system will return the corresponding to the business terminal.
  • the successful write information of the target keyword Key is assigned to the service terminal, so that the service terminal can execute the corresponding exclusive transaction through the distributed lock.
  • the service terminal receives the write success message, it can perform the logical operation of the specific transaction.
  • the business terminal When the operation is completed, the business terminal will send the corresponding operation completion information to the blockchain business system, and the blockchain business system will release the distributed lock according to the operation completion information so that other business terminals can regain the distribution Type lock for operation.
  • step S30 it further includes:
  • the distributed lock is forcibly recovered to release the lock resource of the distributed lock by the service terminal.
  • a timeout period can be preset, that is, a preset time threshold, such as 2 minutes or 30 minutes, etc.
  • the preset time threshold can be correspondingly set according to the actual transaction type.
  • This embodiment provides a blockchain-based transaction processing method, that is, when a transaction processing request sent by a service terminal is received, the corresponding target keyword Key is determined according to the transaction processing request, and whether the target keyword Key is determined Is in an occupied state; if the target keyword Key is not in an occupied state, the corresponding transaction data is written to the blockchain according to the target keyword Key; when the transaction data writing is completed, the transaction data is written to the business
  • the terminal returns corresponding write success information, and allocates the distributed lock corresponding to the target keyword Key to the service terminal, so that the service terminal can execute the corresponding exclusive transaction through the distributed lock.
  • the application when the application receives a transaction processing request from a business terminal, it controls and manages the transaction processing process through a distributed lock, so that a certain resource can only be used by one business terminal at the same time under high concurrency.
  • To execute so as to ensure the orderliness of transaction processing and the unity of data, and solve the existing technical problems that are prone to confusion and conflicts of high-concurrency data.
  • FIG. 3 is a schematic flowchart of a second embodiment of a blockchain-based transaction processing method of this application.
  • the step S30 includes:
  • Step S31 when the transaction data writing is completed, obtain the number of service terminals that write transaction data into the target keyword Key, and determine whether the number of service terminals is unique;
  • an allocation rule is formulated, that is, the distributed lock is assigned to the service terminal that is written first.
  • the distribution rule may also be to assign the distributed lock first
  • the service terminal, etc., up to the time when the transaction processing request is first initiated, that is, the distribution rule of the distributed lock can be set according to actual service requirements. Specifically, when it is detected that the transaction data writing is completed, the number of service terminals that write transaction data into the target keyword Key is acquired, that is, it is determined whether the service terminal that writes data to the distributed lock is Two or more than two.
  • Step S32 If the number of service terminals is unique, return corresponding write success information to the service terminal, and allocate the distributed lock corresponding to the target keyword Key to the service terminal for the service The terminal executes the corresponding exclusive transaction through the distributed lock.
  • the distributed lock corresponding to the target keyword Key can be directly assigned to the service terminal. Specifically, Return the corresponding write success information to the service terminal, that is, notify the service terminal that the request for the lock resource of the distributed lock is successful, and then the distributed lock corresponding to the target keyword Key can be allocated to the service Terminal, for the service terminal to execute the corresponding exclusive transaction through the distributed lock.
  • Step S33 If the number of service terminals is not unique, return corresponding write success information to the first completed service terminal, and allocate the distributed lock corresponding to the target keyword Key to the first completed The service terminal for the first completed service terminal to execute the corresponding exclusive transaction through the distributed lock.
  • the blockchain business system will The service terminal that first completes the data writing operation returns a write success message, and assigns the distributed lock to the service terminal that completes the writing first.
  • step S33 it further includes:
  • write failure information will be returned to it to indicate that the distributed lock has been acquired by other service terminals At this time, these non-first completed service terminals can try to operate on another resource (another keyword), or wait for the distributed lock to be released.
  • FIG. 4 is a schematic flowchart of a third embodiment of a blockchain-based transaction processing method of this application.
  • the step S10 specifically includes:
  • Step S11 when receiving a transaction processing request sent by the service terminal, determine the corresponding target keyword Key according to the transaction processing request;
  • the transaction object in the transaction processing request may include the target keyword Key.
  • the blockchain business system smart contract
  • receives the transaction processing request it should first determine the corresponding target keyword Key according to the transaction processing request, and then query whether the target keyword Key already exists in the blockchain.
  • Step S12 judging whether the target keyword Key already exists in the blockchain, to determine whether the target keyword Key is in an occupied state
  • the target keyword Key is in an occupied state by determining whether the target keyword Key already exists in the blockchain.
  • Step S13 If the target keyword Key is in an occupied state, a corresponding lock acquisition failure prompt is returned to the service terminal.
  • the target keyword is occupied, and the corresponding lock acquisition failure prompt can be returned to the service terminal at this time; if it does not exist, it can be considered that the target keyword is not in the occupied state. At this time, the next data writing operation can be performed.
  • step S10 specifically includes:
  • the user identity information has the transaction processing authority corresponding to the transaction processing request, determine the corresponding target keyword Key according to the transaction processing request, and determine whether the target keyword Key is in an occupied state;
  • a corresponding non-authorization prompt is returned to the service terminal.
  • the blockchain business system when it receives the transaction processing request, it can first verify the authority of the user performing the operation, that is, obtain the user identity information corresponding to the business terminal, such as account information or user name, etc. , To compare the user identity information with the information of the authorized user with transaction processing authority corresponding to the transaction processing request to determine whether the user has the transaction processing authority corresponding to the transaction processing request, such as data modification/deletion Permissions. If so, the operation of determining the corresponding target keyword Key according to the transaction processing request and determining whether the target keyword Key is in an occupied state is performed. Otherwise, the corresponding non-authority prompt will be returned to the service terminal; of course, for different transactions, the operation authority may be different.
  • the embodiment of the present application also provides a transaction processing device based on blockchain.
  • FIG. 5 is a schematic diagram of the functional modules of the first embodiment of a transaction processing device based on blockchain in this application.
  • the blockchain-based transaction processing device includes:
  • the status judgment module 10 is configured to determine the corresponding target keyword Key according to the transaction processing request when receiving a transaction processing request sent by the service terminal, and determine whether the target keyword Key is in an occupied state;
  • the data writing module 20 is configured to write corresponding transaction data to the blockchain according to the target keyword Key if the target keyword Key is not in an occupied state;
  • the lock allocation module 30 is configured to return the corresponding write success information to the service terminal when the transaction data writing is completed, and allocate the distributed lock corresponding to the target keyword Key to the service terminal, For the service terminal to execute the corresponding exclusive transaction through the distributed lock.
  • block chain-based transaction processing device includes:
  • a processing time judgment module configured to obtain the holding time of the distributed lock by the service terminal, and determine whether the holding time exceeds a preset time threshold;
  • the timeout resource release module is configured to, if the holding time exceeds a preset time threshold, forcibly reclaim the distributed lock, so as to release the locked resource of the distributed lock by the service terminal.
  • lock distribution module 30 specifically includes:
  • a terminal quantity judging unit configured to obtain the number of service terminals that write the transaction data into the target keyword Key when the transaction data is written, and determine whether the number of service terminals is unique;
  • the first allocation unit is configured to, if the number of service terminals is unique, return corresponding write success information to the service terminal, and allocate the distributed lock corresponding to the target keyword Key to the service terminal to For the service terminal to execute the corresponding exclusive transaction through the distributed lock.
  • the second allocation unit is configured to, if the number of service terminals is not unique, return corresponding write success information to the first completed service terminal, and allocate the distributed lock corresponding to the target keyword Key to all The first completed service terminal is used for the first completed service terminal to execute the corresponding exclusive transaction through the distributed lock.
  • lock distribution module 30 is also used for:
  • state judgment module 10 specifically includes:
  • the keyword determining unit is configured to determine the corresponding target keyword Key according to the transaction processing request when the transaction processing request sent by the service terminal is received;
  • Occupancy judging unit used to judge whether the target keyword Key already exists in the blockchain, to judge whether the target keyword Key is in an occupied state
  • the failure prompt unit is configured to return a corresponding lock acquisition failure prompt to the service terminal if the target keyword Key is in an occupied state.
  • state judgment module 10 is also used for:
  • the user identity information has the transaction processing authority corresponding to the transaction processing request, determine the corresponding target keyword Key according to the transaction processing request, and determine whether the target keyword Key is in an occupied state;
  • a corresponding non-authorization prompt is returned to the service terminal.
  • each module in the above-mentioned blockchain-based transaction processing device corresponds to each step in the above-mentioned blockchain-based transaction processing method embodiment, and its functions and implementation processes are not repeated here.
  • the embodiments of the present application also provide a computer-readable storage medium, and the computer-readable storage medium may be a non-volatile readable storage medium.
  • the computer-readable storage medium of the present application stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the steps of the above-mentioned blockchain-based transaction processing method are realized.
  • the method implemented when the computer-readable instruction is executed can refer to the various embodiments of the blockchain-based transaction processing method of this application, which will not be repeated here.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种基于区块链的事务处理方法、装置、设备及存储介质,所述方法包括:在接收到业务中断发送的事物处理请求时,根据所述事务处理请求确定对应目标关键字Key,并判断所述目标关键字Key是否处于占用状态(S10);若不处于占用状态,则根据所述目标关键字Key向区块链中写入对应的事务数据(S20);当所述事务数据写入完成时,向所述业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述业务终端,以供所述业务终端通过所述分布式锁执行对应的排他性事务(S30)。所述方法基于区块链对应的分布式账本的特性,通过分布式锁的方式对事务处理过程进行控制和管理,使得某一项资源在高并发情况下同一时间只能被一个业务终端去执行,从而保证事务处理的有序性和数据的统一性。

Description

基于区块链的事务处理方法、装置、设备及存储介质
本申请要求于2019年05月07日提交中国专利局、申请号为201910376443.3、发明名称为“基于区块链的事务处理方法、装置、设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及区块链技术领域,尤其涉及一种基于区块链的事务处理方法、装置、设备及计算机可读存储介质。
背景技术
区块链一般可理解为一个分布式账本,它的本质也是一个分布式的数据库,其底层使用的是一个持久化的键值Key-Value 数据库。目前,采用区块链技术进行数据和管理已经开始逐渐应用到了不同的实际业务场景中。在联盟链的情况下,各个机构都可以部署自己的区块链应用。但在实际业务中,容易产生高并发数据的混乱和冲突,影响业务的正常运行。
因此,如何解决现有容易产生高并发数据的混乱和冲突的问题,是目前亟需解决的问题。
发明内容
本申请的主要目的在于提供一种基于区块链的事务处理方法、装置、设备及计算机可读存储介质,旨在解决现有容易产生高并发数据的混乱和冲突的技术问题。
为实现上述目的,本申请提供一种基于区块链的事务处理方法,其中,所述基于区块链的事务处理方法包括以下步骤:
在接收到业务终端发送的事务处理请求时,根据所述事务处理请求确定对应目标关键字Key,并判断所述目标关键字Key是否处于占用状态;
若所述目标关键字Key不处于占用状态,则根据所述目标关键字Key向区块链中写入对应的事务数据;
当所述事务数据写入完成时,向所述业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述业务终端,以供所述业务终端通过所述分布式锁执行对应的排他性事务。
其中,所述当所述事务数据写入完成时,向所述业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述业务终端,以供所述业务终端通过所述分布式锁执行对应的排他性事务的步骤包括:
当所述事务数据写入完成时,获取向所述目标关键字Key中写入事务数据的业务终端数量,并判断所述业务终端数量是否唯一;
若所述业务终端数量唯一,则向所述业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述业务终端,以供所述业务终端通过所述分布式锁执行对应的排他性事务。
此外,为实现上述目的,本申请还提供一种基于区块链的事务处理装置,所述基于区块链的事务处理装置包括:
状态判断模块,用于在接收到业务终端发送的事务处理请求时,根据所述事务处理请求确定对应目标关键字Key,并判断所述目标关键字Key是否处于占用状态;
数据写入模块,用于若所述目标关键字Key不处于占用状态,则根据所述目标关键字Key向区块链中写入对应的事务数据;
锁分配模块,用于当所述事务数据写入完成时,向所述业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述业务终端,以供所述业务终端通过所述分布式锁执行对应的排他性事务。
此外,为实现上述目的,本申请还提供一种基于区块链的事务处理设备,所述基于区块链的事务处理设备包括处理器、存储器、以及存储在所述存储器上并可被所述处理器执行的计算机可读指令,其中所述计算机可读指令被所述处理器执行时,实现如上述的基于区块链的事务处理方法的步骤。
此外,为实现上述目的,本申请还提供一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机可读指令,其中所述计算机可读指令被处理器执行时,实现如上述的基于区块链的事务处理方法的步骤。
本申请提供一种基于区块链的事务处理方法,即在接收到业务终端发送的事务处理请求时,根据所述事务处理请求确定对应目标关键字Key,并判断所述目标关键字Key是否处于占用状态;若所述目标关键字Key不处于占用状态,则根据所述目标关键字Key向区块链中写入对应的事务数据;当所述事务数据写入完成时,向所述业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述业务终端,以供所述业务终端通过所述分布式锁执行对应的排他性事务。通过上述方式,本申请在接收到业务终端的事务处理请求时,通过分布式锁的方式对事务处理过程进行控制和管理,使得某一项资源在高并发情况下同一时间只能被一个业务终端去执行,从而保证事务处理的有序性和数据的统一性,解决了现有容易产生高并发数据的混乱和冲突的技术问题。
附图说明
图1为本申请实施例方案中涉及的基于区块链的事务处理设备的硬件结构示意图;
图2为本申请基于区块链的事务处理方法第一实施例的流程示意图;
图3为本申请基于区块链的事务处理方法第二实施例的流程示意图;
图4为本申请基于区块链的事务处理方法第三实施例的流程示意图;
图5为本申请基于区块链的事务处理装置第一实施例的功能模块示意图。
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。
具体实施方式
应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。
本申请实施例涉及的基于区块链的事务处理方法主要应用于基于区块链的事务处理设备,该基于区块链的事务处理设备可以是PC、便携计算机、移动终端等具有显示和处理功能的设备。
参照图1,图1为本申请实施例方案中涉及的基于区块链的事务处理设备的硬件结构示意图。本申请实施例中,基于区块链的事务处理设备可以包括处理器1001(例如CPU),通信总线1002,用户接口1003,网络接口1004,存储器1005。其中,通信总线1002用于实现这些组件之间的连接通信;用户接口1003可以包括显示屏(Display)、输入单元比如键盘(Keyboard);网络接口1004可选的可以包括标准的有线接口、无线接口(如WI-FI接口);存储器1005可以是高速RAM存储器,也可以是稳定的存储器(non-volatile memory),例如磁盘存储器,存储器1005可选的还可以是独立于前述处理器1001的存储装置。
本领域技术人员可以理解,图1中示出的硬件结构并不构成对基于区块链的事务处理设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。
继续参照图1,图1中作为一种计算机可读存储介质的存储器1005可以包括操作系统、网络通信模块以及计算机可读指令。
在图1中,网络通信模块主要用于连接服务器,与服务器进行数据通信;而处理器1001可以调用存储器1005中存储的计算机可读指令,并执行本申请实施例提供的基于区块链的事务处理方法。
本申请实施例提供了一种基于区块链的事务处理方法。
参照图2,图2为本申请基于区块链的事务处理方法第一实施例的流程示意图。
本实施例中,所述基于区块链的事务处理方法包括以下步骤:
步骤S10,在接收到业务终端发送的事务处理请求时,根据所述事务处理请求确定对应目标关键字Key,并判断所述目标关键字Key是否处于占用状态;
目前,采用区块链技术进行数据和管理已经开始逐渐应用到了不同的实际业务场景中。在联盟链的情况下,各个机构都可以部署自己的区块链应用。但在实际业务中,需要保证这些区块链应用在同一时刻只能有一个对同一项资源进行操作,否则会容易产生高并发数据的混乱和冲突,影响业务的正常运行。对此,本申请提供一种基于区块链的事务处理方法,在接收到业务终端的事务处理请求时,通过分布式锁的方式对事务处理过程进行控制和管理,使得某一项资源在高并发情况下同一时间只能被一个业务终端去执行,从而保证事务处理的有序性和数据的统一性,并由此解决了现有容易产生高并发数据的混乱和冲突的技术问题。
本申请基于区块链的事务处理方法应用在区块链业务系统(区块链业务平台),该事务处理方法的各步骤则可以是通过智能合约实现,区块链业务系统中预先设置有智能合约,智能合约可理解为是代码和数据的集合,寄存与区块链节点中;智能合约在时间或事件的驱动下能自动执行一些功能,如可以在各节点之间相互传递信息,修改区块链的状态(账户信息等),以及图灵完备计算(可以用图灵机做到的所有事情,通俗来说就是一般编程语言可以做的所有事情)等。而对于该区块链业务系统的各业务参与方,则可通过各自的业务终端访问对应的区块链节点,并向区块链业务系统的智能合约发送相关的业务操作指令。具体的,当某一业务参与方需要对区块链业务系统执行数据写入操作(对某一项资源进行操作),可通过某一业务终端(如PC、笔记本电脑、手机、平板等)向区块链的智能合约发送事务处理请求。对于该事务处理请求,包括有需要进行处理的事务对象。由于区块链底层使用的是一个持久化的键值Key-Value 数据库,而本申请中用以控制事务处理流程所用的分布式锁是以关键字(Key)进行设置,因此该事务处理请求中的事务对象可以包括目标关键字Key。区块链业务系统(智能合约)接收到该事务处理请求时,首先将可根据该事务处理请求确定对应的目标关键字Key,然后将会查询该目标关键字Key在区块链中是否已存在;若已存在,则可认为该目标关键字已占用,此时可向业务终端返回对应的获取锁失败提示;而若不存在,则可认为该目标关键字不处于占用状态,此时可进行下一步数据写入操作。
步骤S20,若所述目标关键字Key不处于占用状态,则根据所述目标关键字Key向区块链中写入对应的事务数据;
本实施例中,当判断目标关键字Key不处于占用状态时,区块链业务系统将会根据该目标关键字Key向区块链中写入对应的事务数据。值得说明的是,当判断目标关键字Key不处于占用状态时,并未立即向业务终端分配对应的分布式锁,而是先尝试进行数据写入操作。
步骤S30,当所述事务数据写入完成时,向所述业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述业务终端,以供所述业务终端通过所述分布式锁执行对应的排他性事务。
本实施例中,当事务数据写入完成时,区块链业务系统即可确定将该目标关键字Key对应的排他性操作资格授予该业务终端,对此区块链业务系统会向业务终端返回对应的写入成功信息,并将该目标关键字Key对应的分布式锁分配至给业务终端,以供业务终端通过该分布式锁执行对应的排他性事务。业务终端在接收到该写入成功信息时,即可进行具体事务的逻辑操作。当操作完成时,该业务终端将向区块链业务系统发送对应的操作完成信息,区块链业务系统则根据该操作完成信息释放该分布式锁,以使得其他的业务终端可重新获取该分布式锁进行操作。
进一步地,所述步骤S30之后,还包括:
获取所述业务终端对所述分布式锁的持有时间,并判断所述持有时间是否超过预设时间阈值;
若所述持有时间超过预设时间阈值,则强制回收所述分布式锁,以释放所述业务终端对所述分布式锁的锁定资源。
本实施例中,对于该分布式锁,可以预设一超时时间,即预设时间阈值,如2分钟或30分钟等,所述预设时间阈值可以根据实际事务类型进行对应设置。当业务终端获取该分布式锁并进行事务操作时,通过计时器对所述业务终端对所述分布式锁的持有时间进行计时。若所述持有时间超过该预设时间阈值,仍未完成该事务操作,则区块链业务系统会强制释放该分布式锁,也即释放掉该锁定资源,回收所述分布式锁的资源,并将所述分布式锁进行重新分配,避免资源长时间占用造成的其它问题。
本实施例提供一种基于区块链的事务处理方法,即在接收到业务终端发送的事务处理请求时,根据所述事务处理请求确定对应目标关键字Key,并判断所述目标关键字Key是否处于占用状态;若所述目标关键字Key不处于占用状态,则根据所述目标关键字Key向区块链中写入对应的事务数据;当所述事务数据写入完成时,向所述业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述业务终端,以供所述业务终端通过所述分布式锁执行对应的排他性事务。通过上述方式,本申请在接收到业务终端的事务处理请求时,通过分布式锁的方式对事务处理过程进行控制和管理,使得某一项资源在高并发情况下同一时间只能被一个业务终端去执行,从而保证事务处理的有序性和数据的统一性,解决了现有容易产生高并发数据的混乱和冲突的技术问题。
参照图3,图3为本申请基于区块链的事务处理方法第二实施例的流程示意图。
基于上述图2所示实施例,本实施例中,所述步骤S30包括:
步骤S31,当所述事务数据写入完成时,获取向所述目标关键字Key中写入事务数据的业务终端数量,并判断所述业务终端数量是否唯一;
本实施例中,为了避免多个业务终端占用所述分布式锁,导致同一时刻有多个业务终端对同一项资源进行操作,造成数据混乱和冲突,在两个及以上的业务终端就同一目标关键字Key进行事务数据写入操作时,制定一分配规则,即优先将分布式锁分配至该最先写入完成的业务终端,具体实施例中,分配规则还可以是优先将分布式锁分配至最先发起事务处理请求的时间的业务终端等,即所述分布式锁的分配规则可以根据实际业务需求进行设置。具体地,在检测到所述事务数据写入完成时,获取向所述目标关键字Key中写入事务数据的业务终端数量,即判断向所述分布式锁进行写入数据操作的业务终端是否为两个或者两个以上。
步骤S32,若所述业务终端数量唯一,则向所述业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述业务终端,以供所述业务终端通过所述分布式锁执行对应的排他性事务。
本实施例中,在判定只有一个业务终端向所述分布式锁进行写入数据操作时,即可直接将所述目标关键字Key对应的分布式锁分配至所述业务终端,具体地,可向所述业务终端返回对应的写入成功信息,即通知所述业务终端请求所述分布式锁的锁定资源成功,然后即可将所述目标关键字Key对应的分布式锁分配至所述业务终端,以供所述业务终端通过所述分布式锁执行对应的排他性事务。
步骤S33,若所述业务终端数量不唯一,则向所述最先完成的业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述最先完成的业务终端,以供所述最先完成的业务终端通过所述分布式锁执行对应的排他性事务。
本实施例中,若判定所述业务终端数据为两个或者两个以上,则需要按照预设分配规则,将所述分布式锁分配至对应的业务终端。具体地,对于同一资源(同一关键字Key),若同时有两个以上(此处“以上”包括本数)的业务终端就同一关键字Key需要进行数据写入操作,区块链业务系统会向最先完成数据写入操作的业务终端返回写入成功信息,并将分布式锁分配至该最先写入完成的业务终端。
进一步地,所述步骤S33之后,还包括:
向所述最先完成的业务终端以外的其他业务终端返回写入失败信息,并将所述其他业务终端的终端标识添加至所述目标关键字Key对应的待分配列表,以在所述分布式锁被释放后将所述分布式锁对应分配至所述其他业务终端。
本实施例中,而对于非最先完成的业务终端,即最先完成的业务终端以外的其他业务终端,则会向其返回写入失败信息,以说明该分布式锁已被其它业务终端获得,此时这些非最先完成的业务终端可以尝试对另一资源(另一个关键字)进行操作,或是等待该分布式锁被释放。
参照图4,图4为本申请基于区块链的事务处理方法第三实施例的流程示意图。
基于上述图2所示实施例,本实施例中,所述步骤S10具体包括:
步骤S11,在接收到业务终端发送的事务处理请求时,根据所述事务处理请求确定对应的目标关键字Key;
本实施例中,由于区块链底层使用的是一个持久化的键值Key-Value 数据库,而本申请中用以控制事务处理流程所用的分布式锁是以关键字(Key)进行设置,因此该事务处理请求中的事务对象可以包括目标关键字Key。区块链业务系统(智能合约)接收到该事务处理请求时,首先应根据该事务处理请求确定对应的目标关键字Key,然后将会查询该目标关键字Key在区块链中是否已存在。
步骤S12,判断区块链中所述目标关键字Key是否已存在,以判断所述目标关键字Key是否处于已占用状态;
本实施例中,若已存在,则可认为该目标关键字已占用,而若不存在,则可认为该目标关键字不处于占用状态。由此,可通过判断区块链中所述目标关键字Key是否已存在,以判断所述目标关键字Key是否处于已占用状态。
步骤S13,若所述目标关键字Key处于占用状态,则向业务终端返回对应的获取锁失败提示。
本实施例中,若已存在,则可认为该目标关键字已占用,此时可向业务终端返回对应的获取锁失败提示;而若不存在,则可认为该目标关键字不处于占用状态,此时可进行下一步数据写入操作。
进一步地,所述步骤S10具体包括:
在接收到业务终端发送的事务处理请求时,获取所述业务终端对应的用户身份信息,并判断所述用户身份信息是否具有所述事务处理请求对应的事务处理权限;
若所述用户身份信息具有所述事务处理请求对应的事务处理权限,则根据所述事务处理请求确定对应目标关键字Key,并判断所述目标关键字Key是否处于占用状态;
若所述用户身份信息不具有所述事务处理请求对应的事务处理权限,则向业务终端返回对应的无权限提示。
本实施例中,区块链业务系统在接收到该事务处理请求时,可先对进行该操作的用户进行权限验证,即获取所述业务终端对应的用户身份信息,如账号信息或者用户名等,将所述用户身份信息与所述事务处理请求对应的具有事务处理权限的权限用户信息进行比对,以判断该用户是否具有所述事务处理请求对应的事务处理权限,如数据修改/删除的权限。若有,才会进行根据所述事务处理请求确定对应目标关键字Key,并判断所述目标关键字Key是否处于占用状态的操作。否则将向业务终端返回对应的无权限提示;当然对于不同的事务,其操作权限可能会具有区别。
此外,本申请实施例还提供一种基于区块链的事务处理装置。
参照图5,图5为本申请基于区块链的事务处理装置第一实施例的功能模块示意图。
本实施例中,所述基于区块链的事务处理装置包括:
状态判断模块10,用于在接收到业务终端发送的事务处理请求时,根据所述事务处理请求确定对应目标关键字Key,并判断所述目标关键字Key是否处于占用状态;
数据写入模块20,用于若所述目标关键字Key不处于占用状态,则根据所述目标关键字Key向区块链中写入对应的事务数据;
锁分配模块30,用于当所述事务数据写入完成时,向所述业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述业务终端,以供所述业务终端通过所述分布式锁执行对应的排他性事务。
进一步地,所述基于区块链的事务处理装置包括:
处理时间判断模块,用于获取所述业务终端对所述分布式锁的持有时间,并判断所述持有时间是否超过预设时间阈值;
超时资源释放模块,用于若所述持有时间超过预设时间阈值,则强制回收所述分布式锁,以释放所述业务终端对所述分布式锁的锁定资源。
进一步地,所述锁分配模块30具体包括:
终端数量判断单元,用于当所述事务数据写入完成时,获取向所述目标关键字Key中写入事务数据的业务终端数量,并判断所述业务终端数量是否唯一;
第一分配单元,用于若所述业务终端数量唯一,则向所述业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述业务终端,以供所述业务终端通过所述分布式锁执行对应的排他性事务。
第二分配单元,用于若所述业务终端数量不唯一,则向所述最先完成的业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述最先完成的业务终端,以供所述最先完成的业务终端通过所述分布式锁执行对应的排他性事务。
进一步地,所述锁分配模块30还用于:
向所述最先完成的业务终端以外的其他业务终端返回写入失败信息,并将所述其他业务终端的终端标识添加至所述目标关键字Key对应的待分配列表,以在所述分布式锁被释放后将所述分布式锁对应分配至所述其他业务终端。
进一步地,所述状态判断模块10具体包括:
关键字确定单元,用于在接收到业务终端发送的事务处理请求时,根据所述事务处理请求确定对应的目标关键字Key;
占用判断单元,用于判断区块链中所述目标关键字Key是否已存在,以判断所述目标关键字Key是否处于已占用状态;
失败提示单元,用于若所述目标关键字Key处于占用状态,则向业务终端返回对应的获取锁失败提示。
进一步地,所述状态判断模块10还用于:
在接收到业务终端发送的事务处理请求时,获取所述业务终端对应的用户身份信息,并判断所述用户身份信息是否具有所述事务处理请求对应的事务处理权限;
若所述用户身份信息具有所述事务处理请求对应的事务处理权限,则根据所述事务处理请求确定对应目标关键字Key,并判断所述目标关键字Key是否处于占用状态;
若所述用户身份信息不具有所述事务处理请求对应的事务处理权限,则向业务终端返回对应的无权限提示。
其中,上述基于区块链的事务处理装置中各个模块与上述基于区块链的事务处理方法实施例中各步骤相对应,其功能和实现过程在此处不再一一赘述。
此外,本申请实施例还提供一种计算机可读存储介质,计算机可读存储介质可以为非易失性可读存储介质。
本申请计算机可读存储介质上存储有计算机可读指令,其中所述计算机可读指令被处理器执行时,实现如上述的基于区块链的事务处理方法的步骤。
其中,计算机可读指令被执行时所实现的方法可参照本申请基于区块链的事务处理方法的各个实施例,此处不再赘述。
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者系统不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者系统所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者系统中还存在另外的相同要素。
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在如上所述的一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本申请各个实施例所述的方法。
以上仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。

Claims (20)

  1. 一种基于区块链的事务处理方法,其中,所述基于区块链的事务处理方法包括以下步骤:
    在接收到业务终端发送的事务处理请求时,根据所述事务处理请求确定对应目标关键字Key,并判断所述目标关键字Key是否处于占用状态;
    若所述目标关键字Key不处于占用状态,则根据所述目标关键字Key向区块链中写入对应的事务数据;
    当所述事务数据写入完成时,向所述业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述业务终端,以供所述业务终端通过所述分布式锁执行对应的排他性事务;
    其中,所述当所述事务数据写入完成时,向所述业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述业务终端,以供所述业务终端通过所述分布式锁执行对应的排他性事务的步骤包括:
    当所述事务数据写入完成时,获取向所述目标关键字Key中写入事务数据的业务终端数量,并判断所述业务终端数量是否唯一;
    若所述业务终端数量唯一,则向所述业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述业务终端,以供所述业务终端通过所述分布式锁执行对应的排他性事务。
  2. 如权利要求1所述的基于区块链的事务处理方法,其中,所述当所述事务数据写入完成时,获取向所述目标关键字Key中写入事务数据的业务终端数量,并判断所述业务终端数量是否唯一的步骤之后,还包括:
    若所述业务终端数量不唯一,则向所述最先完成的业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述最先完成的业务终端,以供所述最先完成的业务终端通过所述分布式锁执行对应的排他性事务。
  3. 如权利要求2所述的基于区块链的事务处理方法,其中,所述在若所述业务终端数量不唯一,则向所述最先完成的业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述最先完成的业务终端,以供所述最先完成的业务终端通过所述分布式锁执行对应的排他性事务的步骤之后,还包括:
    向所述最先完成的业务终端以外的其他业务终端返回写入失败信息,并将所述其他业务终端的终端标识添加至所述目标关键字Key对应的待分配列表,以在所述分布式锁被释放后将所述分布式锁对应分配至所述其他业务终端。
  4. 如权利要求1所述的基于区块链的事务处理方法,其中,所述在接收到业务终端发送的事务处理请求时,根据所述事务处理请求确定对应目标关键字Key,并判断所述目标关键字Key是否处于占用状态的步骤包括:
    在接收到业务终端发送的事务处理请求时,根据所述事务处理请求确定对应的目标关键字Key;
    判断区块链中所述目标关键字Key是否已存在,以判断所述目标关键字Key是否处于已占用状态;
    若所述目标关键字Key处于占用状态,则向业务终端返回对应的获取锁失败提示。
  5. 如权利要求1所述的基于区块链的事务处理方法,其中,所述当所述事务数据写入完成时,向所述业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述业务终端,以供所述业务终端通过所述分布式锁执行对应的排他性事务的步骤之后,还包括:
    获取所述业务终端对所述分布式锁的持有时间,并判断所述持有时间是否超过预设时间阈值;
    若所述持有时间超过预设时间阈值,则强制回收所述分布式锁,以释放所述业务终端对所述分布式锁的锁定资源。
  6. 如权利要求1所述的基于区块链的事务处理方法,其中,所述在接收到业务终端发送的事务处理请求时,根据所述事务处理请求确定对应目标关键字Key,并判断所述目标关键字Key是否处于占用状态的步骤具体包括:
    在接收到业务终端发送的事务处理请求时,获取所述业务终端对应的用户身份信息,并判断所述用户身份信息是否具有所述事务处理请求对应的事务处理权限;
    若所述用户身份信息具有所述事务处理请求对应的事务处理权限,则根据所述事务处理请求确定对应目标关键字Key,并判断所述目标关键字Key是否处于占用状态;
    若所述用户身份信息不具有所述事务处理请求对应的事务处理权限,则向业务终端返回对应的无权限提示。
  7. 一种基于区块链的事务处理装置,其中,所述基于区块链的事务处理装置包括:
    状态判断模块,用于在接收到业务终端发送的事务处理请求时,根据所述事务处理请求确定对应目标关键字Key,并判断所述目标关键字Key是否处于占用状态;
    数据写入模块,用于若所述目标关键字Key不处于占用状态,则根据所述目标关键字Key向区块链中写入对应的事务数据;
    锁分配模块,用于当所述事务数据写入完成时,向所述业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述业务终端,以供所述业务终端通过所述分布式锁执行对应的排他性事务。
  8. 如权利要求7所述的所述基于区块链的事务处理装置,其中,基于区块链的事务处理装置包括:
    处理时间判断模块,用于获取所述业务终端对所述分布式锁的持有时间,并判断所述持有时间是否超过预设时间阈值;
    超时资源释放模块,用于若所述持有时间超过预设时间阈值,则强制回收所述分布式锁,以释放所述业务终端对所述分布式锁的锁定资源。
  9. 如权利要求8所述的所述基于区块链的事务处理装置,其中,所述锁分配模块具体包括:
    终端数量判断单元,用于当所述事务数据写入完成时,获取向所述目标关键字Key中写入事务数据的业务终端数量,并判断所述业务终端数量是否唯一;
    第一分配单元,用于若所述业务终端数量唯一,则向所述业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述业务终端,以供所述业务终端通过所述分布式锁执行对应的排他性事务;
    第二分配单元,用于若所述业务终端数量不唯一,则向所述最先完成的业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述最先完成的业务终端,以供所述最先完成的业务终端通过所述分布式锁执行对应的排他性事务。
  10. 如权利要求7所述的所述基于区块链的事务处理装置,其中,所述锁分配模块还用于:
    向所述最先完成的业务终端以外的其他业务终端返回写入失败信息,并将所述其他业务终端的终端标识添加至所述目标关键字Key对应的待分配列表,以在所述分布式锁被释放后将所述分布式锁对应分配至所述其他业务终端。
  11. 如权利要求7所述的所述基于区块链的事务处理装置,其中,所述状态判断模块具体包括:
    关键字确定单元,用于在接收到业务终端发送的事务处理请求时,根据所述事务处理请求确定对应的目标关键字Key;
    占用判断单元,用于判断区块链中所述目标关键字Key是否已存在,以判断所述目标关键字Key是否处于已占用状态;
    失败提示单元,用于若所述目标关键字Key处于占用状态,则向业务终端返回对应的获取锁失败提示。
  12. 如权利要求7所述的所述基于区块链的事务处理装置,其中,所述状态判断模块还用于:
    在接收到业务终端发送的事务处理请求时,获取所述业务终端对应的用户身份信息,并判断所述用户身份信息是否具有所述事务处理请求对应的事务处理权限;
    若所述用户身份信息具有所述事务处理请求对应的事务处理权限,则根据所述事务处理请求确定对应目标关键字Key,并判断所述目标关键字Key是否处于占用状态;
    若所述用户身份信息不具有所述事务处理请求对应的事务处理权限,则向业务终端返回对应的无权限提示。
  13. 一种基于区块链的事务处理设备,其中,所述基于区块链的事务处理设备包括处理器、存储器、以及存储在所述存储器上并可被所述处理器执行的计算机可读指令,其中所述计算机可读指令被所述处理器执行时,实现如下步骤:
    在接收到业务终端发送的事务处理请求时,根据所述事务处理请求确定对应目标关键字Key,并判断所述目标关键字Key是否处于占用状态;
    若所述目标关键字Key不处于占用状态,则根据所述目标关键字Key向区块链中写入对应的事务数据;
    当所述事务数据写入完成时,向所述业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述业务终端,以供所述业务终端通过所述分布式锁执行对应的排他性事务;
    其中,所述当所述事务数据写入完成时,向所述业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述业务终端,以供所述业务终端通过所述分布式锁执行对应的排他性事务的步骤包括:
    当所述事务数据写入完成时,获取向所述目标关键字Key中写入事务数据的业务终端数量,并判断所述业务终端数量是否唯一;
    若所述业务终端数量唯一,则向所述业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述业务终端,以供所述业务终端通过所述分布式锁执行对应的排他性事务。
  14. 如权利要求13所述的所述基于区块链的事务处理设备,其中,所述当所述事务数据写入完成时,获取向所述目标关键字Key中写入事务数据的业务终端数量,并判断所述业务终端数量是否唯一的步骤之后,还包括:
    若所述业务终端数量不唯一,则向所述最先完成的业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述最先完成的业务终端,以供所述最先完成的业务终端通过所述分布式锁执行对应的排他性事务。
  15. 如权利要求14所述的所述基于区块链的事务处理设备,其中,所述在若所述业务终端数量不唯一,则向所述最先完成的业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述最先完成的业务终端,以供所述最先完成的业务终端通过所述分布式锁执行对应的排他性事务的步骤之后,还包括:
    向所述最先完成的业务终端以外的其他业务终端返回写入失败信息,并将所述其他业务终端的终端标识添加至所述目标关键字Key对应的待分配列表,以在所述分布式锁被释放后将所述分布式锁对应分配至所述其他业务终端。
  16. 如权利要求13所述的所述基于区块链的事务处理设备,其中,所述在接收到业务终端发送的事务处理请求时,根据所述事务处理请求确定对应目标关键字Key,并判断所述目标关键字Key是否处于占用状态的步骤包括:
    在接收到业务终端发送的事务处理请求时,根据所述事务处理请求确定对应的目标关键字Key;
    判断区块链中所述目标关键字Key是否已存在,以判断所述目标关键字Key是否处于已占用状态;
    若所述目标关键字Key处于占用状态,则向业务终端返回对应的获取锁失败提示。
  17. 一种计算机可读存储介质,其中,所述计算机可读存储介质上存储有计算机可读指令,其中所述计算机可读指令被处理器执行时,实现如下步骤:
    在接收到业务终端发送的事务处理请求时,根据所述事务处理请求确定对应目标关键字Key,并判断所述目标关键字Key是否处于占用状态;
    若所述目标关键字Key不处于占用状态,则根据所述目标关键字Key向区块链中写入对应的事务数据;
    当所述事务数据写入完成时,向所述业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述业务终端,以供所述业务终端通过所述分布式锁执行对应的排他性事务;
    其中,所述当所述事务数据写入完成时,向所述业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述业务终端,以供所述业务终端通过所述分布式锁执行对应的排他性事务的步骤包括:
    当所述事务数据写入完成时,获取向所述目标关键字Key中写入事务数据的业务终端数量,并判断所述业务终端数量是否唯一;
    若所述业务终端数量唯一,则向所述业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述业务终端,以供所述业务终端通过所述分布式锁执行对应的排他性事务。
  18. 如权利要求17所述的所述基于区块链的事务处理设备,其中,所述当所述事务数据写入完成时,获取向所述目标关键字Key中写入事务数据的业务终端数量,并判断所述业务终端数量是否唯一的步骤之后,还包括:
    若所述业务终端数量不唯一,则向所述最先完成的业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述最先完成的业务终端,以供所述最先完成的业务终端通过所述分布式锁执行对应的排他性事务。
  19. 如权利要求18所述的所述基于区块链的事务处理设备,其中,所述在若所述业务终端数量不唯一,则向所述最先完成的业务终端返回对应的写入成功信息,并将所述目标关键字Key对应的分布式锁分配至所述最先完成的业务终端,以供所述最先完成的业务终端通过所述分布式锁执行对应的排他性事务的步骤之后,还包括:
    向所述最先完成的业务终端以外的其他业务终端返回写入失败信息,并将所述其他业务终端的终端标识添加至所述目标关键字Key对应的待分配列表,以在所述分布式锁被释放后将所述分布式锁对应分配至所述其他业务终端。
  20. 如权利要求17所述的所述基于区块链的事务处理设备,其中,所述在接收到业务终端发送的事务处理请求时,根据所述事务处理请求确定对应目标关键字Key,并判断所述目标关键字Key是否处于占用状态的步骤包括:
    在接收到业务终端发送的事务处理请求时,根据所述事务处理请求确定对应的目标关键字Key;
    判断区块链中所述目标关键字Key是否已存在,以判断所述目标关键字Key是否处于已占用状态;
    若所述目标关键字Key处于占用状态,则向业务终端返回对应的获取锁失败提示。
PCT/CN2019/121996 2019-05-07 2019-11-29 基于区块链的事务处理方法、装置、设备及存储介质 Ceased WO2020224249A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910376443.3 2019-05-07
CN201910376443.3A CN110231979A (zh) 2019-05-07 2019-05-07 基于区块链的事务处理方法、装置、设备及存储介质

Publications (1)

Publication Number Publication Date
WO2020224249A1 true WO2020224249A1 (zh) 2020-11-12

Family

ID=67860425

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/121996 Ceased WO2020224249A1 (zh) 2019-05-07 2019-11-29 基于区块链的事务处理方法、装置、设备及存储介质

Country Status (2)

Country Link
CN (1) CN110231979A (zh)
WO (1) WO2020224249A1 (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113205417A (zh) * 2021-04-27 2021-08-03 华东师范大学 一种面向联盟链的交易并行处理方法及系统
CN113781230A (zh) * 2021-09-24 2021-12-10 支付宝(杭州)信息技术有限公司 基于区块链的交易处理方法和装置
CN117193974A (zh) * 2023-09-01 2023-12-08 中国人民财产保险股份有限公司 基于多进程/线程的配置请求处理方法及装置

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110231979A (zh) * 2019-05-07 2019-09-13 深圳壹账通智能科技有限公司 基于区块链的事务处理方法、装置、设备及存储介质
CN110597923B (zh) * 2019-09-29 2024-02-02 腾讯云计算(北京)有限责任公司 区块链资源管理方法、装置及存储介质
CN110888858B (zh) * 2019-10-29 2023-06-30 北京奇艺世纪科技有限公司 数据库的操作方法和装置、存储介质、电子装置
CN111190913A (zh) * 2019-12-30 2020-05-22 联动优势(北京)数字科技有限公司 一种分布式锁实现方法及系统
CN111210270B (zh) * 2020-01-02 2023-06-20 广州虎牙科技有限公司 业务处理方法、装置、服务集群、计算机设备和存储介质
CN111209593A (zh) * 2020-01-10 2020-05-29 杭州溪塔科技有限公司 基于区块链的分布式锁处理方法及相关装置和电子设备
CN111897646A (zh) * 2020-08-13 2020-11-06 银联商务股份有限公司 异步分布式锁实现方法及其装置、存储介质以及电子设备
CN112486696A (zh) * 2020-12-11 2021-03-12 上海悦易网络信息技术有限公司 一种获取分布式锁的方法及设备
CN113239059B (zh) * 2021-05-28 2024-05-14 北京达佳互联信息技术有限公司 一种分布式锁的切换方法、装置、服务器和存储介质
CN113806384A (zh) * 2021-08-19 2021-12-17 紫光云(南京)数字技术有限公司 基于redis的分配递增整型数据的方法
CN114443180B (zh) * 2022-01-19 2025-08-26 北京三快在线科技有限公司 一种业务处理方法及装置
CN116881271A (zh) * 2023-07-27 2023-10-13 金蝶软件(中国)有限公司 一种并发数据的数据处理方法及系统

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108920257A (zh) * 2018-06-25 2018-11-30 百度在线网络技术(北京)有限公司 事务处理方法、装置、设备及存储介质
US20180359095A1 (en) * 2017-06-12 2018-12-13 Cisco Technology, Inc. Dynamically-Changing Identity For IoT Devices With Blockchain Validation
CN109165224A (zh) * 2018-08-24 2019-01-08 东北大学 一种在区块链数据库上针对关键字key的索引方法
CN109213791A (zh) * 2018-08-22 2019-01-15 北京京东尚科信息技术有限公司 数据处理方法、区块链节点、系统和计算机可读存储介质
CN109684307A (zh) * 2018-12-26 2019-04-26 百度在线网络技术(北京)有限公司 一种数据存储方法、装置、设备及存储介质
CN110231979A (zh) * 2019-05-07 2019-09-13 深圳壹账通智能科技有限公司 基于区块链的事务处理方法、装置、设备及存储介质

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104679881B (zh) * 2015-03-13 2019-03-08 华为技术有限公司 一种并发控制方法及装置
WO2017100978A1 (zh) * 2015-12-14 2017-06-22 华为技术有限公司 一种集群中锁管理的方法、锁服务器及客户端
US9774578B1 (en) * 2016-05-23 2017-09-26 Accenture Global Solutions Limited Distributed key secret for rewritable blockchain
CN108769150B (zh) * 2018-05-14 2021-11-12 百度在线网络技术(北京)有限公司 区块链网络的数据处理方法、装置、集群节点和存储介质
CN108804112B (zh) * 2018-05-22 2022-02-11 上海分布信息科技有限公司 一种区块链落账处理方法及系统

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180359095A1 (en) * 2017-06-12 2018-12-13 Cisco Technology, Inc. Dynamically-Changing Identity For IoT Devices With Blockchain Validation
CN108920257A (zh) * 2018-06-25 2018-11-30 百度在线网络技术(北京)有限公司 事务处理方法、装置、设备及存储介质
CN109213791A (zh) * 2018-08-22 2019-01-15 北京京东尚科信息技术有限公司 数据处理方法、区块链节点、系统和计算机可读存储介质
CN109165224A (zh) * 2018-08-24 2019-01-08 东北大学 一种在区块链数据库上针对关键字key的索引方法
CN109684307A (zh) * 2018-12-26 2019-04-26 百度在线网络技术(北京)有限公司 一种数据存储方法、装置、设备及存储介质
CN110231979A (zh) * 2019-05-07 2019-09-13 深圳壹账通智能科技有限公司 基于区块链的事务处理方法、装置、设备及存储介质

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113205417A (zh) * 2021-04-27 2021-08-03 华东师范大学 一种面向联盟链的交易并行处理方法及系统
CN113781230A (zh) * 2021-09-24 2021-12-10 支付宝(杭州)信息技术有限公司 基于区块链的交易处理方法和装置
WO2023045532A1 (zh) * 2021-09-24 2023-03-30 蚂蚁区块链科技(上海)有限公司 基于区块链的交易处理
CN117193974A (zh) * 2023-09-01 2023-12-08 中国人民财产保险股份有限公司 基于多进程/线程的配置请求处理方法及装置

Also Published As

Publication number Publication date
CN110231979A (zh) 2019-09-13

Similar Documents

Publication Publication Date Title
WO2020224249A1 (zh) 基于区块链的事务处理方法、装置、设备及存储介质
WO2018036167A1 (zh) 测试任务执行机分配方法、装置、服务器和存储介质
WO2021006616A1 (en) Method for providing relational decentralized identifier service and blockchain node using the same
WO2012111905A2 (ko) 맵 리듀스를 이용한 분산 메모리 클러스터 제어 장치 및 방법
WO2012057581A2 (ko) 클라우드 컴퓨팅 시스템 및 그의 데이터 동기화 방법
WO2018135766A1 (ko) 블록 체인을 이용하여 데이터를 관리하는 장치 및 방법
WO2013048110A2 (en) Apparatus and method for synchronizing application data
WO2018099067A1 (zh) 分布式任务调度方法和系统
WO2019198885A1 (ko) 블록체인 기반의 다수의 서비스 노드를 사용하는 탈중앙화 서비스 플랫폼
WO2020119115A1 (zh) 数据审核方法、装置、设备及存储介质
WO2020042464A1 (zh) 数据交互方法、装置、设备及可读存储介质
WO2018094809A1 (zh) 一种资源共享方法及装置
WO2020220412A1 (zh) 基于零知识证明的公民隐私保护的方法、系统及存储介质
WO2020224251A1 (zh) 区块链事务的处理方法、装置、设备及存储介质
WO2021125502A1 (ko) 컨테이너 기반의 클라우드 서비스 제공 시스템 및 그 방법
WO2021040283A1 (ko) 무선 ap 접속 정보에 기초하여 근태 관리를 수행할 수 있는 근태 관리 시스템 서버 및 그 동작 방법
WO2020042482A1 (zh) 坐席业务处理方法、装置、设备及计算机可读存储介质
WO2020237859A1 (zh) 基于nbd设备的数据迁移方法、装置、设备及存储介质
CN107800737A (zh) 一种服务器集群中主节点的确定方法、装置及服务器集群
WO2025023426A2 (ko) 컨테이너 기반 클라우드 접근통제 시스템 및 방법
WO2013176431A1 (ko) 단말을 서버에 할당하고 단말로의 효율적인 메시징을 위한 시스템 및 방법
WO2022010136A1 (ko) 클라우드 서버 및 이의 제어 방법
WO2023171973A1 (en) Apparatus and method of managing non-fungible tokens based on blockchain
WO2014084603A1 (ko) 어플리케이션 삭제에 연동한 se 애플릿 관리 방법 및 이를 적용한 모바일 기기와 서비스 관리 서버
WO2025014013A1 (ko) Qr코드를 이용한 안심전화 서비스를 위한 운영 서버 및 그 동작 방법

Legal Events

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

Ref document number: 19928149

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19928149

Country of ref document: EP

Kind code of ref document: A1

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

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

122 Ep: pct application non-entry in european phase

Ref document number: 19928149

Country of ref document: EP

Kind code of ref document: A1