Disclosure of Invention
The description provides an accounting method based on a block chain, wherein the block chain comprises at least one general account accounting node and a plurality of branch account accounting nodes which are taken as member nodes of the block chain; wherein, each account node corresponds to different types of accounting service, the method comprises:
the account-based accounting node receives an accounting transaction initiated by a transaction initiator; the accounting transaction comprises account detail records related to accounting business corresponding to the account-dividing accounting nodes;
synchronizing the accounting transaction to other accounting nodes in the blockchain to initiate consensus processing for the accounting transaction;
and responding to the notification message that the bookkeeping transaction consensus passes, recording the sub-account detail in the distributed account book of the block chain for storage, so that the general account node performs sub-account collection based on the distributed account book of the block chain to generate a general account.
Optionally, the accounting transaction includes a service identifier indicating a type of an accounting service corresponding to the accounting transaction; before synchronizing the accounting transaction with other accounting nodes in the blockchain, the method further comprises:
and if the service identification is different from the accounting service type corresponding to the account-keeping node, the account-keeping node does not accept and process the transaction, and broadcasts the accounting transaction in the block chain.
Optionally, the method further includes:
and if the block chain fails to agree with the accounting transaction, returning a notification message of accounting failure to the transaction initiator.
Optionally, the block chain is a federation chain.
Optionally, the consensus algorithm carried by the block chain is a PBFT algorithm.
The application also provides an accounting device based on the block chain, wherein the block chain comprises at least one general account accounting node and a plurality of branch account accounting nodes which are taken as member nodes of the block chain; wherein, each account book node of branch account book corresponds the account book business of different grade type respectively, the device includes:
the acquisition module is used for receiving the accounting transaction initiated by the transaction initiator by the account-based accounting node; the accounting transaction comprises account detail records related to accounting business corresponding to the account-dividing accounting nodes;
the accounting module is used for synchronizing the accounting transaction with other accounting nodes in the block chain so as to initiate consensus processing for the accounting transaction; and the sub-account detail record is stored in the distributed account book of the block chain in response to the notification message that the bookkeeping transaction consensus passes, so that the general account node performs sub-account collection based on the distributed account book of the block chain to generate a general account.
Optionally, the obtaining module further:
and if the service identification is different from the accounting service type corresponding to the account-keeping node, the account-keeping node does not accept and process the transaction, and broadcasts the accounting transaction in the block chain.
Optionally, the apparatus further comprises:
and the return module is used for returning a notification message of accounting failure to the transaction initiator if the block chain fails to identify the accounting transaction together.
Optionally, the block chain is a federation chain.
Optionally, the consensus algorithm carried by the block chain is a PBFT algorithm.
This specification also proposes an electronic device including:
a processor;
a memory for storing machine executable instructions;
wherein the processor is caused to:
the account-based accounting node receives an accounting transaction initiated by a transaction initiator; the accounting transaction comprises account detail records related to accounting business corresponding to the account-dividing accounting nodes;
synchronizing the accounting transaction to other accounting nodes in the blockchain to initiate consensus processing for the accounting transaction;
and responding to the notification message that the bookkeeping transaction consensus passes, recording the sub-account detail in the distributed account book of the block chain for storage, so that the general account node performs sub-account collection based on the distributed account book of the block chain to generate a general account.
With the above embodiment, since the accounting transactions of the account-splitting accounts of different service types are stored in the blockchain, the accounting transactions include account-splitting account detail records related to the accounting service corresponding to the account-splitting account accounting node; in addition, in the accounting transaction process of the account accounts of different service types, synchronous accounting of the accounting information of the account accounts of the different service types stored in the block chain is introduced; therefore, the general ledger node and a plurality of sub-account ledger nodes of different service types share one set of sub-account ledger book, and the general ledger node is based on the locally stored copies of the sub-account ledger book, so that the problems of low speed, poor timeliness and inconsistent data when the general ledger is checked with the plurality of sub-account ledgers of different service types can be fundamentally solved, and single-point data loss or malicious tampering can be avoided due to multi-node distributed storage of the sub-account ledger book.
Detailed Description
In some scenes of accounting, when a user summarizes the general ledger, the general ledger is generally obtained based on detail data generated by the detail ledger, wherein the general ledger is also called a general ledger and is an account book classified and registered according to the state-specified accounting subjects, and the general ledger can comprehensively and comprehensively reflect and record capital movement and financial balance caused by economic business and provide data support for compiling accounting statements.
The itemized account in general practice uses an account-based account. The account-splitting account is one of the detailed accounts, is a detailed record of each subject of the general account, and is also a basis for checking accounts with units. Since the general ledger contains a plurality of subjects, the general ledger data summarized by the general ledger node may be derived from a plurality of types of branch ledger nodes.
In one scenario, when a sub-account node of a certain type generates a detail flow, it is notified to the general ledger node in an asynchronous message. In the actual transmission process of the message, due to the fact that the network environment is abnormal, the situations of delay, loss, disorder and the like can occur in the process of the message reaching the general ledger node, and therefore general ledger summary errors are caused; in another scenario, when some type of sub-account data is tampered maliciously, the general account summary error is caused, and the general account (the general account and various types of sub-account data) check data is inconsistent.
Based on this, in this specification, a technical solution is provided, in which different types of accounting transaction requests are processed and synchronized on a blockchain based on a general ledger accounting node and different types of individual ledger accounting nodes, and an accounted transaction including different types of individual ledger particulars is recorded in a distributed ledger of the blockchain and stored, so that the general ledger accounting node generates a general ledger based on the collection of the distributed ledger, thereby avoiding a traditional single-point fault of the individual ledger and inconsistency of general ledger checking data.
In implementation, the general ledger accounting node may no longer be only a single node, but be composed of a general ledger cluster composed of a plurality of nodes. The account-based accounting node can be no longer only a single node supporting a certain service type, but also a group of account-based accounting nodes consisting of a plurality of devices supporting the service type, and the devices in the group can share the same private key or each device can independently maintain a private key, and the private key is used for encrypting the accounting transaction. The service type cluster is responsible for receiving an accounting transaction which is initiated by a transaction initiator and corresponds to the service type, wherein the accounting transaction comprises account detail records related to the accounting service corresponding to the account detail records; in a blockchain network, there are multiple split-account clusters that support different traffic types.
For example, the ledger accounting node is actually a ledger cluster consisting of 3 devices. The account-dividing accounting node supporting the deposit business type is a deposit account-dividing cluster consisting of 5 devices; the sub-account accounting node supporting the loan service type is a loan sub-account cluster consisting of 7 devices; the account-based accounting node supporting the virtual account service type is a virtual account-based accounting cluster formed by 9 devices. The account node for supporting the deposit service account is responsible for receiving an account transaction of the deposit service initiated by a transaction initiator, wherein the account transaction comprises at least one deposit detail record, such as: deposit account name, deposit amount, account balance.
When the deposit business account-dividing and accounting node receives the storage accounting transaction, the accounting transaction is synchronized with other accounting nodes in the block chain, and the other accounting nodes may be a general account accounting node and an account-dividing and accounting node supporting other business types, for example: the loan account division and accounting node and the virtual account division and accounting node are connected; in this scenario, the other accounting nodes decrypt the storage accounting transaction based on the public key corresponding to the private key of the deposit accounting node, obtain the storage accounting transaction, initiate consensus processing on the storage accounting transaction, and determine the effectiveness of the accounting transaction. The consensus algorithm and the specific consensus process used are not described in detail in this specification, and those skilled in the art can refer to the description in the related art when implementing the technical solutions described in this specification. For example, for a federation chain, an algorithm such as the PBFT algorithm, or other similar consensus algorithm, may be employed.
And after the other accounting nodes recognize the deposit accounting transaction, sending a notification message to the deposit service account splitting and accounting node. Based on the requirement of the adopted consensus algorithm, if the consensus passes, the deposit business account and keeping node records the deposit account and keeping transaction details contained in the deposit account and keeping transaction institute in the distributed account book of the block chain for storage. And after the deposit sub-account details are stored in the distributed account book of the block chain, the general account node performs sub-account book collection based on the distributed account book to generate a general account.
For example: the distributed account book of the block chain records deposit sub-account details, loan sub-account details and virtual account sub-account details; and the general ledger accounting node summarizes the three branch account details to generate the general ledger.
In the above technical solution, since the accounting transactions of the account-splitting accounts of different service types are stored in the blockchain, the accounting transactions include account-splitting account detail records related to the accounting service corresponding to the account-splitting account accounting node; in addition, in the accounting transaction process of the account accounts of different service types, synchronous accounting of the accounting information of the account accounts of the different service types stored in the block chain is introduced; therefore, the general ledger node and a plurality of sub-account ledger nodes of different service types share one set of sub-account ledger book, and the general ledger node is based on the locally stored copies of the sub-account ledger book, so that the problems of low speed, poor timeliness and inconsistent data when the general ledger is checked with the plurality of sub-account ledgers of different service types can be fundamentally solved, and single-point data loss or malicious tampering can be avoided due to multi-node distributed storage of the sub-account ledger book.
The present specification is described below with reference to specific embodiments and specific application scenarios.
Referring to fig. 1, fig. 1 is a block chain-based accounting method applied to a separate account accounting node according to an embodiment of the present disclosure; the block chain comprises at least one general account and accounting node and a plurality of branch account and accounting nodes which are taken as member nodes of the block chain; wherein, each account node corresponds to different types of accounting service, the method comprises the following steps:
102, receiving accounting transaction initiated by a transaction initiator; the accounting transaction comprises account detail records related to accounting business corresponding to the account-dividing accounting nodes;
step 104, synchronizing the accounting transaction with other accounting nodes in the blockchain to initiate consensus processing for the accounting transaction;
and 106, responding to the notification message that the bookkeeping transaction consensus passes, recording the sub-account detail in the distributed account book of the block chain for storage, so that the general account node performs sub-account collection based on the distributed account book of the block chain to generate a general account.
The blockchain described in this specification may specifically include a private chain, a common chain, a federation chain, and the like, and is not particularly limited in this specification.
For example, in one scenario, the block chain may specifically be a federation chain formed by a plurality of account-based accounting nodes and general-account accounting nodes of different service types as federation members; the operator of the alliance chain can rely on the alliance chain to deploy the accounting business aiming at the accounting transaction initiated by the transaction initiator; and the above-described multiple sub-accounting nodes and general accounting nodes supporting different service types as coalition members can be used as one service node of the above-described accounting service. When the sub-account accounting node of a certain service type initiates synchronization to the accounting transaction of the service type in the block chain, if other accounting nodes achieve consensus to the accounting transaction, the other accounting nodes respond to the sub-account accounting node initiating the accounting transaction with the consensus success message, the sub-account accounting node corresponding to the accounting transaction initiates a distributed database in the alliance chain to store, and the uplink accounting of the accounting transaction is completed.
The sub-account bookkeeping nodes of different service types can only receive and process bookkeeping transactions of the service types, if the bookkeeping transactions are different from the bookkeeping service types corresponding to the sub-account bookkeeping nodes, the sub-account bookkeeping nodes do not accept and process the transactions, namely, the bookkeeping transactions correspond to the sub-account bookkeeping nodes, only have bookkeeping authority for the bookkeeping transactions of the service types, only can synchronously acquire and commonly identify the bookkeeping transactions of other service types for the bookkeeping transactions of other service types, and cannot initiate the operation of writing the first account into the distributed account book, and the general bookkeeping node cannot directly receive and process the bookkeeping transactions of any service type.
For example, in one embodiment shown, if the transaction type is different from the accounting type corresponding to the account-splitting accounting node, the account-splitting accounting node does not admit processing of the transaction, but broadcasts the accounting transaction in the blockchain. And if the account-based accounting node corresponding to the transaction type receives the transaction type, the account-based accounting node performs accounting service processing according to the methods described in the steps 102 to 106.
If the block chain fails to identify the accounting transaction together, the account-based accounting node returns an accounting failure notification message to the transaction initiator.
For example, in one embodiment shown, the blockchain is a federation chain, there are 3f +1 accounting nodes, where f is a positive integer; the consensus algorithm used for this blockchain piggybacking is PBFT. If the transaction agrees for less than 2f +1 nodes of the accounting transaction, which indicates that the transaction agrees is not passed, the account-splitting accounting node returns a notification message of accounting failure to the transaction initiator.
It should be noted that the accounting transaction described in this specification refers to a piece of data that is created by a transaction initiator of a certain type of account-based account through a client of a blockchain and needs to be finally issued to a distributed database of the blockchain, where the piece of data includes: accounting business type and individual account detail record.
Transactions in a blockchain, generally have a narrow sense of transaction and a broad sense of transaction score. A narrowly defined transaction refers to a transfer of value issued by a user to a blockchain; for example, in a conventional bitcoin blockchain network, the transaction may be a transfer initiated by the user in the blockchain. The broad transaction refers to a piece of business data with business intention, which is issued to the blockchain by a user; for example, an operator may build a federation chain based on actual business requirements, relying on the federation chain to deploy some other types of online businesses unrelated to value transfer (e.g., anti-counterfeiting business, house renting business, vehicle scheduling business, insurance claim settlement business, credit service, medical service, etc.), and in such federation chain, a transaction may be a business message or business request with a business intent issued by a user in the federation chain.
The following block chains are taken as union chains and comprise: taking the account-based accounting nodes and the general accounting nodes of a plurality of service types as examples, the technical scheme of the specification is explained in detail;
it should be emphasized that the above-mentioned account-based accounting nodes and general accounting nodes of multiple service types are only exemplary.
Referring to fig. 2, fig. 2 is an architecture diagram of a federation chain shown in this specification.
As shown in fig. 2, there are three service types of account-based accounting nodes and general accounting nodes, which can be joined into the federation chain as federation members, and issue accounting transactions generated by respective corresponding service types to the federation chain in the form of transactions, and after the transactions are processed by consensus of consensus nodes in the federation chain, store the transactions in a distributed database in the federation chain, and complete "uplink" storage of the accounting transactions.
With continued reference to fig. 2, in the present specification, the accounting transaction stored in the federation chain may specifically include three parts, namely, an account detail record of the accounting transaction, an accounting transaction type, and an accounting transaction summary.
In one embodiment shown, a type 1 account-splitting accounting node receives an accounting transaction of type 1 initiated by a transaction initiator; wherein the billing transaction comprises: the accounting transaction type is type 1, type 1 account detail record and the note account transaction abstract; the account node of the account book transaction summary of type 1 carries out signature acquisition based on the held private key; the type 1 account accounting node synchronizes the accounting transaction to other accounting nodes in the blockchain, such as: the type 2 and type 3 account-based accounting nodes and the general account accounting node are used for initiating consensus processing for the accounting transaction;
and if the other accounting nodes pass the consensus on the accounting transaction, the consensus passing notification message is sent to the accounting nodes of the type 1. Taking the block chain as a federation chain and the consensus algorithm used by the block chain piggyback as PBFT, there are 3f +1 accounting nodes, where f is a positive integer. If less than 2f +1 nodes agree on the transaction for the booked transaction, it is said that the agreement did not pass for the transaction. Such as: if the type 1 account-based node receives the notification message that the consensus of 2f +1 nodes is passed or exceeded, the consensus is passed for the transaction.
The sub-account book keeping node of type 1 records the sub-account details in the distributed account book of the block chain for storage, as shown in fig. 2, the sub-account book of type 1 is stored in the block chain, so that the general account keeping node carries out sub-account book collection based on the sub-account book of type 1 to generate a general account.
In one embodiment shown, a type 2 ledger accounting node receives type 2 accounting transactions initiated by a transaction initiator; wherein the billing transaction comprises: the accounting transaction type is type 2, type 2 account detail record and the note account transaction abstract; the account node of the account book transaction summary of type 2 carries out signature acquisition based on the held private key; the type 2 account accounting node synchronizes the accounting transaction to other accounting nodes in the blockchain, such as: the type 1 and type 3 account-based accounting nodes and the general account accounting node are used for initiating consensus processing for the accounting transaction;
taking the block chain as a federation chain and the consensus algorithm used by the block chain piggyback as PBFT, there are 3f +1 accounting nodes, where f is a positive integer. If less than 2f +1 nodes agree on the transaction for the booked transaction, it is said that the agreement did not pass for the transaction. Such as: if the type 2 account-based node does not receive the notification message that the 2f +1 node consensus is passed, the transaction consensus is not passed. And the type 2 account-making node returns a notification message of accounting failure to the transaction initiator.
In one embodiment shown, a type 3 ledger accounting node receives type 2 accounting transactions initiated by a transaction initiator; wherein the billing transaction comprises: the accounting transaction type is type 2 and type 2 account detail records; before synchronizing the accounting transaction with other accounting nodes in the block chain, the type 3 account accounting node acquires the transaction service type, which is service type 2, and is different from the accounting service type, i.e. type 3, corresponding to the type 3 account accounting node, so that the type 3 account accounting node does not accept and process the transaction, but broadcasts the accounting transaction in the block chain. If the type 2 sub-accounting node receives the transaction broadcast by the type 3 sub-accounting node, the type 2 sub-accounting node performs accounting service processing according to the method described in steps 102 to 106.
In one embodiment shown, the ledger accounting node receives type 3 accounting transactions initiated by the transaction initiator; wherein the billing transaction comprises: the accounting transaction type is type 3 and type 3 account detail records; the general ledger accounting node does not admit processing of the transaction, but broadcasts the accounting transaction in the blockchain. If the type 3 sub-accounting billing node receives the transaction broadcast by the general-account billing node, the type 3 sub-accounting billing node performs the billing service processing according to the method described in the steps 102 to 106.
In one embodiment, please refer to fig. 2, the distributed database in the blockchain stores: the type 1 sub-account book, the type 2 sub-account book and the type 3 sub-account book; the general ledger accounting node is used for summarizing the general ledger according to the accounting rules of the general ledger based on the type 1, type 2 and type 3 sub-account book copies of the local storage, and the accounting rules are not detailed one by one.
As can be seen from the above embodiments, in this specification, the accounting transactions corresponding to a certain service type and stored in the blockchain are stored in a distributed manner in a plurality of account nodes of the sub-accounts, and the general account node is in the blockchain, so that centralized and centralized storage of the account nodes of the sub-accounts of a single service type is not used, and a single-point failure of the service is avoided; changes of the branch account of any business type are synchronized to the distributed database of the block chain, and the data of the general account accounting node can quickly acquire the update of the branch account. The general ledger node and a plurality of sub-account ledger nodes of different business types share one set of sub-account ledger book, and the general ledger node is based on the locally stored copies of the sub-account ledger books, so that the problems of low speed, poor timeliness and inconsistent data when the general ledger is checked with the plurality of sub-account ledgers of different business types can be fundamentally solved, and single-point data loss or malicious tampering can be avoided due to multi-node distributed storage of the sub-account ledger books.
Corresponding to the above method embodiments, the present specification also provides an embodiment of a block chain based accounting device. The embodiment of the block chain based accounting device in the present specification can be applied to an electronic device. The device embodiments may be implemented by software, or by hardware, or by a combination of hardware and software. Taking a software implementation as an example, as a logical device, the device is formed by reading, by a processor of the electronic device where the device is located, a corresponding computer program instruction in the nonvolatile memory into the memory for operation. From a hardware aspect, as shown in fig. 3, the hardware structure diagram of the electronic device where the block chain based accounting device of this specification is located is shown in fig. 3, except for the processor, the memory, the network interface, and the nonvolatile memory shown in fig. 3, the electronic device where the device is located in the embodiment may also include other hardware according to an actual function of the electronic device, which is not described again.
Fig. 4 is a block diagram of a block chain based billing apparatus according to an exemplary embodiment of the present disclosure.
Referring to fig. 4, the block chain based accounting device 40 may be applied to the electronic device shown in fig. 3; the block chain comprises at least one general account and accounting node and a plurality of branch account and accounting nodes which are taken as member nodes of the block chain; wherein, each account node corresponds to different types of accounting services; the device 40 comprises: an acquisition module 401, a billing module 402 and a return module 403.
An obtaining module 401, configured to receive, by an account-based accounting node, an accounting transaction initiated by a transaction initiator; the accounting transaction comprises account detail records related to accounting business corresponding to the account-dividing accounting nodes;
a billing module 402 for synchronizing the billing transaction to other billing nodes in the blockchain to initiate consensus processing for the billing transaction; and the sub-account detail record is stored in the distributed account book of the block chain in response to the notification message that the bookkeeping transaction consensus passes, so that the general account node performs sub-account collection based on the distributed account book of the block chain to generate a general account.
In this embodiment, the accounting transaction includes a service identifier indicating a type of an accounting service corresponding to the accounting transaction; before synchronizing the accounting transactions to other accounting nodes in the blockchain, the obtaining module 401 further:
and if the service identification is different from the accounting service type corresponding to the account-keeping node, the account-keeping node does not accept and process the transaction, and broadcasts the accounting transaction in the block chain.
In this embodiment, the apparatus 40 further includes:
a returning module 403, configured to return a notification message of the accounting failure to the transaction initiator if the block chain fails to agree with the accounting transaction.
In this embodiment, the block chain is a federation chain.
In this embodiment, the consensus algorithm carried by the block chain is a PBFT algorithm.
For the device embodiments, since they substantially correspond to the method embodiments, reference may be made to the partial description of the method embodiments for relevant points. The above-described embodiments of the apparatus are merely illustrative, wherein the modules described as separate parts may or may not be physically separate, and the parts displayed as modules may or may not be physical modules, may be located in one place, or may be distributed on a plurality of network modules. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution in the specification. One of ordinary skill in the art can understand and implement it without inventive effort.
The systems, devices, modules or modules illustrated in the above embodiments may be implemented by a computer chip or an entity, or by an article of manufacture with certain functionality. A typical implementation device is a computer, which may take the form of a personal computer, laptop computer, cellular telephone, camera phone, smart phone, personal digital assistant, media player, navigation device, email messaging device, game console, tablet computer, wearable device, or a combination of any of these devices.
Corresponding to the method embodiment, the present specification also provides an embodiment of an electronic device. The electronic device includes: a processor and a memory for storing machine executable instructions; wherein the processor and the memory are typically interconnected by an internal bus. In other possible implementations, the device may also include an external interface to enable communication with other devices or components.
In this embodiment, the processor is caused to, by reading and executing machine executable instructions stored by the memory corresponding to control logic for blockchain based accounting:
the account-based accounting node receives an accounting transaction initiated by a transaction initiator; the accounting transaction comprises account detail records related to accounting business corresponding to the account-dividing accounting nodes; the block chain comprises at least one general account and accounting node and a plurality of branch account and accounting nodes which are taken as member nodes of the block chain; wherein, each account node corresponds to different types of accounting services;
synchronizing the accounting transaction to other accounting nodes in the blockchain to initiate consensus processing for the accounting transaction;
and responding to the notification message that the bookkeeping transaction consensus passes, recording the sub-account detail in the distributed account book of the block chain for storage, so that the general account node performs sub-account collection based on the distributed account book of the block chain to generate a general account.
In this embodiment, the accounting transaction includes a service identifier indicating a type of an accounting service corresponding to the accounting transaction; before synchronizing the accounting transaction with other accounting nodes in the blockchain, the method further comprises:
and if the service identification is different from the accounting service type corresponding to the account-keeping node, the account-keeping node does not accept and process the transaction, and broadcasts the accounting transaction in the block chain.
In this embodiment, the processor is caused to, by reading and executing machine executable instructions stored by the memory corresponding to control logic for blockchain based accounting:
and if the block chain fails to agree with the accounting transaction, returning a notification message of accounting failure to the transaction initiator.
Other embodiments of the present disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This specification is intended to cover any variations, uses, or adaptations of the specification following, in general, the principles of the specification and including such departures from the present disclosure as come within known or customary practice within the art to which the specification pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the specification being indicated by the following claims.
It will be understood that the present description is not limited to the precise arrangements described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present description is limited only by the appended claims.
The above description is only a preferred embodiment of the present disclosure, and should not be taken as limiting the present disclosure, and any modifications, equivalents, improvements, etc. made within the spirit and principle of the present disclosure should be included in the scope of the present disclosure.