This application claims priority to Chinese Patent Application No. 202010504776.2 filed on Jun. 5, 2020, the contents of which are incorporated by reference herein.
The subject matter herein generally relates to recording by blockchain, especially to a method of recording transactions based on blockchain and an electronic device using the same.
Bitcoin in 2009 has accelerated blockchain technology. However, existing blockchain technology does not meet the number of transactions per second preferred for commercial-grade transactions, i.e. 30 million transactions per second. The processing of blockchain protocols need to be more efficient.
Many aspects of the disclosure can be better understood with reference to the following drawings. The components in the drawings are not necessarily drawn to scale, the emphasis instead being placed upon clearly illustrating the principles of the disclosure. Moreover, in the drawings, like reference numerals designate corresponding parts throughout the several views.
It will be appreciated that for simplicity and clarity of illustration, where appropriate, reference numerals have been repeated among the different figures to indicate corresponding or analogous elements. In addition, numerous specific details are set forth in order to provide a thorough understanding of the embodiments described herein. However, it will be understood by those of ordinary skill in the art that the embodiments described herein can be practiced without these specific details. In other instances, methods, procedures, and components have not been described in detail so as not to obscure the related relevant feature being described. Also, the description is not to be considered as limiting the scope of the embodiments described herein. The drawings are not necessarily to scale and the proportions of certain parts may be exaggerated to better illustrate details and features of the present disclosure.
The present disclosure, including the accompanying drawings, is illustrated by way of examples and not by way of limitation. Several definitions that apply throughout this disclosure will now be presented. It should be noted that references to “an” or “one” embodiment in this disclosure are not necessarily to the same embodiment, and such references mean “at least one.”
The term “module”, as used herein, refers to logic embodied in hardware or firmware, or to a collection of software instructions, written in a programming language, such as, Java, C, or assembly. One or more software instructions in the modules can be embedded in firmware, such as in an EPROM. The modules described herein can be implemented as either software and/or hardware modules and can be stored in any type of non-transitory computer-readable medium or other storage device. Some non-limiting examples of non-transitory computer-readable media include CDs, DVDs, BLU-RAY, flash memory, and hard disk drives. The term “comprising” means “including, but not necessarily limited to”; it specifically indicates open-ended inclusion or membership in a so-described combination, group, series, and the like.
A method of recording transactions for recording data of financial transactions based on blockchain is applied in an electronic device. The electronic device can include, but is not limited to, a microprocessor, an Application Specific Integrated Circuit, a Field-Programmable Gate Array, a Signal Digital Processor, embedded devices, and the like, and software to enable function.
At block 11, a server 2 receives transactions sent by terminal device 1, where each transaction includes a transaction category, an associated account number, and a transaction status.
In one embodiment, the terminal device 1 encapsulates the transaction and sends the encapsulated transaction to the server 2. In one embodiment, each transaction includes a transaction number, a transaction status, a transaction category, an associated account number, a transaction content, and an inspection code. In one embodiment, the transaction number serializes and identifies the transaction. The transaction number can consist of letters and numbers, for example, the transaction number may be expressed as “Tx4939”. The transaction status indicates the status of the transaction. In one embodiment, the transaction status includes a released status, a pending chain status, a confirmed status, and a failed status. The transaction category is used to indicate a type of transaction. In one embodiment, the transaction category includes a currency transfer and a transaction record. In one embodiment, the associated account number is associated with the transaction, for example, the associated account number may be expressed as “User account A” and “User account B”. The inspection code is used to inspect the transaction. In one embodiment, the inspection code is a hash value. In one embodiment, when the terminal device 1 sends the transaction to the server 2, the status of the transactions is the released status.
At block 12, the server 2 extracts the transaction category, the associated account number, and the transaction status from the transactions and determines whether the transaction category of each transaction is the currency transfer. In one embodiment, when the transaction category is the currency transfer, block 13 is executed, and when the transaction category is the transaction record, block 18 is executed.
At block 13, the server 2 accesses the trading pool 4 and/or the blockchain 5 by the chain node 3 and determines whether target transactions related to the associated account are filtered out from the trading pool 4 and/or the blockchain 5. In one embodiment, when the target transactions related to the associated account are filtered out from the trading pool 4 and/or the blockchain 5, block 14 is executed. When the target transactions related to the associated account are not filtered out from the trading pool 4 and/or the blockchain 5, block 15 is executed.
At block 14, the server 2 calculates results of the target transactions according to chronological order and determines whether the transactions are correct according to the result of the target transaction, marks the transaction status of the correct transactions as the pending chain status, and sends the marked transactions to the terminal device 1 for confirmation. In one embodiment, after block 14, block 16 is executed.
For example, when the associated account numbers of the transactions relate to user account A and user account B, the server 2 accesses the trading pool 4 and/or the blockchain 5 by the chain node 3, and filters out the target transactions related to the user account A and user account B. The results of the target transactions in sequence according to the chronological order are calculated, and the correctness of the transactions is determined, marks the transaction status of the correct transactions as pending chain status, and sends the marked transactions to the terminal device 1 for confirmation.
In one embodiment, the server 2 calculates the content of the target transactions according to chronological order, determines that the transactions are correct when the content of the target transactions is consistent, and determines that the transactions are incorrect when the content of the transactions is inconsistent.
At block 15, the server 2 obtains balance of the associated account number of the transactions from the chain node 3 of the blockchain 5 and determines whether the transactions are correct according to the balance of the associated account. The transaction status of the correct transactions is marked as the pending chain status, and the marked transactions are sent to the terminal device 1 for confirmation. In one embodiment, after block 15, block 16 is executed.
In one embodiment, when the balance of a transferred account in the associated account of the transactions is not less than a transfer amount, the transactions are deemed correct; when the balance of the transferred account in the associated account of the transactions is less than the transfer amount, the transactions are deemed incorrect.
At block 16, the server 2 receives successful transaction information or failed transaction information of the transactions sent by the terminal device 1, and marks the transaction status of the transactions as the confirmed status when receiving the successful transaction information, and packages the transactions into blocks, and transmits the blocks to the blockchain 5 by the chain node 3.
In one embodiment, the server 2 transmits the transactions with the pending chain status to the transaction pool 4 by the chain node 3, obtains the transactions with the pending chain status from the trading pool 4 by the chain node 3 when receiving the successful transaction information of the transactions sent by the terminal device 1, and packages the transactions into the blocks, and transmits the blocks the blockchain 5 by the chain node 3.
At block 17, the server 2 marks the transaction status of the transactions as a failed status when receiving the failed transaction information of the transactions sent by the terminal device 1, and sends the marked transactions to the terminal device 1 by the chain node 3.
At block 18, the server 2 accesses the trading pool 4 and/or the blockchain 5 by the chain node 3, and filters out all of the target transactions associated with the transactions from the trading pool 4 and/or the blockchain 5. The results of the target transactions are calculated according to chronological order, and the target transactions corresponding to correct transactions are packaged into blocks, and transmitted to the blockchain 5 by the chain node 3.
In one embodiment, the method of recording transactions further includes the server 2 marking the status of incorrect transactions as failed status, and transmitting the incorrect transactions with failed status to the terminal device 1. The terminal device 1 is notified to delete the incorrect transactions.
In one embodiment, the server 2 filters out the target transactions related to the associated account number of the transactions from the trading pool 4 and the blockchain 5, and determines that the transactions are correct when calculation results of the target transactions are correct. When the target transactions related to the related account of the transaction are not filtered out from the trading pool 4 and the blockchain 5, the server 2 determines whether the transactions are correct according to the balances of the associated account of the transactions. When the transactions are correct and the server 2 receives the successful transaction information of the transactions sent by the terminal device, the server 2 packages the transactions into blocks, and transmits the blocks to the blockchain 5 by chain node 3, thereby improving processing efficiency of the blockchains and meeting commercial requirements for the processable number of transactions of the blockchain.
The receiving module 301 receives transactions sent by terminal device 1, where each of the transactions includes transaction category, associated account number, and transaction status.
In one embodiment, the terminal device 1 encapsulates the transaction and sends the encapsulated transaction to the server 2. In one embodiment, each transaction includes a transaction number, a transaction status, a transaction category, an associated account number, a transaction content, an inspection code. In one embodiment, the transaction number is used to serialize and identify the transaction. The transaction number consists of letters and numbers, for example, the transaction number may be expressed as “Tx4939”. The transaction status is used to indicate the status of the transaction. In one embodiment, the transaction status includes a released status, a pending chain status, a confirmed status and a failed status. The transaction category is used to indicate a type of transaction. In one embodiment, the transaction category includes a currency transfer and a transaction record. In one embodiment, the associated account number is associated with the transaction, for example, the associated account number may be expressed as “User account A” and “User account B”. The inspection code is used to inspect the transaction. In one embodiment, the inspection code is a hash value. In one embodiment, when the terminal device 1 sends the transaction to the server 2, the status of the transaction is the released status.
The first determining module 302 extracts the transaction category, the associated account number, and the transaction status from the transactions and determines whether the transaction category is the currency transfer.
The filtering module 303 accesses the trading pool 4 and/or the blockchain 5 by the chain node 3 and determines whether target transactions related to the associated account are filtered out from the trading pool 4 and/or the blockchain 5.
The second determining module 304 calculates results of the target transactions according to chronological order and determines whether the transactions are correct according to the result of the target transaction, marks the transaction status of the correct transactions as the pending chain status, and sends the marked transactions to the terminal device 1 for confirmation.
For example, when the associated account numbers of the transactions are user account A and user account B, the second determining module 304 accesses the trading pool 4 and/or the blockchain 5 by the chain node 3, and filters out the target transactions related to the user account A and user account B, and calculates the results of the target transactions in sequence according to the chronological order, determines whether the transactions are correct according to the results of the target transaction, marks the transaction status of the correct transactions as pending chain status, and sends the marked transactions to the terminal device 1 for confirmation.
In one embodiment, the second determining module 304 calculates the content of the target transactions according to chronological order, determines that the transactions are correct when the content of the target transactions is consistent, and determines that the transactions are incorrect when the content of the transactions is inconsistent.
The second determining module 304 obtains balance of the associated account number of the transactions from the chain node 3 of the blockchain 5 and determines whether the transactions are correct according to the balance of the associated account, marks the transaction status of the correct transactions as the pending chain status, and sends the marked transactions to the terminal device 1 for confirmation.
In one embodiment, when the balance of a transferred account in the associated account of the transactions is not less than a transfer amount, the transactions are deemed correct; when the balance of the transferred account in the associated account of the transactions is less than the transfer amount, the transactions are deemed incorrect.
The chain module 305 receives successful transaction information or failed transaction information of the transactions sent by the terminal device 1, and marks the transaction status of the transactions as the confirmed status when receiving the successful transaction information, and packages the transactions into blocks, and transmits the blocks to the blockchain 5 by the chain node 3.
In one embodiment, the chain module 305 transmits the transactions with the pending chain status to the transaction pool 4 by the chain node 3, obtains the transactions with the pending chain status from the trading pool 4 by the chain node 3 when receiving the successful transaction information of the transactions sent by the terminal device 1, and packages the transactions into the blocks, and transmits the blocks the blockchain 5 by the chain node 3.
When the transaction category is the transaction record, the chain module 305 further accesses the trading pool 4 and/or the blockchain 5 by the chain node 3, and filters out all of the target transactions associated with the transactions from the trading pool 4 and/or the blockchain 5, calculates the results of the target transactions according to chronological order, and packages the target transaction corresponding to the correct transactions into blocks, and transmits the blocks to the blockchain 5 by the chain node 3.
The notification module 306 marks the transaction status of the transactions as failed status when receiving the transaction information as to failed sent by the terminal device 1, and sends the marked transactions to the terminal device 1 by the chain node 3.
In one embodiment, the notification module 306 further marks the status of transactions which are incorrect as failed, and transmits such transactions to the terminal device 1, and notifies the terminal device 1 to delete the incorrect transactions.
In one embodiment, when the transactions are correct and the server 2 receives the successful transaction information of the transactions sent by the terminal device, the server 2 packages the transactions into blocks, and transmits the blocks to the blockchain 5 by chain node 3, thereby improving processing efficiency of the blockchains and meeting the number of transactions of the blockchain in commerce.
In one embodiment, the computer program 63 can be partitioned into one or more modules/units that are stored in the storage 61 and executed by the processor 62. The one or more modules/units may be a series of computer program instruction segments capable of performing a particular function, and the instruction segments describe the execution of the computer program 63 in the electronic device 6. For example, the computer program 63 can be divided into the receiving module 301, the first determining module 302, the filtering module 303, the second determining module 304, the chain module 305, and the notification module 306 as shown in
The processor 62 can be a central processing unit (CPU), and also include other general-purpose processors, a digital signal processor (DSP), and application specific integrated circuit (ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, etc. The processor 62 may be a microprocessor or the processor may be any conventional processor or the like. The processor 62 is the control center of the electronic device 6, and connects the entire electronic device 6 by using various interfaces and lines.
The storage 61 stores data and programs of the electronic device 6. For example, the storage 61 can store the trading system 30 based on blockchain. In at least one exemplary embodiment, the storage 61 can include various types of non-transitory computer-readable storage mediums. For example, the storage 61 can be an internal storage system, such as a flash memory, a random access memory for temporary storage of information, and/or a read-only memory for permanent storage of information. The storage 61 can also be an external storage system, such as a hard disk, a storage card, or a data storage medium.
In one embodiment, the modules/units integrated in the electronic device 6 can be stored in a computer readable storage medium if such modules/units are implemented in the form of a purchased product. Thus, the present disclosure may be implemented and realized in any part of the method of the foregoing embodiments, or may be implemented by the computer program, which may be stored in the computer readable storage medium. The steps of the various method embodiments described above may be implemented by a computer program when executed by a processor. The computer program includes computer program code, which may be in the form of source code, object code form, executable file, or some intermediate form. The computer readable medium may include any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a removable hard disk, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media.
The exemplary embodiments shown and described above are only examples. Even though numerous characteristics and advantages of the present disclosure have been set forth in the foregoing description, together with details of the structure and function of the present disclosure, the disclosure is illustrative only, and changes may be made in the detail, including in matters of shape, size, and arrangement of the parts within the principles of the present disclosure, up to and including the full extent established by the broad general meaning of the terms used in the claims.
Number | Date | Country | Kind |
---|---|---|---|
202010504776.2 | Jun 2020 | CN | national |