CN109493223B - Accounting method and device - Google Patents

Accounting method and device Download PDF

Info

Publication number
CN109493223B
CN109493223B CN201811319215.4A CN201811319215A CN109493223B CN 109493223 B CN109493223 B CN 109493223B CN 201811319215 A CN201811319215 A CN 201811319215A CN 109493223 B CN109493223 B CN 109493223B
Authority
CN
China
Prior art keywords
node
state data
transaction
blockchain system
message
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811319215.4A
Other languages
Chinese (zh)
Other versions
CN109493223A (en
Inventor
陈正
李贲
殷舒
徐加明
刘胜
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Union Mobile Pay Co Ltd
Original Assignee
Union Mobile Pay Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Union Mobile Pay Co Ltd filed Critical Union Mobile Pay Co Ltd
Priority to CN201811319215.4A priority Critical patent/CN109493223B/en
Publication of CN109493223A publication Critical patent/CN109493223A/en
Application granted granted Critical
Publication of CN109493223B publication Critical patent/CN109493223B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • 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
    • 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/40Authorisation, e.g. identification of payer or payee, verification of customer or shop credentials; Review and approval of payers, e.g. check credit lines or negative lists
    • G06Q20/407Cancellation of a transaction

Abstract

The invention discloses a billing method and a billing device, which are applied to a block chain system, wherein the block chain system comprises at least 2 nodes, and the method comprises the following steps: a first node receives a first transaction request sent by a transaction initiator; the first node is any node in the blockchain system; the first node acquires first state data of the current moment from an account book of the blockchain system according to the first transaction request; the first state data is used for representing the current state of an account corresponding to the first transaction; the first node executes the first transaction request according to the first transaction request and the first state data, and generates a first transaction value; the first trading value is a result after the first trading request is executed; and packaging the first state data and the second transaction value into a first message, and issuing the first message to the blockchain system.

Description

Accounting method and device
Technical Field
The invention relates to the technical field of block chains, in particular to an accounting method and device.
Background
To improve the service processing capability, different node servers in the blockchain may process multiple transactions simultaneously, and to avoid the concurrency conflict, a multi-version control protocol (MVCC) may be used, and specifically, the MVCC maintains a version number (version) for the blockchain system, where the version number is an increasing sequence. When a certain node server receives a transaction, a version dependency (verDep) is added to each transaction, namely the version number of the state data of the transaction is set from the time point of sending the transaction to the end of the transaction. When the transaction is finally executed, whether the additional version is consistent with the version of the state data of the current block chain or not is verified, and if not, the transaction is rejected.
When the concurrency conflict occurs, the transaction can be directly failed, and the subsequent transaction is greatly influenced. After the transaction is rejected, the terminal is required to initiate the transaction request again, and the node server executes the transaction again, so that the transaction processing efficiency is low.
Disclosure of Invention
The invention aims to provide an accounting method and an accounting device, which aim to solve the problem that in the prior art, concurrent transactions are easy to fail, so that accounting efficiency in a block chain is reduced.
The purpose of the invention is realized by the following technical scheme:
in a first aspect, an embodiment of the present invention provides a billing method, which is applied to a blockchain system, where the blockchain system includes at least 2 nodes, and the method includes:
a first node receives a first transaction request sent by a transaction initiator; the first node is any node in the blockchain system;
the first node acquires first state data of the current moment from an account book of the blockchain system according to the first transaction request; the first state data is used for representing the current state of an account corresponding to the first transaction;
the first node executes the first transaction request according to the first transaction request and the first state data, and generates a first transaction value; the first trading value is a result after the first trading request is executed;
and packaging the first state data and the first transaction value into a first message, and issuing the first message to the blockchain system.
In one possible implementation, the method further includes:
the first node receives an accounting result of the first message sent by a second node;
the first node receives a block sent by the second node, wherein the block comprises the first transaction value, and the block is generated when the second node determines that second state data is the same as the first state data; the second state data is the current state of the account obtained by the second node from the ledger of the blockchain system after receiving the first message.
In one possible implementation, the method further includes:
if the first node determines that the accounting result is failure, acquiring third state data from an account book of the block chain system; the third status data is used to characterize the current status of the account;
the first node generates a second trading value according to the third state data and the first trading request;
and the first node packs the third state data and the second trading value into a second message and issues the second message to the blockchain system.
In a second aspect, an embodiment of the present invention provides a billing method, which is applied to a blockchain system, where the blockchain system includes at least 2 nodes, and the method includes:
a second node receives a first message sent by a first node; the first message comprises a first transaction value and first state data; the first state data is the state data of an account corresponding to a first transaction request acquired from an account book of the blockchain system by the first node after the first transaction request sent by a transaction initiator is received by the first node; the first transaction value is generated by the first node according to the first transaction request and the first state data;
the second node acquires second state data from the account book of the blockchain system, wherein the second state data is the current state of the account corresponding to the first transaction;
if the second node determines that the second state data is the same as the first state data, generating a block containing the first trading value;
the second node issues the block to the blockchain system.
In one possible implementation, the method further includes:
and if the second node determines that the second state data is different from the first state data, the second node notifies the first node of the accounting failure of the first message, so that the first node processes the first transaction request again.
In a third aspect, an embodiment of the present invention provides an accounting apparatus, applied to a blockchain system, where the blockchain system includes at least 2 nodes, and the apparatus includes:
the receiving and sending unit is used for receiving a first transaction request sent by a transaction initiator;
the processing unit is used for acquiring first state data of the current moment from an account book of the blockchain system according to the first transaction request; the first state data is used for representing the current state of an account corresponding to the first transaction; executing the first transaction request according to the first transaction request and the first state data, and generating a first transaction value; the first trading value is a result after the first trading request is executed;
the receiving and sending unit is configured to package the first state data and the first transaction value into a first message, and issue the first message to the blockchain system.
In one possible implementation manner, the transceiver unit is further configured to: receiving an accounting result of the first message sent by the second node; receiving a block sent by the second node, wherein the block comprises the first transaction value, and the block is generated when the second node determines that second state data is the same as the first state data; the second state data is the current state of the account obtained by the second node from the ledger of the blockchain system after receiving the first message.
In one possible implementation, the processing unit is further configured to: if the accounting result is determined to be failure, acquiring third state data from an account book of the block chain system; the third status data is used to characterize the current status of the account; generating a second trading value according to the third state data and the first trading request;
the transceiver unit is further configured to package the third state data and the second transaction value into a second message, and issue the second message to the blockchain system.
In a fourth aspect, an embodiment of the present invention provides an accounting apparatus, applied to a blockchain system, where the blockchain system includes at least 2 nodes, and the apparatus includes:
a receiving and sending unit, configured to receive a first message sent by a first node; the first message comprises a first transaction value and first state data; the first state data is the state data of an account corresponding to a first transaction request acquired from an account book of the blockchain system by the first node after the first transaction request sent by a transaction initiator is received by the first node; the first transaction value is generated by the first node according to the first transaction request and the first state data;
the processing unit is used for acquiring second state data from the account book of the blockchain system, wherein the second state data is the current state of the account corresponding to the first transaction; if the second state data is determined to be the same as the first state data, generating a block containing the first trading value;
the transceiver unit is further configured to issue the block to the block chain system.
In one possible implementation, the processing unit is further configured to: and if the second state data is different from the first state data, notifying the first node of accounting failure of the first message, so that the first node processes the first transaction request again.
In a fifth aspect, the present invention provides an accounting device, including:
a memory for storing program instructions;
a processor for calling the program instructions stored in the memory and executing the method of the first aspect according to the obtained program.
In a sixth aspect, the present invention provides a computer-readable storage medium storing computer instructions, which, when executed on a computer, cause the computer to perform the method of the first aspect.
According to the accounting method and device provided by the invention, the first node acquires the first state data of the current moment from the account book of the block chain system according to the first transaction request; the first state data is used for representing the current state of an account corresponding to the first transaction; the first node executes the first transaction request according to the first transaction request and the first state data, and generates a first transaction value; packaging the first state data and the first transaction value into a first message, and issuing the first message to the blockchain system; whether the transaction failure occurs is determined according to the actual transaction value instead of the marked transaction state, so that the problem of transaction failure caused by the fact that the transaction state change in the accounting process is considered as transaction conflict is solved, and the accounting efficiency is improved.
Drawings
Fig. 1 is a schematic flow chart of a billing method according to an embodiment of the present invention;
fig. 2 is a schematic diagram of a billing method according to an embodiment of the present invention;
fig. 3 is a schematic diagram of a billing method according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an accounting device according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of an accounting device according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an accounting device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The block chain technology is a technical scheme for maintaining a reliable database collectively in a decentralized and trust-removing mode, and more generally speaking, the block chain technology is a mode for people to participate in accounting.
In the above embodiment, the obtaining of the transaction data sent by the multiple applications may be sending immediately after the applications complete the transaction, or may be sending periodically by the applications, or may be obtaining the transaction data from each application periodically. Wherein, applications that can generate transaction records are all applicable to the embodiments of the present invention, such as payment treasure, panning treasure, etc.; the stored data is an object, for example, if the transfer is carried out, the object comprises information such as time, account numbers of both transfer parties, transfer amount and the like, and if the transfer is a text record, the object comprises information content and an identifier of an information sender; the type of storage may be file storage, cache, relational data storage, non-relational data storage, etc. for guaranteeing availability of the transaction data, including but not limited to these types, and may be other types.
In one embodiment, the blockchain infrastructure is divided into 6 layers, including: the system comprises a data layer, a network layer, a consensus layer, an excitation layer, a contract layer and an application layer, wherein each layer respectively completes a core function, and the layers are matched with each other to realize a decentralized trust mechanism. The data layer mainly describes the physical form of the blockchain technology, and the physical implementation of the blockchain technology is a chain formed by blocks with the same specification through a chain structure. The main purpose of the network layer is to exchange information between nodes in a blockchain network, which is essentially a Peer-to-Peer network (P2P network), and each node receives and generates information. The consensus layer is responsible for providing a mechanism for highly dispersed nodes to efficiently agree on the validity of block data in a decentralized system. Common consensus mechanisms include: proof of workload (POW), Proof of rights (POS) certificate of rights (delete Proof of stamp, DPOS). The incentive layer aims to provide certain incentive measures to encourage the nodes to participate in the safety verification work of the block chain. The contract layer encapsulates various types of scripting code, algorithms, and more complex intelligent contracts generated thereby, of the blockchain system. The application layer is primarily a user-oriented programmable application.
The accounting node is a main body for executing and recording transaction data, the working process of the accounting node is to collect all transaction data which are not confirmed and to collect the transaction data into a data block, the accounting node broadcasts the data to other nodes one by one for verification, the transaction data are placed into a built-in batch processing queue after verification, when a batch processing space is saturated or reaches overtime, the accounting node writes the transaction data into a preprocessed block space, meanwhile, the accounting node calculates a hash value in a specific format, the process of calculating the hash value in the specific format by the accounting node is accounting, the process of calculating the hash value in the specific format by the accounting node is called accounting success, and after the accounting is successful, the accounting node packs the verified transaction data in the period of time into a block and broadcasts the block to other nodes for synchronization.
A block is a basic unit constituting a block chain, and the block contains information required to be described by a specific application.
The transaction data specifically refers to different forms of data needing to be recorded, such as transaction records, transfer records and other valuable information data; the accounting node may be a node that periodically monitors the capability of processing transaction data, and the set period may be determined according to specific situations.
Transaction data submitted by each application is stored in the storage area; specifically, the storage area stores data submitted by each application, so that the application does not directly submit transaction data to the blockchain network, and the storage area can adopt various storage forms, such as message queues. The application may be various applications that generate transaction data, such as Taobao, Paobao, etc.; the capability of acquiring the transaction data refers to the amount of the transaction data acquired from the storage area by the accounting node;
after the first accounting node acquires the transaction data from the storage area, the method further comprises the following steps:
the block chain network comprises M nodes, wherein the M nodes comprise N +1 accounting nodes and M-N-1 non-accounting nodes, and if the first accounting node generates nodes for the blocks of the corresponding amount of transaction data, the first accounting node broadcasts the blocks of the corresponding amount of transaction data to the M-1 nodes in the block chain network; otherwise, the first accounting node downloads the block of the transaction data generated by the second accounting node, and the second accounting node is any accounting node except the first accounting node in the block chain network.
In a specific implementation, the blockchain network includes a plurality of nodes, the accounting node is a part of all nodes, and each node participating in accounting belongs to an accounting node, for example, 100 nodes are shared in the blockchain network, where there are 60 nodes participating in accounting, and then there are 60 accounting nodes and 40 common nodes in the blockchain network. And the 60 accounting nodes acquire corresponding transaction data from the storage area according to the capability of acquiring and processing the transaction data respectively, and collect the transaction data into respective batch processing queues, and when the batch processing queues reach saturation or reach overtime, the accounting nodes write the acquired transaction data into a preprocessed block space. When the accounting nodes acquire transaction data, the accounting nodes perform accounting operation, one accounting node in 60 accounting nodes is successful in accounting at first, the winning accounting node is a block generation node, the block generation node packages verified transactions in the period of time into a block broadcast and synchronizes the block broadcast to other 99 nodes, the other 59 accounting nodes except the block generation node in the block chain network stop the current accounting operation after receiving the broadcast and download the block broadcast by the block generation node, meanwhile, the downloaded transaction data in the block is compared with the transaction data in the batch processing queue, the transaction data in the batch processing queue which is the same as the transaction data in the downloaded block is deleted, and 40 common nodes also download the block broadcast by the block generation node.
The ability of the first billing node to process the transaction data is related to at least the network environment in which the first billing node resides and the current device processing capabilities of the first billing node. In a specific implementation, the quality of a network environment where an accounting node in a blockchain network is located is affected by a plurality of factors, such as bandwidth flow of the accounting node; the network environment in which the billing node is located may affect the speed of the billing node broadcast, which in turn affects the ability of the billing node to process transactions. The accounting node needs to perform a large amount of mathematical calculations in the accounting process, the current hardware device of the accounting node affects the computing power of the accounting node itself, and further affects the transaction data Processing capability of the accounting node, and the hardware device used by the accounting node for accounting may be a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), a special chip, or the like.
In the block chain network, a certain accounting node in the block chain network receives transaction data sent by an application, the accounting node broadcasts the received transaction data to other accounting nodes, each accounting node performs accounting after receiving a certain amount of transaction data, and the accounting node which succeeds in accounting generates a block of the transaction data so as to allow other nodes in the block chain network to download the block, thereby achieving the mode of citizen participating in accounting.
With the development of services, the transaction amount of a transaction system gradually increases, a transaction peak occurs in a certain period of time, and when a large amount of transaction data is flooded into a blockchain network, different nodes may perform accounting on the transaction data of the same account within an accounting period of an accounting node, so that a concurrence conflict is caused.
While concurrently reading and writing data, the read operation may not be consistent data (dirty read). To avoid this, concurrent access control of data needs to be implemented, the simplest way being locking access. Since locking serializes the read and write operations, no inconsistent state occurs. However, read operations can be blocked by write operations, greatly reducing read performance.
Currently, there is a Multi-Version concurrency Control (MVCC) method to prevent concurrency conflicts. Under the MVCC protocol, each read operation sees a consistent snapshot and non-blocking reads can be implemented. MVCC allows data to have multiple versions, which may be time stamps or globally incremented transaction IDs, where different transactions see different data at the same point in time. MVCC, when write operation is carried out, copy data is carried out, original data cannot be influenced, then modification is carried out, atoms replace old data after modification is completed, and read operation only reads the original data. In this way, the read operation is not blocked by the write operation, thereby optimizing the read efficiency. The write operations are mutually exclusive, and each write operation has copy once, so that the method is only suitable for the case that the read is larger than the write.
Assuming that there are two concurrent operations R (T1) and U (T2), T1 and T2 are transaction IDs, T1 is smaller than T2, the system contains data a ═ 1(T1), and the operations of R and W are as follows:
the version T1 of R (read operation) indicates the version of data to be read, and the version is updated only later by a write operation, and not by a read operation. On the time axis, R is later than U, but is not visible to R since U commits after R starts. Therefore, R will only read the data of version T1, i.e., a equals 1.
Since the consistency of existing data cannot be affected until the update operation commits, the old data will not be changed and the update operation will be split into insert + delete. Old data, insert new data, needs to be marked for deletion. Only after the update commits will subsequent read operations be affected. Whereas for a read operation, and only all write operations preceding it can be read, the write operation being performed is not visible to it.
The isolation of the transaction is well realized through the MVCC, and a required read level can be reached.
Therefore, the block chain can be controlled to be concurrently controlled through the multi-version control protocol, the super account book is controlled to be concurrently controlled by utilizing the read-write set, when the transaction is packed, the read-write set is added to the transaction, when the block is dropped, whether all keys in the read set are consistent with the current state data or not is compared, if the read set is updated to the state data all the time, and if the read set is not consistent with the current state data, the batch of transaction is invalid. The block chain maintains the version number of the state data, and when the transaction is sent out, the node designates the version dependence of the transaction. If the versions are inconsistent, the transaction is directly refused.
However, in real business, since the blockchain is asynchronous transaction, a large number of version number conflicts may occur in one out-of-block period, so that a large number of transactions are rejected. After a plurality of transactions are submitted, if concurrency problems occur, the final execution result is uncontrollable and unpredictable, and great influence is generated on subsequent transactions. In addition, only by means of version dependence, namely, judging whether the versions of the state data of the current block chain are consistent, if not, the transaction is rejected, although the version numbers of the rejected transactions are changed, the state data of the account numbers may be consistent, namely, result conflicts do not necessarily exist, and therefore, the throughput of the block chain platform is reduced through concurrent control of MVCC.
Therefore, as shown in fig. 1, an embodiment of the present invention provides a billing method applied to a blockchain system, where the blockchain system includes at least 2 nodes, and the method includes:
step 101: a first node receives a first transaction request sent by a transaction initiator; the first node is any node in the blockchain system;
step 102: the first node acquires first state data of the current moment from an account book of the blockchain system according to the first transaction request; the first state data is used for representing the current state of an account corresponding to the first transaction;
step 103: the first node executes the first transaction request according to the first transaction request and the first state data, and generates a first transaction value; the first trading value is a result after the first trading request is executed;
step 104: and the first node packages the first state data and the first transaction value into a first message and issues the first message to the blockchain system.
By the method, the problem that a large amount of memory space is consumed by the version number along with the increase of the state data due to the fact that one version number is additionally maintained and additionally occupies memory space is solved, and due to the fact that the actual concurrent transactions are large in number, concurrent control is conducted according to the actual state data of the account, the misjudgment of a large amount of abnormal transactions caused by the fact that the version numbers are judged to be inconsistent in the MVCC is avoided, and execution efficiency and throughput in a block chain are improved.
After the first node issues the first message to the blockchain system, the accounting node starts to perform verification of the transaction when reaching the accounting period, and determines whether the first transaction in the first message can be successfully transacted, which is specifically, as shown in fig. 2, including:
step 201: a second node receives a first message sent by a first node; the first message comprises a first transaction value and first state data; the first state data is the state data of an account corresponding to a first transaction request acquired from an account book of the blockchain system by the first node after the first transaction request sent by a transaction initiator is received by the first node; the first transaction value is generated by the first node according to the first transaction request and the first state data;
step 202: the second node acquires second state data from the account book of the blockchain system, wherein the second state data is the current state of the account corresponding to the first transaction;
step 203: if the second node determines that the second state data is the same as the first state data, generating a block containing the first transaction value;
step 204: the second node issues the block to the blockchain system.
It should be noted that the second node is an accounting node in the blockchain system, and the first node and the second node may be the same node or different nodes, which is not limited herein.
For the scene that the billing result is successful, the method further comprises the following steps:
step one, a first node receives an accounting result of a first message sent by a second node;
step two, the first node receives a block sent by the second node, wherein the block comprises the first transaction value, and the block is generated when the second node determines that second state data is the same as the first state data; the second state data is the current state of the account obtained by the second node from the ledger of the blockchain system after receiving the first message.
And for the scene that the accounting result is failure, if the second node determines that the second state data is different from the first state data, the second node notifies the first node of accounting failure of the first message, so that the first node processes the first transaction request again.
Optionally, the method further includes:
step one, if the first node determines that the accounting result is failure, acquiring third state data from an account book of the block chain system; the third status data is used to characterize the current status of the account;
step two, the first node generates a second trading value according to the third state data and the first trading request;
and step three, the first node packs the third state data and the second trading value into a second message and issues the second message to the block chain system.
In the above embodiment, a verification request of first transaction data is sent to a first node in a blockchain network, a first transaction data processing state is verified, whether first transaction data processing is successful or not is judged, and if the first transaction data processing is unsuccessful, the first transaction data is sent to the blockchain network again, so that the blockchain network processes the first transaction data again, and the problem that efficiency is low due to failure of the first transaction caused by concurrency conflicts in the blockchain network and need to be notified again to the node to initiate a transaction is solved.
Fig. 3 is a schematic flow chart of a billing method provided by an embodiment of the present invention, which includes the following steps:
step 301: a first node receives a first transaction request sent by an application;
step 302: the first node acquires first state data of the current moment from an account book of the blockchain system according to the first transaction request; the first state data is used for representing the current state of an account corresponding to the first transaction;
specifically, after receiving the first transaction request, the first node determines the pre-execution state data v 1.
Step 303: the first node executes the first transaction request according to the first transaction request and the first state data, and generates a first transaction value;
specifically, after the first node receives the first transaction request, the node performs pre-execution on the transaction, and determines a result t1 after execution.
Step 304: and the first node packages the first state data and the first transaction value into a first message and issues the first message to the blockchain system.
Specifically, after the first node receives the first transaction request, the node performs pre-execution on the transaction, and adds the state data v1 before execution and the result t1 after execution to the submitted first message.
Step 305: a second node receives a first message sent by a first node;
step 306: the second node acquires second state data from the account book of the blockchain system, wherein the second state data is the current state of the account corresponding to the first transaction;
step 307: judging whether the second state data is the same as the first state data, if so, executing step 308; otherwise, go to step 309;
specifically, whether the state data v1 added in the first message is equal to the current value v 1' of the state data is compared, and if so, the step 308 is executed; otherwise, go to step 309;
step 308: the first node receives the block sent by the second node;
specifically, the second node locks the data and directly updates the target value t1 into the state data; and sending the generated block to the whole network and recording the block.
Step 309: notifying the first node of accounting failure of the first message;
step 310: the first node returns a value step 302;
specifically, the first node acquires the latest status data and execution result according to the current status data, re-executes the first transaction request, and then repeats the determination process of step 307, and updates the execution result to the current status data if the additional status data v1 is the same as the current status data v 1'.
In view of the above method flow, an embodiment of the present invention further provides a device for verifying transaction data written in a block chain, and specific contents of the software pre-deployment device may be implemented with reference to the above method.
As shown in fig. 4, an accounting apparatus applied to a blockchain system, where the blockchain system includes at least 2 nodes, the apparatus includes:
a transceiver unit 401, configured to receive a first transaction request sent by a transaction initiator; the first node is any node in the blockchain system;
a processing unit 402, configured to obtain, according to the first transaction request, first state data at a current time from an account book of the blockchain system; the first state data is used for representing the current state of an account corresponding to the first transaction; executing the first transaction request according to the first transaction request and the first state data, and generating a first transaction value; the first trading value is a result after the first trading request is executed;
the transceiver 401 is configured to package the first state data and the first transaction value into a first message, and issue the first message to the blockchain system.
In a possible implementation manner, the transceiver unit 401 is further configured to: receiving an accounting result of the first message sent by the second node; receiving a block sent by the second node, wherein the block comprises the first transaction value, and the block is generated when the second node determines that second state data is the same as the first state data; the second state data is the current state of the account obtained by the second node from the ledger of the blockchain system after receiving the first message.
In one possible implementation manner, the processing unit 402 is further configured to: if the accounting result is determined to be failure, acquiring third state data from an account book of the block chain system; the third status data is used to characterize the current status of the account; generating a second trading value according to the third state data and the first trading request;
the transceiver 401 is further configured to package the third state data and the second transaction value into a second message, and issue the second message to the blockchain system.
As shown in fig. 5, an accounting apparatus applied to a blockchain system, where the blockchain system includes at least 2 nodes, the apparatus includes:
a transceiving unit 501, configured to receive a first message sent by a first node; the first message comprises a first transaction value and first state data; the first state data is the state data of an account corresponding to a first transaction request acquired from an account book of the blockchain system by the first node after the first transaction request sent by a transaction initiator is received by the first node; the first transaction value is generated by the first node according to the first transaction request and the first state data;
a processing unit 502, configured to obtain second state data from an account book of the blockchain system, where the second state data is a current state of an account corresponding to the first transaction; if the second state data is determined to be the same as the first state data, generating a block containing the first trading value;
the transceiver unit 501 is further configured to issue the block to the block chain system.
In one possible implementation manner, the processing unit 502 is further configured to: and if the second state data is different from the first state data, notifying the first node of accounting failure of the first message, so that the first node processes the first transaction request again.
It should be noted that, for the function implementation of each unit in the accounting device in the embodiment of the present invention, reference may be further made to the description of the related method embodiment, and details are not described herein again.
An embodiment of the present application further provides an accounting device, as shown in fig. 6, the accounting device includes:
a memory 202 for storing program instructions;
and the processor 200 is configured to call the program instructions stored in the memory, and execute any method flow described in the embodiments of the present application according to the obtained program.
A transceiver 201 for receiving and transmitting instructions for the billing process under the control of the processor 200.
Where in fig. 6, the bus architecture may include any number of interconnected buses and bridges, with various circuits of one or more processors, represented by processor 200, and memory, represented by memory 202, being linked together. The bus architecture may also link together various other circuits such as peripherals, voltage regulators, power management circuits, and the like, which are well known in the art, and therefore, will not be described any further herein. The bus interface provides an interface.
The transceiver 201 may be a number of elements, including a transmitter and a transceiver, providing a means for communicating with various other apparatus over a transmission medium.
The processor 200 is responsible for managing the bus architecture and general processing, and the memory 202 may store data used by the processor 200 in performing operations.
The processor 200 may be a Central Processing Unit (CPU), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA), or a Complex Programmable Logic Device (CPLD).
Embodiments of the present application also provide a computer storage medium for storing computer program instructions for any apparatus described in the embodiments of the present application, which includes a program for executing any method provided in the embodiments of the present application.
The computer storage media may be any available media or data storage device that can be accessed by a computer, including, but not limited to, magnetic memory (e.g., floppy disks, hard disks, magnetic tape, magneto-optical disks (MOs), etc.), optical memory (e.g., CDs, DVDs, BDs, HVDs, etc.), and semiconductor memory (e.g., ROMs, EPROMs, EEPROMs, non-volatile memory (NAND FLASH), Solid State Disks (SSDs)), etc.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.

