WO2024041505A1 - 数据获取方法、装置和设备 - Google Patents

数据获取方法、装置和设备 Download PDF

Info

Publication number
WO2024041505A1
WO2024041505A1 PCT/CN2023/114179 CN2023114179W WO2024041505A1 WO 2024041505 A1 WO2024041505 A1 WO 2024041505A1 CN 2023114179 W CN2023114179 W CN 2023114179W WO 2024041505 A1 WO2024041505 A1 WO 2024041505A1
Authority
WO
WIPO (PCT)
Prior art keywords
transaction
block
data
target
event
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.)
Ceased
Application number
PCT/CN2023/114179
Other languages
English (en)
French (fr)
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.)
Institute of Printing Science and Technology Peoples Bank of China
Original Assignee
Institute of Printing Science and Technology Peoples Bank of China
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 Institute of Printing Science and Technology Peoples Bank of China filed Critical Institute of Printing Science and Technology Peoples Bank of China
Priority to EP23856595.6A priority Critical patent/EP4550167A4/en
Priority to US19/100,357 priority patent/US20260044509A1/en
Publication of WO2024041505A1 publication Critical patent/WO2024041505A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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 OR CALCULATING; 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 OR CALCULATING; 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 OR CALCULATING; 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
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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/25Integrating or interfacing systems involving database management systems
    • G06F16/252Integrating or interfacing systems involving database management systems between a Database Management System and a front-end application
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/04Payment circuits
    • G06Q20/06Private payment circuits, e.g. involving electronic currency used among participants of a common payment scheme
    • G06Q20/065Private payment circuits, e.g. involving electronic currency used among participants of a common payment scheme using e-cash
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/22Payment schemes or models
    • G06Q20/223Payment schemes or models based on the use of peer-to-peer networks
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/30Payment architectures, schemes or protocols characterised by the use of specific devices or networks
    • G06Q20/36Payment architectures, schemes or protocols characterised by the use of specific devices or networks using electronic wallets or electronic money safes
    • G06Q20/367Payment architectures, schemes or protocols characterised by the use of specific devices or networks using electronic wallets or electronic money safes involving electronic purses or money safes
    • G06Q20/3678Payment architectures, schemes or protocols characterised by the use of specific devices or networks using electronic wallets or electronic money safes involving electronic purses or money safes e-cash details, e.g. blinded, divisible or detecting double spending
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3827Use of message hashing
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3829Payment protocols; Details thereof insuring higher security of transaction involving key management
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/389Keeping log of transactions for guaranteeing non-repudiation of a transaction
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/40Authorisation, e.g. identification of payer or payee, verification of customer or shop credentials; Review and approval of payers, e.g. check credit lines or negative lists
    • G06Q20/401Transaction verification

