WO2021027956A1 - Blockchain system-based transaction processing method and device - Google Patents

Blockchain system-based transaction processing method and device Download PDF

Info

Publication number
WO2021027956A1
WO2021027956A1 PCT/CN2020/109570 CN2020109570W WO2021027956A1 WO 2021027956 A1 WO2021027956 A1 WO 2021027956A1 CN 2020109570 W CN2020109570 W CN 2020109570W WO 2021027956 A1 WO2021027956 A1 WO 2021027956A1
Authority
WO
WIPO (PCT)
Prior art keywords
transaction
operation information
log space
node
log
Prior art date
Application number
PCT/CN2020/109570
Other languages
French (fr)
Chinese (zh)
Inventor
李陈希
李辉忠
张开翔
范瑞彬
Original Assignee
深圳前海微众银行股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳前海微众银行股份有限公司 filed Critical 深圳前海微众银行股份有限公司
Publication of WO2021027956A1 publication Critical patent/WO2021027956A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1415Saving, restoring, recovering or retrying at system level
    • G06F11/1438Restarting or rejuvenating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5022Mechanisms to release resources
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange

Definitions

  • the present invention relates to the technical field of financial technology (Fintech), in particular to a transaction processing method and device based on a blockchain system.
  • Blockchain technology is no exception, but due to the security and real-time requirements of the financial industry , Also put forward higher requirements for technology.
  • the transaction can also be gradually written into the transaction database set up inside the node. For example, the transaction corresponding data can be inserted and updated in the transaction database. Data corresponding to the transaction, deleting the data corresponding to the transaction, etc.
  • the transaction when a node executes a transaction, the transaction may be abnormal due to data errors or program failures.
  • the node In order to ensure the accuracy of the transaction database, the node usually needs to roll back abnormal transactions, that is, cancel the transaction database. All write operations of this abnormal transaction restore the transaction database to the state before the abnormal transaction was executed.
  • the write log list can be preset in the node, and the write log list can be used to record all write operations performed by the node; in this way, if the transaction is found when the transaction is executed Abnormal, the node can obtain the latest write operation written in the log list and the initial write operation of the transaction, and perform the transaction database according to each write operation between the latest write operation and the initial write operation Roll back.
  • the embodiment of the present invention provides a data processing method based on a blockchain system to solve the technical problem of low transaction processing accuracy in the prior art when performing transaction rollback.
  • an embodiment of the present invention provides a transaction processing method based on a blockchain system.
  • the method is applied to any node in the blockchain system and includes:
  • the node determines the first log space corresponding to the first process; wherein, the first log space is used to record that the first process is processing the transaction
  • the operation information of the preset database; the log space allocated by the node for each parallel process is different; further, the node obtains each operation information of the first transaction from the first log space, and based on the Each operation information of the first transaction performs a rollback operation on the preset database.
  • each process corresponds to a log space. Because the process is based on the serial method to process multiple transactions, therefore, in the log space corresponding to the process, The operation information of the transaction is stored in sequence according to the processing order of the transaction; in this way, if the transaction currently processed by the process is abnormal, the node can quickly obtain the operation information of the abnormal transaction by querying the log space corresponding to the process, which can be based on this The operation information of abnormal transactions is accurately rolled back to the preset database to improve the accuracy of transaction processing.
  • the method before the first transaction processed by the first process by the node is abnormal, the method further includes: the node obtains the first log corresponding to the first process from a preset mapping table Space, and use the first log space to record the operation information of the first process on the preset database in the process of processing the first transaction; accordingly, if the node has not obtained from the preset mapping table To the first log space corresponding to the first process, the first log space is allocated for the first process, and the correspondence between the first process and the first log space is added in all The preset mapping table.
  • the corresponding relationship between the process and the log space is stored by setting the preset mapping table, so that when the node determines to use the process to process the transaction, it can directly query the preset mapping table to determine whether the corresponding log space has been allocated for the process. This can avoid allocating multiple log spaces for the same process and improve the flexibility of log space management.
  • the method before the node obtains the first log space corresponding to the first process from a preset mapping table, the method further includes: the node determines that the preset mapping table is in an unlocked state; The unlocked state is used to indicate that no process currently uses the preset mapping table.
  • the state of the preset mapping table needs to be queried before the node uses the preset mapping table. If the preset mapping table is in an unlocked state, the node can use the preset mapping table to assign the corresponding preset mapping table to the process If the preset mapping table is locked, the node cannot use the preset mapping table; that is to say, by setting the lock resource for the preset mapping table in advance (that is, recording the state of the preset mapping table), multiple processes can be avoided Simultaneous access to the preset mapping table causes resource conflicts, and can prevent nodes from allocating the same log space for multiple processes at the same time, thereby ensuring the accuracy of transaction processing.
  • the node uses the first log space to record the operation information of the first process on the preset database in the process of processing the first transaction, including: the node records the The initial position of the first transaction in the first log space where the first piece of operation information is located or the end position where the last operation information of the second transaction is recorded in the first log space; the second transaction is Processing the transaction processed by the first process before the first transaction; further, the node acquiring each operation information of the first transaction from the first log space includes: the node according to the first When the transaction is abnormal, the position of the latest piece of operation information in the first log space and the initial position determine each operation information of the first transaction; or, the node determines the operation information of the first transaction according to the first transaction when the first transaction is abnormal The position of the latest piece of operation information in a log space and the termination position determine each operation information of the first transaction.
  • the process can record the starting position of the transaction in the log space or the ending position of the previous transaction in the log space when processing each transaction.
  • the current log space The operation information between the position and the starting position of the transaction in the log space or the current position in the log space and the ending position of the previous transaction in the log space are the operation information corresponding to the transaction; that is, through Record the start position of each transaction in the log space or the end position of the previous transaction in the log space, which can quickly and accurately obtain the operation information corresponding to each transaction, and improve the rollback of the preset database based on the operation information corresponding to the transaction Accuracy.
  • the method further includes: if the node determines that the first process has processed all the corresponding transactions, releasing the resources occupied by the first log space.
  • an embodiment of the present invention provides a transaction processing device based on a blockchain system, and the device includes:
  • the determining module is used to determine the first log space corresponding to the first process when the first transaction processed by the first process is abnormal; wherein, the first log space is used to record the transaction processing of the first process Operation information of the preset database during the process; the log space allocated by the device for each parallel process is different;
  • An obtaining module configured to obtain various operation information of the first transaction from the first log space
  • the processing module is configured to perform a rollback operation on the preset database based on each operation information of the first transaction.
  • the determining module is further configured to: obtain the first log corresponding to the first process from a preset mapping table
  • the processing module is further configured to: use the first log space to record the operation information of the first process on the preset database in the process of processing the first transaction; further, if the The obtaining module does not obtain the first log space corresponding to the first process from the preset mapping table, and the processing module is further configured to: allocate the first log space for the first process, and Adding the correspondence between the first process and the first log space in the preset mapping table.
  • the determining module is further configured to: determine that the preset mapping table is not Locked state; the unlocked state is used to indicate that no process currently uses the preset mapping table.
  • the processing module is specifically configured to record the initial position of the first piece of operation information in the first log space of the first transaction or record the location of the second transaction in the first log space.
  • the end position of the last piece of operation information in the log space; the second transaction is a transaction processed by the first process before the first transaction is processed; accordingly, the acquisition module is specifically configured to: When a transaction is abnormal, the position of the latest piece of operation information in the first log space and the initial position determine each operation information of the first transaction; or, the node determines the operation information of the first transaction according to the The position of the latest piece of operation information in the first log space and the termination position determine each operation information of the first transaction.
  • the processing module is further configured to: if it is determined that the first process has processed all corresponding transactions, release the resources occupied by the first log space.
  • an embodiment of the present invention provides a computing device that includes at least one processing unit and at least one storage unit, wherein the storage unit stores a computer program, and when the program is executed by the processing unit, The processing unit executes any transaction processing method based on the blockchain system described in the first aspect.
  • an embodiment of the present invention provides a computer-readable storage medium that stores a computer program executable by a computing device, and when the program runs on the computing device, the computing device executes the foregoing On the one hand, any transaction processing method based on the blockchain system.
  • FIG. 1 is a schematic diagram of a flow corresponding to a transaction processing method based on a blockchain system provided by an embodiment of the present invention
  • FIG. 2 is a schematic diagram of the interaction flow of a transaction processing method based on a blockchain system provided by an embodiment of the present invention
  • FIG. 3 is a schematic structural diagram of a transaction processing device based on a blockchain system provided by an embodiment of the present invention
  • FIG. 4 is a schematic structural diagram of a computing device provided by an embodiment of the present invention.
  • the field of financial technology usually involves a variety of transactions.
  • bank transactions can include card sales, deposit transactions, loan transactions, insurance transactions, wealth management transactions, etc.
  • the daily transaction volume of banks can reach thousands or even several. Thousands of pens.
  • the financial technology field can also use blockchain technology to process transactions. For example, if multiple banks are involved in related transactions, you can set up a consortium chain to synchronize related transactions. , Or you can put the courts, customers, etc. on the chain at the same time to jointly maintain the security and stability of the alliance chain.
  • each node can be set up with a transaction database, and each node maintains the public ledger in the blockchain system through the transaction database.
  • the transaction database inside the node can store the transaction block processed by the node. Data and transaction data, block data can mainly include the timestamp of the start of the transaction, the hash value of the block, etc.
  • the transaction database can generally be a key-value database.
  • the key-value database is a non-relational database that can store data based on a simple key-value method.
  • each transaction data can be key-valued.
  • the collection method is stored in a key-value database, and the key is used as a unique identifier to retrieve the corresponding value.
  • Table 1 is a schematic table of a possible transaction database provided by an embodiment of the present invention.
  • Table 1 Schematic table of a transaction database
  • each key-value pair can include a key and a value corresponding to the key.
  • a key-value pair with a key of 1 corresponds to a value of 10
  • a key-value pair with a key of 2 corresponds to a value of 20
  • a key-value pair with a key of 3 corresponds to a value of 30.
  • each key-value pair in the transaction database can identify a certain transaction data of the transaction. For example, if the transaction is a transaction of a certain account, each income or each expenditure of the account can be used as a separate key Value pair.
  • the nodes in the blockchain system can perform various write operations on the internal transaction database, such as inserting a new key-value pair, modifying an existing key-value pair, and deleting an existing one. Key-value equivalence. Among them, these write operations can be performed based on the keys in the transaction database. Three possible write operations are described below:
  • Table 2 Schematic of a transaction database corresponding to an insert operation
  • the updated transaction database can be as shown in Table 3:
  • Table 3 A schematic diagram of the transaction database corresponding to a modification operation
  • the key-value pair with key 2 can be deleted in the transaction database shown in Table 3, and the operation information corresponding to the write operation can be deleted It can be "Type: Delete, Key: 2".
  • the updated transaction database can be as shown in Table 4:
  • Table 4 A schematic diagram of the transaction database corresponding to a delete operation
  • each node can set a log list for the internal transaction database, so as to save all write operations in the log list. Based on the foregoing Tables 1 to 4, the node can record the log list shown in Table 5a in the log list, or can also record the log list shown in Table 5b in the log list, which is not specifically limited.
  • Table 5a Schematic table of a possible log list
  • Types of key value insert 4 10 modify 2 40
  • this type of log list records the write operations of nodes to the transaction database in order from top to bottom, and each row of data is a piece of write operation information; refer to Table 5b, this type of log list It records the write operations of nodes to the transaction database in order from left to right, and each column of data is a piece of write operation information.
  • the node when a node executes each transaction in sequence, if a certain transaction is abnormal, the node can obtain the write operation corresponding to the abnormal transaction in the order of the write operations in the log list, thereby based on the write operation of the abnormal transaction.
  • the transaction database is rolled back by the import operation, which is no problem.
  • the nodes in the blockchain system usually process transactions in parallel, that is, there may be multiple transactions executing at the same time.
  • the write operations of each transaction in the log list can be interspersed; for example, the log The first to fifth write operations in the list belong to the five write operations of transaction a 1 , the sixth write operation belongs to one write operation of transaction a 2 , and the seventh to ten write operations belong to transaction a 1 If the transaction a 1 is found to be abnormal when the tenth write operation is executed, the node can follow the tenth write operation to the first write operation in the log list to return to the transaction database roll. It can be seen that this rollback operation not only rolls back the write operation of the abnormal transaction a 1 but also rolls back the write operation of the normal transaction a 2 , resulting in an error in the transaction processing process.
  • the embodiment of the present invention provides a transaction processing method based on a blockchain system, which is used to accurately roll back the write operation of an abnormal transaction, thereby improving the accuracy of transaction processing.
  • Fig. 1 is a schematic diagram of a process corresponding to a transaction processing method based on a blockchain system provided by an embodiment of the present invention.
  • the method can be applied to any node in the blockchain system.
  • the method includes:
  • Step 101 When the first transaction processed by the first process is abnormal, the node determines the first log space corresponding to the first process.
  • any node in the blockchain system after any node in the blockchain system receives the transaction, it can store the transaction in the transaction pool set inside the node, and at the same time can synchronize the transaction to other nodes in the blockchain system; Correspondingly, after receiving the transaction, other nodes can store the transaction in the transaction pool set internally by other nodes. Further, when the first node to process the transaction is determined from the multiple nodes of the blockchain system, the first node can first create a process for processing the transaction.
  • the first node can create multiple parallel processes at the same time, and can store the corresponding relationship between the process and the transaction in the process pool, and subsequently use each process to process the corresponding transaction; if the first node supports single-process serial processing transactions, You can create a process and use it to process multiple transactions in turn.
  • the first node may create a parallel process to process b 1 b 5 ⁇ ; ⁇ 1 the same process if the process b 5 b processing capacity, the first node may be assigned a transaction process b 1 and transaction 2, b 2 of the process 3 and 4 transactions dispensing transactions, transactions for the process b 3 to 5 and 6 transactions, transactions for the process b 4 to 7 and 8 transactions, transactions for the process b 5 to 9 and 10 transactions.
  • CPU central processing unit
  • the memory may include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type memory, random access memory (Random Access Memory, RAM), and static random access memory (Static Random Access Memory, SRAM). , Programmable Read Only Memory (PROM), Read Only Memory (Read Only Memory, ROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), magnetic memory, Disk, CD, etc.
  • PROM Programmable Read Only Memory
  • ROM Read Only Memory
  • EEPROM Electrically Erasable Programmable Read-Only Memory
  • magnetic memory Disk, CD, etc.
  • the memory is any other medium that can be used to carry or store desired program codes in the form of instructions or data structures and that can be accessed by a computer, but is not limited thereto.
  • the memory in the embodiment of the present invention may also be a circuit or any other device capable of realizing a storage function for storing program instructions and/or data.
  • the first node can set an initial storage space in the memory in advance. After each process is created, the first node can select a sub-storage with a preset amount of data from the storage space not occupied by the initial storage space. The space is used as the log space corresponding to the process. In this way, all write operations performed by the process in the process of processing transactions can be recorded in the log space corresponding to the process.
  • the preset data amount of the sub-storage space and the size of the initial storage space can be set by those skilled in the art based on experience, or can also be set according to actual needs, and the specifics are not limited.
  • sub storage space 1 can Occupied space range 00000010 ⁇ 00000100
  • sub storage space 2 can occupy space range 00000100 ⁇ 00000110
  • sub storage space 3 can occupy space range 00000110 ⁇ 00001000
  • sub storage space 4 can occupy space range 00001000 ⁇ 00001010
  • sub storage space 5 can occupy space
  • the range is from 00001010 to 00001100, and each sub-storage space from sub-storage space 1 to sub-storage space 5 can store a data amount of 00000010.
  • sub-storage space 1 to sub-storage space 5 can be arbitrarily selected from 00000010 to 10000000, for example, sub-storage space 1 occupies a space range of 00000010 to 00000100, and sub-storage space 2 occupies a space range of 00001010 to 00001100, sub-storage space 3 occupies a space range of 0001000 to 00001010, sub-storage space 4 can occupy a space range of 00000100 to 00000110, and sub-storage space 5 can occupy a space range of 00000110 to 000010000, which is not specifically limited.
  • sub-storage space 1 is the log space corresponding to process b 1
  • process b 1 can transfer subsequent
  • the operation information of all transactions processed is recorded in the sub-storage space 1.
  • the process b 1 processes transaction 1 and transaction 2 in turn
  • the first node can preset the process b 1 to process transaction 1 and transaction 2
  • the operation information of the database is recorded in the log space corresponding to the process b 1 in order. So, if the process b 1 to determine which transaction is being processed two exceptions, it can obtain information on the operation of each transaction 2 from the storage space in the sub-1.
  • the first node may also set a preset mapping table, and use the preset mapping table to store the correspondence between the process and the log space.
  • the first node can allocate the corresponding log space for the process b 1 in the following manner: After the process b 1 is created, the first node can first query the preset mapping table to determine whether the preset mapping table is Contains the log space corresponding to the process b 1. If the preset mapping table contains the log space corresponding to the process b 1 , then the first node can directly use the log space corresponding to the process b 1 to record that the process b 1 is Set all operation information of the database.
  • the first node may select a sub-storage space with a preset amount of data from the storage space currently unoccupied by the initial storage space as the sub-storage space corresponding to process b 1 Log space, and the corresponding relationship between the log space corresponding to process b 1 and process b 1 can be added to the preset mapping table; in this way, the first node can use the log space corresponding to process b 1 to record that process b 1 is processing transactions All operation information of the preset database during the process.
  • Table 6 is a schematic table of a possible preset mapping table provided by an embodiment of the present invention.
  • Table 6 An illustration of a preset mapping table
  • the identification of the process and the start and end positions of the log space corresponding to the process can be stored in the preset mapping table.
  • the log space corresponding to the process b 1 occupies the range of 00000010 ⁇ 00000100
  • the first node can store the operation information of the preset database when process b 1 processes transaction 1 and transaction 2 in the space of 00000010 ⁇ 00000100; the log space corresponding to process b 2 occupies the space in the range of 00000100 ⁇ 00000110 ,
  • the first node can store the operation information of the preset database when process b 2 processes transaction 3 and transaction 4 in the space of 00000100 ⁇ 00000110; the log space corresponding to process b 3 occupies the space in the range of 00000110 ⁇ 00001000.
  • One node can store the operation information of the preset database when process b 3 processes transaction 5 and transaction 6 in the space in the range of 00000110 ⁇ 00001000; the log space corresponding to process b 4 occupies the space in the range of 00001000 ⁇ 00001010, the first node
  • the operation information of the preset database when process b 4 processes transactions 7 and 8 can be stored in the space of 00001000 ⁇ 00001010; the log space corresponding to process b 5 occupies the space of 00001010 ⁇ 00001100, the first node can store process 9 b 5 transactions and transaction processing of the default database stored in the operation information space 00001010 00001100 ⁇ 10 range.
  • operation information can be stored in the form of a table in the log space, or can also be stored in other forms, which is not limited.
  • a preset mapping table is set to store the corresponding relationship between the process and the log space, so that when the first node determines to use the process to process the transaction, it can directly query the preset mapping table to determine whether the corresponding process has been allocated Log space, which can avoid allocating multiple log spaces for the same process and improve the flexibility of log space management.
  • the preset mapping table is a common resource, if multiple processes access the preset mapping table at the same time, multiple processes may need to use a competitive method to obtain the preset mapping table, resulting in the preset mapping table being in Unstable state.
  • the first node when the first node sets the preset mapping table, it can also set lock resources for the preset mapping table; in this way, the first node obtains the log corresponding to the process b 1 from the preset mapping table Before space, the state of the preset mapping table can also be determined according to the lock resource of the preset mapping table. If the preset mapping table is determined to be in an unlocked state, the log space corresponding to process b 1 can be obtained. If the preset mapping table is determined to be Locked state, you can perform waiting.
  • the lock resource may exist in the form of a table, or may also exist in the form of a graph, which is not limited.
  • Table 7 is a schematic table of a lock resource provided by an embodiment of the present invention, and the lock resource in Table 7 exists in a table form.
  • Table 7 An illustration of a lock resource
  • the lock resource can include the corresponding relationship between the preset mapping table and the state of the preset mapping table. If the state of the preset mapping table is locked, it means that a certain process currently accesses the preset mapping table. In this way, other processes cannot access the preset mapping table temporarily; if the status of the preset mapping table is unlocked, it means that no process currently accesses the preset mapping table, so other processes can access the preset mapping table.
  • Implementation after creating the first node in the process b 1, can first query determines the default mapping table of the state, if it is determined the preset mapping table in an unlocked state, you can query to determine whether the preset mapping table contains the process b 1 Corresponding log space, and set the state of the preset mapping table to the locked state to prevent other processes from accessing the preset mapping table; further, when the first node obtains the log space corresponding to process b 1 from the preset mapping table log space, or the first node has been allocated for the process corresponding to b 1 b 1 and the process and process b correspondence relationship storage space 1 corresponding to the log after a preset mapping table, the first node may be a state preset mapping table Set to unlocked state. Accordingly, if it is determined the preset mapping table in a locked state, the first node may wait until a predetermined mapping table state to the unlocked state, then check to determine whether the preset mapping table contains the corresponding process b 1 log space.
  • the state of the preset mapping table needs to be queried. If the preset mapping table is in an unlocked state, the first node can use the preset mapping table to assign corresponding processes to the process. If the preset mapping table is locked, the first node cannot use the preset mapping table; that is, by setting lock resources for the preset mapping table in advance, multiple processes can avoid accessing the preset at the same time. The resource conflict caused by the mapping table can prevent the first node from allocating the same log space to multiple processes at the same time, thereby ensuring the accuracy of transaction processing.
  • Step 102 The first node obtains each operation information of the first transaction from the first log space.
  • the first node after the first node allocates the corresponding log space for the process b 1 , it can use the log space corresponding to the process b 1 to record the operation information of the process b 1 on the preset database during the transaction processing;
  • the process b 1 processes transactions in a serial manner. Therefore, if the process b 1 processes multiple transactions, the operation information of the multiple transactions can be sequentially recorded in the log space according to the processing order of the transactions.
  • the transaction process b 1 found in the exception processing a transaction, the first node directly from the process b 1 log space corresponding to the acquired information on the overall operation of unusual transactions; b 1 because the process according to the serial processing mode Therefore, the log space corresponding to the process b 1 will not have the operation information of multiple transactions interspersed with records, which can ensure that all the operation information of the abnormal transaction is obtained, and the speed of the acquisition can be improved.
  • process b 1 processes transaction 1 and transaction 2 in turn, the operation information on the preset database when processing transaction 1 includes operation information 1 and operation information 2, and the operation information on the default database when processing transaction 2 includes operation information 3.
  • Operation information 4 and operation information 5 the log space corresponding to process b 1 can record operation information 1, operation information 2, operation information 3, operation information 4, and operation information 5 in sequence, as shown in Table 8.
  • Table 8 A schematic diagram of log space corresponding to process b 1
  • the first node may log space from process b 1 corresponding to the operation information acquiring operation information 3 and 4.
  • the first node acquires operation information corresponding to unusual transactions
  • correspondence between the identifier of the first node and the transaction may be recorded in the process of operation information b 1 corresponding to log space, thus, the first After a node determines the abnormal transaction, it can obtain the operation information matching the identifier of the abnormal transaction from the log space corresponding to the process b 1 as each operation information of the abnormal transaction.
  • the following describes two implementation methods for obtaining operation information corresponding to abnormal transactions.
  • the first node in the process during process b 1 of each transaction the starting position may be recorded each transaction log space for the first preset operation information database resides; thus, determining a After a transaction is an abnormal transaction, the first node can obtain the location of the latest piece of operation information from the log space corresponding to process b 1 , and can compare the position between the location of the latest piece of operation information and the start position of the abnormal transaction. Each operation information is determined as each operation information of the abnormal transaction.
  • each operation information of the abnormal transaction includes the latest piece of operation information and the operation information corresponding to the starting position of the abnormal transaction.
  • the first node will record the location of the first operation information of transaction 1 when process b 1 is processing transaction 1. Since the first operation information of transaction 1 is operation information 1, Thus the first dot recording position in the first operation information for transactions where a first byte; Accordingly, the first node in a transaction processing 2, the first operation information records where the transaction in process b 2 of Location, since the first piece of operation information of transaction 2 is operation information 3, the position where the first node records the first piece of operation information of transaction 2 is the third byte.
  • process b 1 finds that transaction 2 is an abnormal transaction when processing operation information 4 corresponding to transaction 2, the first node can obtain the position of the current latest operation information, that is, the fourth byte, and can change the third word
  • the operation information between the section and the fourth byte (that is, operation information 3 and operation information 4) is used as the two operation information of abnormal transaction 2.
  • the first node before the process b 1 processes each transaction, the first node can record the termination position of the last operation information of the previous transaction in the log space corresponding to the process b 1 ; in this way, when determining a certain transaction After the abnormal transaction, the first node can obtain the location of the latest piece of operation information from the log space corresponding to the process b 1 , and can determine each piece of operation information between the location of the latest piece of operation information and the termination position as the abnormal transaction Each operation information.
  • each operation information of the abnormal transaction includes the latest piece of operation information, but does not include the operation information corresponding to the termination position of the previous transaction of the abnormal transaction.
  • the first node can record the last operation information of the last transaction of transaction 2 (ie transaction 1) in the log space corresponding to process b 1 before processing transaction 2 in process b 1 Since the last operation information of transaction 1 is operation information 2, the position where the first node records the last operation information of transaction 1 is the second byte.
  • the process b 1 2 4 corresponding to the operation information found in the process of transaction by transaction 2 is abnormal, then the first node may acquire the current position of the latest operation information is located, i.e. the fourth byte, and the second word may be The operation information between the section and the fourth byte (that is, operation information 3 and operation information 4) is used as the two operation information of abnormal transaction 2.
  • the process when processing each transaction, can record the starting position of the transaction in the log space or the ending position of the last transaction in the log space.
  • the log space The operation information between the current position and the starting position of the transaction in the log space or the ending position of the previous transaction in the log space is the operation information corresponding to the abnormal transaction; that is, by recording each transaction At the starting position in the log space or the ending position of the previous transaction in the log space, the operation information corresponding to each transaction can be quickly and accurately obtained, and the accuracy of rolling back the preset database based on the operation information corresponding to the transaction can be improved.
  • Step 103 The first node performs a rollback operation on the preset database based on each operation information of the first transaction.
  • the first node determines that the operation information 3 and the operation information 4 are the operation information of the abnormal transaction 2, it can use the operation information 4 to roll back the preset database, and then use Operation information 3 rolls back the preset database.
  • the state of the preset database is the same as the state of the preset database after the first node finishes executing the operation information 2.
  • the first node can query the thread pool to determine whether there are still transactions unprocessed by process b 1 in the thread pool. If it is determined that there are transactions that have not been processed by process b 1 in the thread pool (for example, transaction 11), the process can continue to be used b 1 Process transaction 11, and record the operation information of the preset database in the process of processing transaction 11 in the log space corresponding to process b 1. Repeat the process from step 101 to step 103 until there is no process in the thread pool b 1 Until unprocessed transactions.
  • the first node can release the log corresponding to process b 1 Resources occupied by space. Based on the preset mapping table shown in Table 6, in specific implementation, the first node determines by querying table 6 that the log space corresponding to process b 1 is 00000010 ⁇ 00000100. In this way, the first node can clear the initial storage space of 00000010 ⁇ 00000100 Data stored in the space.
  • the system resource occupation can be reduced and space is reserved for the log space corresponding to the subsequent process.
  • FIG. 2 is a schematic diagram of the interaction flow of the transaction processing method based on the blockchain system in the embodiment of the present invention. The following describes the embodiment of the present invention in detail with reference to FIG. 2.
  • the transaction processing method based on the blockchain system in the embodiment of the present invention involves various modules in the background, specifically including: a log space manager, a first thread, and the like.
  • the log space manager may be a software device
  • the first thread may be any thread in the nodes of the blockchain system.
  • Step 201 After being created by the node, the first thread sends a log space request message to the log space manager.
  • the node can allocate the corresponding transaction to the first thread; for example, the node can store the correspondence between the first thread and the transaction in the public thread pool, so that the first node can access the public thread by itself The pool obtains the transaction; alternatively, the node can also send the transaction to the first thread, and the first thread will store it in the internal space by itself, which is not limited.
  • the first thread may send a log space request message to the log space manager, and the log space request message may carry the identifier of the first process.
  • Step 202 After receiving the log space request message sent by the first thread, the log space manager obtains the state of the preset mapping table, and determines whether the preset mapping table is locked; if it is determined that the preset mapping table is locked, execute step 203. If it is determined that the preset mapping table is not locked, perform step 204.
  • the lock resource of the preset mapping table may be set in the log space manager, and the log space manager may query the state of the preset mapping table by accessing the lock resource of the preset mapping table. If the state is a locked state, it is determined that the preset mapping table is locked; if the state of the preset mapping table is an unlocked state, it is determined that the preset mapping table is not locked.
  • step 203 the log space manager sends a waiting instruction to the first thread and monitors the state of the preset mapping table until it is determined that the preset mapping table is switched from locked to unlocked, and step 204 is executed.
  • the log space manager can send a waiting instruction to the first process, and the waiting instruction is used to inform the first process to wait for the log The wake-up message of the space manager.
  • the log space manager can monitor the lock resource of the preset mapping table according to the preset period. For example, the lock resource of the preset mapping table can be accessed every 5s. If the status of the preset mapping table is found to be updated during a certain access process In the unlocked state, it can be determined that no other process currently accesses the preset mapping table. In this way, the log space manager can send a wake-up message to the first process.
  • Step 204 The log space manager locks the preset mapping table.
  • the log space manager can use the preset mapping table to process the log space request message of the first process.
  • the log space manager may first update the state in the lock resource of the preset mapping table to the locked state, thereby avoiding other processes accessing the preset mapping table at the same time when the first process accesses the preset mapping table.
  • the first process can be the process that competes for the lock resource first, or it can be the first to send a log space request to the log space manager The progress of the message.
  • step 205 the log space manager determines whether the first log space corresponding to the first thread exists in the preset mapping table, if it does not exist, execute step 206, and if it exists, execute step 207.
  • the preset mapping table may store the corresponding relationship between the process identifier and the location information of the log space.
  • the log space manager may query the preset mapping table according to the identifier of the first process to determine whether there is a corresponding relationship with the first process. The ID matches the log space.
  • Step 206 The log space manager allocates a corresponding first log space for the first thread, and stores the corresponding relationship between the first thread and the first log space in a preset mapping table.
  • Step 207 The log space manager releases the locked state of the preset mapping table, and registers a callback function for the first thread.
  • the log space manager After the log space manager obtains the first log space corresponding to the first thread, it can update the state in the lock resource of the preset mapping table to an unlocked state. In this way, if there are other processes waiting for the preset mapping table, Then the log space manager can wake up other processes.
  • the callback function may be a piece of software program preset in the node, and the callback function is used to instruct the process to release the log space corresponding to the process before exiting.
  • the callback function can monitor the running status of the first thread in real time. If it is determined that the first thread has processed all the corresponding transactions, it can trigger the first thread to release the first log Resources occupied by space.
  • Step 208 The log space manager sends the location information of the first log space to the first thread.
  • the position information of the first log space may refer to the start position and the end position of the space range occupied by the first log space in the initial storage space.
  • step 209 the first thread determines whether there is an unprocessed first transaction, if it exists, execute step 210, if it does not exist, execute step 213.
  • the identification of the process, the identification of the transaction corresponding to the process, and the processing status of the transaction can be stored in the common thread pool, and the processing status of the transaction can be any of unprocessed, processed, and abnormal. Therefore, after receiving the location information of the corresponding log space, the first thread can query the public thread pool to determine whether there are unprocessed transactions.
  • Step 210 The first thread starts to execute the first transaction, and records the starting position of the first operation information of the first transaction in the first log space corresponding to the first thread or the log corresponding to the last transaction in the first thread The location where the last piece of operation information in the space is located; and, during the execution of the first transaction, the first thread uses the first log space corresponding to the first thread to record the operation on the preset database during the execution of the first transaction information.
  • Step 211 in the process of executing the first transaction, the first thread determines whether the first transaction is abnormal, if it is abnormal, execute step 212, and if there is no abnormality, execute step 209.
  • Step 212 Obtain each operation information of the first transaction from the first log space corresponding to the first thread, perform a rollback on the preset database according to the reverse order of the position of each operation information, and execute the step after the rollback is completed 209.
  • the first thread when the first transaction is abnormal, can obtain the latest piece of operation information from the first log space corresponding to the first thread. If the first thread records the starting position of the first transaction, the first thread It can be judged whether the position of the piece of operation information is greater than or equal to the starting position, and if the position of the piece of operation information is greater than or equal to the starting position, a reverse operation can be performed on the preset database according to the piece of operation information .
  • the last piece of operation information of the piece of operation information is obtained, and it is determined whether the position of the last piece of operation information is greater than or equal to the starting position, if the position of the last piece of operation information is If it is less than the starting position, it can be determined that the rollback is completed; accordingly, if the position of the previous operation information is greater than or equal to the starting position, the reverse operation can be performed on the preset database according to the previous operation information, and This process is repeated until the position of the operation information is smaller than the starting position.
  • the first thread can determine whether the location of the piece of operation information is greater than the termination location, and if the location of the piece of operation information is greater than the termination location, Then you can perform a reverse operation on the preset database according to the piece of operation information.
  • the last piece of operation information of the piece of operation information is obtained, and it is determined whether the position of the last piece of operation information is greater than the termination position, and if the position of the last piece of operation information is less than or equal to According to the termination position, the rollback can be determined to be completed; accordingly, if the location of the last operation information is greater than the termination position, the reverse operation can be performed on the preset database according to the previous operation information, and the process can be repeated until The position where the operation information is located is less than or equal to the end position.
  • Step 213 The first thread executes the callback function, releases the resources occupied by the first log space, and exits.
  • step 207 because the log space manager registers the callback function with the first thread, the callback function monitors the state of the first process at all times. Therefore, when all transactions corresponding to the first thread are executed, the first thread can trigger the callback Function so that the callback function releases the resources occupied by the first log space corresponding to the first process. In this way, it can be ensured that the resources occupied by the first log space corresponding to the first process are released while the first process exits, thereby reducing the resource occupancy rate and improving the processing efficiency of the system.
  • any node in the blockchain system determines the first log space corresponding to the first process when the first transaction processed by the first process is abnormal; wherein, the first log space is used to record the first transaction.
  • the operation information of a process on the preset database in the process of processing transactions; the log space allocated by the node for each parallel process is different; further, the node obtains each operation information of the first transaction from the first log space, and based on the first log space
  • Each operation information of the transaction performs a rollback operation on the preset database.
  • each process corresponds to a log space.
  • the operation information of the transaction is stored sequentially according to the processing order of the transaction; in this way, if the transaction currently processed by the process is abnormal, the node can quickly obtain the operation information of the abnormal transaction by querying the log space corresponding to the process, which can be based on The operation information of the abnormal transaction is accurately rolled back to the preset database to improve the accuracy of transaction processing.
  • an embodiment of the present invention also provides a transaction processing device based on a blockchain system.
  • the specific content of the device can be implemented with reference to the foregoing method.
  • Figure 3 is a schematic structural diagram of a transaction processing device based on a blockchain system provided by an embodiment of the present invention, including:
  • the determining module 301 is configured to determine the first log space corresponding to the first process when the first transaction processed by the first process is abnormal; wherein, the first log space is used to record that the first process is processing the transaction The operation information of the preset database during the process; the log space allocated by the device for each parallel process is different;
  • the obtaining module 302 is configured to obtain various operation information of the first transaction from the first log space;
  • the processing module 303 is configured to perform a rollback operation on the preset database based on each operation information of the first transaction.
  • the obtaining module 302 is further configured to: obtain the first log space corresponding to the first process from a preset mapping table;
  • the processing module 303 is further configured to: use the first log space to record the operation information of the first process on the preset database in the process of processing the first transaction;
  • the processing module 303 is further configured to: allocate the first log space for the first process A log space, and the corresponding relationship between the first process and the first log space is added to the preset mapping table.
  • the determining module 301 is further configured to:
  • the preset mapping table is in an unlocked state; the unlocked state is used to indicate that no process currently uses the preset mapping table.
  • the processing module 303 is specifically configured to: record the initial position of the first piece of operation information in the first log space of the first transaction or record the second transaction in the first log space The termination location where the last piece of operation information is located; the second transaction is a transaction processed by the first process before the first transaction is processed;
  • the acquiring module 302 is specifically configured to: determine each operation information of the first transaction according to the location of the latest piece of operation information in the first log space and the initial location when the first transaction is abnormal; or, The node determines each operation information of the first transaction according to the position of the latest piece of operation information in the first log space when the first transaction is abnormal and the termination position.
  • processing module 303 is further configured to:
  • the resources occupied by the first log space are released.
  • any node in the blockchain system determines the first log space corresponding to the first process when the first transaction processed by the first process is abnormal;
  • a log space is used to record the operation information of the first process on the preset database in the process of processing transactions; the log space allocated by the node for each parallel process is different; further, the node obtains each of the first transaction from the first log space Operation information, and roll back the preset database based on each operation information of the first transaction.
  • each process corresponds to a log space.
  • the operation information of the transaction is stored sequentially according to the processing order of the transaction; in this way, if the transaction currently processed by the process is abnormal, the node can quickly obtain the operation information of the abnormal transaction by querying the log space corresponding to the process, which can be based on The operation information of the abnormal transaction is accurately rolled back to the preset database to improve the accuracy of transaction processing.
  • an embodiment of the present invention also provides a computing device, including at least one processing unit and at least one storage unit, wherein the storage unit stores a computer program, and when the program is executed by the processing unit , So that the processing unit executes any method described in FIG. 1 or FIG. 2 above.
  • an embodiment of the present invention also provides a computing device for executing a method of a data processing system in any embodiment of the present invention, and may include a memory 401 and a processor 402.
  • the memory 401 is configured to store a computer program executed by the processor 402.
  • the memory 401 may mainly include a program storage area and a data storage area.
  • the program storage area may store an operating system, an application program required for at least one function, and the like; the data storage area may store data created according to the use of a computing device.
  • the processor 402 may be a central processing unit (central processing unit, CPU), or a digital processing unit, and so on.
  • the embodiment of the present invention does not limit the specific connection medium between the foregoing memory 401 and the processor 402.
  • the memory 401 and the processor 402 are connected through a bus 403, and the bus 403 is represented by a thick line in FIG. 4.
  • the connection mode between other components is only for schematic illustration, not Limited.
  • the bus 403 can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one thick line is used in FIG. 4 to represent it, but it does not mean that there is only one bus or one type of bus.
  • the memory 401 may be a volatile memory (volatile memory), such as a random-access memory (RAM); the memory 401 may also be a non-volatile memory (non-volatile memory), such as a read-only memory, flash Flash memory, hard disk drive (HDD) or solid-state drive (SSD), or memory 401 can be used to carry or store desired program codes in the form of instructions or data structures and can be used by Any other medium accessed by the computer, but not limited to this.
  • the memory 401 may be a combination of the above-mentioned memories.
  • the processor 402 is configured to execute the data processing method based on the blockchain system provided by the embodiment of the present invention when calling the computer program stored in the memory 401.
  • the embodiments of the present invention may be provided as methods or computer program products. Therefore, the present invention may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
  • a computer-usable storage media including but not limited to disk storage, CD-ROM, optical storage, etc.
  • These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device.
  • the device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
  • These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment.
  • the instructions provide steps for implementing functions specified in a flow or multiple flows in the flowchart and/or a block or multiple blocks in the block diagram.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Accounting & Taxation (AREA)
  • Software Systems (AREA)
  • Finance (AREA)
  • General Engineering & Computer Science (AREA)
  • Strategic Management (AREA)
  • General Business, Economics & Management (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Technology Law (AREA)
  • Computer Security & Cryptography (AREA)
  • Quality & Reliability (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

A blockchain system-based transaction processing method and device. Said method comprises: a node determining a first log space corresponding to the first process when a first transaction processed by a first process is anomalous, acquiring, from the first log space, operation information of the first transaction, and performing a rollback operation on a preset database on the basis of the operation information of the first transaction. A process is to process a plurality of transactions in a serial manner, and thus by allocating different log spaces for parallel processes, the log space corresponding to each process sequentially stores operation information of the processed transaction; in this way, the node can rapidly acquire operation information of an anomalous transaction by querying the log space corresponding to the process, thereby improving the accuracy of performing rolling back on the preset database on the basis of the operation information of the anomalous transaction, and improving the accuracy of transaction processing.

Description

一种基于区块链系统的交易处理方法及装置A transaction processing method and device based on block chain system
相关申请的交叉引用Cross references to related applications
本申请要求在2019年08月15日提交中国专利局、申请号为201910752822.8、申请名称为“一种基于区块链系统的交易处理方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office, the application number is 201910752822.8, and the application name is "a method and device for transaction processing based on a blockchain system" on August 15, 2019. The entire content of the application is approved The reference is incorporated in this application.
技术领域Technical field
本发明涉及金融科技(Fintech)技术领域,尤其涉及一种基于区块链系统的交易处理方法及装置。The present invention relates to the technical field of financial technology (Fintech), in particular to a transaction processing method and device based on a blockchain system.
背景技术Background technique
随着计算机技术的发展,越来越多的技术应用在金融领域,传统金融业正在逐步向金融科技(Fintech)转变,区块链技术也不例外,但由于金融行业的安全性、实时性要求,也对技术提出了更高的要求。在区块链系统中,节点在处理交易时,除了会基于交易生成区块外,还可以将交易逐步写入节点内部设置的交易数据库中,比如可以在交易数据库中插入交易对应的数据、更新交易对应的数据、删除交易对应的数据等。With the development of computer technology, more and more technologies are applied in the financial field. The traditional financial industry is gradually transforming to Fintech. Blockchain technology is no exception, but due to the security and real-time requirements of the financial industry , Also put forward higher requirements for technology. In the blockchain system, when a node processes a transaction, in addition to generating blocks based on the transaction, the transaction can also be gradually written into the transaction database set up inside the node. For example, the transaction corresponding data can be inserted and updated in the transaction database. Data corresponding to the transaction, deleting the data corresponding to the transaction, etc.
在区块链系统中,节点在执行交易时,可能会由于数据出错或程序故障导致交易发生异常,为了保证交易数据库的准确性,节点通常需要对异常交易进行回滚处理,即取消交易数据库中该条异常交易的所有写入操作,从而将交易数据库恢复至执行该条异常交易之前的状态。在一种现有的实现方案中,可以在节点中预先设置写入日志列表,使用写入日志列表来记录节点所执行的全部写入操作;如此,若在执行某一条交易时发现该条交易异常,则节点可以获取写入日志列表中最新的写入操作和该条交易的起始写入操作,根据最新的写入操作和起始写入操作之间的各写入操作对交易数据库进行回滚。然而,为了提高交易的处理效率,现阶段区块链系统中的节点大多支持并行处理交易,如此,写入日志列表中多个交易的写入操作可能是交叉存储的,因此,若采用上述实现方式,可能会同时对并行处理的其它交易执行回滚操作,导致交易处理的准确性较低。In the blockchain system, when a node executes a transaction, the transaction may be abnormal due to data errors or program failures. In order to ensure the accuracy of the transaction database, the node usually needs to roll back abnormal transactions, that is, cancel the transaction database. All write operations of this abnormal transaction restore the transaction database to the state before the abnormal transaction was executed. In an existing implementation scheme, the write log list can be preset in the node, and the write log list can be used to record all write operations performed by the node; in this way, if the transaction is found when the transaction is executed Abnormal, the node can obtain the latest write operation written in the log list and the initial write operation of the transaction, and perform the transaction database according to each write operation between the latest write operation and the initial write operation Roll back. However, in order to improve transaction processing efficiency, most of the nodes in the blockchain system at this stage support parallel processing of transactions. Therefore, the write operations of multiple transactions written to the log list may be cross-stored. Therefore, if the above implementation is adopted In this way, other transactions that are processed in parallel may be rolled back at the same time, resulting in lower accuracy of transaction processing.
综上,目前亟需一种基于区块链系统的数据处理方法,用以解决现有技术在执行交易回滚时存在的交易处理准确性低的技术问题。In summary, there is an urgent need for a data processing method based on a blockchain system to solve the technical problem of low transaction processing accuracy when performing transaction rollbacks in the prior art.
发明内容Summary of the invention
本发明实施例提供一种基于区块链系统的数据处理方法,用以解决现有技术在执行交易回滚时存在的交易处理准确性低的技术问题。The embodiment of the present invention provides a data processing method based on a blockchain system to solve the technical problem of low transaction processing accuracy in the prior art when performing transaction rollback.
第一方面,本发明实施例提供的一种基于区块链系统的交易处理方法,所述方法应用于所述区块链系统中的任一节点,包括:In the first aspect, an embodiment of the present invention provides a transaction processing method based on a blockchain system. The method is applied to any node in the blockchain system and includes:
所述节点在第一进程处理的第一交易异常时,确定所述第一进程对应的第一日志空间;其中,所述第一日志空间用于记录所述第一进程在处理交易的过程中对预设数据库的操作信息;所述节点为并行的各进程分配的日志空间不同;进一步地,所述节点从所述第一日志空间获取所述第一交易的各操作信息,并基于所述第一交易的各操作信息对所述预设数据库进行回滚操作。When the first transaction processed by the first process is abnormal, the node determines the first log space corresponding to the first process; wherein, the first log space is used to record that the first process is processing the transaction The operation information of the preset database; the log space allocated by the node for each parallel process is different; further, the node obtains each operation information of the first transaction from the first log space, and based on the Each operation information of the first transaction performs a rollback operation on the preset database.
在上述设计中,通过为并行的各进程分配不同的日志空间,使得每个进程对应一个日志空间,由于进程是基于串行方式来处理多个交易的,因此,在进程对应的日志空间中,交易的操作信息是按照交易的处理顺序依次进行存储的;如此,若进程当前处理的交易异常,则节点可以通过查询进程对应的日志空间快速地获取到异常交易的各操作信息,从而可以基于该异常交易的各操作信息准确地对预设数据库进行回滚,提高交易处理的准确性。In the above design, by allocating different log space for each process in parallel, each process corresponds to a log space. Because the process is based on the serial method to process multiple transactions, therefore, in the log space corresponding to the process, The operation information of the transaction is stored in sequence according to the processing order of the transaction; in this way, if the transaction currently processed by the process is abnormal, the node can quickly obtain the operation information of the abnormal transaction by querying the log space corresponding to the process, which can be based on this The operation information of abnormal transactions is accurately rolled back to the preset database to improve the accuracy of transaction processing.
在一种可能的设计中,所述节点在第一进程处理的第一交易异常之前,所述方法还包括:所述节点从预设映射表获取所述第一进程对应的所述第一日志空间,并使用所述第一日志空间记录所述第一进程在处理所述第一交易的过程中对预设数据库的操作信息;相应地,所述节点若从所述预设映射表未获取到所述第一进程对应的所述第一日志空间,则为所述第一进程分配所述第一日志空间,并将所述第一进程与所述第一日志空间的对应关系添加在所述预设映射表中。In a possible design, before the first transaction processed by the first process by the node is abnormal, the method further includes: the node obtains the first log corresponding to the first process from a preset mapping table Space, and use the first log space to record the operation information of the first process on the preset database in the process of processing the first transaction; accordingly, if the node has not obtained from the preset mapping table To the first log space corresponding to the first process, the first log space is allocated for the first process, and the correspondence between the first process and the first log space is added in all The preset mapping table.
在上述设计中,通过设置预设映射表来存储进程与日志空间的对应关系,使得节点在确定使用进程处理交易时,可以直接查询预设映射表确定是否已为进程分配了对应的日志空间,从而可以避免为同一进程分配多个日志空间,提高对日志空间管理的灵活性。In the above design, the corresponding relationship between the process and the log space is stored by setting the preset mapping table, so that when the node determines to use the process to process the transaction, it can directly query the preset mapping table to determine whether the corresponding log space has been allocated for the process. This can avoid allocating multiple log spaces for the same process and improve the flexibility of log space management.
在一种可能的设计中,所述节点从预设映射表获取所述第一进程对应的所述第一日志空间之前,还包括:所述节点确定所述预设映射表处于未锁定状态;所述未锁定状态用于指示当前不存在进程使用所述预设映射表。In a possible design, before the node obtains the first log space corresponding to the first process from a preset mapping table, the method further includes: the node determines that the preset mapping table is in an unlocked state; The unlocked state is used to indicate that no process currently uses the preset mapping table.
在上述设计中,在节点使用预设映射表之前需要查询预设映射表的状态,若预设映射表处于未锁定状态时,则节点可以使用预设映射表为进程分配对应的预设映射表,若预设映射表处于锁定状态时,则节点无法使用预设映射表;也就是说,通过预先为预设映射表设置锁资源(即记录预设映射表的状态),可以避免多个进程同时访问预设映射表所导致的资源冲突,且可以避免节点同时为多个进程分配相同的日志空间,从而保证交易处理的准确性。In the above design, the state of the preset mapping table needs to be queried before the node uses the preset mapping table. If the preset mapping table is in an unlocked state, the node can use the preset mapping table to assign the corresponding preset mapping table to the process If the preset mapping table is locked, the node cannot use the preset mapping table; that is to say, by setting the lock resource for the preset mapping table in advance (that is, recording the state of the preset mapping table), multiple processes can be avoided Simultaneous access to the preset mapping table causes resource conflicts, and can prevent nodes from allocating the same log space for multiple processes at the same time, thereby ensuring the accuracy of transaction processing.
在一种可能的设计中,所述节点使用所述第一日志空间记录所述第一进程在处理所述第一交易的过程中对预设数据库的操作信息,包括:所述节点记录所述第一交易在所述第一日志空间中的第一条操作信息所在的初始位置或记录第二交易在所述第一日志空间中的最后一条操作信息所在的终止位置;所述第二交易为处理所述第一交易之前所述第一进程处理的交易;进一步地,所述节点从所述第一日志空间获取所述第一交易的各操作信息,包括:所述节点根据所述第一交易异常时所述第一日志空间中的最新一条操作信息所在的位置和所述初始位置确定所述第一交易的各操作信息;或,所述节点根据所述第一交易异常时所述第一日志空间中的最新一条操作信息所在的位置和所述终止位置确定所述第一交易的各操作信息。In a possible design, the node uses the first log space to record the operation information of the first process on the preset database in the process of processing the first transaction, including: the node records the The initial position of the first transaction in the first log space where the first piece of operation information is located or the end position where the last operation information of the second transaction is recorded in the first log space; the second transaction is Processing the transaction processed by the first process before the first transaction; further, the node acquiring each operation information of the first transaction from the first log space includes: the node according to the first When the transaction is abnormal, the position of the latest piece of operation information in the first log space and the initial position determine each operation information of the first transaction; or, the node determines the operation information of the first transaction according to the first transaction when the first transaction is abnormal The position of the latest piece of operation information in a log space and the termination position determine each operation information of the first transaction.
在上述设计中,进程在处理每个交易时可以记录该交易在日志空间中的起始位置或上一交易在日志空间中的终止位置,如此,在某一交易发生异常时,日志空间中当前位置与该交易在日志空间中的起始位置之间的各操作信息或者日志空间中当前位置与上一交易在日志空间中的终止位置即为该交易对应的各个操作信息;也就是说,通过记录每个交易在日志空间中的起始位置或上一交易在日志空间中的终止位置,可以快速且准确地获取每个交易对应的操作信息,提高基于交易对应的操作信息回滚预设数据库的准确性。In the above design, the process can record the starting position of the transaction in the log space or the ending position of the previous transaction in the log space when processing each transaction. In this way, when a certain transaction is abnormal, the current log space The operation information between the position and the starting position of the transaction in the log space or the current position in the log space and the ending position of the previous transaction in the log space are the operation information corresponding to the transaction; that is, through Record the start position of each transaction in the log space or the end position of the previous transaction in the log space, which can quickly and accurately obtain the operation information corresponding to each transaction, and improve the rollback of the preset database based on the operation information corresponding to the transaction Accuracy.
在一种可能的设计中,所述方法还包括:所述节点若确定所述第一进程处理完对应的所有交易,则释放所述第一日志空间占用的资源。In a possible design, the method further includes: if the node determines that the first process has processed all the corresponding transactions, releasing the resources occupied by the first log space.
在上述设计中,在进程处理完对应的所有交易后,通过在进程退出的同时释放进程对应的日志空间,可以降低系统资源占用情况,为后续进程对应的日志空间预留空间。In the above design, after the process has processed all the corresponding transactions, by releasing the log space corresponding to the process when the process exits, the system resource occupation can be reduced and space is reserved for the log space corresponding to the subsequent process.
第二方面,本发明实施例提供了一种基于区块链系统的交易处理装置,所述装置包括:In the second aspect, an embodiment of the present invention provides a transaction processing device based on a blockchain system, and the device includes:
确定模块,用于在第一进程处理的第一交易异常时,确定所述第一进程对应的第一日志空间;其中,所述第一日志空间用于记录所述第一进程在处理交易的过程中对预设数据库的操作信息;所述装置为并行的各进程分配的日志空间不同;The determining module is used to determine the first log space corresponding to the first process when the first transaction processed by the first process is abnormal; wherein, the first log space is used to record the transaction processing of the first process Operation information of the preset database during the process; the log space allocated by the device for each parallel process is different;
获取模块,用于从所述第一日志空间获取所述第一交易的各操作信息;An obtaining module, configured to obtain various operation information of the first transaction from the first log space;
处理模块,用于基于所述第一交易的各操作信息对所述预设数据库进行回滚操作。The processing module is configured to perform a rollback operation on the preset database based on each operation information of the first transaction.
在一种可能的设计中,所述确定模块在第一进程处理的第一交易异常之前,所述获取模块还用于:从预设映射表获取所述第一进程对应的所述第一日志空间;相应地,所述处理模块还用于:使用所述第一日志空间记录所述第一进程在处理所述第一交易的过程中对预设数据库的操作信息;进一步地,若所述获取模块从所述预设映射表未获取到所述第一进程对应的所述第一日志空间,则所述处理模块还用于:为所述第一进程分配所述第一日志空间,并将所述第一进程与所述第一日志空间的对应关系添加在所述预设映射表中。In a possible design, before the first transaction processed by the first process is abnormal, the determining module is further configured to: obtain the first log corresponding to the first process from a preset mapping table Correspondingly, the processing module is further configured to: use the first log space to record the operation information of the first process on the preset database in the process of processing the first transaction; further, if the The obtaining module does not obtain the first log space corresponding to the first process from the preset mapping table, and the processing module is further configured to: allocate the first log space for the first process, and Adding the correspondence between the first process and the first log space in the preset mapping table.
在一种可能的设计中,所述获取模块从预设映射表获取所述第一进程对应的所述第一日志空间之前,所述确定模块还用于:确定所述预设映射表处于未锁定状态;所述未锁定状态用于指示当前不存在进程使用所述预设映射表。In a possible design, before the obtaining module obtains the first log space corresponding to the first process from a preset mapping table, the determining module is further configured to: determine that the preset mapping table is not Locked state; the unlocked state is used to indicate that no process currently uses the preset mapping table.
在一种可能的设计中,所述处理模块具体用于:记录所述第一交易在所述第一日志空间中的第一条操作信息所在的初始位置或记录第二交易在所述第一日志空间中的最后一条操作信息所在的终止位置;所述第二交易为处理所述第一交易之前所述第一进程处理的交易;相应地,所述获取模块具体用于:根据所述第一交易异常时所述第一日志空间中的最新一条操作信息所在的位置和所述初始位置确定所述第一交易的各操作信息;或,所述节点根据所述第一交易异常时所述第一日志空间中的最新一条操作信息所在的位置和所述终止位置确定所述第一交易的各操作信息。In a possible design, the processing module is specifically configured to record the initial position of the first piece of operation information in the first log space of the first transaction or record the location of the second transaction in the first log space. The end position of the last piece of operation information in the log space; the second transaction is a transaction processed by the first process before the first transaction is processed; accordingly, the acquisition module is specifically configured to: When a transaction is abnormal, the position of the latest piece of operation information in the first log space and the initial position determine each operation information of the first transaction; or, the node determines the operation information of the first transaction according to the The position of the latest piece of operation information in the first log space and the termination position determine each operation information of the first transaction.
在一种可能的设计中,所述处理模块还用于:若确定所述第一进程处理完对应的所有交易,则释放所述第一日志空间占用的资源。In a possible design, the processing module is further configured to: if it is determined that the first process has processed all corresponding transactions, release the resources occupied by the first log space.
第三方面,本发明实施例提供了一种计算设备,包括至少一个处理单元以及至少一个存储单元,其中,所述存储单元存储有计算机程序,当所述程序被所述处理单元执行时,使得所述处理单元执行上述第一方面任意所述的基于区块链系统的交易处理方法。In a third aspect, an embodiment of the present invention provides a computing device that includes at least one processing unit and at least one storage unit, wherein the storage unit stores a computer program, and when the program is executed by the processing unit, The processing unit executes any transaction processing method based on the blockchain system described in the first aspect.
第四方面,本发明实施例提供了一种计算机可读存储介质,其存储有可由计算设备执行的计算机程序,当所述程序在所述计算设备上运行时,使得所述计算设备执行上述第一方面任意所述的基于区块链系统的交易处理方法。In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium that stores a computer program executable by a computing device, and when the program runs on the computing device, the computing device executes the foregoing On the one hand, any transaction processing method based on the blockchain system.
本发明的这些方面或其他方面在以下实施例的描述中会更加简明易懂。These and other aspects of the present invention will be more concise and understandable in the description of the following embodiments.
附图说明Description of the drawings
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简要介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域的普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly describe the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings needed in the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings may be obtained from these drawings without creative labor.
图1为本发明实施例提供的一种基于区块链系统的交易处理方法对应的流程示意图;FIG. 1 is a schematic diagram of a flow corresponding to a transaction processing method based on a blockchain system provided by an embodiment of the present invention;
图2为本发明实施例提供的一种基于区块链系统的交易处理方法的交互流程示意图;2 is a schematic diagram of the interaction flow of a transaction processing method based on a blockchain system provided by an embodiment of the present invention;
图3为本发明实施例提供的一种提供的基于区块链系统的交易处理装置的结构示意图;3 is a schematic structural diagram of a transaction processing device based on a blockchain system provided by an embodiment of the present invention;
图4为本发明实施例提供的一种计算设备的结构示意图。FIG. 4 is a schematic structural diagram of a computing device provided by an embodiment of the present invention.
具体实施方式detailed description
为了使本发明的目的、技术方案和优点更加清楚,下面将结合附图对本发明作进一步地详细描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其它实施例,都属于本发明保护的范围。In order to make the objectives, technical solutions and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of them. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the protection scope of the present invention.
金融科技(Fintech)技术领域通常涉及到多种交易,比如,银行的交易可以包括售卡交易、存款交易、贷款交易、保险交易、理财交易等,银行每天的交易量可以达到数千笔甚至数万笔。随着区块链技术的逐步发展,金融科技领域也可以使用区块链技术来处理交易,举例来说,若多家银行之间涉及到相关交易,则可以通过设置联盟链来同步处理相关交易,或者还可以将法院、客户等同时上链,共同维护联盟链的安全和稳定。The field of financial technology (Fintech) usually involves a variety of transactions. For example, bank transactions can include card sales, deposit transactions, loan transactions, insurance transactions, wealth management transactions, etc. The daily transaction volume of banks can reach thousands or even several. Thousands of pens. With the gradual development of blockchain technology, the financial technology field can also use blockchain technology to process transactions. For example, if multiple banks are involved in related transactions, you can set up a consortium chain to synchronize related transactions. , Or you can put the courts, customers, etc. on the chain at the same time to jointly maintain the security and stability of the alliance chain.
在区块链系统中,每个节点内部都可以设置有交易数据库,各个节点通过交易数据库共同维护区块链系统中的公共账本,节点内部的交易数据库可以存储该节点所处理的交易的区块数据和交易数据,区块数据主要可以包括交易开始的时间戳、区块的哈希值等。在实际操作中,交易数据库一般可以为键值数据库,键值数据库属于一种非关系数据库,可以基于简单的键值方法来存储数据,在键值数据库中,每条交易数据都可以以键值对集合的方式存储在键值数据库中,键作为唯一标识符,可以用于检索对应的值。In the blockchain system, each node can be set up with a transaction database, and each node maintains the public ledger in the blockchain system through the transaction database. The transaction database inside the node can store the transaction block processed by the node. Data and transaction data, block data can mainly include the timestamp of the start of the transaction, the hash value of the block, etc. In actual operation, the transaction database can generally be a key-value database. The key-value database is a non-relational database that can store data based on a simple key-value method. In a key-value database, each transaction data can be key-valued. The collection method is stored in a key-value database, and the key is used as a unique identifier to retrieve the corresponding value.
表1为本发明实施例提供的一种可能的交易数据库的示意表。Table 1 is a schematic table of a possible transaction database provided by an embodiment of the present invention.
表1:一种交易数据库的示意表Table 1: Schematic table of a transaction database
key value
11 1010
22 2020
33 3030
如表1所示,交易数据库中可以存储多条键值对,每条键值对均可以包括键和键对应的值。比如键为1的键值对对应的值为10,键为2的键值对对应的值为20,键为3的键值对对应的值为30。其中,交易数据库中的每条键值对可以标识交易的某一条交易数据,比如若交易为某一账户的交易,则该账户的每一笔收入或每一笔支出都可以作为一个单独的键值对。As shown in Table 1, multiple key-value pairs can be stored in the transaction database, and each key-value pair can include a key and a value corresponding to the key. For example, a key-value pair with a key of 1 corresponds to a value of 10, a key-value pair with a key of 2 corresponds to a value of 20, and a key-value pair with a key of 3 corresponds to a value of 30. Among them, each key-value pair in the transaction database can identify a certain transaction data of the transaction. For example, if the transaction is a transaction of a certain account, each income or each expenditure of the account can be used as a separate key Value pair.
本发明实施例中,区块链系统中的节点可以对内部设置的交易数据库进行各种写入操作,比如插入一条新的键值对、修改一条已存在的键值对、删除一条已存在的键值对等。其中,这些写入操作均可以基于交易数据库中的键来执行。下面分别描述三种可能的写入操作:In the embodiment of the present invention, the nodes in the blockchain system can perform various write operations on the internal transaction database, such as inserting a new key-value pair, modifying an existing key-value pair, and deleting an existing one. Key-value equivalence. Among them, these write operations can be performed based on the keys in the transaction database. Three possible write operations are described below:
插入写入操作Insert write operation
若某一时刻收入10,则可以在表1所示的交易数据库中插入一条键为4(也可以为其它值,根据实际需要设置)、对应的值为10的键值对,插入写入操作对应的操作信息可以 为“类型:插入,键:4”。如此,更新后的交易数据库可以如表2所示:If you earn 10 at a certain time, you can insert a key-value pair with a key of 4 (or other values, according to actual needs) and a corresponding value of 10 in the transaction database shown in Table 1, and insert a write operation The corresponding operation information can be "Type: Insert, Key: 4". In this way, the updated transaction database can be as shown in Table 2:
表2:一种插入操作对应的交易数据库的示意Table 2: Schematic of a transaction database corresponding to an insert operation
key value
11 1010
22 2020
33 3030
44 1010
修改写入操作:Modify write operation:
基于表2所示的交易数据库,若某一时刻修改键为2的交易收入为40,则可以在表2所示的交易数据库中将键为2的键值对对应的值改为40,修改写入操作对应的操作信息可以为“类型=修改,键=2,值:40”。如此,更新后的交易数据库可以如表3所示:Based on the transaction database shown in Table 2, if the transaction income with key 2 is modified to 40 at a certain moment, the value corresponding to the key-value pair with key 2 can be changed to 40 in the transaction database shown in Table 2. Modify The operation information corresponding to the write operation may be "type=modify, key=2, value: 40". In this way, the updated transaction database can be as shown in Table 3:
表3:一种修改操作对应的交易数据库的示意Table 3: A schematic diagram of the transaction database corresponding to a modification operation
key value
11 1010
22 4040
33 3030
44 1010
删除写入操作:Delete write operation:
基于表3所示意的交易数据库,若某一时刻撤回键为2的交易收入,则可以在表3所示的交易数据库中将键为2的键值对删除,删除写入操作对应的操作信息可以为“类型:删除,键:2”。如此,更新后的交易数据库可以如表4所示:Based on the transaction database shown in Table 3, if the transaction income with key 2 is withdrawn at a certain moment, the key-value pair with key 2 can be deleted in the transaction database shown in Table 3, and the operation information corresponding to the write operation can be deleted It can be "Type: Delete, Key: 2". In this way, the updated transaction database can be as shown in Table 4:
表4:一种删除操作对应的交易数据库的示意Table 4: A schematic diagram of the transaction database corresponding to a delete operation
key value
11 1010
33 3030
44 1010
在现有技术中,每个节点均可以针对于内部的交易数据库设置一个日志列表,从而将所有的写入操作保存在日志列表中。基于上述表1~表4,节点可以在日志列表中记录如表5a所示的日志列表,或者也可以在日志列表中记录如表5b所示的日志列表,具体不作限定。In the prior art, each node can set a log list for the internal transaction database, so as to save all write operations in the log list. Based on the foregoing Tables 1 to 4, the node can record the log list shown in Table 5a in the log list, or can also record the log list shown in Table 5b in the log list, which is not specifically limited.
表5a:一种可能的日志列表的示意表Table 5a: Schematic table of a possible log list
类型Types of key value
插入insert 44 1010
修改modify 22 4040
删除delete 22  To
表5b:另一种可能的日志列表的示意表Table 5b: Schematic table of another possible log list
Figure PCTCN2020109570-appb-000001
Figure PCTCN2020109570-appb-000001
参照表5a所示,该种日志列表是按照从上到下的顺序依次记录节点对交易数据库的写入操作,每一行数据均为一条写入操作信息;参照表5b所示,该种日志列表是按照从左到右的顺序依次记录节点对交易数据库的写入操作,每一列数据均为一条写入操作信息。Refer to Table 5a, this type of log list records the write operations of nodes to the transaction database in order from top to bottom, and each row of data is a piece of write operation information; refer to Table 5b, this type of log list It records the write operations of nodes to the transaction database in order from left to right, and each column of data is a piece of write operation information.
采用现有技术中的方案,在节点依次执行各个交易时,若某一个交易异常,则节点可以按照日志列表中写入操作的顺序获取该异常交易对应的写入操作,从而基于异常交易的写入操作对交易数据库进行回滚,这是没有问题的。然而,现阶段区块链系统中的节点通常采用并行方式处理交易,即同一时刻可能存在多个交易在执行,如此,日志列表中各个交易的写入操作可以是穿插的;举例来说,日志列表中第一~第五条写入操作属于交易a 1的五条写入操作,第六条写入操作属于交易a 2的一条写入操作,第七~第十条写入操作属于交易a 1的三条写入操作,则若在执行至第十条写入操作时发现交易a 1异常,则节点可以按照日志列表中的第十条写入操作~第一条写入操作对交易数据库进行回滚。由此可知,该次回滚操作在回滚异常交易a 1的写入操作的同时也回滚了正常交易a 2的写入操作,导致交易处理过程出错。 Using the prior art solution, when a node executes each transaction in sequence, if a certain transaction is abnormal, the node can obtain the write operation corresponding to the abnormal transaction in the order of the write operations in the log list, thereby based on the write operation of the abnormal transaction. The transaction database is rolled back by the import operation, which is no problem. However, at this stage, the nodes in the blockchain system usually process transactions in parallel, that is, there may be multiple transactions executing at the same time. In this way, the write operations of each transaction in the log list can be interspersed; for example, the log The first to fifth write operations in the list belong to the five write operations of transaction a 1 , the sixth write operation belongs to one write operation of transaction a 2 , and the seventh to ten write operations belong to transaction a 1 If the transaction a 1 is found to be abnormal when the tenth write operation is executed, the node can follow the tenth write operation to the first write operation in the log list to return to the transaction database roll. It can be seen that this rollback operation not only rolls back the write operation of the abnormal transaction a 1 but also rolls back the write operation of the normal transaction a 2 , resulting in an error in the transaction processing process.
基于此,本发明实施例提供了一种基于区块链系统的交易处理方法,用于准确地回滚异常交易的写入操作,从而提高交易处理的准确性。Based on this, the embodiment of the present invention provides a transaction processing method based on a blockchain system, which is used to accurately roll back the write operation of an abnormal transaction, thereby improving the accuracy of transaction processing.
图1为本发明实施例提供的一种基于区块链系统的交易处理方法对应的流程示意图,该方法可以应用于区块链系统中的任一节点,该方法包括:Fig. 1 is a schematic diagram of a process corresponding to a transaction processing method based on a blockchain system provided by an embodiment of the present invention. The method can be applied to any node in the blockchain system. The method includes:
步骤101,节点在第一进程处理的第一交易异常时,确定第一进程对应的第一日志空间。Step 101: When the first transaction processed by the first process is abnormal, the node determines the first log space corresponding to the first process.
本发明实施例中,区块链系统中的任一节点在接收到交易后,可以将交易存储在节点内部设置的交易池中,同时还可以将交易同步给区块链系统中的其它节点;相应地,其它节点在接收到交易后,可以将交易存储在其它节点内部设置的交易池中。进一步地,当从区块链系统的多个节点中确定出处理交易的第一节点后,第一节点可以先创建用于处理交易的进程,比如,若第一节点支持多进程并行处理交易,则第一节点可以同时创建多个并行的进程,并可以将进程与交易的对应关系存储在进程池中,后续使用每个进程处理对应的交易;若第一节点支持单进程串行处理交易,则可以创建一个进程,并使用该进程依次处理多个交易。举例来说,若第一节点同时接收到交易1~交易10,且第一节点的中央处理器(Central Processing Unit,CPU)核数为5(即第一节点最多支持5个进程并行处理交易),则第一节点可以创建并行的进程b 1~进程b 5;若进程b 1~进程b 5的处理能力相同,则第一节点可以为进程b 1分配交易1和交易2,为进程b 2分配交易3和交易4,为进程b 3分配交易5和交易6,为进程b 4分配交易7和交易8,为进程b 5分配交易9和交易10。 In the embodiment of the present invention, after any node in the blockchain system receives the transaction, it can store the transaction in the transaction pool set inside the node, and at the same time can synchronize the transaction to other nodes in the blockchain system; Correspondingly, after receiving the transaction, other nodes can store the transaction in the transaction pool set internally by other nodes. Further, when the first node to process the transaction is determined from the multiple nodes of the blockchain system, the first node can first create a process for processing the transaction. For example, if the first node supports multi-process parallel processing of transactions, Then the first node can create multiple parallel processes at the same time, and can store the corresponding relationship between the process and the transaction in the process pool, and subsequently use each process to process the corresponding transaction; if the first node supports single-process serial processing transactions, You can create a process and use it to process multiple transactions in turn. For example, if the first node receives transactions 1 to 10 at the same time, and the number of central processing unit (CPU) cores of the first node is 5 (that is, the first node supports up to 5 processes to process transactions in parallel) , the first node may create a parallel process to process b 1 b 5 ~; ~ 1 the same process if the process b 5 b processing capacity, the first node may be assigned a transaction process b 1 and transaction 2, b 2 of the process 3 and 4 transactions dispensing transactions, transactions for the process b 3 to 5 and 6 transactions, transactions for the process b 4 to 7 and 8 transactions, transactions for the process b 5 to 9 and 10 transactions.
进一步地,第一节点在创建并行的进程b 1~进程b 5之后,可以从存储器中为并行的各进程分配不同的日志空间,每个进程对应的日志空间用于记录该进程在处理交易的过程中对 预设数据库的操作信息;此处,预设数据库是指第一节点中的交易数据库。其中,存储器可以包括至少一种类型的存储介质,例如可以包括闪存、硬盘、多媒体卡、卡型存储器、随机访问存储器(Random Access Memory,RAM)、静态随机访问存储器(Static Random Access Memory,SRAM)、可编程只读存储器(Programmable Read Only Memory,PROM)、只读存储器(Read Only Memory,ROM)、带电可擦除可编程只读存储器(Electrically Erasable Programmable Read-Only Memory,EEPROM)、磁性存储器、磁盘、光盘等等。存储器是能够用于携带或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的任何其他介质,但不限于此。本发明实施例中的存储器还可以是电路或者其它任意能够实现存储功能的装置,用于存储程序指令和/或数据。 Further, after the first node creates parallel processes b 1 ˜process b 5 , it can allocate different log space for each parallel process from the memory, and the log space corresponding to each process is used to record the transaction processing of the process. Operation information on the preset database during the process; here, the preset database refers to the transaction database in the first node. The memory may include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type memory, random access memory (Random Access Memory, RAM), and static random access memory (Static Random Access Memory, SRAM). , Programmable Read Only Memory (PROM), Read Only Memory (Read Only Memory, ROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), magnetic memory, Disk, CD, etc. The memory is any other medium that can be used to carry or store desired program codes in the form of instructions or data structures and that can be accessed by a computer, but is not limited thereto. The memory in the embodiment of the present invention may also be a circuit or any other device capable of realizing a storage function for storing program instructions and/or data.
具体实施中,第一节点可以预先在存储器中设置一块初始存储空间,在每次创建一个进程后,第一节点均可以从该初始存储空间未占用的存储空间中选取预设数据量的子存储空间作为进程对应的日志空间,如此,进程在处理交易的过程中所执行的全部写入操作均可以记录在进程对应的日志空间中。其中,子存储空间的预设数据量和初始存储空间的大小可以由本领域技术人员根据经验进行设置,或者也可以根据实际需要进行设置,具体不做限定。In specific implementation, the first node can set an initial storage space in the memory in advance. After each process is created, the first node can select a sub-storage with a preset amount of data from the storage space not occupied by the initial storage space. The space is used as the log space corresponding to the process. In this way, all write operations performed by the process in the process of processing transactions can be recorded in the log space corresponding to the process. Among them, the preset data amount of the sub-storage space and the size of the initial storage space can be set by those skilled in the art based on experience, or can also be set according to actual needs, and the specifics are not limited.
举例来说,若初始存储空间占据的空间范围为00000000~10000000,预设数据量为00000010,则第一节点创建进程b 1~进程b 5之后,若查询初始存储空间确定空间范围00000000~00000010已被占用,则可以从00000010~10000000中选取子存储空间1~子存储空间5,并将子存储空间1~子存储空间5分别分配给进程b 1~进程b 5;比如,子存储空间1可以占用空间范围00000010~00000100,子存储空间2可以占用空间范围00000100~00000110,子存储空间3可以占用空间范围00000110~00001000,子存储空间4可以占用空间范围00001000~00001010,子存储空间5可以占用空间范围00001010~00001100,子存储空间1~子存储空间5中每个子存储空间可以存储00000010的数据量。 For example, if the initial storage space occupies the space range from 00000000 to 10000000 and the preset data volume is 00000010, after the first node creates the process b 1 to process b 5 , if the initial storage space is queried, the space range from 00000000 to 00000010 is determined Is occupied, you can select sub storage space 1 to sub storage space 5 from 00000010 to 10000000, and allocate sub storage space 1 to sub storage space 5 to processes b 1 to process b 5 respectively ; for example, sub storage space 1 can Occupied space range 00000010~00000100, sub storage space 2 can occupy space range 00000100~00000110, sub storage space 3 can occupy space range 00000110~00001000, sub storage space 4 can occupy space range 00001000~00001010, sub storage space 5 can occupy space The range is from 00001010 to 00001100, and each sub-storage space from sub-storage space 1 to sub-storage space 5 can store a data amount of 00000010.
需要说明的是,上述仅是一种示例性的简单说明,其所列举的子存储空间1~子存储空间5所占用的空间范围仅是为了便于说明方案,并不构成对方案的限定,在具体实施中,子存储空间1~子存储空间5所占用的空间范围可以为从00000010~10000000中任意选取的,比如子存储空间1占用空间范围00000010~00000100,子存储空间2占用空间范围00001010~00001100,子存储空间3占用空间范围0001000~00001010,子存储空间4可以占用空间范围00000100~00000110,子存储空间5可以占用空间范围00000110~000010000,具体不作限定。It should be noted that the above is only an exemplary simple description, and the range of space occupied by sub-storage space 1 to sub-storage space 5 is only for the convenience of explaining the solution, and does not constitute a limitation on the solution. In specific implementation, the space occupied by sub-storage space 1 to sub-storage space 5 can be arbitrarily selected from 00000010 to 10000000, for example, sub-storage space 1 occupies a space range of 00000010 to 00000100, and sub-storage space 2 occupies a space range of 00001010 to 00001100, sub-storage space 3 occupies a space range of 0001000 to 00001010, sub-storage space 4 can occupy a space range of 00000100 to 00000110, and sub-storage space 5 can occupy a space range of 00000110 to 000010000, which is not specifically limited.
以第一进程为进程b 1例,具体实施中,第一节点在将子存储空间1分配给进程b 1之后,子存储空间1即为进程b 1对应的日志空间,进程b 1可以将后续处理的所有交易的操作信息记录在子存储空间1中;比如,若进程b 1依次处理交易1和交易2,则第一节点可以将进程b 1处理交易1和交易2的过程中对预设数据库的操作信息按照顺序记录在进程b 1对应的日志空间中。如此,若进程b 1确定其正在处理的交易2异常,则可以从子存储空间1中获取交易2的各操作信息。 Take the first process as an example of process b 1. In specific implementation, after the first node allocates sub-storage space 1 to process b 1 , sub-storage space 1 is the log space corresponding to process b 1 , and process b 1 can transfer subsequent The operation information of all transactions processed is recorded in the sub-storage space 1. For example, if the process b 1 processes transaction 1 and transaction 2 in turn, the first node can preset the process b 1 to process transaction 1 and transaction 2 The operation information of the database is recorded in the log space corresponding to the process b 1 in order. So, if the process b 1 to determine which transaction is being processed two exceptions, it can obtain information on the operation of each transaction 2 from the storage space in the sub-1.
在一种可能的实现方式中,为了便于查询进程对应的日志空间,第一节点还可以设置预设映射表,并使用预设映射表存储进程与日志空间的对应关系。在一种可能的实现方式中,第一节点可以采用下列方式为进程b 1分配对应的日志空间:在创建进程b 1后,第一节点可以先查询预设映射表确定预设映射表中是否包含进程b 1对应的日志空间,若预设映射 表中包含进程b 1对应的日志空间,则第一节点可以直接使用进程b 1对应的日志空间记录进程b 1在处理交易的过程中对预设数据库的所有操作信息。相应地,若预设映射表中不包含进程b 1对应的日志空间,则第一节点可以从初始存储空间当前未占用的存储空间中选取预设数据量的子存储空间作为进程b 1对应的日志空间,并可以将进程b 1与进程b 1对应的日志空间的对应关系添加在预设映射表中;如此,第一节点可以使用进程b 1对应的日志空间记录进程b 1在处理交易的过程中对预设数据库的所有操作信息。 In a possible implementation manner, in order to facilitate the query of the log space corresponding to the process, the first node may also set a preset mapping table, and use the preset mapping table to store the correspondence between the process and the log space. In a possible implementation manner, the first node can allocate the corresponding log space for the process b 1 in the following manner: After the process b 1 is created, the first node can first query the preset mapping table to determine whether the preset mapping table is Contains the log space corresponding to the process b 1. If the preset mapping table contains the log space corresponding to the process b 1 , then the first node can directly use the log space corresponding to the process b 1 to record that the process b 1 is Set all operation information of the database. Correspondingly, if the log space corresponding to process b 1 is not included in the preset mapping table, the first node may select a sub-storage space with a preset amount of data from the storage space currently unoccupied by the initial storage space as the sub-storage space corresponding to process b 1 Log space, and the corresponding relationship between the log space corresponding to process b 1 and process b 1 can be added to the preset mapping table; in this way, the first node can use the log space corresponding to process b 1 to record that process b 1 is processing transactions All operation information of the preset database during the process.
表6为本发明实施例提供的一种可能的预设映射表的示意表。Table 6 is a schematic table of a possible preset mapping table provided by an embodiment of the present invention.
表6:一种预设映射表的示意Table 6: An illustration of a preset mapping table
进程标识Process ID 日志空间Log space
进程b 1 Process b 1 00000010~0000010000000010~00000100
进程b 2 Process b 2 00000100~0000011000000100~00000110
进程b 3 Process b 3 00000110~0000100000000110~00001000
进程b 4 Process b 4 00001000~0000101000001000~00001010
进程b 5 Process b 5 00001010~0000110000001010~00001100
如表6所示,预设映射表中可以存储有进程的标识和进程对应的日志空间的起始位置和终止位置,如表6所示,进程b 1对应的日志空间占用00000010~00000100范围内的空间,第一节点可以将进程b 1处理交易1和交易2时对预设数据库的操作信息存储在00000010~00000100范围的空间中;进程b 2对应的日志空间占用00000100~00000110范围内的空间,第一节点可以将进程b 2处理交易3和交易4时对预设数据库的操作信息存储在00000100~00000110范围的空间中;进程b 3对应的日志空间占用00000110~00001000范围内的空间,第一节点可以将进程b 3处理交易5和交易6时对预设数据库的操作信息存储在00000110~00001000范围的空间中;进程b 4对应的日志空间占用00001000~00001010范围内的空间,第一节点可以将进程b 4处理交易7和交易8时对预设数据库的操作信息存储在00001000~00001010范围的空间中;进程b 5对应的日志空间占用00001010~00001100范围内的空间,第一节点可以将进程b 5处理交易9和交易10时对预设数据库的操作信息存储在00001010~00001100范围的空间中。 As shown in Table 6, the identification of the process and the start and end positions of the log space corresponding to the process can be stored in the preset mapping table. As shown in Table 6, the log space corresponding to the process b 1 occupies the range of 00000010~00000100 The first node can store the operation information of the preset database when process b 1 processes transaction 1 and transaction 2 in the space of 00000010~00000100; the log space corresponding to process b 2 occupies the space in the range of 00000100~00000110 , The first node can store the operation information of the preset database when process b 2 processes transaction 3 and transaction 4 in the space of 00000100~00000110; the log space corresponding to process b 3 occupies the space in the range of 00000110~00001000. One node can store the operation information of the preset database when process b 3 processes transaction 5 and transaction 6 in the space in the range of 00000110~00001000; the log space corresponding to process b 4 occupies the space in the range of 00001000~00001010, the first node The operation information of the preset database when process b 4 processes transactions 7 and 8 can be stored in the space of 00001000~00001010; the log space corresponding to process b 5 occupies the space of 00001010~00001100, the first node can store process 9 b 5 transactions and transaction processing of the default database stored in the operation information space 00001010 00001100 ~ 10 range.
需要说明的是,操作信息在日志空间中可以以表格的形式存储,或者也可以以其它形式存储,不作限定。It should be noted that the operation information can be stored in the form of a table in the log space, or can also be stored in other forms, which is not limited.
本发明实施例中,通过设置预设映射表来存储进程与日志空间的对应关系,使得第一节点在确定使用进程处理交易时,可以直接查询预设映射表确定是否已为进程分配了对应的日志空间,从而可以避免为同一进程分配多个日志空间,提高对日志空间管理的灵活性。In the embodiment of the present invention, a preset mapping table is set to store the corresponding relationship between the process and the log space, so that when the first node determines to use the process to process the transaction, it can directly query the preset mapping table to determine whether the corresponding process has been allocated Log space, which can avoid allocating multiple log spaces for the same process and improve the flexibility of log space management.
在上述实现方式中,由于预设映射表为公共资源,若同时存在多个进程访问预设映射表,则多个进程可能需要采用竞争的方式来获取预设映射表,导致预设映射表处于不稳定状态。为了解决这个问题,在一个示例中,第一节点在设置预设映射表时,还可以为预设映射表设置锁资源;如此,第一节点从预设映射表中获取进程b 1对应的日志空间之前,还可以根据预设映射表的锁资源确定预设映射表的状态,若确定预设映射表处于未锁定状态,则可以获取进程b 1对应的日志空间,若确定预设映射表处于锁定状态,则可以执行等待。 其中,锁资源可以以表格的形式存在,或者也可以以图的形式存在,不作限定。 In the above implementation, since the preset mapping table is a common resource, if multiple processes access the preset mapping table at the same time, multiple processes may need to use a competitive method to obtain the preset mapping table, resulting in the preset mapping table being in Unstable state. To solve this problem, in an example, when the first node sets the preset mapping table, it can also set lock resources for the preset mapping table; in this way, the first node obtains the log corresponding to the process b 1 from the preset mapping table Before space, the state of the preset mapping table can also be determined according to the lock resource of the preset mapping table. If the preset mapping table is determined to be in an unlocked state, the log space corresponding to process b 1 can be obtained. If the preset mapping table is determined to be Locked state, you can perform waiting. Among them, the lock resource may exist in the form of a table, or may also exist in the form of a graph, which is not limited.
表7为本发明实施例提供的一种锁资源的示意表,表7中的锁资源是以表格形式存在的。Table 7 is a schematic table of a lock resource provided by an embodiment of the present invention, and the lock resource in Table 7 exists in a table form.
表7:一种锁资源的示意Table 7: An illustration of a lock resource
资源Resources 状态(未锁定或锁定)Status (unlocked or locked)
预设映射表Default mapping table 未锁定Not locked
如表7所示,锁资源中可以包括预设映射表和预设映射表的状态的对应关系,若预设映射表的状态为锁定状态,则说明当前存在某一进程访问预设映射表,如此,其它进程暂时无法访问预设映射表;若预设映射表的状态为未锁定状态,则说明当前不存在进程访问预设映射表,如此,其它进程可以访问预设映射表。As shown in Table 7, the lock resource can include the corresponding relationship between the preset mapping table and the state of the preset mapping table. If the state of the preset mapping table is locked, it means that a certain process currently accesses the preset mapping table. In this way, other processes cannot access the preset mapping table temporarily; if the status of the preset mapping table is unlocked, it means that no process currently accesses the preset mapping table, so other processes can access the preset mapping table.
具体实施中,第一节点在创建进程b 1后,可以先查询确定预设映射表的状态,若确定预设映射表处于未锁定状态,则可以查询确定预设映射表中是否包含进程b 1对应的日志空间,并将预设映射表的状态设置为锁定状态,以避免其它进程访问预设映射表;进一步地,当第一节点从预设映射表中获取到进程b 1对应的日志空间,或者第一节点已为进程b 1分配对应的日志空间且将进程b 1和进程b 1对应的日志空间的对应关系存储在预设映射表之后,第一节点可以将预设映射表的状态设置为未锁定状态。相应地,若确定预设映射表处于锁定状态,则第一节点可以等待至预设映射表的状态转换为未锁定状态,再查询确定预设映射表中是否包含进程b 1对应的日志空间。 Implementation, after creating the first node in the process b 1, can first query determines the default mapping table of the state, if it is determined the preset mapping table in an unlocked state, you can query to determine whether the preset mapping table contains the process b 1 Corresponding log space, and set the state of the preset mapping table to the locked state to prevent other processes from accessing the preset mapping table; further, when the first node obtains the log space corresponding to process b 1 from the preset mapping table log space, or the first node has been allocated for the process corresponding to b 1 b 1 and the process and process b correspondence relationship storage space 1 corresponding to the log after a preset mapping table, the first node may be a state preset mapping table Set to unlocked state. Accordingly, if it is determined the preset mapping table in a locked state, the first node may wait until a predetermined mapping table state to the unlocked state, then check to determine whether the preset mapping table contains the corresponding process b 1 log space.
本发明实施例中,在第一节点使用预设映射表之前需要查询预设映射表的状态,若预设映射表处于未锁定状态时,则第一节点可以使用预设映射表为进程分配对应的预设映射表,若预设映射表处于锁定状态,则第一节点无法使用预设映射表;也就是说,通过预先为预设映射表设置锁资源,可以避免多个进程同时访问预设映射表所导致的资源冲突,且可以避免第一节点同时为多个进程分配相同的日志空间,从而保证交易处理的准确性。In the embodiment of the present invention, before the first node uses the preset mapping table, the state of the preset mapping table needs to be queried. If the preset mapping table is in an unlocked state, the first node can use the preset mapping table to assign corresponding processes to the process. If the preset mapping table is locked, the first node cannot use the preset mapping table; that is, by setting lock resources for the preset mapping table in advance, multiple processes can avoid accessing the preset at the same time The resource conflict caused by the mapping table can prevent the first node from allocating the same log space to multiple processes at the same time, thereby ensuring the accuracy of transaction processing.
步骤102,第一节点从第一日志空间获取第一交易的各操作信息。Step 102: The first node obtains each operation information of the first transaction from the first log space.
本发明实施例中,第一节点在为进程b 1分配了对应的日志空间后,可以使用进程b 1对应的日志空间记录进程b 1在处理交易的过程中对预设数据库的操作信息;由于进程b 1按照串行方式处理交易,因此若进程b 1处理多个交易,则多个交易的操作信息可以按照交易的处理顺序依次被记录在日志空间中。如此,若进程b 1在处理某一交易时发现该交易异常,则第一节点可以直接从进程b 1对应的日志空间中获取该异常交易的全部操作信息;由于进程b 1按照串行方式处理交易,因此进程b 1对应的日志空间不会存在多个交易的操作信息穿插记录的情况,从而可以保证获取到的全部为异常交易的操作信息,并能提高获取的速度。 In the embodiment of the present invention, after the first node allocates the corresponding log space for the process b 1 , it can use the log space corresponding to the process b 1 to record the operation information of the process b 1 on the preset database during the transaction processing; The process b 1 processes transactions in a serial manner. Therefore, if the process b 1 processes multiple transactions, the operation information of the multiple transactions can be sequentially recorded in the log space according to the processing order of the transactions. Thus, if the transaction process b 1 found in the exception processing a transaction, the first node directly from the process b 1 log space corresponding to the acquired information on the overall operation of unusual transactions; b 1 because the process according to the serial processing mode Therefore, the log space corresponding to the process b 1 will not have the operation information of multiple transactions interspersed with records, which can ensure that all the operation information of the abnormal transaction is obtained, and the speed of the acquisition can be improved.
举例来说,若进程b 1依次处理交易1和交易2,处理交易1时对预设数据库的操作信息包括操作信息1和操作信息2,处理交易2时对预设数据库的操作信息包括操作信息3、操作信息4和操作信息5,则进程b 1对应的日志空间可以依次记录操作信息1、操作信息2、操作信息3、操作信息4和操作信息5,如表8所示。 For example, if process b 1 processes transaction 1 and transaction 2 in turn, the operation information on the preset database when processing transaction 1 includes operation information 1 and operation information 2, and the operation information on the default database when processing transaction 2 includes operation information 3. Operation information 4 and operation information 5, the log space corresponding to process b 1 can record operation information 1, operation information 2, operation information 3, operation information 4, and operation information 5 in sequence, as shown in Table 8.
表8:一种进程b 1对应的日志空间的示意 Table 8: A schematic diagram of log space corresponding to process b 1
位置position 操作信息Operation information
第一字节First byte 操作信息1Operation information 1
第二字节Second byte 操作信息2Operation information 2
第三字节Third byte 操作信息3Operation information 3
第四字节Fourth byte 操作信息4Operation information 4
第五字节Fifth byte 操作信息5Operation information 5
如此,若进程b 1在处理交易2对应的操作信息4时发现交易2为异常交易,则第一节点可以从进程b 1对应的日志空间中获取操作信息3和操作信息4。 Thus, when the process of processing the transaction in the b 1 corresponding to the operation information 2 4 2 is found to be abnormal trading transaction, the first node may log space from process b 1 corresponding to the operation information acquiring operation information 3 and 4.
具体实施中,第一节点获取异常交易对应的操作信息的方式可以有多种,比如第一节点可以将交易的标识和操作信息的对应关系记录在进程b 1对应的日志空间中,如此,第一节点在确定异常交易后,可以从进程b 1对应的日志空间中获取与异常交易的标识匹配的操作信息,作为异常交易的各操作信息。下面描述两种获取异常交易对应的操作信息的实现方式。 In particular embodiments, the first node acquires operation information corresponding to unusual transactions There are many ways, such correspondence between the identifier of the first node and the transaction may be recorded in the process of operation information b 1 corresponding to log space, thus, the first After a node determines the abnormal transaction, it can obtain the operation information matching the identifier of the abnormal transaction from the log space corresponding to the process b 1 as each operation information of the abnormal transaction. The following describes two implementation methods for obtaining operation information corresponding to abnormal transactions.
实现方式一Realization method one
在实现方式一中,第一节点在进程b 1处理每个交易的过程中,可以记录日志空间中每个交易对预设数据库的第一条操作信息所在的起始位置;如此,在确定某一条交易为异常交易后,第一节点可以从进程b 1对应的日志空间中获取最新一条操作信息所在的位置,并可以将最新一条操作信息所在的位置和该异常交易的起始位置之间的各个操作信息确定为异常交易的各操作信息。 In one implementation, the first node in the process during process b 1 of each transaction, the starting position may be recorded each transaction log space for the first preset operation information database resides; thus, determining a After a transaction is an abnormal transaction, the first node can obtain the location of the latest piece of operation information from the log space corresponding to process b 1 , and can compare the position between the location of the latest piece of operation information and the start position of the abnormal transaction. Each operation information is determined as each operation information of the abnormal transaction.
需要说明的是,异常交易的各操作信息包括最新一条操作信息和异常交易的起始位置对应的操作信息。It should be noted that each operation information of the abnormal transaction includes the latest piece of operation information and the operation information corresponding to the starting position of the abnormal transaction.
基于表8所示意的日志空间,第一节点在进程b 1在处理交易1时,会记录交易1的第一条操作信息所在的位置,由于交易1的第一条操作信息为操作信息1,因此第一节点记录交易1的第一条操作信息所在的位置为第一字节;相应地,第一节点在进程b 1在处理交易2时,会记录交易2的第一条操作信息所在的位置,由于交易2的第一条操作信息为操作信息3,因此第一节点记录交易2的第一条操作信息所在的位置为第三字节。如此,若进程b 1在处理交易2对应的操作信息4时发现交易2为异常交易,则第一节点可以获取当前最新的操作信息所在的位置,即第四字节,并可以将第三字节和第四字节之间的操作信息(即操作信息3和操作信息4)作为异常交易2的两个操作信息。 Based on the log space shown in Table 8, the first node will record the location of the first operation information of transaction 1 when process b 1 is processing transaction 1. Since the first operation information of transaction 1 is operation information 1, Thus the first dot recording position in the first operation information for transactions where a first byte; Accordingly, the first node in a transaction processing 2, the first operation information records where the transaction in process b 2 of Location, since the first piece of operation information of transaction 2 is operation information 3, the position where the first node records the first piece of operation information of transaction 2 is the third byte. In this way, if process b 1 finds that transaction 2 is an abnormal transaction when processing operation information 4 corresponding to transaction 2, the first node can obtain the position of the current latest operation information, that is, the fourth byte, and can change the third word The operation information between the section and the fourth byte (that is, operation information 3 and operation information 4) is used as the two operation information of abnormal transaction 2.
实现方式二Implementation method two
在实现方式二中,第一节点在进程b 1处理每个交易之前,可以记录进程b 1对应的日志空间中上一交易的最后一条操作信息所在的终止位置;如此,在确定某一条交易为异常交易后,第一节点可以从进程b 1对应的日志空间中获取最新一条操作信息所在的位置,并可以将最新一条操作信息所在的位置和终止位置之间的各个操作信息确定为异常交易的各操作信息。 In the second implementation mode, before the process b 1 processes each transaction, the first node can record the termination position of the last operation information of the previous transaction in the log space corresponding to the process b 1 ; in this way, when determining a certain transaction After the abnormal transaction, the first node can obtain the location of the latest piece of operation information from the log space corresponding to the process b 1 , and can determine each piece of operation information between the location of the latest piece of operation information and the termination position as the abnormal transaction Each operation information.
需要说明的是,异常交易的各操作信息包括最新一条操作信息,不包括异常交易的上一交易的终止位置对应的操作信息。It should be noted that each operation information of the abnormal transaction includes the latest piece of operation information, but does not include the operation information corresponding to the termination position of the previous transaction of the abnormal transaction.
基于表8所示意的日志空间,第一节点在进程b 1在处理交易2之前,可以记录交易2的上一交易(即交易1)在进程b 1对应的日志空间中的最后一条操作信息所在的位置,由于交易1的最后一条操作信息为操作信息2,因此第一节点记录交易1的最后一条操作信息所在的位置为第二字节。如此,若进程b 1在处理交易2对应的操作信息4时发现交易2为异常交易, 则第一节点可以获取当前最新的操作信息所在的位置,即第四字节,并可以将第二字节和第四字节之间的操作信息(即操作信息3和操作信息4)作为异常交易2的两个操作信息。 Based on the log space shown in Table 8, the first node can record the last operation information of the last transaction of transaction 2 (ie transaction 1) in the log space corresponding to process b 1 before processing transaction 2 in process b 1 Since the last operation information of transaction 1 is operation information 2, the position where the first node records the last operation information of transaction 1 is the second byte. Thus, if the process b 1 2 4 corresponding to the operation information found in the process of transaction by transaction 2 is abnormal, then the first node may acquire the current position of the latest operation information is located, i.e. the fourth byte, and the second word may be The operation information between the section and the fourth byte (that is, operation information 3 and operation information 4) is used as the two operation information of abnormal transaction 2.
本发明实施例中,进程在处理每个交易时可以记录该交易在日志空间中的起始位置或上一交易在日志空间中的终止位置,如此,在某一交易发生异常时,日志空间中当前位置和该交易在日志空间中的起始位置或上一交易在日志空间中的终止位置之间的各操作信息即为该异常交易对应的各个操作信息;也就是说,通过记录每个交易在日志空间中的起始位置或上一交易在日志空间中的终止位置,可以快速且准确地获取每个交易对应的操作信息,提高基于交易对应的操作信息回滚预设数据库的准确性。In the embodiment of the present invention, when processing each transaction, the process can record the starting position of the transaction in the log space or the ending position of the last transaction in the log space. In this way, when a certain transaction is abnormal, the log space The operation information between the current position and the starting position of the transaction in the log space or the ending position of the previous transaction in the log space is the operation information corresponding to the abnormal transaction; that is, by recording each transaction At the starting position in the log space or the ending position of the previous transaction in the log space, the operation information corresponding to each transaction can be quickly and accurately obtained, and the accuracy of rolling back the preset database based on the operation information corresponding to the transaction can be improved.
步骤103,第一节点基于第一交易的各操作信息对预设数据库进行回滚操作。Step 103: The first node performs a rollback operation on the preset database based on each operation information of the first transaction.
具体实施中,基于表8所示意的日志空间,若第一节点确定操作信息3和操作信息4为异常交易2的各个操作信息,则可以先使用操作信息4对预设数据库回滚,再使用操作信息3对预设数据库回滚。其中,在对预设数据库回滚完成后,预设数据库的状态与第一节点执行完操作信息2之后的预设数据库的状态相同。In specific implementation, based on the log space shown in Table 8, if the first node determines that the operation information 3 and the operation information 4 are the operation information of the abnormal transaction 2, it can use the operation information 4 to roll back the preset database, and then use Operation information 3 rolls back the preset database. Wherein, after the rollback of the preset database is completed, the state of the preset database is the same as the state of the preset database after the first node finishes executing the operation information 2.
进一步地,第一节点可以查询线程池确定线程池中是否还存在进程b 1未处理的交易,若确定线程池中存在进程b 1还未处理的交易(比如交易11),则可以继续使用进程b 1处理交易11,并可以将处理交易11的过程中对预设数据库的操作信息顺序记录在进程b 1对应的日志空间中,重复执行步骤101~步骤103的过程直至线程池中不存在进程b 1未处理的交易为止。 Further, the first node can query the thread pool to determine whether there are still transactions unprocessed by process b 1 in the thread pool. If it is determined that there are transactions that have not been processed by process b 1 in the thread pool (for example, transaction 11), the process can continue to be used b 1 Process transaction 11, and record the operation information of the preset database in the process of processing transaction 11 in the log space corresponding to process b 1. Repeat the process from step 101 to step 103 until there is no process in the thread pool b 1 Until unprocessed transactions.
在一种可能的实现方式中,若确定线程池中不存在进程b 1未处理的交易,则说明进程b 1已处理完对应的所有交易,如此,第一节点可以释放进程b 1对应的日志空间占用的资源。基于表6所示的预设映射表,具体实施中,第一节点通过查询表6确定进程b 1对应的日志空间为00000010~00000100,如此,第一节点可以清空初始存储空间中00000010~00000100的空间范围内存储的数据。 In a possible implementation, if it is determined that there are no unprocessed transactions of process b 1 in the thread pool, it means that process b 1 has processed all the corresponding transactions. In this way, the first node can release the log corresponding to process b 1 Resources occupied by space. Based on the preset mapping table shown in Table 6, in specific implementation, the first node determines by querying table 6 that the log space corresponding to process b 1 is 00000010~00000100. In this way, the first node can clear the initial storage space of 00000010~00000100 Data stored in the space.
本发明实施例中,在进程处理完对应的所有交易后,通过在进程退出的同时释放进程对应的日志空间,可以降低系统资源占用情况,为后续进程对应的日志空间预留空间。In the embodiment of the present invention, after the process has processed all the corresponding transactions, by releasing the log space corresponding to the process while the process exits, the system resource occupation can be reduced and space is reserved for the log space corresponding to the subsequent process.
图2为本发明实施例中基于区块链系统的交易处理方法的交互流程示意图,下面结合图2对本发明实施例进行具体介绍。FIG. 2 is a schematic diagram of the interaction flow of the transaction processing method based on the blockchain system in the embodiment of the present invention. The following describes the embodiment of the present invention in detail with reference to FIG. 2.
本发明实施例中基于区块链系统的交易处理方法涉及后台的各个模块,具体包括:日志空间管理器、第一线程等。其中,日志空间管理器可以为软件设备,第一线程可以为区块链系统的节点中的任一线程。The transaction processing method based on the blockchain system in the embodiment of the present invention involves various modules in the background, specifically including: a log space manager, a first thread, and the like. Among them, the log space manager may be a software device, and the first thread may be any thread in the nodes of the blockchain system.
步骤201,第一线程在被节点创建后,向日志空间管理器发送日志空间请求消息。Step 201: After being created by the node, the first thread sends a log space request message to the log space manager.
此处,节点在创建第一线程后,可以向第一线程分配对应的交易;比如,节点可以将第一线程与交易的对应关系存储在公共线程池中,以使第一节点自行访问公共线程池来获取交易;或者,节点也可以将交易发送给第一线程,由第一线程自行存储在内部空间,不作限定。Here, after the node creates the first thread, it can allocate the corresponding transaction to the first thread; for example, the node can store the correspondence between the first thread and the transaction in the public thread pool, so that the first node can access the public thread by itself The pool obtains the transaction; alternatively, the node can also send the transaction to the first thread, and the first thread will store it in the internal space by itself, which is not limited.
进一步地,在被节点创建后,第一线程可以向日志空间管理器发送日志空间请求消息,日志空间请求消息中可以携带第一进程的标识。Further, after being created by the node, the first thread may send a log space request message to the log space manager, and the log space request message may carry the identifier of the first process.
步骤202,日志空间管理器接收到第一线程发送的日志空间请求消息后,获取预设映射表的状态,确定预设映射表是否被锁定;若确定预设映射表已被锁定,则执行步骤203,若确定预设映射表未被锁定,则执行步骤204。Step 202: After receiving the log space request message sent by the first thread, the log space manager obtains the state of the preset mapping table, and determines whether the preset mapping table is locked; if it is determined that the preset mapping table is locked, execute step 203. If it is determined that the preset mapping table is not locked, perform step 204.
本发明实施例中,日志空间管理器中可以设置有预设映射表的锁资源,日志空间管理 器可以通过访问预设映射表的锁资源查询预设映射表的状态,若预设映射表的状态为锁定状态,则确定预设映射表已被锁定;若预设映射表的状态为未锁定状态,则确定预设映射表未被锁定。In the embodiment of the present invention, the lock resource of the preset mapping table may be set in the log space manager, and the log space manager may query the state of the preset mapping table by accessing the lock resource of the preset mapping table. If the state is a locked state, it is determined that the preset mapping table is locked; if the state of the preset mapping table is an unlocked state, it is determined that the preset mapping table is not locked.
步骤203,日志空间管理器向第一线程发送等待指令,并监控预设映射表的状态,直至确定预设映射表由已被锁定切换为未被锁定,执行步骤204。In step 203, the log space manager sends a waiting instruction to the first thread and monitors the state of the preset mapping table until it is determined that the preset mapping table is switched from locked to unlocked, and step 204 is executed.
具体实施中,若确定预设映射表已被锁定,则说明当前存在其它进程访问预设映射表,因此日志空间管理器可以向第一进程发送等待指令,等待指令用于告知第一进程等待日志空间管理器的唤醒消息。In specific implementation, if it is determined that the preset mapping table is locked, it means that other processes currently access the preset mapping table. Therefore, the log space manager can send a waiting instruction to the first process, and the waiting instruction is used to inform the first process to wait for the log The wake-up message of the space manager.
进一步地,日志空间管理器可以按照预设周期监控预设映射表的锁资源,比如可以每5s访问一次预设映射表的锁资源,若在某次访问过程中发现预设映射表的状态更新为未锁定状态,则可以确定当前已不存在其它进程访问预设映射表,如此,日志空间管理器可以向第一进程发送唤醒消息。Further, the log space manager can monitor the lock resource of the preset mapping table according to the preset period. For example, the lock resource of the preset mapping table can be accessed every 5s. If the status of the preset mapping table is found to be updated during a certain access process In the unlocked state, it can be determined that no other process currently accesses the preset mapping table. In this way, the log space manager can send a wake-up message to the first process.
步骤204,日志空间管理器锁定预设映射表。Step 204: The log space manager locks the preset mapping table.
若预设映射表的状态为未锁定状态,说明当前时刻不存在其它进程访问预设映射表,因此,日志空间管理器可以使用预设映射表来处理第一进程的日志空间请求消息。具体操作中,日志空间管理器可以先将预设映射表的锁资源中的状态更新为锁定状态,从而避免在第一进程访问预设映射表时其它进程同时访问预设映射表。If the state of the preset mapping table is unlocked, it means that no other process accesses the preset mapping table at the current moment. Therefore, the log space manager can use the preset mapping table to process the log space request message of the first process. In a specific operation, the log space manager may first update the state in the lock resource of the preset mapping table to the locked state, thereby avoiding other processes accessing the preset mapping table at the same time when the first process accesses the preset mapping table.
需要说明的是,若存在多个进程同时访问预设映射表,则第一进程可以为多个进程中先竞争到锁资源的进程,或者也可以为最先向日志空间管理器发送日志空间请求消息的进程。It should be noted that if there are multiple processes accessing the preset mapping table at the same time, the first process can be the process that competes for the lock resource first, or it can be the first to send a log space request to the log space manager The progress of the message.
步骤205,日志空间管理器确定预设映射表中是否存在第一线程对应的第一日志空间,若不存在,则执行步骤206,若存在,则执行步骤207。In step 205, the log space manager determines whether the first log space corresponding to the first thread exists in the preset mapping table, if it does not exist, execute step 206, and if it exists, execute step 207.
此处,预设映射表中可以存储有进程的标识和日志空间的位置信息的对应关系,如此,日志空间管理器可以根据第一进程的标识查询预设映射表,确定是否存在与第一进程的标识匹配的日志空间。Here, the preset mapping table may store the corresponding relationship between the process identifier and the location information of the log space. In this way, the log space manager may query the preset mapping table according to the identifier of the first process to determine whether there is a corresponding relationship with the first process. The ID matches the log space.
步骤206,日志空间管理器为第一线程分配对应的第一日志空间,并将第一线程与第一日志空间的对应关系存储在预设映射表中。Step 206: The log space manager allocates a corresponding first log space for the first thread, and stores the corresponding relationship between the first thread and the first log space in a preset mapping table.
步骤207,日志空间管理器释放预设映射表的锁定状态,并为第一线程注册回调函数。Step 207: The log space manager releases the locked state of the preset mapping table, and registers a callback function for the first thread.
此处,日志空间管理器获取到第一线程对应的第一日志空间后,可以将预设映射表的锁资源中的状态更新为未锁定状态,如此,若存在其它进程等待预设映射表,则日志空间管理器可以唤醒其它进程。Here, after the log space manager obtains the first log space corresponding to the first thread, it can update the state in the lock resource of the preset mapping table to an unlocked state. In this way, if there are other processes waiting for the preset mapping table, Then the log space manager can wake up other processes.
进一步地,回调函数可以为节点中预先设置的一段软件程序,回调函数用于指示进程在退出之前释放进程对应的日志空间。相应地,日志空间管理器为第一线程注册回调函数后,回调函数可以实时监听第一线程的运行情况,若确定第一线程处理完对应的所有交易,则可以触发第一线程释放第一日志空间占用的资源。Further, the callback function may be a piece of software program preset in the node, and the callback function is used to instruct the process to release the log space corresponding to the process before exiting. Correspondingly, after the log space manager registers the callback function for the first thread, the callback function can monitor the running status of the first thread in real time. If it is determined that the first thread has processed all the corresponding transactions, it can trigger the first thread to release the first log Resources occupied by space.
步骤208,日志空间管理器将第一日志空间的位置信息发送给第一线程。Step 208: The log space manager sends the location information of the first log space to the first thread.
此处,第一日志空间的位置信息可以是指第一日志空间在初始存储空间中占用的空间范围的起始位置和终止位置。Here, the position information of the first log space may refer to the start position and the end position of the space range occupied by the first log space in the initial storage space.
步骤209,第一线程确定是否存在未处理的第一交易,若存在,则执行步骤210,若不存在,则执行步骤213。In step 209, the first thread determines whether there is an unprocessed first transaction, if it exists, execute step 210, if it does not exist, execute step 213.
在一个示例中,公共线程池中可以存储进程的标识、进程对应的交易的标识和交易的处理状态,交易的处理状态可以为未处理、已处理、异常中的任意一项。因此,第一线程在接收到对应的日志空间的位置信息后,可以查询公共线程池确定是否还存在未处理的交易。In an example, the identification of the process, the identification of the transaction corresponding to the process, and the processing status of the transaction can be stored in the common thread pool, and the processing status of the transaction can be any of unprocessed, processed, and abnormal. Therefore, after receiving the location information of the corresponding log space, the first thread can query the public thread pool to determine whether there are unprocessed transactions.
步骤210,第一线程开始执行第一交易,并记录第一交易在第一线程对应的第一日志空间中的第一条操作信息所在的起始位置或上一交易在第一线程对应的日志空间中的最后一条操作信息所在的终止位置;且,在执行第一交易的过程中,第一线程使用第一线程对应的第一日志空间记录执行第一交易的过程中对预设数据库的操作信息。Step 210: The first thread starts to execute the first transaction, and records the starting position of the first operation information of the first transaction in the first log space corresponding to the first thread or the log corresponding to the last transaction in the first thread The location where the last piece of operation information in the space is located; and, during the execution of the first transaction, the first thread uses the first log space corresponding to the first thread to record the operation on the preset database during the execution of the first transaction information.
步骤211,在执行第一交易的过程中,第一线程确定第一交易是否出现异常,若异常,则执行步骤212,若未异常,则执行步骤209。Step 211, in the process of executing the first transaction, the first thread determines whether the first transaction is abnormal, if it is abnormal, execute step 212, and if there is no abnormality, execute step 209.
步骤212,从第一线程对应的第一日志空间中获取第一交易的各操作信息,按照各操作信息在所在的位置的逆向顺序对预设数据库执行回滚,并在回滚完成后执行步骤209。Step 212: Obtain each operation information of the first transaction from the first log space corresponding to the first thread, perform a rollback on the preset database according to the reverse order of the position of each operation information, and execute the step after the rollback is completed 209.
具体实施中,当第一交易异常时,第一线程可以从第一线程对应的第一日志空间中获取最新一条操作信息,若第一线程记录有第一交易的起始位置,则第一线程可以判断该条操作信息所在的位置是否大于或等于所述起始位置,若该条操作信息所在的位置大于或等于所述起始位置,则可以按照该条操作信息对预设数据库执行逆向操作。进一步地,在对预设数据库逆向操作完成后,获取该条操作信息的上一条操作信息,判断上一条操作信息所在的位置是否大于或等于所述起始位置,若上一条操作信息所在的位置小于所述起始位置,则可以确定回滚完成;相应地,若上一条操作信息所在的位置大于或等于所述起始位置,则可以按照上一条操作信息对预设数据库执行逆向操作,并重复执行该过程直至操作信息所在的位置小于所述起始位置。In specific implementation, when the first transaction is abnormal, the first thread can obtain the latest piece of operation information from the first log space corresponding to the first thread. If the first thread records the starting position of the first transaction, the first thread It can be judged whether the position of the piece of operation information is greater than or equal to the starting position, and if the position of the piece of operation information is greater than or equal to the starting position, a reverse operation can be performed on the preset database according to the piece of operation information . Further, after the reverse operation of the preset database is completed, the last piece of operation information of the piece of operation information is obtained, and it is determined whether the position of the last piece of operation information is greater than or equal to the starting position, if the position of the last piece of operation information is If it is less than the starting position, it can be determined that the rollback is completed; accordingly, if the position of the previous operation information is greater than or equal to the starting position, the reverse operation can be performed on the preset database according to the previous operation information, and This process is repeated until the position of the operation information is smaller than the starting position.
相应地,若第一线程记录有上一交易的终止位置,则第一线程可以判断该条操作信息所在的位置是否大于所述终止位置,若该条操作信息所在的位置大于所述终止位置,则可以按照该条操作信息对预设数据库执行逆向操作。进一步地,在对预设数据库逆向操作完成后,获取该条操作信息的上一条操作信息,判断上一条操作信息所在的位置是否大于所述终止位置,若上一条操作信息所在的位置小于或等于所述终止位置,则可以确定回滚完成;相应地,若上一条操作信息所在的位置大于所述终止位置,则可以按照上一条操作信息对预设数据库执行逆向操作,并重复执行该过程直至操作信息所在的位置小于或等于所述终止位置。Correspondingly, if the first thread records the termination location of the previous transaction, the first thread can determine whether the location of the piece of operation information is greater than the termination location, and if the location of the piece of operation information is greater than the termination location, Then you can perform a reverse operation on the preset database according to the piece of operation information. Further, after the reverse operation of the preset database is completed, the last piece of operation information of the piece of operation information is obtained, and it is determined whether the position of the last piece of operation information is greater than the termination position, and if the position of the last piece of operation information is less than or equal to According to the termination position, the rollback can be determined to be completed; accordingly, if the location of the last operation information is greater than the termination position, the reverse operation can be performed on the preset database according to the previous operation information, and the process can be repeated until The position where the operation information is located is less than or equal to the end position.
步骤213,第一线程执行回调函数,释放第一日志空间所占用的资源,并退出。Step 213: The first thread executes the callback function, releases the resources occupied by the first log space, and exits.
在步骤207中,由于日志空间管理器向第一线程注册了回调函数,使得回调函数时刻监听第一进程的状态,因此,当第一线程对应的交易全部执行完成后,第一线程可以触发回调函数,使得回调函数释放第一进程对应的第一日志空间所占用的资源。如此,可以保证在第一进程退出的同时释放了第一进程对应的第一日志空间所占用的资源,降低资源占用率,提高系统处理效率。In step 207, because the log space manager registers the callback function with the first thread, the callback function monitors the state of the first process at all times. Therefore, when all transactions corresponding to the first thread are executed, the first thread can trigger the callback Function so that the callback function releases the resources occupied by the first log space corresponding to the first process. In this way, it can be ensured that the resources occupied by the first log space corresponding to the first process are released while the first process exits, thereby reducing the resource occupancy rate and improving the processing efficiency of the system.
本发明的上述实施例中,区块链系统中的任一节点在第一进程处理的第一交易异常时,确定第一进程对应的第一日志空间;其中,第一日志空间用于记录第一进程在处理交易的过程中对预设数据库的操作信息;节点为并行的各进程分配的日志空间不同;进一步地,节点从第一日志空间获取第一交易的各操作信息,并基于第一交易的各操作信息对预设数据库进行回滚操作。本发明实施例中,通过为并行的各进程分配不同的日志空间,使得每 个进程对应一个日志空间,由于进程是基于串行方式来处理多个交易,因此,在进程对应的日志空间中,交易的操作信息是按照交易的处理顺序依次进行存储的;如此,若进程当前处理的交易发生异常,则节点可以通过查询进程对应的日志空间快速地获取到异常交易的各操作信息,从而可以基于该异常交易的各操作信息准确地对预设数据库进行回滚,提高交易处理的准确性。In the foregoing embodiment of the present invention, any node in the blockchain system determines the first log space corresponding to the first process when the first transaction processed by the first process is abnormal; wherein, the first log space is used to record the first transaction. The operation information of a process on the preset database in the process of processing transactions; the log space allocated by the node for each parallel process is different; further, the node obtains each operation information of the first transaction from the first log space, and based on the first log space Each operation information of the transaction performs a rollback operation on the preset database. In the embodiment of the present invention, by allocating different log spaces for each process in parallel, each process corresponds to a log space. Since the process processes multiple transactions in a serial manner, in the log space corresponding to the process, The operation information of the transaction is stored sequentially according to the processing order of the transaction; in this way, if the transaction currently processed by the process is abnormal, the node can quickly obtain the operation information of the abnormal transaction by querying the log space corresponding to the process, which can be based on The operation information of the abnormal transaction is accurately rolled back to the preset database to improve the accuracy of transaction processing.
针对上述方法流程,本发明实施例还提供一种基于区块链系统的交易处理装置,该装置的具体内容可以参照上述方法实施。In view of the foregoing method flow, an embodiment of the present invention also provides a transaction processing device based on a blockchain system. The specific content of the device can be implemented with reference to the foregoing method.
图3为本发明实施例提供的一种基于区块链系统地交易处理装置的结构示意图,包括:Figure 3 is a schematic structural diagram of a transaction processing device based on a blockchain system provided by an embodiment of the present invention, including:
确定模块301,用于在第一进程处理的第一交易异常时,确定所述第一进程对应的第一日志空间;其中,所述第一日志空间用于记录所述第一进程在处理交易的过程中对预设数据库的操作信息;所述装置为并行的各进程分配的日志空间不同;The determining module 301 is configured to determine the first log space corresponding to the first process when the first transaction processed by the first process is abnormal; wherein, the first log space is used to record that the first process is processing the transaction The operation information of the preset database during the process; the log space allocated by the device for each parallel process is different;
获取模块302,用于从所述第一日志空间获取所述第一交易的各操作信息;The obtaining module 302 is configured to obtain various operation information of the first transaction from the first log space;
处理模块303,用于基于所述第一交易的各操作信息对所述预设数据库进行回滚操作。The processing module 303 is configured to perform a rollback operation on the preset database based on each operation information of the first transaction.
可选地,所述确定模块301在第一进程处理的第一交易异常之前,所述获取模块302还用于:从预设映射表获取所述第一进程对应的所述第一日志空间;Optionally, before the first transaction processed by the first process is abnormal by the determining module 301, the obtaining module 302 is further configured to: obtain the first log space corresponding to the first process from a preset mapping table;
所述处理模块303还用于:使用所述第一日志空间记录所述第一进程在处理所述第一交易的过程中对预设数据库的操作信息;The processing module 303 is further configured to: use the first log space to record the operation information of the first process on the preset database in the process of processing the first transaction;
若所述获取模块302从所述预设映射表未获取到所述第一进程对应的所述第一日志空间,则所述处理模块303还用于:为所述第一进程分配所述第一日志空间,并将所述第一进程与所述第一日志空间的对应关系添加在所述预设映射表中。If the obtaining module 302 does not obtain the first log space corresponding to the first process from the preset mapping table, the processing module 303 is further configured to: allocate the first log space for the first process A log space, and the corresponding relationship between the first process and the first log space is added to the preset mapping table.
可选地,所述获取模块302从预设映射表获取所述第一进程对应的所述第一日志空间之前,所述确定模块301还用于:Optionally, before the obtaining module 302 obtains the first log space corresponding to the first process from a preset mapping table, the determining module 301 is further configured to:
确定所述预设映射表处于未锁定状态;所述未锁定状态用于指示当前不存在进程使用所述预设映射表。It is determined that the preset mapping table is in an unlocked state; the unlocked state is used to indicate that no process currently uses the preset mapping table.
可选地,所述处理模块303具体用于:记录所述第一交易在所述第一日志空间中的第一条操作信息所在的初始位置或记录第二交易在所述第一日志空间中的最后一条操作信息所在的终止位置;所述第二交易为处理所述第一交易之前所述第一进程处理的交易;Optionally, the processing module 303 is specifically configured to: record the initial position of the first piece of operation information in the first log space of the first transaction or record the second transaction in the first log space The termination location where the last piece of operation information is located; the second transaction is a transaction processed by the first process before the first transaction is processed;
所述获取模块302具体用于:根据所述第一交易异常时所述第一日志空间中的最新一条操作信息所在的位置和所述初始位置确定所述第一交易的各操作信息;或,所述节点根据所述第一交易异常时所述第一日志空间中的最新一条操作信息所在的位置和所述终止位置确定所述第一交易的各操作信息。The acquiring module 302 is specifically configured to: determine each operation information of the first transaction according to the location of the latest piece of operation information in the first log space and the initial location when the first transaction is abnormal; or, The node determines each operation information of the first transaction according to the position of the latest piece of operation information in the first log space when the first transaction is abnormal and the termination position.
可选地,所述处理模块303还用于:Optionally, the processing module 303 is further configured to:
若确定所述第一进程处理完对应的所有交易,则释放所述第一日志空间占用的资源。If it is determined that the first process has processed all the corresponding transactions, the resources occupied by the first log space are released.
从上述内容可以看出:本发明的上述实施例中,区块链系统中的任一节点在第一进程处理的第一交易异常时,确定第一进程对应的第一日志空间;其中,第一日志空间用于记录第一进程在处理交易的过程中对预设数据库的操作信息;节点为并行的各进程分配的日志空间不同;进一步地,节点从第一日志空间获取第一交易的各操作信息,并基于第一交易的各操作信息对预设数据库进行回滚操作。本发明实施例中,通过为并行的各进程分配不同的日志空间,使得每个进程对应一个日志空间,由于进程是基于串行方式来处理多个交易,因此,在进程对应的日志空间中,交易的操作信息是按照交易的处理顺序依次进行 存储的;如此,若进程当前处理的交易发生异常,则节点可以通过查询进程对应的日志空间快速地获取到异常交易的各操作信息,从而可以基于该异常交易的各操作信息准确地对预设数据库进行回滚,提高交易处理的准确性。It can be seen from the foregoing that: in the foregoing embodiment of the present invention, any node in the blockchain system determines the first log space corresponding to the first process when the first transaction processed by the first process is abnormal; A log space is used to record the operation information of the first process on the preset database in the process of processing transactions; the log space allocated by the node for each parallel process is different; further, the node obtains each of the first transaction from the first log space Operation information, and roll back the preset database based on each operation information of the first transaction. In the embodiment of the present invention, by allocating different log spaces for each process in parallel, each process corresponds to a log space. Since the process processes multiple transactions in a serial manner, in the log space corresponding to the process, The operation information of the transaction is stored sequentially according to the processing order of the transaction; in this way, if the transaction currently processed by the process is abnormal, the node can quickly obtain the operation information of the abnormal transaction by querying the log space corresponding to the process, which can be based on The operation information of the abnormal transaction is accurately rolled back to the preset database to improve the accuracy of transaction processing.
基于同一发明构思,本发明实施例还提供了一种计算设备,包括至少一个处理单元以及至少一个存储单元,其中,所述存储单元存储有计算机程序,当所述程序被所述处理单元执行时,使得所述处理单元执行如上述图1或图2任意所述的方法。Based on the same inventive concept, an embodiment of the present invention also provides a computing device, including at least one processing unit and at least one storage unit, wherein the storage unit stores a computer program, and when the program is executed by the processing unit , So that the processing unit executes any method described in FIG. 1 or FIG. 2 above.
请参见图4,基于同一技术构思,本发明实施例还提供了一种计算设备,用于执行数据处理系统在本发明任一实施例中的方法,可以包括存储器401和处理器402。Referring to FIG. 4, based on the same technical concept, an embodiment of the present invention also provides a computing device for executing a method of a data processing system in any embodiment of the present invention, and may include a memory 401 and a processor 402.
所述存储器401,用于存储处理器402执行的计算机程序。存储器401可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序等;存储数据区可存储根据计算设备的使用所创建的数据等。处理器402,可以是一个中央处理单元(central processing unit,CPU),或者为数字处理单元等等。本发明实施例中不限定上述存储器401和处理器402之间的具体连接介质。本发明实施例在图4中以存储器401和处理器402之间通过总线403连接,总线403在图4中以粗线表示,其它部件之间的连接方式,仅是进行示意性说明,并不引以为限。所述总线403可以分为地址总线、数据总线、控制总线等。为便于表示,图4中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。The memory 401 is configured to store a computer program executed by the processor 402. The memory 401 may mainly include a program storage area and a data storage area. The program storage area may store an operating system, an application program required for at least one function, and the like; the data storage area may store data created according to the use of a computing device. The processor 402 may be a central processing unit (central processing unit, CPU), or a digital processing unit, and so on. The embodiment of the present invention does not limit the specific connection medium between the foregoing memory 401 and the processor 402. In the embodiment of the present invention, in FIG. 4, the memory 401 and the processor 402 are connected through a bus 403, and the bus 403 is represented by a thick line in FIG. 4. The connection mode between other components is only for schematic illustration, not Limited. The bus 403 can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one thick line is used in FIG. 4 to represent it, but it does not mean that there is only one bus or one type of bus.
存储器401可以是易失性存储器(volatile memory),例如随机存取存储器(random-access memory,RAM);存储器401也可以是非易失性存储器(non-volatile memory),例如只读存储器,快闪存储器(flash memory),硬盘(hard disk drive,HDD)或固态硬盘(solid-state drive,SSD)、或者存储器401是能够用于携带或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的任何其他介质,但不限于此。存储器401可以是上述存储器的组合。The memory 401 may be a volatile memory (volatile memory), such as a random-access memory (RAM); the memory 401 may also be a non-volatile memory (non-volatile memory), such as a read-only memory, flash Flash memory, hard disk drive (HDD) or solid-state drive (SSD), or memory 401 can be used to carry or store desired program codes in the form of instructions or data structures and can be used by Any other medium accessed by the computer, but not limited to this. The memory 401 may be a combination of the above-mentioned memories.
处理器402,用于调用所述存储器401中存储的计算机程序时执行本发明实施例提供的基于区块链系统的数据处理方法。The processor 402 is configured to execute the data processing method based on the blockchain system provided by the embodiment of the present invention when calling the computer program stored in the memory 401.
本领域内的技术人员应明白,本发明的实施例可提供为方法、或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art should understand that the embodiments of the present invention may be provided as methods or computer program products. Therefore, the present invention may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present invention is described with reference to flowcharts and/or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and/or block in the flowchart and/or block diagram, and the combination of processes and/or blocks in the flowchart and/or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing equipment to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing equipment are generated It is a device that realizes the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个 方框中指定的功能。These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device. The device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment. The instructions provide steps for implementing functions specified in a flow or multiple flows in the flowchart and/or a block or multiple blocks in the block diagram.
尽管已描述了本发明的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本发明范围的所有变更和修改。Although the preferred embodiments of the present invention have been described, those skilled in the art can make additional changes and modifications to these embodiments once they learn the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present invention.
显然,本领域的技术人员可以对本发明进行各种改动和变型而不脱离本发明的精神和范围。这样,倘若本发明的这些修改和变型属于本发明权利要求及其等同技术的范围之内,则本发明也意图包含这些改动和变型在内。Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. In this way, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalent technologies, the present invention is also intended to include these modifications and variations.

Claims (12)

  1. 一种基于区块链系统的交易处理方法,其特征在于,所述方法应用于所述区块链系统中的任一节点,所述方法包括:A transaction processing method based on a blockchain system, characterized in that the method is applied to any node in the blockchain system, and the method includes:
    所述节点在第一进程处理的第一交易异常时,确定所述第一进程对应的第一日志空间;其中,所述第一日志空间用于记录所述第一进程在处理交易的过程中对预设数据库的操作信息;所述节点为并行的各进程分配的日志空间不同;When the first transaction processed by the first process is abnormal, the node determines the first log space corresponding to the first process; wherein, the first log space is used to record that the first process is processing the transaction Operation information of the preset database; the log space allocated by the node for each parallel process is different;
    所述节点从所述第一日志空间获取所述第一交易的各操作信息;The node obtains each operation information of the first transaction from the first log space;
    所述节点基于所述第一交易的各操作信息对所述预设数据库进行回滚操作。The node performs a rollback operation on the preset database based on each operation information of the first transaction.
  2. 根据权利要求1所述的方法,其特征在于,所述节点在第一进程处理的第一交易异常之前,所述方法还包括:The method according to claim 1, characterized in that, before the first transaction processed by the first process by the node is abnormal, the method further comprises:
    所述节点从预设映射表获取所述第一进程对应的所述第一日志空间,并使用所述第一日志空间记录所述第一进程在处理所述第一交易的过程中对预设数据库的操作信息;The node obtains the first log space corresponding to the first process from a preset mapping table, and uses the first log space to record that the first process performs a preset process of processing the first transaction. Operating information of the database;
    所述节点若从所述预设映射表未获取到所述第一进程对应的所述第一日志空间,则为所述第一进程分配所述第一日志空间,并将所述第一进程与所述第一日志空间的对应关系添加在所述预设映射表中。If the node does not obtain the first log space corresponding to the first process from the preset mapping table, it allocates the first log space for the first process, and sets the first process The corresponding relationship with the first log space is added to the preset mapping table.
  3. 根据权利要求2所述的方法,其特征在于,所述节点从预设映射表获取所述第一进程对应的所述第一日志空间之前,还包括:The method according to claim 2, wherein before the node obtains the first log space corresponding to the first process from a preset mapping table, the method further comprises:
    所述节点确定所述预设映射表处于未锁定状态;所述未锁定状态用于指示当前不存在进程使用所述预设映射表。The node determines that the preset mapping table is in an unlocked state; the unlocked state is used to indicate that no process currently uses the preset mapping table.
  4. 根据权利要求2所述的方法,其特征在于,所述节点使用所述第一日志空间记录所述第一进程在处理所述第一交易的过程中对预设数据库的操作信息,包括:The method according to claim 2, wherein the node uses the first log space to record the operation information of the first process on the preset database in the process of processing the first transaction, comprising:
    所述节点记录所述第一交易在所述第一日志空间中的第一条操作信息所在的初始位置或记录第二交易在所述第一日志空间中的最后一条操作信息所在的终止位置;所述第二交易为处理所述第一交易之前所述第一进程处理的交易;The node records the initial position of the first piece of operation information of the first transaction in the first log space or records the end position of the last piece of operation information of the second transaction in the first log space; The second transaction is a transaction processed by the first process before processing the first transaction;
    所述节点从所述第一日志空间获取所述第一交易的各操作信息,包括:The node acquiring each operation information of the first transaction from the first log space includes:
    所述节点根据所述第一交易异常时所述第一日志空间中的最新一条操作信息所在的位置和所述初始位置确定所述第一交易的各操作信息;或,所述节点根据所述第一交易异常时所述第一日志空间中的最新一条操作信息所在的位置和所述终止位置确定所述第一交易的各操作信息。The node determines the operation information of the first transaction according to the position of the latest piece of operation information in the first log space when the first transaction is abnormal and the initial position; or, the node determines the operation information of the first transaction according to the When the first transaction is abnormal, the position of the latest piece of operation information in the first log space and the termination position determine each operation information of the first transaction.
  5. 根据权利要求1至4任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 1 to 4, wherein the method further comprises:
    所述节点若确定所述第一进程处理完对应的所有交易,则释放所述第一日志空间占用的资源。If the node determines that the first process has processed all the corresponding transactions, it releases the resources occupied by the first log space.
  6. 一种基于区块链系统的交易处理装置,其特征在于,所述装置包括:A transaction processing device based on a blockchain system, characterized in that the device includes:
    确定模块,用于在第一进程处理的第一交易异常时,确定所述第一进程对应的第一日志空间;其中,所述第一日志空间用于记录所述第一进程在处理交易的过程中对预设数据库的操作信息;所述装置为并行的各进程分配的日志空间不同;The determining module is used to determine the first log space corresponding to the first process when the first transaction processed by the first process is abnormal; wherein, the first log space is used to record the transaction processing of the first process Operation information of the preset database during the process; the log space allocated by the device for each parallel process is different;
    获取模块,用于从所述第一日志空间获取所述第一交易的各操作信息;An obtaining module, configured to obtain various operation information of the first transaction from the first log space;
    处理模块,用于基于所述第一交易的各操作信息对所述预设数据库进行回滚操作。The processing module is configured to perform a rollback operation on the preset database based on each operation information of the first transaction.
  7. 根据权利要求6所述的装置,其特征在于,所述确定模块在第一进程处理的第一交 易异常之前,所述获取模块还用于:从预设映射表获取所述第一进程对应的所述第一日志空间;7. The device according to claim 6, wherein the determining module is used to obtain the data corresponding to the first process from a preset mapping table before the first transaction processed by the first process is abnormal. The first log space;
    所述处理模块还用于:使用所述第一日志空间记录所述第一进程在处理所述第一交易的过程中对预设数据库的操作信息;The processing module is further configured to: use the first log space to record the operation information of the first process on the preset database in the process of processing the first transaction;
    若所述获取模块从所述预设映射表未获取到所述第一进程对应的所述第一日志空间,则所述处理模块还用于:为所述第一进程分配所述第一日志空间,并将所述第一进程与所述第一日志空间的对应关系添加在所述预设映射表中。If the obtaining module does not obtain the first log space corresponding to the first process from the preset mapping table, the processing module is further configured to: allocate the first log for the first process Space, and add the correspondence between the first process and the first log space in the preset mapping table.
  8. 根据权利要求7所述的装置,其特征在于,所述获取模块从预设映射表获取所述第一进程对应的所述第一日志空间之前,所述确定模块还用于:8. The apparatus according to claim 7, wherein before the obtaining module obtains the first log space corresponding to the first process from a preset mapping table, the determining module is further configured to:
    确定所述预设映射表处于未锁定状态;所述未锁定状态用于指示当前不存在进程使用所述预设映射表。It is determined that the preset mapping table is in an unlocked state; the unlocked state is used to indicate that no process currently uses the preset mapping table.
  9. 根据权利要求7所述的装置,其特征在于,所述处理模块具体用于:记录所述第一交易在所述第一日志空间中的第一条操作信息所在的初始位置或记录第二交易在所述第一日志空间中的最后一条操作信息所在的终止位置;所述第二交易为处理所述第一交易之前所述第一进程处理的交易;The device according to claim 7, wherein the processing module is specifically configured to: record the initial position of the first piece of operation information in the first log space of the first transaction or record the second transaction The termination position where the last piece of operation information in the first log space is located; the second transaction is a transaction processed by the first process before the first transaction is processed;
    所述获取模块具体用于:根据所述第一交易异常时所述第一日志空间中的最新一条操作信息所在的位置和所述初始位置确定所述第一交易的各操作信息;或,所述节点根据所述第一交易异常时所述第一日志空间中的最新一条操作信息所在的位置和所述终止位置确定所述第一交易的各操作信息。The acquiring module is specifically configured to: determine each operation information of the first transaction according to the location of the latest piece of operation information in the first log space and the initial position when the first transaction is abnormal; or, The node determines each operation information of the first transaction according to the position of the latest piece of operation information in the first log space when the first transaction is abnormal and the termination position.
  10. 根据权利要求6至9任一项所述的装置,其特征在于,所述处理模块还用于:The device according to any one of claims 6 to 9, wherein the processing module is further configured to:
    若确定所述第一进程处理完对应的所有交易,则释放所述第一日志空间占用的资源。If it is determined that the first process has processed all the corresponding transactions, the resources occupied by the first log space are released.
  11. 一种计算设备,其特征在于,包括至少一个处理单元以及至少一个存储单元,其中,所述存储单元存储有计算机程序,当所述程序被所述处理单元执行时,使得所述处理单元执行权利要求1~5任一权利要求所述的方法。A computing device, characterized by comprising at least one processing unit and at least one storage unit, wherein the storage unit stores a computer program, and when the program is executed by the processing unit, the processing unit executes the right The method according to any one of claims 1 to 5.
  12. 一种计算机可读存储介质,其特征在于,其存储有可由计算设备执行的计算机程序,当所述程序在所述计算设备上运行时,使得所述计算设备执行权利要求1~5任一权利要求所述的方法。A computer-readable storage medium, characterized in that it stores a computer program executable by a computing device, and when the program runs on the computing device, the computing device executes any one of claims 1 to 5 Require the described method.
PCT/CN2020/109570 2019-08-15 2020-08-17 Blockchain system-based transaction processing method and device WO2021027956A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910752822.8 2019-08-15
CN201910752822.8A CN110473100B (en) 2019-08-15 2019-08-15 Transaction processing method and device based on blockchain system

Publications (1)

Publication Number Publication Date
WO2021027956A1 true WO2021027956A1 (en) 2021-02-18

Family

ID=68511415

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/109570 WO2021027956A1 (en) 2019-08-15 2020-08-17 Blockchain system-based transaction processing method and device

Country Status (2)

Country Link
CN (1) CN110473100B (en)
WO (1) WO2021027956A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114363162A (en) * 2021-12-31 2022-04-15 支付宝(杭州)信息技术有限公司 Block chain log generation method and device, electronic equipment and storage medium
CN115357664A (en) * 2022-10-21 2022-11-18 北京航空航天大学 Multidirectional trusted system based on block chain and data query method

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110473100B (en) * 2019-08-15 2023-07-11 深圳前海微众银行股份有限公司 Transaction processing method and device based on blockchain system
CN111046109B (en) * 2019-12-27 2023-09-15 深圳市迅雷网络技术有限公司 Cross-chain task processing method, device, equipment and readable storage medium
CN111210350A (en) * 2020-01-03 2020-05-29 平安科技(深圳)有限公司 Block chain transaction method and device, computer equipment and storage medium
CN111324425B (en) * 2020-02-28 2023-03-31 百度在线网络技术(北京)有限公司 Data access method, device, equipment and storage medium
CN112016921B (en) * 2020-03-03 2022-08-19 支付宝(杭州)信息技术有限公司 Transaction processing method, device and equipment
CN112433885B (en) * 2020-11-19 2021-09-10 腾讯科技(深圳)有限公司 Block chain consensus processing method and device, electronic equipment and storage medium
CN112835687B (en) * 2021-01-22 2023-05-26 恒生电子股份有限公司 Method and system for processing computer transaction

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105278922A (en) * 2015-09-29 2016-01-27 新浪网技术(中国)有限公司 Data distribution method, system and apparatus
CN107391628A (en) * 2017-06-30 2017-11-24 北京奇虎科技有限公司 Method of data synchronization and device
CN108537543A (en) * 2018-03-30 2018-09-14 百度在线网络技术(北京)有限公司 Method for parallel processing, device, equipment and the storage medium of block chain data
CN108804112A (en) * 2018-05-22 2018-11-13 上海分布信息科技有限公司 A kind of block chain falls account processing method and system
US20190182284A1 (en) * 2016-08-16 2019-06-13 Alcatel Lucent Blockchain-based security threat detection method and system
CN110473100A (en) * 2019-08-15 2019-11-19 深圳前海微众银行股份有限公司 A kind of transaction processing method and device based on block catenary system

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS63307551A (en) * 1987-06-08 1988-12-15 インターナシヨナル・ビジネス・マシーンズ・コーポレーシヨン Roll backing in system for first write logging type transaction
US8296271B1 (en) * 2005-03-28 2012-10-23 Federal Home Loan Mortgage Corporation System and method for optimizing data recovery in a parallel database
US9183200B1 (en) * 2012-08-02 2015-11-10 Symantec Corporation Scale up deduplication engine via efficient partitioning
CN102902764B (en) * 2012-09-25 2016-05-11 北京奇虎科技有限公司 A kind of method and apparatus of log recording
CN110019050A (en) * 2017-10-19 2019-07-16 中兴通讯股份有限公司 A kind of data rewind method, system, equipment and computer readable storage medium
CN110111147A (en) * 2019-05-07 2019-08-09 上海哈蜂信息科技有限公司 A kind of system of market integration method and realization the method based on trust valuation mechanism and rollback transaction

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105278922A (en) * 2015-09-29 2016-01-27 新浪网技术(中国)有限公司 Data distribution method, system and apparatus
US20190182284A1 (en) * 2016-08-16 2019-06-13 Alcatel Lucent Blockchain-based security threat detection method and system
CN107391628A (en) * 2017-06-30 2017-11-24 北京奇虎科技有限公司 Method of data synchronization and device
CN108537543A (en) * 2018-03-30 2018-09-14 百度在线网络技术(北京)有限公司 Method for parallel processing, device, equipment and the storage medium of block chain data
CN108804112A (en) * 2018-05-22 2018-11-13 上海分布信息科技有限公司 A kind of block chain falls account processing method and system
CN110473100A (en) * 2019-08-15 2019-11-19 深圳前海微众银行股份有限公司 A kind of transaction processing method and device based on block catenary system

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114363162A (en) * 2021-12-31 2022-04-15 支付宝(杭州)信息技术有限公司 Block chain log generation method and device, electronic equipment and storage medium
CN114363162B (en) * 2021-12-31 2024-05-03 支付宝(杭州)信息技术有限公司 Block chain log generation method and device, electronic equipment and storage medium
CN115357664A (en) * 2022-10-21 2022-11-18 北京航空航天大学 Multidirectional trusted system based on block chain and data query method

Also Published As

Publication number Publication date
CN110473100B (en) 2023-07-11
CN110473100A (en) 2019-11-19

Similar Documents

Publication Publication Date Title
WO2021027956A1 (en) Blockchain system-based transaction processing method and device
US8108587B2 (en) Free-space reduction in cached database pages
CN108509462B (en) Method and device for synchronizing activity transaction table
US8135688B2 (en) Partition/table allocation on demand
US20130254240A1 (en) Method of processing database, database processing apparatus, computer program product
US20090063807A1 (en) Data redistribution in shared nothing architecture
US11321302B2 (en) Computer system and database management method
TWI733390B (en) Method and device for simultaneously executing transactions in block chain, computer readable storage medium and computing equipment
WO2021057482A1 (en) Method and device for generating bloom filter in blockchain
WO2017128028A1 (en) Transaction processing method and apparatus
CN112416972A (en) Real-time data stream processing method, device, equipment and readable storage medium
CN111159140B (en) Data processing method, device, electronic equipment and storage medium
CN110597912B (en) Block storage method and device
US11983168B2 (en) Block verification method, apparatus and device
US20110099347A1 (en) Managing allocation and deallocation of storage for data objects
CN113535087A (en) Data processing method, server and storage system in data migration process
WO2021093323A1 (en) Data recovery method and system, data storage node, and database management node
CN112748865B (en) Method, electronic device and computer program product for storage management
US11138231B2 (en) Method and system for data handling
CN109710698B (en) Data aggregation method and device, electronic equipment and medium
US20140149697A1 (en) Memory Pre-Allocation For Cleanup and Rollback Operations
CN106202271A (en) The read method of the product database of OTA
CN109508140B (en) Storage resource management method and device, electronic equipment and system
CN115563109A (en) L0 layer data processing method and device for LSM-tree storage
WO2022002128A1 (en) Data reading method, data writing method, device, and system

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: 20851990

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: 20851990

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 1205A DATED 05.08.2022)

122 Ep: pct application non-entry in european phase

Ref document number: 20851990

Country of ref document: EP

Kind code of ref document: A1