Claims (12)

1. A billing method applied to a blockchain system comprising at least 2 nodes, the method comprising:
a first node receives a first transaction request sent by a transaction initiator; the first node is any node in the blockchain system;
the first node acquires first state data of the current moment from an account book of the blockchain system according to the first transaction request; the first state data is used for representing the current state of an account corresponding to the first transaction;
the first node executes the first transaction request according to the first transaction request and the first state data, and generates a first transaction value; the first trading value is a result after the first trading request is executed;
and packaging the first state data and the first transaction value into a first message, and issuing the first message to the blockchain system.
2. The method of claim 1, wherein the method further comprises:
the first node receives an accounting result of the first message sent by a second node;
the first node receives a block sent by the second node, wherein the block comprises the first transaction value, and the block is generated when the second node determines that second state data is the same as the first state data; the second state data is the current state of the account obtained by the second node from the ledger of the blockchain system after receiving the first message.
3. The method of claim 2, wherein the method further comprises:
if the first node determines that the accounting result is failure, acquiring third state data from an account book of the block chain system; the third status data is used to characterize the current status of the account;
the first node generates a second trading value according to the third state data and the first trading request;
and the first node packs the third state data and the second trading value into a second message and issues the second message to the blockchain system.
4. A billing method applied to a blockchain system comprising at least 2 nodes, the method comprising:
a second node receives a first message sent by a first node; the first message comprises a first transaction value and first state data; the first state data is the state data of an account corresponding to a first transaction request acquired from an account book of the blockchain system by the first node after the first transaction request sent by a transaction initiator is received by the first node; the first transaction value is generated by the first node according to the first transaction request and the first state data;
the second node acquires second state data from the account book of the blockchain system, wherein the second state data is the current state of the account corresponding to the first transaction;
if the second node determines that the second state data is the same as the first state data, generating a block containing the first trading value;
the second node issues the block to the blockchain system.
5. The method of claim 4, wherein the method further comprises:
and if the second node determines that the second state data is different from the first state data, the second node notifies the first node of the accounting failure of the first message, so that the first node processes the first transaction request again.
6. An accounting apparatus applied to a blockchain system, the blockchain system comprising at least 2 nodes, the apparatus comprising:
the receiving and sending unit is used for receiving a first transaction request sent by a transaction initiator;
the processing unit is used for acquiring first state data of the current moment from an account book of the blockchain system according to the first transaction request; the first state data is used for representing the current state of an account corresponding to the first transaction; executing the first transaction request according to the first transaction request and the first state data, and generating a first transaction value; the first trading value is a result after the first trading request is executed;
the receiving and sending unit is configured to package the first state data and the first transaction value into a first message, and issue the first message to the blockchain system.
7. The apparatus as recited in claim 6, wherein said transceiver unit is further configured to: receiving an accounting result of the first message sent by the second node; receiving a block sent by the second node, wherein the block comprises the first transaction value, and the block is generated when the second node determines that second state data is the same as the first state data; the second state data is the current state of the account obtained by the second node from the ledger of the blockchain system after receiving the first message.
8. The apparatus as recited in claim 7, said processing unit to further: if the accounting result is determined to be failure, acquiring third state data from an account book of the block chain system; the third status data is used to characterize the current status of the account; generating a second trading value according to the third state data and the first trading request;
the transceiver unit is further configured to package the third state data and the second transaction value into a second message, and issue the second message to the blockchain system.
9. An accounting apparatus applied to a blockchain system, the blockchain system comprising at least 2 nodes, the apparatus comprising:
a receiving and sending unit, configured to receive a first message sent by a first node; the first message comprises a first transaction value and first state data; the first state data is the state data of an account corresponding to a first transaction request acquired from an account book of the blockchain system by the first node after the first transaction request sent by a transaction initiator is received by the first node; the first transaction value is generated by the first node according to the first transaction request and the first state data;
the processing unit is used for acquiring second state data from the account book of the blockchain system, wherein the second state data is the current state of the account corresponding to the first transaction; if the second state data is determined to be the same as the first state data, generating a block containing the first trading value;
the transceiver unit is further configured to issue the block to the block chain system.
10. The apparatus as recited in claim 9, said processing unit to further: and if the second state data is different from the first state data, notifying the first node of accounting failure of the first message, so that the first node processes the first transaction request again.
11. An accounting device, comprising:
a memory for storing program instructions;
a processor for calling the program instructions stored in the memory and executing the method of any one of claims 1 to 3 or executing the method of any one of claims 4 to 5 according to the obtained program.
12. A computer readable storage medium having stored thereon computer instructions which, when run on a computer, cause the computer to perform the method of any of claims 1 to 3 or perform the method of any of claims 4 to 5.
CN201811319215.4A 2018-11-07 2018-11-07 Accounting method and device Active CN109493223B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811319215.4A CN109493223B (en) 2018-11-07 2018-11-07 Accounting method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811319215.4A CN109493223B (en) 2018-11-07 2018-11-07 Accounting method and device