Definitions

  • the present disclosure relates to the field of Internet technology, and in particular, to a data acquisition method, device and equipment.
  • Blockchain is a way for everyone to participate in accounting and has the characteristics of decentralization and trustlessness. Clients can conduct transactions through any blockchain node, and transaction data is stored in blocks in the blockchain in the form of electronic records.
  • the transaction mode in the blockchain is the unspent transaction output (UTXO) mode, that is, the output data in the transaction data of one transaction event is stored in the block and used as the transaction data in the subsequent transaction event. Input data.
  • UXO unspent transaction output
  • inventions of the present disclosure provide a data acquisition method, including: creating a target database.
  • the target database is a database that stores transaction data corresponding to transaction identifiers of multiple transaction events in the blockchain.
  • the transaction data includes input data and output data; receiving a first request message requesting acquisition of target transaction data of a target transaction event, the first request message including: a target transaction identifier of the target transaction event; responding to the first A request message, using the target transaction identifier as an index, obtains the target transaction data from the target database; and sends the target transaction data.
  • the target database includes: a first corresponding relationship of one-to-one correspondence between the transaction identifiers of the multiple transaction events and the transaction data of the multiple transaction events; the data acquisition method also includes: acquiring The transaction identifier of the first transaction event stored in the first block, the output data of the first transaction event, and the transaction identifier of the previous transaction event corresponding to the first transaction event, the first transaction event is For any one of the multiple transaction events, the first block is a block in the blockchain that stores the output data of the first transaction event; according to the corresponding previous transaction of the first transaction event The transaction identifier of the event determines the second block that stores the input data of the first transaction event; determines the output data of the second transaction event stored in the second block as the input of the first transaction event data, the second transaction event is the previous transaction event of the first transaction event; the input data of the first transaction event and the output data of the first transaction event are determined as the first transaction event.
  • the transaction identifier of the transaction event includes: calling the target interface to obtain the block data of the first block.
  • the block data of the first block includes: the transaction identifier of the first transaction event, the first The output data of the transaction event, and the transaction identifier of the previous transaction event corresponding to the first transaction event, and the target interface includes a remote procedure call RPC interface.
  • the target database further includes: a second correspondence relationship between block identifiers of multiple blocks and block data of the multiple blocks, where the multiple blocks include the The first block, the block data of the first block also includes: the block identifier of the first block; the data acquisition method further includes: creating the block identifier of the first block and The second correspondence relationship between the block data of the first block.
  • calling the target interface to obtain the block data of the first block includes: calling the target interface to obtain the block identifier of the first block; and reading the third block. 2.
  • calling the target interface to obtain the block identifier of the first block includes: calling the target interface, traversing multiple blocks in the blockchain, and obtaining the multiple blocks. The block ID for each block in the block.
  • the data acquisition method further includes: receiving a second request message requesting acquisition of target block data of the target block, and the second request message includes: the target area a target block identifier of the block; in response to the second request message, obtain the target block data from the target database using the target block identifier as an index; and send the target block data.
  • the target database includes a transaction database configured to store a first correspondence and a block database configured to store a second correspondence.
  • the transaction database and the block database are key-value databases.
  • the target database stores the correspondence in a target format, including a comma separated values (CSV) format.
  • CSV comma separated values
  • the transaction identifier includes: at least one of a transaction hash value, a transaction number, or a transaction index value.
  • the transaction mode in the blockchain is an unspent transaction output UTXO mode.
  • some embodiments of the present disclosure provide a data acquisition device, including: a communication unit and a processing unit; the processing unit is configured to create a target database, the target database is to store multiple transaction events in the blockchain a database of transaction data corresponding to the transaction identifier, the transaction data including input data and output data; the communication unit is configured to receive a first request message requesting acquisition of target transaction data of a target transaction event , the first request message includes: the target transaction identifier of the target transaction event; the processing unit is further configured to respond to the first request message, using the target transaction identifier as an index, from the target The target transaction data is obtained from the database; the communication unit is also configured to send the target transaction data.
  • some embodiments of the present disclosure provide an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor. When executed by the processor, the computer program implements the first aspect data acquisition method.
  • some embodiments of the present disclosure provide a computer-readable storage medium.
  • a computer program is stored on the computer-readable storage medium. When executed by a processor, the computer program implements the data acquisition method of the first aspect.
  • Figure 1 is a composition diagram of a data acquisition system according to one or more embodiments
  • Figure 2 is a structural diagram of a blockchain node according to one or more embodiments
  • Figure 3 is a flow chart of a data acquisition method according to one or more embodiments.
  • Figure 4 is a flow chart of another data acquisition method according to one or more embodiments.
  • Figure 5 is an index diagram of transaction data according to one or more embodiments.
  • Figure 6 is a flow chart of yet another data acquisition method according to one or more embodiments.
  • Figure 7 is a flow chart of yet another data acquisition method according to one or more embodiments.
  • Figure 8 is a composition diagram of a target database according to one or more embodiments.
  • Figure 9 is a flow chart of yet another data acquisition method according to one or more embodiments.
  • Figure 10 is a flow chart of yet another data acquisition method according to one or more embodiments.
  • Figure 11 is a composition diagram of another target database according to one or more embodiments.
  • Figure 12 is a structural diagram of a data acquisition device according to one or more embodiments.
  • Figure 13 is a structural diagram of another data acquisition device according to one or more embodiments.
  • Blockchain technology also known as distributed ledger technology, is an emerging technology in which several computing devices jointly participate in "bookkeeping" (that is, record transaction data) and jointly maintain a complete distributed database. . Since blockchain technology has the characteristics of decentralization (that is, there is no central node), openness and transparency, each computing device can participate in database records, and data can be synchronized quickly between computing devices, blockchain technology has been widely used in Widely used in many fields.
  • a blockchain system may include multiple blockchain nodes.
  • Blockchain nodes are devices with communication functions and storage functions, such as devices that store blockchain.
  • nodes are used to represent blockchain nodes. That is to say, the nodes involved in the embodiments of this disclosure can all be used to represent blockchain nodes.
  • Each node can both receive and generate information. Different nodes maintain communication by maintaining a common blockchain. In some embodiments, in the blockchain system, any node can generate a new block based on transaction-related data sent by the client, and notify other nodes in the form of broadcast, and other nodes can perform operations on this block. verify. When all nodes in the blockchain system reach consensus, new blocks can be added to the blockchain.
  • a node may be a physical device, such as a server or terminal device.
  • the node can be a virtual computer; a virtual computer Virtual computer is a general term for the running environment virtualized by software in all types of virtualization devices. This concept includes virtual machines and containers.
  • the node can be a process or a thread; a thread is the smallest unit that the operating system can perform calculation scheduling. A thread is included in a process and is the actual operating unit in the process; a process is a computer
  • the program in is a running activity on a certain data collection and is the basic unit for resource allocation and scheduling in the system.
  • Blocks are generated one by one in chronological order. Each block records all transactions that occurred during its creation. All blocks are aggregated to form a chained record collection. Since the throughput rates of nodes are different in different blockchain systems, the block size may also be different in different blockchain systems.
  • each blockchain may not be exactly the same, but a block usually includes a block header and a block body.
  • the block header is mainly used to record the characteristic value of the current block, which can include the identification of the current block (such as the block number), the hash value of the block body in the current block, and the timestamp (used to represent the block's Generation time), transaction number (transaction count) and random number (nonce) and other information.
  • the block header can also include the hash value of the previous block (specifically, the block header in the previous block hash value).
  • the block header includes multiple feature values.
  • the block body can include multiple transaction data.
  • the block body also includes information such as the client's certificate (used to describe the initiator of the transaction), the certificate of the endorsing node, and the signature of the endorsing node for the transaction.
  • the block body may also include the signature of the ordering node (or consensus node) for the transaction.
  • the signatures here are used to represent the authentication of the transaction by the device corresponding to the signature, and the certificates are used to represent the identity.
  • the above data such as signatures and certificates are used to verify transaction data, and these data usually occupy 70% of the storage space in the block body.
  • Table 1 shows one structural form of a block.
  • the structure of the block is not limited to what is shown in Table 1, and the values of each structure are not limited to what is shown in Table 1.
  • the transactions involved in the embodiments of this disclosure refer to the process in which users create and publish data through any node to the distributed database of the blockchain.
  • This transaction can be divided into narrow transaction and broad transaction.
  • a transaction in a narrow sense refers to a value transfer issued by a user to the blockchain; for example, in the traditional Bitcoin blockchain network, a transaction can be a transfer initiated by the user in the blockchain.
  • a broad transaction refers to a user releasing an arbitrary piece of data to the blockchain: for example, the operator can build a consortium chain based on actual business needs, and rely on the consortium chain to deploy some online businesses (for example, rental business, vehicle dispatching business, Insurance claims business, credit services, medical services, etc.), and in this type of alliance chain, the transaction can be a business message or business request with business intention published by the user in the alliance chain; for another example, the transaction can also be Users send data (such as account balances, etc.) to the blockchain to change the user's account status.
  • some online businesses for example, rental business, vehicle dispatching business, Insurance claims business, credit services, medical services, etc.
  • the transaction can be a business message or business request with business intention published by the user in the alliance chain
  • the transaction can also be Users send data (such as account balances, etc.) to the blockchain to change the user's account status.
  • the client can be deployed on any electronic device and implemented through the corresponding software development kit (SDK) of the blockchain system.
  • SDK software development kit
  • the electronic device communicates with nodes in the blockchain network to achieve the corresponding functions of the client.
  • the data involved in the embodiments of this disclosure may be data authorized by the user or fully authorized by all parties.
  • the blockchain node needs to call multiple interfaces to obtain the transaction data in multiple blocks respectively, and the entire process requires multiple interfaces.
  • the call takes a long time, resulting in low data acquisition efficiency in the blockchain.
  • embodiments of the present disclosure provide a data acquisition method.
  • the blockchain node After receiving the first request message, the blockchain node can respond to the first request message and obtain the target from the pre-created target database using the target transaction identifier as an index. Transaction data. Subsequently, the blockchain node can send the target transaction data. In this way, since the transaction data stored in the database includes input data and output data, the blockchain node only needs to access the target database, which can improve the efficiency of data acquisition.
  • Figure 1 is a composition diagram of a data acquisition system according to one or more embodiments.
  • the data acquisition system may include: a client 110 and multiple blockchain nodes in the blockchain 120 (Including blockchain node 121).
  • Client 110 can access blockchain 120 through blockchain node 121.
  • the blockchain node 121 may be any one of multiple blockchain nodes.
  • the blockchain 120 includes multiple blocks, and the block data stored in each block includes transaction data of transaction events occurring within a time period.
  • the transaction mode in the blockchain 120 may be a UTXO mode, that is, only unspent outputs are recorded.
  • the block data includes: the transaction identifier of the transaction event, the input data in the transaction data of the transaction event, Output data and the corresponding transaction identifier of the previous transaction event.
  • Table 2 shows a storage format of block data.
  • the storage format of block data is not limited to what is shown in Table 2, and the values of each structure are not limited to what is shown in Table 2.
  • the client 110 can implement functions such as creating chain codes and initiating transactions.
  • the client 110 can be deployed on any electronic device and implemented through the corresponding software development tool kit of the blockchain system.
  • the electronic device communicates with the blockchain node 121 to realize the corresponding functions of the client 110 .
  • the embodiments of this disclosure do not limit the implementation of the client 110.
  • multiple blockchain nodes in the blockchain 120 are devices with communication functions and storage functions, and may be a single server, or may also be a server cluster composed of multiple servers. In some implementations, the server cluster may also be a distributed cluster. The embodiments of this disclosure also do not limit the implementation of multiple blockchain nodes in the blockchain 120.
  • client 110 and multiple blockchain nodes in the blockchain 120 can all be called electronic devices.
  • FIG 2 is a structural diagram of a blockchain node according to one or more embodiments.
  • the blockchain node 121 may include: a block database 210 and a transaction database 220.
  • the block database 210 is used to store the transaction data of each block in a plurality of blocks in the blockchain 120 .
  • the block database 210 may be a key-value (KV) database. At this time, the corresponding relationship between the block identifier and the block data is stored in the block database 210.
  • KV key-value
  • the transaction database 220 is used to store transaction data of multiple transactions in the blockchain 120 .
  • the transaction database 220 may be a KV database. At this time, the corresponding relationship between the transaction identifier and the transaction data is stored in the transaction database 220.
  • the key is the transaction identifier of a transaction event
  • the value is the transaction data of the transaction event.
  • the transaction identifier may include: a transaction hash value of the transaction event, a transaction number of the transaction event, a transaction index value of the transaction event, and other unique identifiers of the transaction event.
  • the transaction data may include: input data of the target transaction event, such as input address and input amount, and may also include output data of the target transaction event, such as output address and output amount.
  • Table 3 shows a storage format for a transaction database.
  • the data acquisition method provided by the embodiment of the present disclosure can be applied to the blockchain node 121 in the application scenario shown in Figure 1.
  • the data acquisition method may include: steps 301 to 304.
  • Step 301 The blockchain node creates a target database.
  • the target database is used to store transaction data corresponding to transaction identifiers of multiple transaction events in the blockchain.
  • the target database stores data in the target format.
  • the target format may be CSV format.
  • the target database may include: a first correspondence between transaction identifiers of multiple transaction events and transaction data of multiple transaction events, and block identifiers of multiple blocks and block identifiers of multiple blocks.
  • the second correspondence relationship is one-to-one correspondence between block data.
  • Block data for multiple blocks may include transaction data for multiple transaction events.
  • the target database may include: at least one of the block database 210 or the transaction database 220.
  • the transaction data may include: input data of the transaction event, such as input address and input amount, and may also include output data of the transaction event, such as output address and output. amount.
  • the transaction identifier may include: the transaction hash value of the transaction event (transaction hash, Tx hash), the transaction number of the transaction event, the transaction index value of the transaction event (transaction index, Tx index) and other unique transaction events. logo.
  • Step 302 The blockchain node receives the first request message.
  • the first request message is used to request acquisition of target transaction data of the target transaction event.
  • the first request message includes: the target transaction identifier of the target transaction event.
  • the method for the blockchain node to receive the first request message may include: the client sends the first request message to the blockchain node.
  • a transaction event on the blockchain When a transaction event on the blockchain is completed, a block is generated on the blockchain to store the transaction data of this transaction event.
  • the client can receive the receipt message sent by the blockchain node.
  • the receipt message includes the transaction identifier of this transaction event.
  • data synchronization can be achieved based on the blockchain, and the client can send the first request message to any blockchain node.
  • Step 303 The blockchain node responds to the first request message and obtains the target transaction data from the target database using the target transaction identifier as an index.
  • the blockchain node Since the target database stores transaction data corresponding to the transaction identifiers of multiple transaction events, after receiving the request message, the blockchain node uses the target transaction identifier as an index to obtain the target transaction data from the target database.
  • Step 304 The blockchain node sends the target transaction data.
  • the technical solution provided by the above embodiments at least brings the following beneficial effects: It can be seen from steps 301 to 304 that after the blockchain node receives the first request message, it can respond to the first request message and use the target transaction identifier as an index to Obtain target transaction data from the pre-created target database. Subsequently, the blockchain node can send the target Standard transaction data. In this way, since the transaction data stored in the database includes input data and output data, the blockchain node only needs to access the target database, which can provide data acquisition efficiency.
  • the data acquisition method also includes: step 401 to step 405.
  • Step 401 The blockchain node obtains the transaction identifier of the first transaction event stored in the first block, the output data of the first transaction event, and the transaction identifier of the previous transaction event corresponding to the first transaction event.
  • the first transaction event is any event among multiple transaction events.
  • the first block is a block in the blockchain used to store the output data of the first transaction event.
  • the first transaction event may also be the latest transaction event in the blockchain.
  • the block can store the transaction identifier of the current transaction event, the output data of the current transaction event, and the transaction identifier of the previous transaction event.
  • the blockchain node can traverse the data stored in multiple blocks on the blockchain to obtain the transaction identifier of the first transaction event, the output data of the first transaction event, and the corresponding previous transaction of the first transaction event.
  • the transaction ID of the transaction event is the transaction ID of the transaction event.
  • the transaction identifier of the previous transaction event may include: a spend hash value (spent hash) and a spend index value (spent index).
  • Step 402 The blockchain node determines the second block that stores the input data of the first transaction event based on the transaction identifier of the previous transaction event corresponding to the first transaction event.
  • the blockchain node After the blockchain node obtains the transaction identifier of the previous transaction event corresponding to the first transaction event, it can traverse the data stored in multiple blocks. When there is a transaction identifier of the current transaction event stored in the block and the transaction identifier of the first transaction event. When the transaction identifiers of the corresponding previous transaction events are the same, it means that the current transaction event stored in the block is the corresponding previous transaction event of the first transaction event. At this time, the block can be determined as the input to store the first transaction event. The second block of data.
  • Step 403 The blockchain node determines the output data of the second transaction event stored in the second block as the input data of the first transaction event.
  • the second transaction event is a transaction event preceding the first transaction event.
  • the blockchain node can add the data in the second block to the previous transaction event.
  • the stored output data of the second transaction event is determined as the input data of the first transaction event.
  • Step 404 The blockchain node determines the input data of the first transaction event and the output data of the first transaction event as the transaction data of the first transaction event.
  • Step 405 The blockchain node determines the corresponding relationship between the transaction identifier of the first transaction event and the transaction data of the first transaction event as the first corresponding relationship of the first transaction event.
  • the blockchain node can obtain the transaction hash value of transaction event B as "y” from the data stored in the block.
  • Transaction event B includes: the transaction sequence number is “0”", the input with the transaction sequence number "1” and the input with the transaction sequence number "2", and the output with the transaction sequence number "0", the transaction sequence number "1” and the transaction sequence number "2” Output.
  • Inputs with transaction sequence number "1” include: corresponding to transaction event B The transaction identifier of the previous transaction event A (the spend hash value is "x" and the spend index value is "0").
  • the blockchain node traverses the data stored in multiple blocks and obtains the transaction event A with the transaction hash value "x", including: input with the transaction sequence number "0", input with the transaction sequence number "1” and transaction Input with sequence number "2", and output with transaction sequence number "0", transaction sequence number "1” and output with transaction sequence number "2".
  • the output data corresponding to the transaction sequence number "0" that is the same as the spending index value "0" includes: address and amount.
  • the blockchain node can determine the address and amount, as well as the input data with the transaction sequence number "1" in transaction event B, as the transaction data of transaction event B, and store the transaction hash value "y" and the value of transaction event B Correspondence of transaction data.
  • the blockchain node can determine the transaction identifier of each transaction event based on the data of each transaction event stored in each block. The first correspondence with transaction data. Subsequently, when the client queries the transaction data stored in different blocks, the blockchain node can directly read the first correspondence to obtain the transaction data without accessing the data stored in multiple blocks.
  • the blockchain node obtains the transaction identifier of the first transaction event stored in the first block, the output data of the first transaction event, and the transaction identifier of the previous transaction event corresponding to the first transaction event.
  • this embodiment provides a possible implementation.
  • the blockchain node obtains the transaction identifier of the first transaction event stored in the first block, the output data of the first transaction event, and the corresponding data of the first transaction event.
  • the method of identifying the transaction of the previous transaction event includes: step 601.
  • Step 601 The blockchain node calls the target interface to obtain the block data of the first block.
  • the block data (block info) of the first block includes: the transaction identifier of the first transaction event, the output data of the first transaction event, and the transaction identifier of the previous transaction event corresponding to the first transaction event.
  • the target interface may include a remote procedure call.
  • the block data of the first block also includes: the block identifier corresponding to the first block
  • the block data of the first block may include block header data and block body data.
  • Block header data includes the block identifier.
  • the block body data includes the transaction identifier of the first transaction event, the output data of the first transaction event, and the transaction identifier of the previous transaction event corresponding to the first transaction event.
  • the blockchain node calls the target interface
  • the method of obtaining the block data of the first block may include: the blockchain node calls the target interface, traverses multiple blocks in the blockchain, Get the block data for each block in multiple blocks.
  • the blockchain node can call the target interface to obtain the block data of the first block, so that subsequent blocks can be based on the block data of the first block.
  • the data determines the transaction data and transaction identifier of the first transaction event.
  • the data acquisition method also includes: step 701.
  • Step 701 The blockchain node creates a second corresponding relationship between the block identifier of the first block and the block data of the first block.
  • the target database includes: a one-to-one second correspondence relationship between block identifiers of multiple blocks and block data of multiple blocks.
  • a plurality of blocks includes the first block.
  • the target database includes a block database 210.
  • the block database 210 is a KV database
  • the key is the block identifier of a block
  • the value is the block data of the block.
  • the block identifier may include: a hash value of the block, a block number, and other unique identifiers of the block.
  • the blockchain node can create a second corresponding relationship between the block identifier of the first block and the block data of the first block. Later, when the block data needs to be queried, the blockchain node can directly read the target database to obtain the block data, without the need for an interface to obtain the block data stored on the block.
  • step 601 the blockchain node calls the target interface to obtain the block data of the first block, including: step 702-step 703.
  • Step 702 The blockchain node calls the target interface to obtain the block identifier of the first block.
  • the blockchain node calls the target interface
  • the method of obtaining the block identifier of the first block may include: the blockchain node calls the target interface, traverses multiple blocks in the blockchain, Get the block ID of each block in multiple blocks.
  • Step 703 The blockchain node reads the second correspondence relationship and obtains the block data of the first block corresponding to the block identifier of the first block.
  • the blockchain node can access the second corresponding relationship from the block database 210 .
  • the second correspondence relationship stored in the target database may include: block data 0 stored in the block corresponding to block ID 0, and block data stored in the block corresponding to block ID 1.
  • Data 1 stored in the block corresponding to block identifier n.
  • the blockchain node can call the target interface to obtain the block identifier of the first block, and then read the second corresponding relationship to obtain The block data of the first block corresponding to the block identifier of the first block.
  • the blockchain node does not need to request block data from the block, which reduces the amount of data obtained by calling the interface and effectively improves the efficiency of data acquisition.
  • the data acquisition method also includes: steps 901 to 903.
  • Step 901 The blockchain node receives the second request message.
  • the second request message is used to request to obtain the target block data of the target block.
  • the second request message includes: the target block identifier of the target block.
  • the method for the blockchain node to receive the second request message may include: the client sends the second request message to the blockchain node, or any blockchain node on the blockchain performs When the business service needs to obtain block data, it can generate a second request message.
  • Step 902 The blockchain node responds to the second request message and obtains the target block data from the target database using the target block identifier as an index.
  • the blockchain node Since the target database stores block data corresponding to the block identifiers of multiple blocks, after receiving the request message, the blockchain node uses the target block identifier as an index to obtain the target block data from the target database.
  • Step 903 The blockchain node sends the target block data.
  • the technical solution provided by the above embodiments at least brings the following beneficial effects: It can be seen from steps 901 to 903 that after the blockchain node receives the second request message, it can respond to the second request message, using the target block identifier as the index, Get the target block data from the pre-created target database. Subsequently, the blockchain node can send the target block data. In this way, the blockchain node only needs to access the target database to obtain block data, which can improve the efficiency of data acquisition.
  • the data acquisition method includes: step 1001-step 1008.
  • Step 1001 The blockchain node synchronizes the block data in the blockchain.
  • the blockchain nodes on the blockchain can synchronize block data after running.
  • Step 1002 The blockchain node obtains block data and block identification.
  • Step 1003 The blockchain node creates a second correspondence between block data and block identification, and stores the second correspondence in the target database.
  • Step 1004 The blockchain node obtains the transaction identifier of the first transaction event, the output data of the first transaction event, and the transaction identifier of the previous transaction event corresponding to the first transaction event from the block database.
  • Step 1005 The blockchain node uses the transaction identifier of the previous transaction event corresponding to the first transaction event as an index, determines the output data of the previous transaction event from the target database as the input data of the first transaction event, and determines the first transaction event.
  • the input data of the transaction event and the output data of the first transaction event are transaction data of the first transaction event.
  • Step 1006 The blockchain node creates a first correspondence between the transaction identifier of the first transaction event and the transaction data of the first transaction event.
  • Step 1007 The blockchain node determines whether the target database includes transaction data of all transaction events in the blockchain.
  • steps 1002 to 1007 are repeatedly executed.
  • step 1008 is executed.
  • Step 1008 The blockchain node stores the transaction data in the target database in the target format.
  • the target database created by the blockchain node also includes: transaction data 0 of the transaction event corresponding to the transaction identifier 0, transaction data 1 of the transaction event corresponding to the transaction identifier 1, ... transaction events corresponding to the transaction identifier m transaction data m.
  • the data acquisition device described in the embodiment of the present disclosure may include one or more hardware structures and/or software modules for implementing the aforementioned corresponding data acquisition methods. These execution hardware structures and/or software modules Modules can form an electronic device.
  • the embodiments of the present disclosure may be implemented based on hardware or a combination of hardware and computer software. Whether a function is performed by hardware or computer software driving the hardware depends on the specific application and design constraints of the technical solution. Skilled artisans may use different methods to implement the described functions for each specific application, but such implementations should not be considered to be beyond the scope of the disclosed embodiments.
  • FIG. 12 is a structural diagram of a data acquisition device according to one or more embodiments.
  • the data acquisition device package It includes: communication unit 1201 and processing unit 1202.
  • the communication unit 1201 is configured to receive the request message.
  • the processing unit 1202 is configured to respond to the request message and obtain the target transaction data from the target database using the target transaction identifier as an index.
  • the communication unit 1201 is also configured to send target transaction data.
  • the processing unit 1202 is also configured to obtain the transaction identifier of the first transaction event stored in the first block, the output data of the first transaction event, and the corresponding previous transaction event of the first transaction event.
  • transaction identifier According to the transaction identifier of the previous transaction event corresponding to the first transaction event, the second block storing the input data of the first transaction event is determined; the output data of the second transaction event stored in the second block is determined as the second block.
  • Input data for a transaction event The input data of the first transaction event and the output data of the first transaction event are determined as the transaction data of the first transaction event, and the corresponding relationship between the transaction identifier of the first transaction event and the transaction data of the first transaction event is determined as the first transaction.
  • the first correspondence of events According to the transaction identifier of the previous transaction event corresponding to the first transaction event, the second block storing the input data of the first transaction event is determined; the output data of the second transaction event stored in the second block is determined as the second block.
  • Input data for a transaction event
  • the processing unit 1202 is configured to call the target interface to obtain the block data of the first block.
  • the processing unit 1202 is further configured to create a second corresponding relationship between the block identifier of the first block and the block data of the first block.
  • the processing unit 1202 is configured to call the target interface, obtain the block identifier of the first block, read the second correspondence relationship, and obtain the block identifier of the first block corresponding to the first block. block data.
  • the processing unit 1202 is configured to call the target interface, traverse multiple blocks in the blockchain, and obtain the block identifier of each block in the multiple blocks.
  • the communication unit 1201 is also configured to receive a second request message, respond to the second request message, obtain the target block data from the target database using the target block identifier as an index, and send the target block data. .
  • embodiments of the present disclosure can divide blockchain nodes into functional modules according to the above method examples.
  • the above integrated modules can be implemented in the form of hardware or software function modules.
  • the division of modules in the embodiment of the present disclosure is schematic and is only a logical function division. In actual implementation, there may be other division methods.
  • each functional module can be divided corresponding to each function, or two or more functions can be integrated into one processing module.
  • FIG. 13 is a structural diagram of another data acquisition device according to one or more embodiments.
  • the data acquisition device may include at least one processor 221, a communication bus 222, a memory 223 and at least one communication interface 224.
  • the processor 221 may be a processor (central processing units, CPU), a microprocessing unit, an ASIC, or one or more integrated circuits used to control program execution of the disclosed solution. In conjunction with FIG. 13 , the processor 221 is configured to perform operations performed by the processing unit 1202 .
  • Communication bus 222 may include a path for communicating information between the above-mentioned components.
  • the communication interface 224 uses any device such as a transceiver for communicating with other devices or communication networks, such as electronic devices, Ethernet, radio access network (RAN), wireless local area networks, WLAN) etc. In conjunction with FIG. 13 , the communication interface 224 is used to perform operations performed by the communication unit 1201 .
  • RAN radio access network
  • WLAN wireless local area networks
  • Memory 223 may be a read-only memory (ROM) or other type of static storage device that can store static information and instructions, a random access memory (random access memory (RAM)) or other type that can store information and instructions. Dynamic storage device, it can also be electrically erasable programmable read-only memory (EEPROM), read-only optical disk
  • CD-ROM compact disc read-only memory
  • optical disc storage including compressed optical discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.
  • magnetic disk storage media or other magnetic storage devices, or can be used without limitation, any other medium that carries or stores the desired program code in the form of instructions or data structures that can be accessed by a computer.
  • the memory can exist independently and be connected to the processing unit through a bus. The memory can also be integrated with the processing unit.
  • the memory 223 is used to store application program code for executing the disclosed solution, and is controlled by the processor 221 for execution.
  • the processor 221 is used to execute the application program code stored in the memory 223, thereby realizing the functions in the disclosed method.
  • processor 221 may include one or more CPUs, such as Processor 0 and Processor 1 in Figure 13 .
  • the data acquisition device may include multiple processors, such as processor 221 and processor 225 in FIG. 13 .
  • processors may be a single-CPU processor or a multi-CPU processor.
  • a processor here may refer to one or more devices, circuits, and/or processing cores for processing data (eg, computer program instructions).
  • the data acquisition device may also include an input device 226 and an output device 227.
  • the input device 226 communicates with the output device 227 and can accept user input in a variety of ways.
  • the input device 226 may be a mouse, a keyboard, a touch screen device, a sensing device, or the like.
  • the output device 227 communicates with the processor 221 and can display information in a variety of ways.
  • the output device 227 may be a liquid crystal display (LCD), a light emitting diode (LED) display device, etc.
  • LCD liquid crystal display
  • LED light emitting diode
  • Figure 13 does not constitute a limitation on the data acquisition device, and may include more or fewer components than shown, or combine certain components, or adopt different component arrangements.
  • Embodiments of the present disclosure also provide a computer-readable storage medium including instructions. Instructions are stored on the computer-readable storage medium. When the instructions in the computer-readable storage medium are executed by a processor of a data acquisition device, , so that the data acquisition device can execute the data acquisition method provided by the embodiment shown above.
  • the computer-readable storage medium may be a memory 223 including instructions, and the instructions may be executed by the processor 221 of the data acquisition device to complete the above method.
  • the computer-readable storage medium may be a non-transitory computer-readable storage medium.
  • the non-transitory computer-readable storage medium may include a hard disk drive (HDD), a floppy disk drive , flash memory, optical disk, magneto-optical disk, tape or universal serial bus (USB) drive or a combination of two or more of these.
  • the computer-readable storage medium may include removable or non-removable (or fixed) media, or the computer-readable storage medium may be non-volatile solid-state memory.
  • the computer-readable storage medium may be internal to or external to the data acquisition device.

Landscapes

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

Abstract

一种数据获取方法,涉及互联网技术领域,可以解决数据获取效率低的问题。该数据获取方法包括:创建目标数据库;目标数据库用于存储区块链中多个交易事件的交易标识对应的交易数据;交易数据包括输入数据和输出数据;接收第一请求消息;第一请求消息用于请求获取目标交易事件的目标交易数据;第一请求消息包括:目标交易事件的目标交易标识;响应于第一请求消息,以目标交易标识为索引,从目标数据库中获取目标交易数据;发送目标交易数据。

Description

数据获取方法、装置和设备
本申请要求于2022年08月22日提交的、申请号为202211007893.3的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本公开涉及互联网技术领域,尤其涉及一种数据获取方法、装置和设备。
背景技术
区块链(block chain)是一种全民参与记账的方式,具有去中心化和去信任的特点。客户端可以通过任一区块链节点进行交易,交易数据以电子记录的形式存储在区块链中的区块。
通常区块链中的交易模式为未花费的交易输出(unspent transaction output,UTXO)模式,即将一个交易事件的交易数据中的输出数据存储在区块中,作为后一交易事件的交易数据中的输入数据。
发明内容
一方面,本公开实施例提供一种数据获取方法,包括:创建目标数据库,所述目标数据库是存储区块链中多个交易事件的交易标识对应的交易数据的数据库,所述交易数据包括输入数据和输出数据;接收第一请求消息,所述第一请求消息请求获取目标交易事件的目标交易数据,所述第一请求消息包括:所述目标交易事件的目标交易标识;响应于所述第一请求消息,以所述目标交易标识为索引,从所述目标数据库中获取所述目标交易数据;以及发送所述目标交易数据。
在一些实施例中,所述目标数据库包括:所述多个交易事件的交易标识和所述多个交易事件的交易数据一一对应的第一对应关系;所述数据获取方法,还包括:获取第一区块中存储的第一交易事件的交易标识、所述第一交易事件的输出数据、以及所述第一交易事件的对应的前一交易事件的交易标识,所述第一交易事件为所述多个交易事件中的任意一个事件,所述第一区块为区块链中存储所述第一交易事件的输出数据的区块;根据所述第一交易事件的对应的前一交易事件的交易标识,确定存储所述第一交易事件的输入数据的第二区块;将所述第二区块中存储的第二交易事件的输出数据,确定为所述第一交易事件的输入数据,所述第二交易事件为所述第一交易事件的前一交易事件;将所述第一交易事件的输入数据和所述第一交易事件的输出数据确定为所述第一交易事件的交易数据;以及将所述第一交易事件的交易标识和所述第一交易事件的交易数据的对应关系确定为所述第一交易事件的第一对应关系。
在一些实施例中,所述获取所述第一区块中存储的所述第一交易事件的交易标识、所述第一交易事件的输出数据、以及所述第一交易事件的对应的前一交易事件的交易标识,包括:调用目标接口,获取所述第一区块的区块数据,所述第一区块的区块数据包括:所述第一交易事件的交易标识、所述第一交易事件的输出数据、以及所述第一交易事件的对应的前一交易事件的交易标识,所述目标接口包括远程过程调用RPC接口。
在一些实施例中,所述目标数据库还包括:多个区块的区块标识和所述多个区块的区块数据一一对应的第二对应关系,所述多个区块包括所述第一区块,所述第一区块的区块数据还包括:所述第一区块的区块标识;所述数据获取方法,还包括:创建所述第一区块的区块标识与所述第一区块的区块数据的第二对应关系。
在一些实施例中,所述调用目标接口,获取所述第一区块的区块数据,包括:调用所述目标接口,获取所述第一区块的区块标识;以及读取所述第二对应关系,获取所述第一区块的区块标识对应的所述第一区块的区块数据。
在一些实施例中,所述调用目标接口,获取所述第一区块的区块标识,包括:调用所述目标接口,遍历所述区块链中的多个区块,获取所述多个区块中每个区块的区块标识。
在一些实施例中,所述数据获取方法,还包括:接收第二请求消息,所述第二请求消息请求获取目标区块的目标区块数据,所述第二请求消息包括,所述目标区块的目标区块标识;响应于所述第二请求消息,以所述目标区块标识为索引,从所述目标数据库中获取所述目标区块数据;以及发送所述目标区块数据。
在一些实施例中,所述目标数据库包括交易数据库和区块数据库,所述交易数据库被配置为存储第一对应关系,所述区块数据库被配置为存储第二对应关系。
在一些实施例中,所述交易数据库和所述区块数据库为键值数据库。
在一些实施例中,所述目标数据库以目标格式存储对应关系,所述目标格式包括字符分隔值(comma separated values,CSV)格式。
在一些实施例中,所述交易标识包括:交易哈希值、交易号或交易索引值中的至少一个。
在一些实施例中,所述区块链中的交易模式为未花费的交易输出UTXO模式。
另一方面,本公开一些实施例提供一种数据获取装置,包括:通信单元和处理单元;所述处理单元,被配置为创建目标数据库,所述目标数据库是存储区块链中多个交易事件的交易标识对应的交易数据的数据库,所述交易数据包括输入数据和输出数据;所述通信单元,被配置为接收第一请求消息,所述第一请求消息请求获取目标交易事件的目标交易数据,所述第一请求消息包括:所述目标交易事件的目标交易标识;所述处理单元,还被配置为响应于所述第一请求消息,以所述目标交易标识为索引,从所述目标数据库中获取所述目标交易数据;通信单元,还被配置为发送所述目标交易数据。
又一方面,本公开一些实施例提供一种电子设备,包括:存储器,处理器及存储在存储器上并可在处理器上运行的计算机程序,计算机程序在被处理器执行时实现如第一方面的数据获取方法。
又一方面,本公开一些实施例提供一种计算机可读存储介质,计算机可读存储介质上存储有计算机程序,计算机程序在被处理器执行时实现如第一方面的数据获取方法。
附图说明
图1为根据一个或多个实施例的一种数据获取系统的组成图;
图2为根据一个或多个实施例的一种区块链节点的结构图;
图3为根据一个或多个实施例的一种数据获取方法的流程图;
图4为根据一个或多个实施例的另一种数据获取方法的流程图;
图5为根据一个或多个实施例的一种交易数据的索引图;
图6为根据一个或多个实施例的又一种数据获取方法的流程图;
图7为根据一个或多个实施例的又一种数据获取方法的流程图;
图8为根据一个或多个实施例的一种目标数据库的组成图;
图9为根据一个或多个实施例的又一种数据获取方法的流程图;
图10为根据一个或多个实施例的又一种数据获取方法的流程图;
图11为根据一个或多个实施例的另一种目标数据库的组成图;
图12为根据一个或多个实施例的一种数据获取装置的结构图;
图13为根据一个或多个实施例的另一种数据获取装置的结构图。
具体实施方式
为了使本领域普通人员更好地理解本公开的技术方案,下面将结合附图,对本公开实施例中的技术方案进行清楚、完整地描述。
需要说明的是,本公开实施例的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本公开实施例可以基于除了在这里图示或描述的那些以外的顺序实施。以下示例性实施例中所描述的实施方式并不代表与本公开实施例相一致的所有实施方式。相反,它们仅是与如所附权利要求书中所详述的、本公开实施例的一些方面相一致的装置和方法的例子。
还应当理解的是,术语“包括”指示所描述特征、整体、步骤、操作、元素和/或组件的存在,但并不排除一个或多个其他特征、整体、步骤、操作、元素和/或组件的存在或添加。
为了便于理解本公开实施例,现对本公开实施例涉及到的相关要素进行描述。
(1)区块链技术,也被称为分布式账本技术,是一种由若干台计算设备共同参与“记账”(即记录交易数据),共同维护一份完整的分布式数据库的新兴技术。由于区块链技术具有去中心化(即没有中心节点)、公开透明、每台计算设备可以参与数据库记录、并且各计算设备之间可以快速的进行数据同步的特性,使得区块链技术已在众多的领域中广泛的进行应用。
区块链系统可包括多个区块链节点。区块链节点为具有通信功能以及存储功能的设备,如存储有区块链的设备。为了便于描述,本公开实施例采用节点表示区块链节点。也就是说,本公开实施例涉及到的节点均可用于表示区块链节点。
每一个节点既可接收信息,也可生成信息。不同的节点之间通过维护一个共同的区块链来保持通信。在一些实施例中,在区块链系统中,任一节点可以根据客户端发送的与交易相关的数据生成新的区块,并以广播的形式通知其他节点,其他节点可以对这个区块进行验证。当区块链系统中的所有节点达成共识后,新的区块就可以被添加到区块链中。
本公开实施例中的节点可以理解为处理单元。在一种实现方式中,节点可以为物理设备,例如服务器或终端设备。在另一种实现方式中,节点可以为虚拟计算机;虚 拟计算机为所有类型的虚拟化设备中软件虚拟出来的运行环境的统称,该概念包括虚拟机、容器。在其他实现方式中,节点可以为进程(process)或者线程(thread);线程是操作系统可以进行运算调度的最小单位,线程被包含在进程之中,是进程中的实际运作单位;进程是计算机中的程序关于某数据集合上的一次运行活动,是系统进行资源分配和调度的基本单位。
(2)在区块链技术中,交易数据以电子记录的形式被永久储存下来,存放这些电子记录的文件我们称之为“区块”。区块是按时间顺序一个个先后生成的,每一个区块记录有它在被创建期间发生的所有交易,所有区块汇总起来形成一个链式的记录合集。由于不同区块链系统中,节点的吞吐率不同,因此,在不同区块链系统中,区块的大小可能也不同。
可以看出,区块中记录有该区块生成时间段内的交易数据,因此,区块的主体实际上是交易数据的合集。每一种区块链的结构设计可能不完全相同,但区块通常包括区块头(header)和区块体(body)两部分。
区块头主要用于记录当前区块的特征值,可以包括当前区块的标识(如区块的编号)、当前区块中区块体的哈希值、时间戳(用于表示该区块的生成时间)、交易数量(transaction count)和随机数(nonce)等信息中的至少一种信息,此外,区块头还可以包括前一区块的哈希值(具体为前一区块中区块头的哈希值)。
区块头包括有多个特征值,在确定该区块的哈希值时,需要将该区块头中的各个特征值按照顺序连接在一起,以组成一个字符串,再对这个字符串计算哈希值。由于不同区块的区块头所包括的特征值的数值通常不同,因此,每一区块均唯一对应一个哈希值。基于每一区块均唯一对应一个哈希值,且每个区块的区块头均包括有前一区块的哈希值,这样,多个区块即可形成区块链。
区块体可以包括多个交易数据。对于每一交易数据而言,区块体还包括客户端的证书(用于说明交易的发起端)、背书节点的证书以及背书节点针对该交易的签名等信息。在一些实施例中,对于每一笔交易而言,区块体还可以包括排序节点(或称为共识节点)对该笔交易的签名。这里的签名均用于表示与该签名对应的设备对交易的鉴权,证书均用于表示身份。
上述签名和证书等数据均用于对交易数据的验证,这些数据通常占用区块体中70%的存储空间。
在一些示例中,表1示出了区块的一种结构形式。当然,区块的结构不仅仅局限于表1所示,且各个结构的取值也不仅仅局限于表1所示。
表1

(3)交易
本公开实施例涉及到的交易,是指用户通过任一节点创建,并发布数据至区块链的分布式数据库中的过程。
该交易存在狭义的交易以及广义的交易之分。
狭义的交易是指用户向区块链发布的一笔价值转移;例如,在传统的比特币区块链网络中,交易可以是用户在区块链中发起的一笔转账。
广义的交易是指用户向区块链发布一笔任意的数据:例如,运营方可以基于实际的业务需求搭建一个联盟链,依托于联盟链部署一些在线业务(比如,租房业务、车辆调度业务、保险理赔业务、信用服务、医疗服务等),而在这类联盟链中,交易可以是用户在联盟链中发布的一笔具有业务意图的业务消息或者业务请求;又如,该交易还可以是用户向区块链发送数据(如账户余额等),以使得更改用户的账户状态。
因此,只要是用户向区块链的分布式数据库发布任意数据,均可属于本公开实施例所述的“交易”。
(4)客户端(client)
用户可以通过区块链系统中的客户端实现创建链码,发起交易等功能。客户端可以部署在任意的电子设备上,通过区块链系统相应的软件开发工具包(software development kit,SDK)实现。该电子设备通过与区块链网络中的节点进行通信,从而实现客户端相应的功能。
本公开实施例所涉及的数据可以为经用户授权或者经过各方充分授权的数据。
如背景技术中所描述,当一个交易事件的交易数据存储在不同的区块中时,区块链节点需要调用多个接口分别获取多个区块中的交易数据,整个过程需要进行多次接口调用,耗时较长,导致区块链的数据获取效率较低。
基于此,本公开实施例提供一种数据获取方法,区块链节点接收到第一请求消息之后,可以响应于第一请求消息,以目标交易标识为索引,从预先创建的目标数据库中获取目标交易数据。后续,区块链节点可以发送目标交易数据。这样一来,由于数据库中存储的交易数据包括输入数据和输出数据,区块链节点只需访问目标数据库,可以提高数据获取效率。
以下结合附图对本公开实施例提供的数据获取方法进行示例性说明:
图1为根据一个或多个实施例的一种数据获取系统的组成图,如图1所示,该数据获取系统中可以包括:客户端110和区块链120中的多个区块链节点(包括区块链节点121)。客户端110可以通过区块链节点121访问区块链120。
区块链节点121可以是多个区块链节点中的任意一个区块链节点。
区块链120中包括多个区块,每个区块存储的区块数据包括一个时间段内发生的交易事件的交易数据。
在一些实施例中,区块链120中的交易模式可以为UTXO模式,即只记录未花费的输出。此时,区块数据包括:交易事件的交易标识、交易事件的交易数据中的输 出数据,以及对应的前一交易事件的交易标识。
在一些示例中,表2示出了一种区块数据的存储格式。当然,区块数据的存储格式不仅仅局限于表2所示,且各个结构的取值也不仅仅局限于表2所示。
表2
一些实施例中,客户端110可以实现创建链码,发起交易等功能。客户端110可以部署在任意的电子设备上,通过区块链系统相应的软件开发工具包实现。该电子设备通过与区块链节点121进行通信,从而实现客户端110相应的功能。本公开实施例对客户端110的实现方式不作限制。
一些实施例中,区块链120中的多个区块链节点为具有通信功能以及存储功能的设备,可以是单独的一个服务器,或者,也可以是由多个服务器构成的服务器集群。部分实施方式中,服务器集群还可以是分布式集群。本公开实施例对区块链120中的多个区块链节点的实现方式也不作限制。
需要说明的是,上述客户端110和区块链120中的多个区块链节点均可以称为电子设备。
图2为根据一个或多个实施例的一种区块链节点的结构图,如图2所示,区块链节点121可以包括:区块数据库210、交易数据库220。
区块数据库210用于存储区块链120中的多个区块中各个区块的交易数据。
一些实施例中,区块数据库210可以为键值(key-value,KV)数据库。此时区块数据库210中存储区块标识和区块数据的对应关系。
交易数据库220用于存储区块链120中的多个交易的交易数据。
一些实施例中,交易数据库220可以为KV数据库。此时交易数据库220中存储交易标识和交易数据的对应关系。
在一些实施例中,当交易数据库220为KV数据库时,键为一个交易事件的交易标识,值为该交易事件的交易数据。
在一些实施例中,交易标识可以包括:交易事件的交易哈希值、交易事件的交易号、交易事件的交易索引值等交易事件的唯一标识。
在一些实施例中,交易数据可以包括:目标交易事件的输入数据,例如输入地址和输入金额,还可以包括目标交易事件的输出数据,例如输出地址和输出金额。
在一些示例中,表3示出了一种交易数据库的存储格式。
表3

本公开实施例提供的数据获取方法可以应用于前述图1所示的应用场景中的区块链节点121。如图3所示,该数据获取方法可以包括:步骤301-步骤304。
步骤301、区块链节点创建目标数据库。
目标数据库用于存储区块链中多个交易事件的交易标识对应的交易数据。
在一些实施例中,目标数据库以目标格式存储数据。
在一些实施例中,目标格式可以为CSV格式。
在一些实施例中,目标数据库可以包括:多个交易事件的交易标识和多个交易事件的交易数据一一对应的第一对应关系,以及多个区块的区块标识和多个区块的区块数据一一对应的第二对应关系。多个区块的区块数据可以包括多个交易事件的交易数据。
在一些实施例中,结合图2,目标数据库可以包括:区块数据库210或交易数据库220中的至少一个。
在一些实施例中,交易数据可以包括:交易事件的输入(input)数据,例如输入地址(address)和输入金额(amount),还可以包括交易事件的输出(output)数据,例如输出地址和输出金额。
在一些实施例中,交易标识可以包括:交易事件的交易哈希值(transaction hash,Tx hash)、交易事件的交易号、交易事件的交易索引值(transaction index,Tx index)等交易事件的唯一标识。
步骤302、区块链节点接收第一请求消息。
第一请求消息用于请求获取目标交易事件的目标交易数据。第一请求消息包括:目标交易事件的目标交易标识。
在一种可以实现的方式中,区块链节点接收第一请求消息的方法可以包括:客户端向区块链节点发送第一请求消息。
当区块链上的交易事件完成时,区块链上生成存储本次交易事件的交易数据的区块,此时,客户端可以接收到区块链节点发送的回执消息。回执消息包括本次交易事件的交易标识。后续,当持有客户端的用户需要查询区块链中的目标交易事件的目标交易数据时,基于区块链可以实现数据同步,客户端可以向任意一个区块链节点发送第一请求消息。
步骤303、区块链节点响应于第一请求消息,以目标交易标识为索引,从目标数据库中获取目标交易数据。
由于目标数据库中存储有多个交易事件的交易标识对应的交易数据,区块链节点接收到请求消息之后,以目标交易标识为索引,从目标数据库中获取目标交易数据。
步骤304、区块链节点发送目标交易数据。
上述实施例提供的技术方案至少带来以下有益效果:由步骤301-步骤304可知,区块链节点接收到第一请求消息之后,可以响应于第一请求消息,以目标交易标识为索引,从预先创建的目标数据库中获取目标交易数据。后续,区块链节点可以发送目 标交易数据。这样一来,由于数据库中存储的交易数据包括输入数据和输出数据,区块链节点只需访问目标数据库,可以提供数据获取效率。
在一些实施例中,在图3示出的方法实施例的基础上,结合图3,如图4所示,当目标数据库包括:多个交易事件的交易标识和多个交易事件的交易数据一一对应的第一对应关系时,为了确定第一对应关系,该数据获取方法还包括:步骤401-步骤405。
步骤401、区块链节点获取第一区块中存储的第一交易事件的交易标识、第一交易事件的输出数据、以及第一交易事件的对应的前一交易事件的交易标识。
第一交易事件为多个交易事件中的任意一个事件。第一区块为区块链中用于存储第一交易事件的输出数据的区块。
在一些实施例中,第一交易事件还可以为区块链中最新发生的交易事件。
由于UTXO模式中,当前交易事件的输入数据即为前一交易事件的输出数据,所以,区块中可以存储当前交易事件的交易标识、当前交易事件的输出数据和前一交易事件的交易标识。此时,区块链节点可以遍历区块链上的多个区块中存储的数据,获取第一交易事件的交易标识、第一交易事件的输出数据、以及第一交易事件的对应的前一交易事件的交易标识。
在一些实施例中,前一交易事件的交易标识可以包括:花费哈希值(spent hash)和花费索引值(spent index)。
步骤402、区块链节点根据第一交易事件的对应的前一交易事件的交易标识,确定存储第一交易事件的输入数据的第二区块。
区块链节点获取到第一交易事件的对应的前一交易事件的交易标识之后,可以遍历多个区块存储的数据,当存在区块存储的当前交易事件的交易标识与第一交易事件的对应的前一交易事件的交易标识相同时,表示区块存储的当前交易事件为第一交易事件的对应的前一交易事件,此时,可以将该区块确定为存储第一交易事件的输入数据的第二区块。
步骤403、区块链节点将第二区块中存储的第二交易事件的输出数据,确定为第一交易事件的输入数据。
第二交易事件为第一交易事件的前一交易事件。
由于UTXO模式中,当前交易事件的输入数据即为前一交易事件的输出数据,所以,第二交易事件为第一交易事件的前一交易事件时,区块链节点可以将第二区块中存储的第二交易事件的输出数据,确定为第一交易事件的输入数据。
步骤404、区块链节点将第一交易事件的输入数据和第一交易事件的输出数据确定为第一交易事件的交易数据。
步骤405、区块链节点将第一交易事件的交易标识和第一交易事件的交易数据的对应关系确定为第一交易事件的第一对应关系。
在一些示例中,如图5所示,区块链节点可以从区块存储的数据中,获取到交易事件B的交易哈希值为“y”,交易事件B包括:交易序列号为“0”的输入、交易序列号为“1”的输入和交易序列号为“2”的输入,以及交易序列号为“0”的输出、交易序列号为“1”和交易序列号为“2”的输出。交易序列号为“1”的输入包括:交易事件B对应 的前一交易事件A的交易标识(花费哈希值为“x”和花费索引值为“0”)。
区块链节点遍历多个区块存储的数据,获取到交易哈希值为“x”的交易事件A包括:交易序列号为“0”的输入、交易序列号为“1”的输入和交易序列号为“2”的输入,以及交易序列号为“0”的输出、交易序列号为“1”和交易序列号为“2”的输出。与花费索引值“0”相同的交易序列号“0”对应的输出中输出数据包括:地址和金额。
区块链节点可以将地址和金额,以及交易事件B中交易序列号为“1”的输入中输入数据确定为交易事件B的交易数据,并存储交易哈希值“y”与交易事件B的交易数据的对应关系。
上述实施例提供的技术方案至少带来以下有益效果:由步骤401-步骤405可知,区块链节点可以根据每个区块中存储的每个交易事件的数据,确定每个交易事件的交易标识与交易数据的第一对应关系。后续,当客户端查询存储在不同区块中的交易数据时,区块链节点可以直接读取第一对应关系获取交易数据,无需访问多个区块存储的数据。
在一些实施例中,区块链节点获取第一区块中存储的第一交易事件的交易标识、第一交易事件的输出数据、以及第一交易事件的对应的前一交易事件的交易标识的方法,在图4示出的方法实施例的基础上,本实施例提供一种可能实现方式。结合图4,如图6所示,步骤401中,区块链节点获取第一区块中存储的第一交易事件的交易标识、第一交易事件的输出数据、以及第一交易事件的对应的前一交易事件的交易标识的方法包括:步骤601。
步骤601、区块链节点调用目标接口,获取第一区块的区块数据。
第一区块的区块数据(block info)包括:第一交易事件的交易标识、第一交易事件的输出数据、以及第一交易事件的对应的前一交易事件的交易标识。
在一些实施例中,目标接口可以包括远程过程调用(remote procedure call,
RPC)接口。
在一些实施例中,第一区块的区块数据还包括:第一区块对应的区块标识
(block id)。
在一些实施例中,第一区块的区块数据可以包括区块头数据和区块体数据。区块头数据包括区块标识。区块体数据包括第一交易事件的交易标识、第一交易事件的输出数据、以及第一交易事件的对应的前一交易事件的交易标识。
在一种可以实现的方式中,区块链节点调用目标接口,获取第一区块的区块数据的方法可以包括:区块链节点调用目标接口,遍历区块链中的多个区块,获取多个区块中每个区块的区块数据。
上述实施例提供的技术方案至少带来以下有益效果:由步骤601可知,区块链节点可以调用目标接口,获取第一区块的区块数据,以使得后续可以根据第一区块的区块数据确定第一交易事件的交易数据和交易标识。
在一些实施例中,在图6示出的方法实施例的基础上,本实施例提供一种可能实现方式。如图7所示,数据获取方法,还包括:步骤701。
步骤701、区块链节点创建第一区块的区块标识与第一区块的区块数据的第二对应关系。
目标数据库包括:多个区块的区块标识和多个区块的区块数据一一对应的第二对应关系。多个区块包括所述第一区块。
在一些实施例中,结合图2,目标数据库包括区块数据库210,当区块数据库210为KV数据库时,键为一个区块的区块标识,值为该区块的区块数据。
在一些实施例中,区块标识可以包括:区块的哈希值、区块号等区块的唯一标识。
上述实施例提供的技术方案至少带来以下有益效果:由步骤701可知,区块链节点可以创建第一区块的区块标识与第一区块的区块数据的第二对应关系。后续,当需要查询区块数据时,区块链节点可以直接读取目标数据库获取区块数据,无需接口获取区块上存储的区块数据。
如图7所示,步骤601中,区块链节点调用目标接口,获取第一区块的区块数据的方法,包括:步骤702-步骤703。
步骤702、区块链节点调用目标接口,获取第一区块的区块标识。
在一种可以实现的方式中,区块链节点调用目标接口,获取第一区块的区块标识的方法可以包括:区块链节点调用目标接口,遍历区块链中的多个区块,获取多个区块中每个区块的区块标识。
步骤703、区块链节点读取第二对应关系,获取第一区块的区块标识对应的第一区块的区块数据。
在一种可以实现的方式中,结合图2,当目标数据库包括区块数据库210时,区块链节点可以从区块数据库210中访问第二对应关系。
在一些示例中,如图8所示,目标数据库中存储的第二对应关系可以包括:区块标识0对应的区块存储的区块数据0、区块标识1对应的区块存储的区块数据1、……区块标识n对应的区块存储的区块数据n。
上述实施例提供的技术方案至少带来以下有益效果:由步骤702-步骤703可知,区块链节点可以调用目标接口,获取第一区块的区块标识,然后读取第二对应关系,获取第一区块的区块标识对应的第一区块的区块数据。这样一来,区块链节点无需向区块请求区块数据,降低了调用接口获取的数据数量,有效提高了数据获取的效率。
在一些实施例中,如图9所示,数据获取方法,还包括:步骤901-步骤903。
步骤901、区块链节点接收第二请求消息。
第二请求消息用于请求获取目标区块的目标区块数据。第二请求消息包括:目标区块的目标区块标识。
在一种可以实现的方式中,区块链节点接收第二请求消息的方法可以包括:客户端向区块链节点发送第二请求消息,或者,区块链上的任意一个区块链节点进行业务服务需要获取区块数据时,可以生成第二请求消息。
步骤902、区块链节点响应于第二请求消息,以目标区块标识为索引,从目标数据库中获取目标区块数据。
由于目标数据库中存储有多个区块的区块标识对应的区块数据,区块链节点接收到请求消息之后,以目标区块标识为索引,从目标数据库中获取目标区块数据。
步骤903、区块链节点发送目标区块数据。
上述实施例提供的技术方案至少带来以下有益效果:由步骤901-步骤903可知,区块链节点接收到第二请求消息之后,可以响应于第二请求消息,以目标区块标识为索引,从预先创建的目标数据库中获取目标区块数据。后续,区块链节点可以发送目标区块数据。这样一来,区块链节点只需访问目标数据库获取区块数据,可以提高数据获取效率。
下面结合图10,对本公开实施例进行说明,数据获取方法包括:步骤1001-步骤1008。
步骤1001、区块链节点同步区块链中的区块数据。
在一些实施例中,区块链系统初始化完成后,区块链上的区块链节点运行后可以同步区块数据。
步骤1002、区块链节点获取区块数据和区块标识。
步骤1003、区块链节点创建区块数据和区块标识的第二对应关系,并在目标数据库中存储第二对应关系。
步骤1004、区块链节点从区块数据库中获取第一交易事件的交易标识、第一交易事件的输出数据、以及第一交易事件的对应的前一交易事件的交易标识。
步骤1005、区块链节点以第一交易事件的对应的前一交易事件的交易标识为索引,从目标数据库中确定前一交易事件的输出数据为第一交易事件的输入数据,并确定第一交易事件的输入数据和第一交易事件的输出数据为第一交易事件的交易数据。
步骤1006、区块链节点创建第一交易事件的交易标识与第一交易事件的交易数据的第一对应关系。
步骤1007、区块链节点确定目标数据库中是否包括区块链中所有交易事件的交易数据。
当目标数据库中未包括区块链中所有交易事件的交易数据时,重复执行步骤1002-步骤1007。
当目标数据库中包括区块链中所有交易事件的交易数据时,执行步骤1008。
步骤1008、区块链节点以目标格式存储目标数据库中的交易数据。
如图11所示,区块链节点创建的目标数据库还包括:交易标识0对应的交易事件的交易数据0、交易标识1对应的交易事件的交易数据1、……交易标识m对应的交易事件的交易数据m。
可以理解的,在实际实施时,本公开实施例所述的数据获取装置可以包含有用于实现前述对应数据获取方法的一个或多个硬件结构和/或软件模块,这些执行硬件结构和/或软件模块可以构成一个电子设备。本领域技术人员应该很容易意识到,结合本文中所公开的实施例描述的各示例的算法步骤,本公开实施例可以基于硬件或硬件和计算机软件的结合形式来实现。某个功能究竟以硬件还是计算机软件驱动硬件的方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本公开实施例的范围。
基于这样的理解,本公开实施例还对应提供一种数据获取装置。图12为根据一个或多个实施例的一种数据获取装置的结构图。如图12所示,该数据获取装置包 括:通信单元1201和处理单元1202。通信单元1201,被配置为接收请求消息。处理单元1202,被配置为响应于请求消息,以目标交易标识为索引,从目标数据库中获取目标交易数据。通信单元1201,还被配置为发送目标交易数据。
在一些实施例中,处理单元1202,还被配置为获取第一区块中存储的第一交易事件的交易标识、第一交易事件的输出数据、以及第一交易事件的对应的前一交易事件的交易标识。根据第一交易事件的对应的前一交易事件的交易标识,确定存储第一交易事件的输入数据的第二区块;将第二区块中存储的第二交易事件的输出数据,确定为第一交易事件的输入数据。将第一交易事件的输入数据和第一交易事件的输出数据确定为第一交易事件的交易数据,将第一交易事件的交易标识和第一交易事件的交易数据的对应关系确定为第一交易事件的第一对应关系。
在一些实施例中,处理单元1202,被配置为调用目标接口,获取第一区块的区块数据。
在一些实施例中,处理单元1202,还被配置为创建第一区块的区块标识与第一区块的区块数据的第二对应关系。
在一些实施例中,处理单元1202,被配置为调用目标接口,获取第一区块的区块标识,读取第二对应关系,获取第一区块的区块标识对应的第一区块的区块数据。
在一些实施例中,处理单元1202,被配置为调用目标接口,遍历区块链中的多个区块,获取多个区块中每个区块的区块标识。
在一些实施例中,通信单元1201,还被配置为接收第二请求消息,响应于第二请求消息,以目标区块标识为索引,从目标数据库中获取目标区块数据,发送目标区块数据。
如上所述,本公开实施例可以根据上述方法示例对区块链节点进行功能模块的划分。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。另外,还需要说明的是,本公开实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。例如,可以对应各个功能划分各个功能模块,也可以将两个或两个以上的功能集成在一个处理模块中。
关于上述实施例中的数据获取装置,各个模块执行操作的方式、以及具备的有益效果,均已经在前述方法实施例中进行了详细描述,此处不再赘述。
本公开实施例还提供一种数据获取装置。图13为根据一个或多个实施例的另一种数据获取装置的结构图。该数据获取装置可以包括至少一个处理器221,通信总线222,存储器223以及至少一个通信接口224。
处理器221可以是一个处理器(central processing units,CPU),微处理单元,ASIC,或一个或多个用于控制本公开方案程序执行的集成电路。结合图13,处理器221用于执行处理单元1202执行的操作。
通信总线222可包括一通路,在上述组件之间传送信息。
通信接口224,使用任何收发器一类的装置,用于与其他设备或通信网络通信,如电子设备、以太网,无线接入网(radio access network,RAN),无线局域网(wireless local area networks,WLAN)等。结合图13,通信接口224用于执行通信单元1201执行的操作。
存储器223可以是只读存储器(read-only memory,ROM)或可存储静态信息和指令的其他类型的静态存储设备,随机存取存储器(random access memory,RAM)或者可存储信息和指令的其他类型的动态存储设备,也可以是电可擦可编程只读存储器(electrically erasable programmable read-only memory,EEPROM)、只读光盘
(compact disc read-only memory,CD-ROM)或其他光盘存储、光碟存储(包括压缩光碟、激光碟、光碟、数字通用光碟、蓝光光碟等)、磁盘存储介质或者其他磁存储设备、或者可以用于携带或存储具有指令或数据结构形式的期望的程序代码并可以由计算机存取的任何其他介质,但不限于此。存储器可以是独立存在,通过总线与处理单元相连接。存储器也可以和处理单元集成在一起。
存储器223用于存储执行本公开方案的应用程序代码,并由处理器221来控制执行。处理器221用于执行存储器223中存储的应用程序代码,从而实现本公开方法中的功能。
在一些实施例中,处理器221可以包括一个或多个CPU,例如图13中的处理器0和处理器1。
在一些实施例中,数据获取装置可以包括多个处理器,例如图13中的处理器221和处理器225。这些处理器中的每一个可以是一个单核(single-CPU)处理器,也可以是一个多核(multi-CPU)处理器。这里的处理器可以指一个或多个设备、电路、和/或用于处理数据(例如计算机程序指令)的处理核。
在一些实施例中,数据获取装置还可以包括输入设备226和输出设备227。输入设备226和输出设备227通信,可以基于多种方式接受用户的输入。例如,输入设备226可以是鼠标、键盘、触摸屏设备或传感设备等。输出设备227和处理器221通信,可以基于多种方式来显示信息。例如,输出设备227可以是液晶显示器(liquid crystal display,LCD),发光二级管(light emitting diode,LED)显示设备等。
本领域技术人员可以理解,图13中示出的结构并不构成对数据获取装置的限定,可以包括比图示更多或更少的组件,或者组合某些组件,或者采用不同的组件布置。
本公开实施例还提供了一种包括指令的计算机可读存储介质,所述计算机可读存储介质上存储有指令,当所述计算机可读存储介质中的指令由数据获取装置的处理器执行时,使得数据获取装置可以执行上述所示实施例提供的数据获取方法。例如,计算机可读存储介质可以为包括指令的存储器223,上述指令可由数据获取装置的处理器221执行以完成上述方法。
在一些实施例中,计算机可读存储介质可以是非暂态计算机可读存储介质,举例来说而非限制,非暂态计算机可读存储介质可以包括硬盘驱动器(hard disk drive,HDD)、软盘驱动器、闪存、光盘、磁光盘、磁带或通用串行总线(universal serial bus,USB)驱动器或者两个或更多个以上这些的组合。在一些实例中,计算机可读存储介质可以包括可移除或不可移除(或固定)的介质,或者计算机可读存储介质是非易失性固态存储器。计算机可读存储介质可在数据获取装置的内部或外部。
本领域技术人员在考虑说明书及实践这里公开的发明后,将容易想到本公开的其它实施方案。本公开旨在涵盖本公开的任何变型、用途或者适应性变化,这些变型、 用途或者适应性变化遵循本公开的一般性原理并包括本公开未公开的本技术领域中的公知常识或惯用技术手段。说明书和实施例仅被视为示例性的,本公开的真正范围和精神由下面的权利要求指出。
应当理解的是,本公开并不局限于上面已经描述并在附图中示出的精确结构,并且可以在不脱离其范围进行各种修改和改变。本公开的范围仅由所附的权利要求来限制。

Claims (15)

  1. 一种数据获取方法,包括:
    创建目标数据库,所述目标数据库是存储区块链中多个交易事件的交易标识对应的交易数据的数据库,所述交易数据包括输入数据和输出数据;
    接收第一请求消息,所述第一请求消息请求获取目标交易事件的目标交易数据,所述第一请求消息包括:所述目标交易事件的目标交易标识;
    响应于所述第一请求消息,以所述目标交易标识为索引,从所述目标数据库中获取所述目标交易数据;以及
    发送所述目标交易数据。
  2. 根据权利要求1所述的数据获取方法,其中,所述目标数据库包括:所述多个交易事件的交易标识和所述多个交易事件的交易数据一一对应的第一对应关系;所述数据获取方法,还包括:
    获取第一区块中存储的第一交易事件的交易标识、所述第一交易事件的输出数据、以及所述第一交易事件的对应的前一交易事件的交易标识,所述第一交易事件为所述多个交易事件中的任意一个事件,所述第一区块为所述区块链中存储所述第一交易事件的输出数据的区块;
    根据所述第一交易事件的对应的前一交易事件的交易标识,确定存储所述第一交易事件的输入数据的第二区块;
    将所述第二区块中存储的第二交易事件的输出数据,确定为所述第一交易事件的输入数据,所述第二交易事件为所述第一交易事件的前一交易事件;
    将所述第一交易事件的输入数据和所述第一交易事件的输出数据确定为所述第一交易事件的交易数据;以及
    将所述第一交易事件的交易标识和所述第一交易事件的交易数据的对应关系确定为所述第一交易事件的第一对应关系。
  3. 根据权利要求2所述的数据获取方法,其中,所述获取所述第一区块中存储的第一交易事件的交易标识、所述第一交易事件的输出数据、以及所述第一交易事件的对应的前一交易事件的交易标识,包括:
    调用目标接口,获取所述第一区块的区块数据,所述第一区块的区块数据包括:所述第一交易事件的交易标识、所述第一交易事件的输出数据、以及所述第一交易事件的对应的前一交易事件的交易标识,所述目标接口包括远程过程调用RPC接口。
  4. 根据权利要求3所述的数据获取方法,其中,所述目标数据库还包括:多个区块的区块标识和所述多个区块的区块数据一一对应的第二对应关系,所述多个区块包括所述第一区块,所述第一区块的区块数据还包括:所述第一区块的区块标识;所述数据获取方法,还包括:
    创建所述第一区块的区块标识与所述第一区块的区块数据的第二对应关系。
  5. 根据权利要求4所述的数据获取方法,其中,所述调用目标接口,获取所述第一区块的区块数据,包括:
    调用所述目标接口,获取所述第一区块的区块标识;以及
    读取所述第二对应关系,获取所述第一区块的区块标识对应的所述第一区块的区 块数据。
  6. 根据权利要求5所述的数据获取方法,其中,所述调用所述目标接口,获取所述第一区块的区块标识,包括:
    调用所述目标接口,遍历所述区块链中的多个区块,获取所述多个区块中每个区块的区块标识。
  7. 根据权利要求4-6中任一项所述的数据获取方法,还包括:
    接收第二请求消息,所述第二请求消息请求获取目标区块的目标区块数据,所述第二请求消息包括,所述目标区块的目标区块标识;
    响应于所述第二请求消息,以所述目标区块标识为索引,从所述目标数据库中获取所述目标区块数据;以及
    发送所述目标区块数据。
  8. 根据权利要求4-7中任一项所述的数据获取方法,其中,所述目标数据库包括交易数据库和区块数据库,所述交易数据库被配置为存储所述第一对应关系,所述区块数据库被配置为存储所述第二对应关系。
  9. 根据权利要求8所述的数据获取方法,其中,所述交易数据库和所述区块数据库为键值数据库。
  10. 根据权利要求1-9中任一项所述的数据获取方法,其中,所述目标数据库以目标格式存储对应关系,所述目标格式包括字符分隔值CSV格式。
  11. 根据权利要求1-10中任一项所述的数据获取方法,其中,所述交易标识包括:交易哈希值、交易号或交易索引值中的至少一个。
  12. 根据权利要求1-11中任一项所述的数据获取方法,其中,所述区块链中的交易模式为未花费的交易输出UTXO模式。
  13. 一种数据获取装置,包括:通信单元和处理单元;
    所述处理单元,被配置为创建目标数据库,所述目标数据库是存储区块链中多个交易事件的交易标识对应的交易数据的数据库,所述交易数据包括输入数据和输出数据;
    所述通信单元,被配置为接收第一请求消息,所述第一请求消息请求获取目标交易事件的目标交易数据,所述第一请求消息包括:所述目标交易事件的目标交易标识;
    所述处理单元,还被配置为响应于所述第一请求消息,以所述目标交易标识为索引,从所述目标数据库中获取所述目标交易数据;
    所述通信单元,还被配置为发送所述目标交易数据。
  14. 一种电子设备,包括:存储器,处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述计算机程序在被所述处理器执行时,实现如权利要求1至12中任一项所述的数据获取方法。
  15. 一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序在被处理器执行时,实现如权利要求1至12中任一项所述的数据获取方法。
PCT/CN2023/114179 2022-08-22 2023-08-22 数据获取方法、装置和设备 Ceased WO2024041505A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP23856595.6A EP4550167A4 (en) 2022-08-22 2023-08-22 DATA ACQUISITION METHOD AND APPARATUS, AND DEVICE
US19/100,357 US20260044509A1 (en) 2022-08-22 2023-08-22 Data Acquisition Method and Apparatus, and Device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211007893.3 2022-08-22
CN202211007893.3A CN115422184A (zh) 2022-08-22 2022-08-22 一种数据获取方法、装置、设备及存储介质

Publications (1)

Publication Number Publication Date
WO2024041505A1 true WO2024041505A1 (zh) 2024-02-29

Family

ID=84197897

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/114179 Ceased WO2024041505A1 (zh) 2022-08-22 2023-08-22 数据获取方法、装置和设备

Country Status (4)

Country Link
US (1) US20260044509A1 (zh)
EP (1) EP4550167A4 (zh)
CN (1) CN115422184A (zh)
WO (1) WO2024041505A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115422184A (zh) * 2022-08-22 2022-12-02 中国人民银行数字货币研究所 一种数据获取方法、装置、设备及存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106503053A (zh) * 2016-09-26 2017-03-15 江苏通付盾科技有限公司 Utxo查询方法及装置
CN113222752A (zh) * 2019-04-12 2021-08-06 创新先进技术有限公司 基于区块链的数据处理系统、方法、计算设备及存储介质
CN113450223A (zh) * 2021-07-13 2021-09-28 成都质数斯达克科技有限公司 基于utxo模型的交易处理方法、装置、设备及存储介质
CN114860806A (zh) * 2022-05-11 2022-08-05 金蝶软件(中国)有限公司 区块链的数据查询方法、装置、计算机设备和存储介质
CN115422184A (zh) * 2022-08-22 2022-12-02 中国人民银行数字货币研究所 一种数据获取方法、装置、设备及存储介质

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
AU2009249272B2 (en) * 2008-05-18 2014-11-20 Google Llc Secured electronic transaction system
AU2018278351A1 (en) * 2017-06-01 2020-01-23 Schvey, Inc. d/b/a/ Axoni Distributed privately subspaced blockchain data structures with secure access restriction management
US20190378119A1 (en) * 2018-06-12 2019-12-12 Fressets Inc. Wallet device for cryptocurrency and method of signature for the use thereof
US10929473B2 (en) * 2018-09-27 2021-02-23 Palo Alto Research Center Incorporated Integrated index blocks and searching in blockchain systems
US10795874B2 (en) * 2019-07-29 2020-10-06 Alibaba Group Holding Limited Creating index in blockchain-type ledger
CN112529647B (zh) * 2019-09-19 2023-05-26 上海哔哩哔哩科技有限公司 基于区块链的商品交易方法、装置、计算机设备
CN111339106B (zh) * 2020-05-18 2020-08-28 杭州趣链科技有限公司 一种区块链数据索引的方法
CN113268345A (zh) * 2021-04-07 2021-08-17 北京邮电大学 基于区块链系统的交易方法、装置以及存储介质
CN113641649B (zh) * 2021-10-18 2022-02-18 杭州趣链科技有限公司 数据获取方法、装置、设备和存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106503053A (zh) * 2016-09-26 2017-03-15 江苏通付盾科技有限公司 Utxo查询方法及装置
CN113222752A (zh) * 2019-04-12 2021-08-06 创新先进技术有限公司 基于区块链的数据处理系统、方法、计算设备及存储介质
CN113450223A (zh) * 2021-07-13 2021-09-28 成都质数斯达克科技有限公司 基于utxo模型的交易处理方法、装置、设备及存储介质
CN114860806A (zh) * 2022-05-11 2022-08-05 金蝶软件(中国)有限公司 区块链的数据查询方法、装置、计算机设备和存储介质
CN115422184A (zh) * 2022-08-22 2022-12-02 中国人民银行数字货币研究所 一种数据获取方法、装置、设备及存储介质

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP4550167A4

Also Published As

Publication number Publication date
CN115422184A (zh) 2022-12-02
US20260044509A1 (en) 2026-02-12
EP4550167A1 (en) 2025-05-07
EP4550167A4 (en) 2025-10-22

Similar Documents

Publication Publication Date Title
CN112153085B (zh) 一种数据处理方法、节点及区块链系统
TWI724574B (zh) 基於區塊鏈的記帳方法及裝置、電子設備
CN107786642B (zh) 用于数据流通的区块链构建方法及装置、存储介质、服务器
WO2019042101A1 (zh) 一种跨链交易方法及装置
WO2020001370A1 (zh) 一种多链并发交易方法
WO2020082892A1 (zh) 基于区块链的交易处理方法及装置、电子设备
WO2020082893A1 (zh) 基于区块链的交易处理方法及装置、电子设备
US9372879B1 (en) Balanced append tree data structure
US11418342B2 (en) System and methods for data exchange using a distributed ledger
EP3618352A1 (en) Virtual machine management
CN106354544A (zh) 虚拟机创建方法、系统以及主机
CN111400112A (zh) 分布式集群的存储系统的写入方法、装置及可读存储介质
JP2024539911A (ja) 分散型ブロックチェーン機能のための方法およびシステム
US9262241B2 (en) Computer system, computer-implemented method and computer program product for sequencing incoming messages for processing at an application
CN113315630A (zh) 区块链、量子密钥分发方法和装置
CN109951374A (zh) 一种虚拟资源对象分配的方法及设备
CN106559453A (zh) 云互通的外部资源管理方法、装置及系统
WO2024041505A1 (zh) 数据获取方法、装置和设备
CN114331428A (zh) 一种非同质化通证分配方法及装置
CN116723246A (zh) 多云资源数据的处理方法、装置、设备及存储介质
CN111932239A (zh) 业务处理方法、装置、节点设备及存储介质
CN111209263A (zh) 数据存储方法、装置、设备及存储介质
CN113656411B (zh) 用于图数据入库的方法及其装置
CN112181599B (zh) 模型训练方法、装置及存储介质
CN113516476B (zh) 对账处理方法及装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23856595

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 2023856595

Country of ref document: EP

ENP Entry into the national phase

Ref document number: 2023856595

Country of ref document: EP

Effective date: 20250203

NENP Non-entry into the national phase

Ref country code: DE

WWP Wipo information: published in national office

Ref document number: 2023856595

Country of ref document: EP