CN111506557A - UTXO library establishing method, UTXO library establishing device, computer equipment and storage medium - Google Patents

UTXO library establishing method, UTXO library establishing device, computer equipment and storage medium Download PDF

Info

Publication number
CN111506557A
CN111506557A CN202010281339.9A CN202010281339A CN111506557A CN 111506557 A CN111506557 A CN 111506557A CN 202010281339 A CN202010281339 A CN 202010281339A CN 111506557 A CN111506557 A CN 111506557A
Authority
CN
China
Prior art keywords
transaction
database
utxo
records
library
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
CN202010281339.9A
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.)
Shanghai Qiyin Information Technology Co ltd
Original Assignee
Shanghai Qiyin Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Qiyin Information Technology Co ltd filed Critical Shanghai Qiyin Information Technology Co ltd
Priority to CN202010281339.9A priority Critical patent/CN111506557A/en
Publication of CN111506557A publication Critical patent/CN111506557A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • 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/21Design, administration or maintenance of databases
    • 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/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • 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/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • Business, Economics & Management (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • Development Economics (AREA)
  • General Business, Economics & Management (AREA)
  • Technology Law (AREA)
  • Software Systems (AREA)
  • Strategic Management (AREA)
  • Marketing (AREA)
  • Economics (AREA)
  • Computational Linguistics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a UTXO library establishing method, which comprises the following steps: traversing all nodes of the bitcoin chain to obtain all transaction output records, and storing the obtained all transaction output records into a first database; traversing all nodes of the bitcoin chain to obtain all transaction input records, and storing the obtained all transaction input records into the first database; the first database deletes the corresponding transaction output records according to the transaction input records to obtain all the transaction output records which are not spent; an address-indexed UTXO library is built in a second database based on all non-spent transaction output records. Also discloses a device, computer equipment and storage medium for realizing the UTXO library establishing method. The invention creates the UTXO library with the address as the index, and the user can efficiently inquire the UTXO record through the address, thereby greatly improving the inquiry efficiency.

Description

UTXO library establishing method, UTXO library establishing device, computer equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a UTXO library establishing method and apparatus, a computer device, and a storage medium.
Background
The transaction of the bitcoin is composed of transaction input and transaction output, and the transaction input is the output of the previous transaction, each transaction costs (span) one input to generate one output (output), and the generated output is the "unspent transaction output", i.e. UTXO. If a UTXO library with addresses as indexes is to be established, a user can conveniently and efficiently inquire UTXO records through the addresses, a transaction input corresponding output address needs to be inquired through a bitcoin chain, billions of levels of interface calling needs to be carried out, 5 months or even longer is needed in the whole process, and the inquiry effect of the user is greatly influenced. To this end, the applicant has sought, through useful research and research, a solution to the above-mentioned problems, in the context of which the technical solutions to be described below have been made.
Disclosure of Invention
One of the technical problems to be solved by the present invention is: aiming at the defects of the prior art, the UTXO library establishing method for improving the query of the UTXO record is provided.
The second technical problem to be solved by the present invention is: an apparatus for building the UTXO library is provided to implement the above method for building the UTXO library.
The third technical problem to be solved by the invention is that: there is provided a computer apparatus for implementing the UTXO library building method described above.
The fourth technical problem to be solved by the invention is that: there is provided a computer-readable storage medium for implementing the UTXO library building method described above.
A UTXO library creating method as a first aspect of the present invention includes the steps of:
traversing all nodes of the bitcoin chain to obtain all transaction output records, and storing the obtained all transaction output records into a first database;
traversing all nodes of the bitcoin chain to obtain all transaction input records, and storing the obtained all transaction input records into the first database;
the first database deletes the corresponding transaction output records according to the transaction input records to obtain all the transaction output records which are not spent;
an address-indexed UTXO library is built in a second database based on all non-spent transaction output records.
In a preferred embodiment of the present invention, the transaction output record includes a transaction output hash value, a transaction output index, and a transaction output address.
In a preferred embodiment of the invention, the transaction input record comprises a transaction input hash value, a transaction input index and a transaction input address.
In a preferred embodiment of the present invention, the first database is a redis database and the second database is a mysql database.
An UTXO library creating apparatus as a second aspect of the present invention for implementing the above UTXO library creating method includes:
the transaction output acquisition module is used for traversing all nodes of the bitcoin chain to acquire all transaction output records and storing the acquired all transaction output records into a first database;
the transaction input acquisition module is used for traversing all nodes of the bitcoin chain to acquire all transaction input records and storing the acquired all transaction input records into the first database;
the first database module is used for deleting the corresponding transaction output records according to the transaction input records to obtain all the transaction output records which are not spent; and
and the second database module is used for acquiring all the non-cost transaction output records obtained by the first database module and establishing a UTXO library with the address as an index in a second database according to all the non-cost transaction output records.
A computer apparatus as a third aspect of the present invention for implementing the UTXO library building method described above includes a memory storing a computer program and a processor implementing the following steps when the processor executes the computer program:
traversing all nodes of the bitcoin chain to obtain all transaction output records, and storing the obtained all transaction output records into a first database;
traversing all nodes of the bitcoin chain to obtain all transaction input records, and storing the obtained all transaction input records into the first database;
the first database deletes the corresponding transaction output records according to the transaction input records to obtain all the transaction output records which are not spent;
an address-indexed UTXO library is built in a second database based on all non-spent transaction output records.
The fourth technical problem to be solved by the invention is that: a computer-readable storage medium for implementing the UTXO library building method described above, having a computer program stored thereon, which when executed by a processor, performs the steps of:
traversing all nodes of the bitcoin chain to obtain all transaction output records, and storing the obtained all transaction output records into a first database;
traversing all nodes of the bitcoin chain to obtain all transaction input records, and storing the obtained all transaction input records into the first database;
the first database deletes the corresponding transaction output records according to the transaction input records to obtain all the transaction output records which are not spent;
an address-indexed UTXO library is built in a second database based on all non-spent transaction output records.
Due to the adoption of the technical scheme, the invention has the beneficial effects that: the invention creates the UTXO library with the address as the index, and the user can efficiently inquire the UTXO record through the address, thereby greatly improving the inquiry efficiency.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a diagram of an application scenario of an embodiment of the UTXO library establishment method of the present invention.
Fig. 2 is a flowchart of the UTXO library building method of the present invention.
Fig. 3 is a schematic structural diagram of an embodiment of the UTXO library creating apparatus of the present invention.
Fig. 4 is an internal structural view of the computer device of the present invention.
Detailed Description
In order to make the technical means, the creation characteristics, the achievement purposes and the effects of the invention easy to understand, the invention is further explained below by combining the specific drawings.
The UTXO library establishment method provided by the invention can be applied to the application environment shown in figure 1. Wherein a user terminal 101 communicates with a server 102 via a network. The user terminal 101 may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices, and the server 102 may be implemented by an independent server or a server cluster formed by a plurality of servers. The server 102 creates a UTXO library with an index related to an address, the user terminal 101 accesses the server 102 through a network, sends an inquiry request to the server 102, and the server 102 retrieves the UTXO library according to address information in the inquiry request and feeds back a corresponding UTXO record to the user terminal 101, thereby greatly improving inquiry efficiency.
Referring to fig. 2, there is provided a UTXO library building method of the present invention, comprising the steps of:
step S10, traverse all nodes of the bitcoin chain to obtain all transaction output records, and store all the obtained transaction output records in the first database. In this embodiment, the transaction output record includes a transaction output hash value, a transaction output index, and a transaction output address.
Step S20, traverse all nodes of the bitcoin chain to obtain all transaction input records, and store all the obtained transaction input records in the first database. In this embodiment, the transaction input record includes a transaction input hash value, a transaction input index, and a transaction input address.
In step S30, the first database deletes the corresponding transaction output records according to the transaction input records, resulting in all non-spent transaction output records. In this embodiment, the first database is preferably a redis database. The redis database is a Key-Value database and has higher reading and writing efficiency, so that all transaction output and transaction input are stored in the redis database, the interface calling times can be greatly reduced, hundreds of millions of grades are reduced to hundreds of thousands of grades, and the index establishing time is greatly reduced. Moreover, the redis database also only needs to provide 16G memory overhead. Based on this premise, the UTXO library of addresses can be established only by scanning the block chain once. For monitoring the blocks which start to continuously extend at present, as the bit coins generate one block every ten minutes or so, the latest block is monitored, the corresponding interface is inquired and input in the transaction through the interface, the UTXO of the address is established, and the whole process can be completed within minutes for completing one block. The input of the transaction in the BTC block chain is from the output transaction, each input transaction has the index of the previous output transaction and txid, and the corresponding output transaction can be quickly found in the redis database according to the txid and the index, so that the corresponding output transaction is deleted.
Step S40, creates a UTXO library indexed by address in the second database based on all the unspent transaction output records. In this embodiment, the second database is preferably a mysql database.
Referring to fig. 3, the UTXO library building apparatus of the present invention is shown to include a transaction output acquisition module 110, a transaction input acquisition module 120, a first database module 130, and a second database module 140.
The transaction output obtaining module 110 is configured to traverse all nodes of the bitcoin chain to obtain all transaction output records, and store all the obtained transaction output records in the first database.
The transaction input acquisition module 120 is configured to traverse all nodes of the bitcoin chain to acquire all transaction input records, and store all acquired transaction input records in the first database.
The first database module 130 is configured to delete the corresponding transaction output record according to the transaction input record, so as to obtain all the non-spent transaction output records. In the present embodiment, the database employed in the first database module 130 is preferably a redis database.
The second database module 140 is configured to obtain all the costless transaction output records obtained by the first database module 130, and establish an address-indexed UTXO library in the second database according to all the costless transaction output records. In the present embodiment, the database employed in the second database module 140 is preferably a mysql database.
The various modules in the UTXO library building apparatus of the present invention may be implemented in whole or in part by software, hardware, and combinations thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
The present invention also provides a computer device for implementing the UTXO library establishing method, where the computer device may be a server, and its internal structure diagram may be as shown in fig. 4. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer device is used for storing data such as user information, record information and files. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a UTXO library building method as described above.
Those skilled in the art will appreciate that the configuration shown in fig. 4 is a block diagram of only a portion of the configuration associated with the present solution and does not constitute a limitation on the computing device to which the present solution applies, and that a particular computing device may include more or less components than those shown, or combine certain components, or have a different arrangement of components.
Specifically, the computer device of the present invention includes a memory storing a computer program and a processor implementing the following steps when the processor executes the computer program:
traversing all nodes of the bitcoin chain to obtain all transaction output records, and storing the obtained all transaction output records into a first database;
traversing all nodes of the bitcoin chain to obtain all transaction input records, and storing the obtained all transaction input records into a first database;
the first database deletes the corresponding transaction output records according to the transaction input records to obtain all the transaction output records which are not spent;
an address-indexed UTXO library is built in a second database based on all non-spent transaction output records.
The present invention also provides a computer-readable storage medium for implementing the above UTXO library building method, having a computer program stored thereon, which when executed by a processor, implements the steps of:
traversing all nodes of the bitcoin chain to obtain all transaction output records, and storing the obtained all transaction output records into a first database;
traversing all nodes of the bitcoin chain to obtain all transaction input records, and storing the obtained all transaction input records into a first database;
the first database deletes the corresponding transaction output records according to the transaction input records to obtain all the transaction output records which are not spent;
an address-indexed UTXO library is built in a second database based on all non-spent transaction output records.
It will be understood by those of ordinary skill in the art that all or a portion of the processes of the methods of the embodiments described above may be implemented by a computer program that may be stored on a non-volatile computer-readable storage medium, which when executed, may include the processes of the embodiments of the methods described above, wherein any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory.
The foregoing shows and describes the general principles and broad features of the present invention and advantages thereof. It will be understood by those skilled in the art that the present invention is not limited to the embodiments described above, which are described in the specification and illustrated only to illustrate the principle of the present invention, but that various changes and modifications may be made therein without departing from the spirit and scope of the present invention, which fall within the scope of the invention as claimed. The scope of the invention is defined by the appended claims and equivalents thereof.

Claims (7)

1. A UTXO library establishment method is characterized by comprising the following steps:
traversing all nodes of the bitcoin chain to obtain all transaction output records, and storing the obtained all transaction output records into a first database;
traversing all nodes of the bitcoin chain to obtain all transaction input records, and storing the obtained all transaction input records into the first database;
the first database deletes the corresponding transaction output records according to the transaction input records to obtain all the transaction output records which are not spent;
an address-indexed UTXO library is built in a second database based on all non-spent transaction output records.
2. The UTXO library setup method of claim 1, wherein the transaction output record comprises a transaction output hash value, a transaction output index, and a transaction output address.
3. The UTXO library setup method of claim 1, wherein the transaction input record comprises a transaction input hash value, a transaction input index, and a transaction input address.
4. The UTXO library setup method of claim 1, wherein the first database is a redis database and the second database is a mysql database.
5. An UTXO library creation apparatus, comprising:
the transaction output acquisition module is used for traversing all nodes of the bitcoin chain to acquire all transaction output records and storing the acquired all transaction output records into a first database;
the transaction input acquisition module is used for traversing all nodes of the bitcoin chain to acquire all transaction input records and storing the acquired all transaction input records into the first database;
the first database module is used for deleting the corresponding transaction output records according to the transaction input records to obtain all the transaction output records which are not spent; and
and the second database module is used for acquiring all the non-cost transaction output records obtained by the first database module and establishing a UTXO library with the address as an index in a second database according to all the non-cost transaction output records.
6. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor, when executing the computer program, implements the steps of the UTXO library building method of any one of claims 1 to 4.
7. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the UTXO library building method according to any one of claims 1 to 4.
CN202010281339.9A 2020-04-10 2020-04-10 UTXO library establishing method, UTXO library establishing device, computer equipment and storage medium Pending CN111506557A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010281339.9A CN111506557A (en) 2020-04-10 2020-04-10 UTXO library establishing method, UTXO library establishing device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010281339.9A CN111506557A (en) 2020-04-10 2020-04-10 UTXO library establishing method, UTXO library establishing device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN111506557A true CN111506557A (en) 2020-08-07

Family

ID=71870919

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010281339.9A Pending CN111506557A (en) 2020-04-10 2020-04-10 UTXO library establishing method, UTXO library establishing device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111506557A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112365248A (en) * 2020-11-16 2021-02-12 厦门市美亚柏科信息安全研究所有限公司 Method and system for analyzing digital currency transaction path

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106503053A (en) * 2016-09-26 2017-03-15 江苏通付盾科技有限公司 UTXO querying methods and device
CN109299336A (en) * 2018-09-30 2019-02-01 腾讯科技(深圳)有限公司 Data back up method, device, storage medium and calculating equipment
US20190207757A1 (en) * 2017-12-29 2019-07-04 Commissariat A L'energie Atomique Et Aux Energies Ternatives Method for exchanging keys authenticated by blockchain
CN110032664A (en) * 2019-03-07 2019-07-19 上海七印信息科技有限公司 A method of quickly establishing the full node address index of bit coin block chain

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106503053A (en) * 2016-09-26 2017-03-15 江苏通付盾科技有限公司 UTXO querying methods and device
US20190207757A1 (en) * 2017-12-29 2019-07-04 Commissariat A L'energie Atomique Et Aux Energies Ternatives Method for exchanging keys authenticated by blockchain
CN109299336A (en) * 2018-09-30 2019-02-01 腾讯科技(深圳)有限公司 Data back up method, device, storage medium and calculating equipment
CN110032664A (en) * 2019-03-07 2019-07-19 上海七印信息科技有限公司 A method of quickly establishing the full node address index of bit coin block chain

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
邵奇峰等: "区块链技术:架构及进展" *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112365248A (en) * 2020-11-16 2021-02-12 厦门市美亚柏科信息安全研究所有限公司 Method and system for analyzing digital currency transaction path
CN112365248B (en) * 2020-11-16 2023-01-24 厦门市美亚柏科信息安全研究所有限公司 Method and system for analyzing digital currency transaction path

Similar Documents

Publication Publication Date Title
WO2019165671A1 (en) Method for rapidly importing big data, apparatus, terminal device, and storage medium
CN112015820A (en) Method, system, electronic device and storage medium for implementing distributed graph database
WO2016169237A1 (en) Data processing method and device
CN108512930B (en) Shared file management method, device, server and storage medium
CN109344296B (en) Domain lifecycle control method, system, server and storage medium for implementing HASH key of Redis
US11868371B2 (en) System and method for data pruning via dynamic partition management
CN113886496A (en) Data synchronization method and device of block chain, computer equipment and storage medium
CN111506557A (en) UTXO library establishing method, UTXO library establishing device, computer equipment and storage medium
CN110781137A (en) Directory reading method and device for distributed system, server and storage medium
US9405786B2 (en) System and method for database flow management
CN110543465B (en) Directory operation method and device, computer equipment and storage medium
CN111752941B (en) Data storage and access method and device, server and storage medium
CN113515518A (en) Data storage method and device, computer equipment and storage medium
CN111242621A (en) Transaction data storage method, device, equipment and storage medium
CN111427920A (en) Data acquisition method, device, system, computer equipment and storage medium
CN114416689A (en) Data migration method and device, computer equipment and storage medium
CN109254997B (en) Data synchronization method, system, computer device and readable storage medium
CN116932779B (en) Knowledge graph data processing method and device
CN116302206B (en) Presto data source hot loading method based on MQ
CN115733833B (en) File downloading method and device, computer equipment and storage medium
CN117112206B (en) Transaction resource isolation method, device, computer equipment and storage medium
CN114461659A (en) Searching and killing method and device, computer equipment and storage medium
CN114510490B (en) Method and device for improving data insertion performance of database
CN115994244B (en) Directed graph data processing method and device based on big data and computer equipment
CN117938514A (en) Token processing method, device, server, storage medium and program product

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
WD01 Invention patent application deemed withdrawn after publication
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20200807