Publications (2)

Publication Number Publication Date
CN109493223A CN109493223A (en) 2019-03-19
CN109493223B true CN109493223B (en) 2021-12-21

Family

ID=65695163

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811319215.4A Active CN109493223B (en) 2018-11-07 2018-11-07 Accounting method and device

Country Status (1)

Country Link
CN (1) CN109493223B (en)

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111614709B (en) * 2019-02-26 2022-12-16 傲为有限公司 Partition transaction method and system based on block chain
CN110084600B (en) * 2019-04-29 2021-08-27 百度在线网络技术(北京)有限公司 Processing and verifying method, device, equipment and medium for resolution transaction request
CN110321219A (en) * 2019-05-06 2019-10-11 百度在线网络技术(北京)有限公司 A kind of parallel execution method, apparatus, equipment and the medium of transactions requests
CN112561695B (en) * 2019-09-25 2021-07-23 支付宝(杭州)信息技术有限公司 Method and apparatus for concurrently executing transactions in a blockchain
CN110727712B (en) 2019-10-15 2021-06-04 腾讯科技(深圳)有限公司 Data processing method and device based on block chain network, electronic equipment and storage medium
CN110727964B (en) * 2019-10-22 2023-10-31 北京国联视讯信息技术股份有限公司 Block chain big data processing method and system
US11082527B2 (en) 2019-12-10 2021-08-03 International Business Machines Corporation Controlling transaction requests between applications and servers
CN111199485A (en) * 2020-01-02 2020-05-26 支付宝(杭州)信息技术有限公司 Method and device for processing transaction data at block chain nodes
CN111353869B (en) * 2020-03-15 2023-04-07 策拉人工智能科技(云南)有限公司 Method applied to cloud financial learning and memorizing billing habit
CN111563124B (en) * 2020-05-08 2023-06-23 中国工商银行股份有限公司 Operation processing method, device and system based on block chain
CN111984421B (en) * 2020-09-03 2022-09-16 深圳壹账通智能科技有限公司 Data processing method, device and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108282474A (en) * 2018-01-18 2018-07-13 山东大学 The maintaining method of digital asset trade identity based on block chain
CN108717606A (en) * 2018-06-08 2018-10-30 北京工商大学 A kind of food security multiplicity of interests main body credit assessment method based on block chain

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108282474A (en) * 2018-01-18 2018-07-13 山东大学 The maintaining method of digital asset trade identity based on block chain
CN108717606A (en) * 2018-06-08 2018-10-30 北京工商大学 A kind of food security multiplicity of interests main body credit assessment method based on block chain

