CN114626948A - Block chain transaction accounting method and device, electronic equipment and storage medium - Google Patents

Block chain transaction accounting method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN114626948A
CN114626948A CN202210283514.7A CN202210283514A CN114626948A CN 114626948 A CN114626948 A CN 114626948A CN 202210283514 A CN202210283514 A CN 202210283514A CN 114626948 A CN114626948 A CN 114626948A
Authority
CN
China
Prior art keywords
transaction
bill
temporary
time difference
consensus
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.)
Pending
Application number
CN202210283514.7A
Other languages
Chinese (zh)
Inventor
李宁
薄辰龙
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
OneConnect Financial Technology Co Ltd Shanghai
Original Assignee
OneConnect Financial Technology Co Ltd Shanghai
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by OneConnect Financial Technology Co Ltd Shanghai filed Critical OneConnect Financial Technology Co Ltd Shanghai
Priority to CN202210283514.7A priority Critical patent/CN114626948A/en
Publication of CN114626948A publication Critical patent/CN114626948A/en
Pending legal-status Critical Current

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
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Accounting & Taxation (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Finance (AREA)
  • Computing Systems (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Strategic Management (AREA)
  • Technology Law (AREA)
  • General Business, Economics & Management (AREA)
  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)

Abstract

The invention relates to a block chain technology, and discloses a block chain transaction accounting method, which comprises the following steps: receiving transaction information, and acquiring a timestamp of the transaction information; generating a transaction queue according to the timestamp and the transaction information; acquiring current time, extracting target transaction information and a target timestamp from a transaction queue, and generating a time difference according to the target timestamp and the current time; when the time difference meets a preset condition, executing target transaction to obtain a temporary bill, and generating a temporary ID according to the temporary bill; broadcasting the temporary bill and the temporary ID when the transaction number of the temporary bill reaches a preset threshold value; performing consensus according to the confirmation result returned by the node according to the broadcast and the temporary ID; and confirming the consensus ID according to the consensus result, acquiring a consensus bill corresponding to the consensus ID, and synchronizing the consensus bill to the on-chain area. The invention also provides a block chain transaction accounting device, equipment and medium. The invention can improve the resource utilization rate and the chain bill safety in the block chain transaction accounting process.

Description

Block chain transaction accounting method and device, electronic equipment and storage medium
Technical Field
The invention relates to the technical field of block chains, in particular to a block chain transaction accounting method and device, electronic equipment and a computer readable storage medium.
Background
In the field of block chain technology billing, block chain technology is currently billed in blocks, a certain node is required to block the blocks, and a plurality of transaction information to be executed are placed in the blocks during the block punching. This solution enables sequential execution of transactions through ordered blocks. After the transaction is completed, the uplink of transaction information is completed based on the block connection. However, to achieve ordering of blocks, hash collision (computation) is often used, and unnecessary waste of computer resources is often generated in the process; in utilizing the common block uplink, the security of the bill corresponding to the transaction information cannot be well guaranteed.
Disclosure of Invention
The invention provides a block chain transaction accounting method and device and a computer readable storage medium, and mainly aims to solve the problems of low resource utilization rate and low safety of bills on a chain in the block chain transaction accounting process.
In order to achieve the above object, the invention provides a block chain transaction accounting method, which comprises:
receiving transaction information and acquiring a timestamp of the transaction information;
generating a transaction queue according to the timestamp and the transaction information;
acquiring current time, extracting target transaction information and a corresponding target timestamp from the transaction queue, generating a time difference according to the target timestamp and the current time, and judging whether the time difference meets a preset condition;
if the time difference does not meet the preset condition, stopping executing the transaction corresponding to the target transaction information;
if the time difference meets a preset condition, executing the transaction corresponding to the target transaction information to obtain a temporary bill, and generating a temporary ID according to the temporary bill;
broadcasting the temporary bill and the temporary ID when the transaction number of the temporary bill reaches a preset threshold value;
receiving a confirmation result returned by a preset node according to broadcasting, and performing consensus according to the confirmation result and the temporary ID;
and confirming a consensus ID according to a consensus result, acquiring a consensus bill corresponding to the consensus ID, and synchronizing the consensus bill to a preset on-chain area.
Optionally, the obtaining the time stamp of the transaction information includes:
acquiring a data tag of the timestamp;
retrieving in the transaction information according to the data tag;
and extracting information corresponding to the retrieved label to obtain a time stamp.
Optionally, the generating a transaction queue according to the timestamp and the transaction information includes:
sorting the transaction information according to the size of the timestamp;
and putting the sequenced transaction information into an information queue to obtain a transaction queue.
Optionally, the determining whether the time difference meets a preset condition includes:
judging whether the time difference is within a first interval of the preset condition or not;
if the time difference is within a first interval of the preset condition, judging that the time difference meets the preset condition;
if the time difference is not in the first interval of the preset condition, judging that the time difference is in the second interval of the preset condition or the third interval of the preset condition;
if the time difference is within a second interval of the preset condition, calculating waiting time according to the time difference and a right boundary value of the second interval;
when the waiting time is up, judging that the time difference meets a preset condition;
and if the time difference is within a third interval of the preset condition, judging that the time difference does not accord with the preset condition.
Optionally, the executing the transaction corresponding to the target transaction information includes:
identifying the execution attribute of the target transaction, and acquiring a corresponding execution code according to the execution attribute;
running the target transaction according to the execution code, and acquiring a record generated in the target transaction execution process;
and extracting target information from the record according to a preset bill label to obtain a temporary bill.
Optionally, the generating a temporary ID according to the temporary bill includes:
carrying out bill calculation according to the temporary bill to obtain a bill balance;
and carrying out Hash calculation on the bill balance to obtain a temporary ID.
Optionally, the broadcasting the temporary bill and the temporary ID includes:
generating a message to be broadcasted according to the temporary bill and the temporary ID;
acquiring nodes covered by broadcast to obtain a node list;
constructing a pre-complete N-ary tree according to the node list;
determining a root node according to the full N-ary tree, wherein the root node has a node topological relation;
and sending the message to be broadcasted to the root node, and forwarding the message to be broadcasted to a preset associated node according to the node topological relation.
In order to solve the above problem, the present invention further provides a blockchain transaction accounting device, including:
the transaction queue generating module is used for receiving transaction information and acquiring a timestamp of the transaction information; generating a transaction queue according to the timestamp and the transaction information;
the transaction execution module is used for acquiring current time, extracting target transaction information and a corresponding target timestamp from the transaction queue, generating a time difference according to the target timestamp and the current time, and judging whether the time difference meets a preset condition; if the time difference does not accord with the preset condition, stopping executing the transaction corresponding to the target transaction information; if the time difference meets a preset condition, executing the transaction corresponding to the target transaction information to obtain a temporary bill, and generating a temporary ID according to the temporary bill;
the transaction broadcasting module is used for broadcasting the temporary bill and the temporary ID when the transaction quantity of the temporary bill reaches a preset threshold value;
the transaction consensus module is used for receiving a confirmation result returned by a preset node according to broadcasting and performing consensus according to the confirmation result and the temporary ID;
and the bill synchronization module is used for confirming the consensus ID according to the consensus result, acquiring the consensus bill corresponding to the consensus ID, and synchronizing the consensus bill to a preset on-chain area.
In order to solve the above problem, the present invention also provides an electronic device, including:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores a computer program executable by the at least one processor, the computer program being executable by the at least one processor to enable the at least one processor to perform the blockchain transaction billing method described above.
In order to solve the above problem, the present invention further provides a computer-readable storage medium, in which at least one computer program is stored, and the at least one computer program is executed by a processor in an electronic device to implement the block chain transaction billing method described above.
According to the embodiment of the invention, the transaction information is directly processed, and the transaction queue is generated according to the transaction information, so that the transaction information is orderly executed, and the effective utilization of computer resources is improved; whether target transaction is executed is further judged by extracting target transaction information and calculating time difference; after the target transaction is executed, the temporary ID is generated according to the bill corresponding to the target transaction instead of directly linking the chain, so that the reliability of the bill on the chain is ensured; the temporary bill and the temporary ID are broadcasted, and the bill and the ID of the uplink are determined according to the information returned by other nodes, so that the accuracy of the bill data on the chain is ensured. Therefore, the block chain transaction billing method, the block chain transaction billing device, the electronic equipment and the computer readable storage medium can solve the problems of low resource utilization rate and low chain bill safety in the block chain transaction billing process.
Drawings
Fig. 1 is a schematic flowchart of a block chain transaction billing method according to an embodiment of the present invention;
FIG. 2 is a flow chart illustrating a transaction execution according to an embodiment of the present invention;
fig. 3 is a flowchart illustrating broadcasting of the temporary bill and the temporary ID according to an embodiment of the present invention;
FIG. 4 is a functional block diagram of a blockchain transaction billing device according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of an electronic device for implementing the blockchain transaction accounting method according to an embodiment of the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The embodiment of the application provides a block chain transaction accounting method. The execution subject of the blockchain transaction billing method includes, but is not limited to, at least one of the electronic devices of the server, the terminal, and the like, which can be configured to execute the method provided by the embodiments of the present application. In other words, the blockchain transaction billing method may be performed by software or hardware installed in the terminal device or the server device, and the software may be a blockchain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, and the like. The server may be an independent server, or may be a cloud server that provides basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a Network service, cloud communication, a middleware service, a domain name service, a security service, a Content Delivery Network (CDN), a big data and artificial intelligence platform, and the like.
Referring to fig. 1, a flow chart of a block chain transaction billing method according to an embodiment of the invention is shown. In this embodiment, the block chain transaction accounting method includes:
s1, receiving transaction information of the transaction, and acquiring a timestamp of the transaction information;
in the embodiment of the present invention, the transaction information may include purchase information generated when the user purchases an article, running information generated by transferring between users/accounts, and the like.
In an embodiment of the present invention, the obtaining the timestamp of the transaction information includes:
acquiring a data tag of the timestamp;
retrieving in the transaction information according to the data tag;
and extracting information corresponding to the retrieved label to obtain a time stamp.
In an alternative embodiment of the present invention, a computer sentence with data capture function (e.g. java sentence, python sentence, etc.) may be used to obtain the transaction information from a pre-constructed storage area for storing transaction information, and extract the timestamp, where the storage area includes, but is not limited to, a database, a block chain node, a network cache, etc.
S2, generating a transaction queue according to the time stamp and the transaction information;
in the embodiment of the present invention, the transaction queue may have a linked list structure.
In an embodiment of the present invention, the generating a transaction queue according to the timestamp and the transaction information includes:
sorting the transaction information according to the size of the timestamp;
and putting the sequenced transaction information into an information queue to obtain a transaction queue.
In the embodiment of the invention, the transactions which are sorted in the reverse order according to the time stamps are sequentially arranged from right to left in the transaction queue, namely the rightmost transaction is the transaction which is generated firstly, and the leftmost transaction is the transaction which is generated latest.
In the embodiment of the invention, after receiving the transaction information corresponding to the new transaction, a new timestamp is generated according to the transaction information, the timestamp is compared with other timestamps in the transaction queue, the position of the transaction information is further determined, and then the new transaction information is placed at the position in the transaction queue.
S3, acquiring current time, extracting target transaction information and a corresponding target timestamp from the transaction queue, generating a time difference according to the target timestamp and the current time, and judging whether the time difference meets a preset condition;
in the embodiment of the invention, the current time is the real-time of the system.
In the embodiment of the invention, when the transaction information of the transaction queue is taken, the transaction information which is generated firstly in the transaction queue needs to be taken out.
In the embodiment of the invention, the transaction information is the transaction queue generated according to the timestamp, and the transaction information with the smallest timestamp is arranged on the rightmost side of the transaction queue.
In the embodiment of the present invention, the time difference is a difference between the target timestamp and the current time, and may be obtained by performing a simple subtraction operation according to the target timestamp and the current time, or by calculating according to a preset operation rule.
In the embodiment of the present invention, the determining whether the time difference meets a preset condition includes:
judging whether the time difference is within a first interval of the preset condition or not;
if the time difference is within a first interval of the preset condition, judging that the time difference meets the preset condition;
if the time difference is not in the first interval of the preset condition, judging that the time difference is in the second interval of the preset condition or the third interval of the preset condition;
if the time difference is within a second interval of the preset condition, calculating waiting time according to the time difference and a right boundary value of the second interval;
when the waiting time is up, judging that the time difference meets a preset condition;
and if the time difference is within a third interval of the preset condition, judging that the time difference does not accord with the preset condition.
For example, if a first interval of the preset conditions is (5, 10), a second interval is [0,5], a third interval is (10, ∞) and has a unit of seconds, a first time difference is 6 seconds and belongs to the first interval, the time difference is determined to meet the preset conditions, a second time difference is 3 seconds and belongs to the second interval, a right boundary value of the second interval is 5, the waiting time is calculated to be 2 seconds, the time difference is determined to meet the preset conditions after 2 seconds, and the third time difference is 12 seconds and belongs to the third interval, the time difference is determined to not meet the preset conditions.
In the embodiment of the present invention, when the time difference is in the second interval, a new transaction may also be generated, and when the time difference of the transaction is in the first interval, the newly generated transaction may be executed first.
In an optional embodiment of the present invention, if the transaction information is in the transaction queue, and the right-most transaction information is waiting to be executed, the time difference of all transaction information on the left side of the transaction is increased due to the waiting time; and if the time difference corresponding to the rightmost transaction information in the transaction queue is in the first interval, directly executing the transaction corresponding to the transaction information, and continuing to judge the time difference corresponding to the adjacent transaction information on the left side of the transaction information.
If the time difference does not meet the preset condition, executing S4 and stopping executing the transaction corresponding to the target transaction information;
in the embodiment of the invention, when the time difference does not meet the preset condition, namely the transaction information corresponding to the time difference is expired, the transaction corresponding to the target transaction information is stopped to be executed, and the transaction information is discarded.
If the time difference meets the preset condition, executing S5, executing the transaction corresponding to the target transaction information to obtain a temporary bill, and generating a temporary ID according to the temporary bill;
in an embodiment of the present invention, please refer to fig. 2, where the executing the transaction corresponding to the target transaction information includes:
s51, identifying the execution attribute of the target transaction, and acquiring a corresponding execution code according to the execution attribute;
s52, operating the target transaction according to the execution code, and acquiring a record generated in the target transaction execution process;
and S53, extracting target information from the record according to the preset bill label to obtain a temporary bill.
In this embodiment of the present invention, the execution attribute may be an operation attribute of a transaction, for example: refund and payment; the bill tag is a tag corresponding to bill data required by the temporary bill, for example: payers, payees, bill amounts, etc.
In this embodiment of the present invention, the generating a temporary ID according to the temporary bill includes:
carrying out bill calculation according to the temporary bill to obtain a bill balance;
and carrying out Hash calculation on the bill balance to obtain a temporary ID.
In the embodiment of the present invention, the temporary bill may include one or more transaction information, and there is a direct connection between adjacent transaction information, for example: the balance of the previous transaction information participates in the calculation of the balance of the next transaction information.
In the embodiment of the present invention, the hash calculation may be performed to calculate the balance of the bill by using a hash algorithm.
Further, the hash algorithm comprises a sha256 algorithm and a ripemm 160 algorithm, and is a combination of the sha256 algorithm and the ripemm 160 algorithm, and a specific calculation formula is as follows:
A=RIPEMD160(HA256(K))
where A is the temporary ID and K is the billing balance.
S6, broadcasting the temporary bill and the temporary ID when the transaction number of the temporary bill reaches a preset threshold value;
in the embodiment of the present invention, the temporary bill may include a plurality of transaction information, and when the number of the transaction information reaches a threshold (for example, the number of the transaction information reaches 10000), the temporary bill is broadcasted to other nodes.
In the embodiment of the present invention, referring to fig. 3, the broadcasting the temporary bill and the temporary ID includes:
s61, generating a message to be broadcasted according to the temporary bill and the temporary ID;
s62, acquiring nodes covered by the broadcast to obtain a node list;
s63, constructing a complete N-ary tree according to the node list;
s64, determining a root node according to the complete N-ary tree, wherein the root node has a node topological relation;
s65, sending the message to be broadcast to the root node, and forwarding the message to be broadcast to a preset associated node according to the node topological relation.
For example, the preset associated nodes in the node topological relationship may include 7 nodes [ a0, a1, a2, A3, a4, and a5], and the nodes may have a connection relationship therebetween, where the connection relationship may be a TCP connection. For example, if the message to be broadcasted is sent from a0, the message to be broadcasted will be broadcasted to nodes [ a1, a2, A3], and after the a2 node receives the a0 message to be broadcasted, the message to be broadcasted will be broadcasted to [ a5, a4] in the same way, after the a5 receives the a2 message to be broadcasted, the message to be broadcasted will continue to be broadcasted to [ A3, a4] in the same time, and the broadcasting will continue until the broadcasting converges.
S7, receiving a confirmation result returned by the preset node according to the broadcast, and performing consensus according to the confirmation result and the temporary ID;
in this embodiment of the present invention, the node may be an account ID corresponding to a preset node according to a confirmation result returned by the broadcast, and the account ID may correspond to the temporary ID.
In this embodiment of the present invention, the performing consensus according to the confirmation result and the temporary ID includes:
counting the confirmation result and the temporary ID to obtain statistical data;
and selecting the data which is greater than a preset consensus threshold value in the statistical data as a consensus result.
For example, there are node X and node Y, the confirmation results returned by node X and node Y according to the broadcast are 3567 and 7872, respectively, the temporary ID is 3567, the frequency of 3567 is counted as 2, the frequency of 7872 is counted as 1, and it is assumed that the preset consensus threshold is the highest frequency, so it can be determined that 3567 is the consensus result.
And S8, confirming the consensus ID according to the consensus result, obtaining the consensus bill corresponding to the consensus ID, and synchronizing the consensus bill to a preset on-chain area.
In the embodiment of the present invention, the result of the consensus may be used as the consensus ID.
In the embodiment of the invention, if the consensus ID is the same as the temporary ID, the temporary bill can be determined as the consensus bill; if the consensus ID is different from the temporary ID, extracting a node corresponding to the consensus ID, and if the node returns a confirmation result and contains a bill, directly extracting the node; and if the node contains the bill when returning the confirmation result, sending a bill acquisition request to the node, and receiving information returned by the node according to the bill acquisition request to further acquire the consensus bill.
In the embodiment of the invention, after the consensus bill is obtained, the consensus bill can be synchronized to the block chain, so that the bill on the block chain has credibility.
According to the embodiment of the invention, the transaction information is directly processed, and the transaction queue is generated according to the transaction information, so that the transaction information is orderly executed, and the effective utilization of computer resources is improved; whether target transaction is executed is further judged by extracting target transaction information and calculating time difference; after the target transaction is executed, the temporary ID is generated according to the bill corresponding to the target transaction instead of directly linking the chain, so that the reliability of the bill on the chain is ensured; the temporary bill and the temporary ID are broadcasted, and the bill and the ID of the uplink are determined according to the information returned by other nodes, so that the accuracy of the bill data on the chain is ensured. Therefore, the block chain transaction billing method provided by the invention can solve the problems of low resource utilization rate and low safety of bills on the chain in the block chain transaction billing process.
Fig. 4 is a functional block diagram of a blockchain transaction billing device according to an embodiment of the present invention.
The blockchain transaction accounting device 100 of the present invention can be installed in an electronic device. According to the implemented functions, the blockchain transaction billing device 100 may include a transaction queue generating module 101, a transaction executing module 102, a transaction broadcasting module 103, a transaction recognizing module 104, and a bill synchronizing module 105. The module of the present invention, which may also be referred to as a unit, refers to a series of computer program segments that can be executed by a processor of an electronic device and that can perform a fixed function, and that are stored in a memory of the electronic device.
In the present embodiment, the functions regarding the respective modules/units are as follows:
the transaction queue generating module 101 is configured to receive transaction information and obtain a timestamp of the transaction information; generating a transaction queue according to the timestamp and the transaction information;
the transaction execution module 102 is configured to obtain a current time, extract target transaction information and a corresponding target timestamp from the transaction queue, generate a time difference according to the target timestamp and the current time, and determine whether the time difference meets a preset condition; if the time difference does not accord with the preset condition, stopping executing the transaction corresponding to the target transaction information; if the time difference meets a preset condition, executing the transaction corresponding to the target transaction information to obtain a temporary bill, and generating a temporary ID according to the temporary bill;
the transaction broadcasting module 103 is configured to broadcast the temporary bill and the temporary ID when the transaction amount of the temporary bill reaches a preset threshold;
the transaction consensus module 104 is configured to receive a confirmation result returned by a preset node according to a broadcast, and perform consensus according to the confirmation result and the temporary ID;
the bill synchronization module 105 is configured to determine a consensus ID according to a result of consensus, obtain a consensus bill corresponding to the consensus ID, and synchronize the consensus bill to a preset on-chain region.
In detail, in the embodiment of the present invention, when the modules in the blockchain transaction billing device 100 are used, the same technical means as the blockchain transaction billing method described in fig. 1 to fig. 3 are used, and the same technical effects can be produced, and details are not described here.
Fig. 5 is a schematic structural diagram of an electronic device implementing a block chain transaction accounting method according to an embodiment of the present invention.
The electronic device 1 may comprise a processor 10, a memory 11, a communication bus 12 and a communication interface 13, and may further comprise a computer program, such as a blockchain transaction accounting program, stored in the memory 11 and executable on the processor 10.
In some embodiments, the processor 10 may be composed of an integrated circuit, for example, a single packaged integrated circuit, or may be composed of a plurality of integrated circuits packaged with the same function or different functions, and includes one or more Central Processing Units (CPUs), a microprocessor, a digital Processing chip, a graphics processor, a combination of various control chips, and the like. The processor 10 is a Control Unit (Control Unit) of the electronic device, connects various components of the whole electronic device by using various interfaces and lines, and executes various functions and processes data of the electronic device by running or executing programs or modules (for example, executing a block chain transaction accounting program, etc.) stored in the memory 11 and calling data stored in the memory 11.
The memory 11 includes at least one type of readable storage medium including flash memory, removable hard disks, multimedia cards, card-type memory (e.g., SD or DX memory, etc.), magnetic memory, magnetic disks, optical disks, etc. The memory 11 may in some embodiments be an internal storage unit of the electronic device, for example a removable hard disk of the electronic device. The memory 11 may also be an external storage device of the electronic device in other embodiments, such as a plug-in mobile hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the electronic device. Further, the memory 11 may also include both an internal storage unit and an external storage device of the electronic device. The memory 11 may be used not only for storing application software installed in the electronic device and various types of data, such as codes of a block chain transaction accounting program, etc., but also for temporarily storing data that has been output or will be output.
The communication bus 12 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is arranged to enable connection communication between the memory 11 and at least one processor 10 or the like.
The communication interface 13 is used for communication between the electronic device and other devices, and includes a network interface and a user interface. Optionally, the network interface may include a wired interface and/or a wireless interface (e.g., WI-FI interface, bluetooth interface, etc.), which are commonly used to establish a communication connection between the electronic device and other electronic devices. The user interface may be a Display (Display), an input unit such as a Keyboard (Keyboard), and optionally a standard wired interface, a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, or the like. The display, which may also be referred to as a display screen or display unit, is suitable, among other things, for displaying information processed in the electronic device and for displaying a visualized user interface.
Fig. 5 only shows an electronic device with components, and it will be understood by a person skilled in the art that the structure shown in fig. 5 does not constitute a limitation of the electronic device 1, and may comprise fewer or more components than shown, or a combination of certain components, or a different arrangement of components.
For example, although not shown, the electronic device may further include a power supply (such as a battery) for supplying power to each component, and preferably, the power supply may be logically connected to the at least one processor 10 through a power management device, so that functions of charge management, discharge management, power consumption management and the like are realized through the power management device. The power supply may also include any component of one or more dc or ac power sources, recharging devices, power failure detection circuitry, power converters or inverters, power status indicators, and the like. The electronic device may further include various sensors, a bluetooth module, a Wi-Fi module, and the like, which are not described herein again.
It is to be understood that the described embodiments are for purposes of illustration only and that the scope of the appended claims is not limited to such structures.
The blockchain transaction accounting program stored in the memory 11 of the electronic device 1 is a combination of instructions, which when executed in the processor 10, can realize:
receiving transaction information and acquiring a timestamp of the transaction information;
generating a transaction queue according to the timestamp and the transaction information;
acquiring current time, extracting target transaction information and a corresponding target timestamp from the transaction queue, generating a time difference according to the target timestamp and the current time, and judging whether the time difference meets a preset condition;
if the time difference does not meet the preset condition, stopping executing the transaction corresponding to the target transaction information;
if the time difference meets a preset condition, executing the transaction corresponding to the target transaction information to obtain a temporary bill, and generating a temporary ID according to the temporary bill;
broadcasting the temporary bill and the temporary ID when the transaction number of the temporary bill reaches a preset threshold value;
receiving a confirmation result returned by a preset node according to broadcasting, and performing consensus according to the confirmation result and the temporary ID;
and confirming a consensus ID according to a consensus result, acquiring a consensus bill corresponding to the consensus ID, and synchronizing the consensus bill to a preset on-chain area.
Specifically, the specific implementation method of the instruction by the processor 10 may refer to the description of the relevant steps in the embodiment corresponding to the drawings, which is not described herein again.
Further, the integrated modules/units of the electronic device 1, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. The computer readable storage medium may be volatile or non-volatile. For example, the computer-readable medium may include: any entity or device capable of carrying said computer program code, recording medium, U-disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM).
The present invention also provides a computer-readable storage medium, storing a computer program which, when executed by a processor of an electronic device, may implement:
receiving transaction information and acquiring a timestamp of the transaction information;
generating a transaction queue according to the timestamp and the transaction information;
acquiring current time, extracting target transaction information and a corresponding target timestamp from the transaction queue, generating a time difference according to the target timestamp and the current time, and judging whether the time difference meets a preset condition;
if the time difference does not meet the preset condition, stopping executing the transaction corresponding to the target transaction information;
if the time difference meets a preset condition, executing the transaction corresponding to the target transaction information to obtain a temporary bill, and generating a temporary ID according to the temporary bill;
broadcasting the temporary bill and the temporary ID when the transaction number of the temporary bill reaches a preset threshold value;
receiving a confirmation result returned by a preset node according to broadcasting, and performing consensus according to the confirmation result and the temporary ID;
and confirming a consensus ID according to a consensus result, acquiring a consensus bill corresponding to the consensus ID, and synchronizing the consensus bill to a preset on-chain area.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus, device and method can be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional module.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof.
The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned.
The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
Furthermore, it will be obvious that the term "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the system claims may also be implemented by one unit or means in software or hardware. The terms first, second, etc. are used to denote names, but not any particular order.
Finally, it should be noted that the above embodiments are only intended to illustrate the technical solutions of the present invention and not to limit the same, and although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

Claims (10)

1. A method for billing blockchain transactions, the method comprising:
receiving transaction information and acquiring a timestamp of the transaction information;
generating a transaction queue according to the timestamp and the transaction information;
acquiring current time, extracting target transaction information and a corresponding target timestamp from the transaction queue, generating a time difference according to the target timestamp and the current time, and judging whether the time difference meets a preset condition;
if the time difference does not meet the preset condition, stopping executing the transaction corresponding to the target transaction information;
if the time difference meets a preset condition, executing the transaction corresponding to the target transaction information to obtain a temporary bill, and generating a temporary ID according to the temporary bill;
broadcasting the temporary bill and the temporary ID when the transaction number of the temporary bill reaches a preset threshold value;
receiving a confirmation result returned by a preset node according to broadcasting, and performing consensus according to the confirmation result and the temporary ID;
and confirming a consensus ID according to a consensus result, acquiring a consensus bill corresponding to the consensus ID, and synchronizing the consensus bill to a preset on-chain area.
2. The blockchain transaction billing method of claim 1 wherein said obtaining a timestamp of the transaction information comprises:
acquiring a data tag of the timestamp;
retrieving in the transaction information according to the data tag;
and extracting information corresponding to the retrieved label to obtain a time stamp.
3. The blockchain transaction billing method of claim 1 wherein said generating a transaction queue based on said timestamp and said transaction information comprises:
sorting the transaction information according to the size of the timestamp;
and putting the sequenced transaction information into an information queue to obtain a transaction queue.
4. The method for billing a blockchain transaction according to claim 1, wherein said determining whether the time difference meets a predetermined condition comprises:
judging whether the time difference is within a first interval of the preset condition or not;
if the time difference is within a first interval of the preset condition, judging that the time difference meets the preset condition;
if the time difference is not in the first interval of the preset condition, judging that the time difference is in the second interval of the preset condition or the third interval of the preset condition;
if the time difference is within a second interval of the preset condition, calculating waiting time according to the time difference and a right boundary value of the second interval;
when the waiting time is up, judging that the time difference meets a preset condition;
and if the time difference is within a third interval of the preset condition, judging that the time difference does not accord with the preset condition.
5. The method for billing a blockchain transaction of claim 1, wherein the executing the transaction corresponding to the target transaction information comprises:
identifying the execution attribute of the target transaction, and acquiring a corresponding execution code according to the execution attribute;
running the target transaction according to the execution code, and acquiring a record generated in the target transaction execution process;
and extracting target information from the record according to a preset bill label to obtain a temporary bill.
6. The method for billing a blockchain transaction of claim 1 wherein said generating a temporary ID based on said temporary bill comprises:
carrying out bill calculation according to the temporary bill to obtain a bill balance;
and carrying out Hash calculation on the bill balance to obtain a temporary ID.
7. The blockchain transaction billing method of any one of claims 1 to 6 wherein said broadcasting the interim bill and the interim ID comprises:
generating a message to be broadcasted according to the temporary bill and the temporary ID;
acquiring nodes covered by broadcast to obtain a node list;
constructing a complete N-ary tree according to the node list;
determining a root node according to the full N-ary tree, wherein the root node has a node topological relation;
and sending the message to be broadcasted to the root node, and forwarding the message to be broadcasted to a preset associated node according to the node topological relation.
8. A blockchain transaction accounting device, the device comprising:
the transaction queue generating module is used for receiving transaction information and acquiring a timestamp of the transaction information; generating a transaction queue according to the timestamp and the transaction information;
the transaction execution module is used for acquiring current time, extracting target transaction information and a corresponding target timestamp from the transaction queue, generating a time difference according to the target timestamp and the current time, and judging whether the time difference meets a preset condition or not; if the time difference does not meet the preset condition, stopping executing the transaction corresponding to the target transaction information; if the time difference meets a preset condition, executing the transaction corresponding to the target transaction information to obtain a temporary bill, and generating a temporary ID according to the temporary bill;
the transaction broadcasting module is used for broadcasting the temporary bill and the temporary ID when the transaction quantity of the temporary bill reaches a preset threshold value;
the transaction consensus module is used for receiving a confirmation result returned by a preset node according to broadcasting and performing consensus according to the confirmation result and the temporary ID;
and the bill synchronization module is used for confirming the consensus ID according to the consensus result, acquiring the consensus bill corresponding to the consensus ID, and synchronizing the consensus bill to a preset on-chain area.
9. An electronic device, characterized in that the electronic device comprises:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores a computer program executable by the at least one processor, the computer program being executable by the at least one processor to enable the at least one processor to perform a blockchain transaction billing method according to any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements a blockchain transaction billing method according to any one of claims 1 to 7.
CN202210283514.7A 2022-03-22 2022-03-22 Block chain transaction accounting method and device, electronic equipment and storage medium Pending CN114626948A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210283514.7A CN114626948A (en) 2022-03-22 2022-03-22 Block chain transaction accounting method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210283514.7A CN114626948A (en) 2022-03-22 2022-03-22 Block chain transaction accounting method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114626948A true CN114626948A (en) 2022-06-14

Family

ID=81904295

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210283514.7A Pending CN114626948A (en) 2022-03-22 2022-03-22 Block chain transaction accounting method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114626948A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117077994A (en) * 2023-10-18 2023-11-17 国网浙江省电力有限公司 Transaction management method and management platform

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117077994A (en) * 2023-10-18 2023-11-17 国网浙江省电力有限公司 Transaction management method and management platform
CN117077994B (en) * 2023-10-18 2024-01-09 国网浙江省电力有限公司 Transaction management method and management platform

Similar Documents

Publication Publication Date Title
CN112541745B (en) User behavior data analysis method and device, electronic equipment and readable storage medium
CN112052370A (en) Message generation method and device, electronic equipment and computer readable storage medium
CN113868528A (en) Information recommendation method and device, electronic equipment and readable storage medium
CN114386509A (en) Data fusion method and device, electronic equipment and storage medium
CN114398560B (en) Marketing interface setting method, device, equipment and medium based on WEB platform
CN112702228A (en) Service current limiting response method and device, electronic equipment and readable storage medium
CN114844844A (en) Delay message processing method, device, equipment and storage medium
CN114626948A (en) Block chain transaction accounting method and device, electronic equipment and storage medium
CN112733531B (en) Virtual resource allocation method and device, electronic equipment and computer storage medium
CN114205322A (en) Message sending method and device, electronic equipment and storage medium
CN111985194A (en) Data storage method and device, electronic equipment and storage medium
CN111901224A (en) Method, device and equipment for loading delayed messages and computer readable storage medium
CN115759746A (en) Configurable user early warning method and device, electronic equipment and storage medium
CN113347451B (en) Video uploading method and device, electronic equipment and computer readable storage medium
CN115221171A (en) Abnormal data intelligent monitoring method and device, electronic equipment and storage medium
CN113469649A (en) Project progress analysis method and device, electronic equipment and storage medium
CN114547011A (en) Data extraction method and device, electronic equipment and storage medium
CN114185588A (en) Incremental package generation method, device, equipment and storage medium
CN113657546A (en) Information classification method and device, electronic equipment and readable storage medium
CN114399293B (en) Information reminding method, device, equipment and storage medium
CN113419916B (en) Wind control inspection program uninterrupted operation method, device, equipment and storage medium
CN113449024B (en) Insurance data analysis method, device, equipment and medium based on big data
CN114240459A (en) Service speed-based provider selection method, device, equipment and storage medium
CN115409581A (en) Product recommendation method, device, equipment and medium based on user behavior configuration
CN114547010A (en) Data analysis method and device, electronic equipment and storage medium

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