Also Published As

Publication number Publication date
CN109493223A (en) 2019-03-19

Similar Documents

Publication Publication Date Title
CN109493223B (en) Accounting method and device
US10986177B2 (en) Systems and methods of self-forking blockchain protocol
CN109426949B (en) Cross-chain transaction method and device
TWI694390B (en) Blockchain-based transaction processing method and device, and electronic equipment
US20190354518A1 (en) Chain mesh network for decentralized transaction systems
US20230100223A1 (en) Transaction processing method and apparatus, computer device, and storage medium
EP3816910B1 (en) Blockchain-based transaction processing method and apparatus, and electronic device
Enes et al. State-machine replication for planet-scale systems
EP3791353A1 (en) Prioritization in a permissioned blockchain
Balegas et al. Extending eventually consistent cloud databases for enforcing numeric invariants
CN110009338B (en) Accounting method and device based on block chain and electronic equipment
US9990391B1 (en) Transactional messages in journal-based storage systems
CN111338766A (en) Transaction processing method and device, computer equipment and storage medium
EP4332870A1 (en) Transaction data processing method and apparatus, computer device and storage medium
EP3816912B1 (en) Blockchain-based transaction processing method and apparatus, and electronic device
US10108658B1 (en) Deferred assignments in journal-based storage systems
US11720429B2 (en) Optimizing logging of decision outcomes in distributed transactions
CN113743950B (en) Method, node and blockchain system for performing transactions in blockchain system
US11627122B2 (en) Inter-system linking method and node
EP4071646A1 (en) Scalable, secure, efficient, and adaptable distributed digital ledger transaction network
CN114936256A (en) Method for executing transaction in block chain and block chain link point
Dinh et al. A blueprint for interoperable blockchains
JP2023541298A (en) Transaction processing methods, systems, devices, equipment, and programs
CN114942847A (en) Method for executing transaction and block link point
CN114827165A (en) Method and block link point for grouping multiple transactions

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant