WO2022142781A1 - 区块链的异步落账方法、装置、介质及电子设备 - Google Patents

区块链的异步落账方法、装置、介质及电子设备 Download PDF

Info

Publication number
WO2022142781A1
WO2022142781A1 PCT/CN2021/130637 CN2021130637W WO2022142781A1 WO 2022142781 A1 WO2022142781 A1 WO 2022142781A1 CN 2021130637 W CN2021130637 W CN 2021130637W WO 2022142781 A1 WO2022142781 A1 WO 2022142781A1
Authority
WO
WIPO (PCT)
Prior art keywords
block
data
item
blockchain
asynchronous
Prior art date
Application number
PCT/CN2021/130637
Other languages
English (en)
French (fr)
Inventor
刘攀
Original Assignee
腾讯科技(深圳)有限公司
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 腾讯科技(深圳)有限公司 filed Critical 腾讯科技(深圳)有限公司
Priority to EP21913524.1A priority Critical patent/EP4207688A4/en
Publication of WO2022142781A1 publication Critical patent/WO2022142781A1/zh
Priority to US17/974,233 priority patent/US20230052935A1/en

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/23Updating
    • G06F16/2358Change logging, detection, and notification
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • G06F16/273Asynchronous replication or reconciliation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/901Indexing; Data structures therefor; Storage structures
    • G06F16/9024Graphs; Linked lists
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/08Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
    • H04L43/0876Network utilisation, e.g. volume of load or congestion level
    • H04L43/0888Throughput

Definitions

  • the present application relates to the field of computer and communication technologies, and in particular to the asynchronous settlement of blockchains.
  • the blockchain nodes need to write the block information into the ledger.
  • the node accounting method is to serially write the block information to the disk or distributed storage.
  • the block header is written to disk or distributed storage.
  • the transaction list and transaction execution result set are written to disk or distributed storage.
  • the write set is written to disk. Or distributed storage, when the writing set is completed, the node accounting is completed and the next round of consensus block generation begins.
  • the embodiments of the present application provide an asynchronous account settlement method, device, medium and electronic device for a blockchain, which can reduce the delay in the settlement of blocks at least to a certain extent and improve the processing performance of the blockchain network.
  • an asynchronous account settlement method for a blockchain including: after a consensus is reached on a block, writing each item of data contained in the block information corresponding to the block into in the message queue corresponding to each item of data; after each item of data is written into the corresponding message queue, start the next round of block consensus process; respectively from the message queue corresponding to each item of data Read data for persistent processing of blockchain ledger.
  • an asynchronous account settlement device for a blockchain including: a first processing unit configured to include the block information corresponding to the block in the block information after the block reaches a consensus Each item of data is written into the message queue corresponding to the item of data respectively; the second processing unit is configured to start the next round of block consensus after writing the item of data into the corresponding message queue respectively Process; a persistence unit, configured to read data from the message queues corresponding to the various pieces of data respectively to perform persistence processing of the blockchain ledger.
  • the first processing unit is further configured to: write each item of data included in the block information corresponding to the block into a message corresponding to the item of data, respectively queue and cache.
  • the first processing unit is further configured to: after the block reaches a consensus, write the block and the corresponding block execution result into a log; For the target block included in the log, after the data corresponding to the target block is persistently processed, the target block and the block execution result of the target block are deleted from the log. .
  • the first processing unit is further configured to: after the blockchain node restarts, obtain the block and block execution result contained in the log; The blocks and block execution results obtained from the above log are persistently processed.
  • the first processing unit is configured to: after the block and the corresponding block execution result are successfully written into the log, write the block corresponding to the block Items of data included in the block information are written into message queues corresponding to the items of data respectively.
  • the first processing unit is further configured to: if writing the block and the corresponding block execution result to the log fails, perform retry processing, and when After the number of retries reaches the set number of times, the log is still not successfully written, and the account processing for the block is stopped and an alarm notification message is sent.
  • the second processing unit is further configured to: delete the target block from the cache after performing persistence processing on each item of data corresponding to the target block corresponding data.
  • the first processing unit is configured to: write the block header included in the block information into the queue and cache corresponding to the block header, and store the block header in the block header.
  • the transaction data contained in the block information is written into the queue and cache corresponding to the transaction data
  • the write set contained in the block information is written into the queue and cache corresponding to the write set, wherein the transaction data Including transaction information list and transaction execution result.
  • the pieces of data included in the block information include: block header, transaction data, and write set; the first processing unit is configured to take the block height as the key
  • the word and block header data are used as values, and the block header contained in the block information is written into the cache corresponding to the block header; the transaction hash is used as the key and the transaction data is used as the value, and the block information in the block information is used as the value.
  • the included transaction data is written into the cache corresponding to the transaction data; the write set contained in the block information is written into the cache corresponding to the write set with the table name and index as the key and the write data as the value.
  • the persistence unit is configured to: monitor the message queues corresponding to the various pieces of data, and the target message queue is one of the message queues corresponding to the various pieces of data message queue; if it is detected that the target message queue contains data, the data is sequentially read from the target message queue for persistence processing.
  • the persistence unit is configured to: invoke a storage layer interface to perform persistence processing on the data sequentially read from the target message queue; if the persistence processing fails, Then, the storage layer interface is called again to perform persistence processing on the data read from the target message queue until the persistence processing succeeds.
  • the persistence unit is configured to: start a monitoring task for each of the message queues; The message queue to listen to.
  • the second processing unit is further configured to: respond to the service request by using the data stored in the cache before completing the persistent processing of the block information.
  • a computer-readable medium on which a computer program is stored, and when the computer program is executed by a processor, realizes the asynchronous settlement of the blockchain as described in the foregoing embodiments method.
  • an electronic device including: one or more processors; and a storage device for storing one or more programs, when the one or more programs are stored by the one or more programs When executed by multiple processors, the one or more processors are made to implement the asynchronous account settlement method of the blockchain as described in the foregoing embodiments.
  • a computer program product or computer program where the computer program product or computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium.
  • the processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the block chain asynchronous settlement method provided in the various optional embodiments above.
  • the technical solutions of the embodiments of the present application reduce the delay in the settlement of the block by processing various data contained in the block information in parallel; on the other hand, after the data is written into the message queue, the Starting the next round of block consensus process, there is no need to wait for the persistence process of various data in the block, which improves the throughput of the blockchain network, thereby effectively improving the processing performance of the blockchain network.
  • Figure 1 shows a schematic structural diagram of a blockchain network
  • Figure 2 shows a schematic diagram of the connection relationship of each block in the blockchain
  • Fig. 3 shows the process schematic diagram of generating a block
  • FIG. 4 shows a flowchart of an asynchronous account settlement method of a blockchain according to an embodiment of the present application
  • FIG. 5 shows a block diagram of an asynchronous account settlement device of a blockchain according to an embodiment of the present application
  • FIG. 6 shows a schematic structural diagram of a computer system suitable for implementing the electronic device according to the embodiment of the present application.
  • Example embodiments will now be described more fully with reference to the accompanying drawings.
  • Example embodiments can be embodied in various forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this application will be thorough and complete, and will fully convey the concept of example embodiments to those skilled in the art.
  • Blockchain is a new application mode of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm.
  • the blockchain is essentially a decentralized database, which is a series of data blocks (ie blocks) associated with cryptographic methods. Each data block contains a batch of network transaction information for verification. The validity of its information (anti-counterfeiting) and the generation of the next block.
  • the blockchain can include the underlying platform of the blockchain, the platform product service layer, and the application service layer.
  • the underlying platform of the blockchain can include processing modules such as user management, basic services, smart contracts, and operation monitoring.
  • the user management module is responsible for the identity information management of all blockchain participants, including maintenance of public and private key generation (account management), key management, and maintenance of the corresponding relationship between the user's real identity and blockchain address (authority management), etc.
  • account management maintenance of public and private key generation
  • key management key management
  • authorization management maintenance of the corresponding relationship between the user's real identity and blockchain address
  • the basic service module is deployed on all blockchain node devices to verify the validity of business requests, After completing the consensus on valid requests, record them in the storage.
  • the basic service For a new business request, the basic service first adapts the interface for analysis and authentication processing (interface adaptation), and then encrypts the business information through the consensus algorithm (consensus management), After encryption, it is completely and consistently transmitted to the shared ledger (network communication), and records are stored; the smart contract module is responsible for the registration and issuance of contracts, as well as contract triggering and contract execution.
  • contract logic through a programming language and publish to On the blockchain (contract registration), according to the logic of the contract terms, call the key or other events to trigger execution, complete the contract logic, and also provide the function of contract upgrade and cancellation;
  • the operation monitoring module is mainly responsible for the deployment in the product release process , configuration modification, contract settings, cloud adaptation, and visual output of real-time status in product operation, such as: alarms, monitoring network conditions, monitoring node equipment health status, etc.
  • the platform product service layer provides the basic capabilities and implementation framework of typical applications. Based on these basic capabilities, developers can superimpose business characteristics to complete the blockchain implementation of business logic.
  • the application service layer provides application services based on blockchain solutions for business participants to use.
  • the blockchain network may include multiple nodes 101, and the multiple nodes 101 may be various clients forming the blockchain network.
  • Each node 101 can receive input information during normal operation, and maintain shared data within the blockchain network based on the received input information.
  • there can be an information connection between each node in the blockchain network and information can be transmitted between the nodes through the above information connection.
  • any node in the blockchain network receives input information
  • other nodes in the blockchain network obtain the input information according to the consensus algorithm, and store the input information as shared data, so that the blockchain network can The data stored on all nodes is consistent.
  • Each node in the blockchain network has its corresponding node ID, and each node in the blockchain network can store the node IDs of other nodes, so that according to the node IDs of other nodes, the The blocks are broadcast to other nodes in the blockchain network.
  • a node identification list may be maintained in each node, and the node name and the node identification are correspondingly stored in the node identification list.
  • the node identifier may be an IP (Internet Protocol, a protocol for interconnection between networks) address and any other information that can be used to identify the node.
  • Every node in a blockchain network stores an identical blockchain.
  • the blockchain consists of multiple blocks, as shown in Figure 2.
  • the blockchain consists of multiple blocks.
  • the founding block includes a block header and a block body.
  • the block header stores the input information feature value, version number, Timestamp and difficulty value, etc., the input information is stored in the block body;
  • the next block of the genesis block takes the genesis block as the parent block, the next block also includes the block header and the block body, and the block header stores the The input information feature value of the current block, the block header feature value of the parent block, the version number, the timestamp and the difficulty value, etc., and so on, so that the block data stored in each block in the blockchain is the same as the The block data stored in the parent block is associated, which ensures the security of the input information in the block.
  • SHA256 is the eigenvalue algorithm used to calculate the eigenvalue
  • version (version number) is the version information of the relevant block protocol in the blockchain
  • prev_hash is the block header eigenvalue of the parent block of the current block
  • merkle_root is the input information
  • the information can be stored correspondingly, the block header and the block body can be generated, and the current block can be obtained.
  • the node where the blockchain is located sends the newly generated block to other nodes in the data sharing system where it is located according to the node identifiers of other nodes in the data sharing system, and the other nodes verify the newly generated block. , and add the newly generated block to its stored blockchain after verification is complete.
  • Each node in the blockchain network can be a server or a terminal device.
  • the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or it can provide cloud services, cloud databases, cloud computing (Cloud Computing), cloud functions, cloud storage, network services, Cloud servers for basic cloud computing services such as cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.
  • the terminal device may be a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited thereto.
  • Each node may be directly or indirectly connected through wired or wireless communication, which is not limited in this application.
  • cloud computing refers to the delivery and use mode of IT infrastructure, specifically referring to obtaining the required resources through the network in an on-demand and easy-to-expand manner; cloud computing in a broad sense refers to the delivery and use mode of services, which refers to the on-demand, Get the services you need in an easily scalable way.
  • Such services can be IT and software, Internet-related, or other services.
  • Cloud computing is grid computing (Grid Computing), distributed computing (Distributed Computing), parallel computing (Parallel Computing), utility computing (Utility Computing), network storage (Network Storage Technologies), virtualization (Virtualization), load balancing ( Load Balance) and other traditional computer and network technology development and integration products.
  • Cloud computing has grown rapidly with the development of the Internet, real-time data streaming, the diversity of connected devices, and the need for search services, social networking, mobile commerce, and open collaboration. Different from the parallel distributed computing in the past, the emergence of cloud computing will promote revolutionary changes in the entire Internet model and enterprise management model.
  • the blockchain node needs to write the block information into the ledger, the block information includes the block and the block execution result, and the block includes the block header and transaction list;
  • the block execution result includes the execution transaction result set and the write set.
  • the node accounting method is to serially write block information to disk or distributed storage, for example, first write block header to disk or distributed storage, and continue to write transaction list and transaction execution result set to disk after this step is completed. Or distributed storage. After the transaction list and transaction execution result set are written, the write set is written to disk or distributed storage. When the write set is written, the node accounting is completed and the next round of consensus block generation begins.
  • this block settlement scheme adopts a serial method as a whole, the performance is heavily dependent on I/O resources, resulting in a large delay in each round of block settlement.
  • the embodiment of the present application proposes a new asynchronous account settlement scheme of the blockchain.
  • the implementation details of the technical scheme of the embodiment of the present application are described in detail below:
  • FIG. 4 shows a flowchart of an asynchronous account settlement method of a blockchain according to an embodiment of the present application, and the asynchronous account settlement method of the blockchain can be executed by any consensus node in the blockchain network.
  • the asynchronous account settlement method of the blockchain at least includes S410 to S430, and the details are as follows:
  • each item of data included in the block information corresponding to the block is written into the message queue corresponding to each item of data, respectively.
  • a message queue may be set for each item of data included in the block information, where the message queue is used to store data that needs to be persistently processed.
  • a cache can also be set up for each piece of data.
  • the function of the cache is to respond to business requests through the data stored in the cache before completing the persistent processing of the block information. , such as responding to query requests through data stored in the cache.
  • various pieces of data included in the block information may include: a block header, transaction data, and a write set.
  • the block header stores the block header information, including the hash value (PreHash) of the previous block, the hash value (Hash) of the current block body, and the timestamp (TimeStamp) and so on.
  • the transaction data includes a transaction information list and a transaction execution result message.
  • the write set contains the value pre-written by the endorser node to the variable during the pre-execution of the transaction, that is, the write of the pair of variables is only recorded in the write set and does not change the world state, and the write set also uses key-value pairs. form of recording.
  • the block header can be written into the queue and cache corresponding to the block header
  • the transaction data can be written into the queue and cache corresponding to the transaction data
  • the write set can be written Write to the queue and cache corresponding to the write set.
  • the block header contained in the block information may be written into the cache corresponding to the block header by using the block height as a key and the block header data as a value.
  • the transaction hash is used as the key and the transaction data is used as the value, and the transaction data contained in the block information is written into the cache corresponding to the transaction data.
  • the write set included in the block information is written into the cache corresponding to the write set with the table name and index as the key and the write data as the value.
  • each consensus node in the blockchain network can start the next round of block consensus process, without waiting for the block information to be persisted before starting the next round of consensus process, which effectively improves the blockchain network. consensus performance.
  • data is read from the message queue corresponding to each item of data to perform persistence processing of the blockchain ledger.
  • the message queue corresponding to each item of data may be monitored, and the target message queue is one of the message queues corresponding to the item of data. If it is detected that the target message queue contains data, the data is sequentially read from the target message queue for persistent processing.
  • the target message queue is a message queue containing data in the message queue corresponding to each item of data in the block information.
  • a monitoring task for each message queue may be started, and then a message queue corresponding to each piece of data is monitored through the monitoring task for each message queue.
  • the process of sequentially reading data from the target message queue and performing persistence processing may be to call a storage layer interface to perform persistence processing on the data sequentially read from the target message queue. If the persistence processing fails, the storage layer interface is called again to persist the data read from the target message queue until the persistence processing succeeds.
  • the data corresponding to the target block may be deleted from the cache.
  • the technical solution of this embodiment can ensure that the cache is cleaned up in time after the data corresponding to the block is persistently processed, so as to release the storage space of the cache.
  • the consensus block and the corresponding block execution result can be written into a log, and the log
  • the target block included in the log can delete the target block and the block execution result of the target block from the log after persisting the data corresponding to the target block.
  • the technical solution of this embodiment makes it possible to temporarily store the consensus block and the corresponding block execution result through the log, so that the blockchain node can determine whether there is block information that has not been persistently processed based on the log, and then can Ensure that the block heights maintained by each blockchain node are consistent.
  • the block and block execution result contained in the log can be obtained, and then according to the block obtained from the log Blocks and block execution results are persisted.
  • the technical solution of this embodiment enables the blockchain node to ensure the integrity of the stored block information based on reading the log after restarting.
  • the consensus block and the corresponding block execution result can be written into the log first, and after the log is written successfully, the Each item of data contained in the block information corresponding to the consensus block is written into the message queue corresponding to each item of data, or also into the cache. That is, in this embodiment, the priority of writing the log is higher, and only after the writing of the log is successful, each item of data contained in the block information is written into the message queue corresponding to each item of data, or write to the cache.
  • a retry process is performed. In the log, the account settlement process is stopped and an alarm notification message is sent.
  • the process of writing the consensus block and the corresponding block execution result into the log, and writing the corresponding block to the consensus block can also be carried out simultaneously; or it can be written to the message queue and cache first, and then written to the log . And after the writing fails, retry can be performed, and when the number of retries reaches the threshold, an alarm notification process is performed.
  • a log management component may be provided, and the log management component is mainly used to prevent the data of the ledger from being inconsistent with the data of other nodes when the node re-books after restarting. Specifically, the log management component will save several latest consensus blocks and block execution results. After the node restarts, the ledger module will first read the blocks and block execution results in the log management component, and then read the The retrieved data is rewritten to disk or distributed storage to ensure the completeness of the node's data and the consistency of the data state with other nodes at the same block height. At the same time, the blocks and block execution results stored in the log management component will be deleted. Specifically, after the node has persistently processed the relevant data of a certain block, it can delete the persistent data from the log management component. The processed block and the block execution result.
  • three different queue components can be set up, one queue is block queue for storing block header data; one queue is transaction queue for storing transaction data (that is, transaction information list and transaction execution result) ; A queue is the writeset queue used to store the write set.
  • one task is the persist block job to monitor whether the block queue has block header data written in real time; one task is the persist transaction job to monitor whether the transaction queue has transaction data written in real time; one task is the persist The writeset job is used to monitor in real time whether the writeset queue has write set writes.
  • a cache management component may also be introduced, and the cache management component caches and clears block header data in the block cache, transaction data in the transaction cache, and write set data in the writeset cache, respectively.
  • the block cache uses the block height as the key and the block header data as the value for caching;
  • the transaction cache uses the transaction hash as the key and the transaction data as the value for caching;
  • the writeset cache uses the table name plus the index as the key and writes the data Cache the value.
  • the ledger module when the ledger module is called to write new block data, the block and the block execution result are first written into the log management component. If writing to the log management component fails, the ledger module will be based on The reason for the failure determines whether to retry. When the retries reach a certain number of times, the settlement of the block will be terminated, and the relevant maintenance personnel will be notified to check and repair.
  • the ledger module writes the block data into the log management component, the block header, the transaction data (that is, the transaction information list and the transaction execution result), and the write set will be simultaneously executed using concurrent execution logic. write operation.
  • the specific writing operation is as follows.
  • a block header message When writing block header data, a block header message will be generated and written to the block queue according to the specifications of the block queue (such as format requirements, etc.), and then written to the cache according to the requirements of the cache management component block cache; write transactions In the same way, a transaction list message is generated and written to the transaction queue according to the specification of the transaction queue, and then written to the cache according to the requirements of the transaction cache; the write set is also written to the queue according to the specification of the writeset queue, and then the write set is written to the writeset cache.
  • the above three types of data are written into the queue and the cache respectively, it can be considered that the accounting is over, and the next round of block consensus process can be started. Since the above three types of data are written concurrently, the billing delay is subject to the writing delay of a certain type of data, which greatly reduces the billing delay.
  • the above three real-time tasks monitor the three queues respectively.
  • the persist block job monitors whether the block queue has block header messages that need to be written to storage
  • the persist transaction job monitors whether the transaction queue has transaction data that needs to be written to storage.
  • the persist writeset job monitors whether the writeset queue has write set data that needs to be written to storage.
  • the persist block job task monitors that the block queue has block header data that needs to be written to storage, it reads the block header data from the block queue in turn. Since the block header data is placed in the block queue in the order of block height, the task reads The output block header data is also in the order of the block high area, and no additional sorting processing is required. When the task reads the block header data, it calls the storage layer interface to persist the block data. Similarly, if the persist transaction job task detects that the transaction queue has transaction data that needs to be written to the storage, it reads the transaction data from the transaction queue in turn. When the task reads the transaction data, it calls the storage layer interface to persist the block data.
  • the persist writeset job task monitors that the writeset queue has write set data that needs to be written to the storage, it reads the write set data from the writeset queue in turn. When the task reads the write set data, it calls the storage layer interface to persist the block data.
  • the above three tasks need to ensure that the call to the storage layer persistence process returns correctly. If the persistence attempt fails and the storage layer interface is called to retry, the retry process can ensure the idempotency of the data, no matter how many attempts are made. Second, the stored data is consistent with the data after the first persistence.
  • the persistently processed block and the block execution result can be deleted from the log management component, Then, the data stored in the log management component is cleaned up in time.
  • the data corresponding to the block that has been persisted can be deleted from the cache, and the block header data and transaction in the block cache can be cleaned up in time.
  • the technical solutions of the above-mentioned embodiments of the present application reduce the delay in the settlement of the block by processing various data contained in the block information in parallel; on the other hand, the data can be opened after the data is written into the message queue and the cache.
  • the next round of block consensus process does not need to wait for the persistence process of various data in the block, realizes the process of asynchronous settlement, improves the throughput of the blockchain network, and effectively improves the blockchain network. processing performance.
  • the following describes the device embodiments of the present application, which can be used to execute the asynchronous account settlement method of the blockchain in the above-mentioned embodiments of the present application.
  • the device embodiments of the present application please refer to the above-mentioned embodiments of the blockchain asynchronous account settlement method of the present application.
  • Fig. 5 shows a block diagram of an asynchronous account settlement device of a blockchain according to an embodiment of the present application, and the asynchronous account settlement device of the blockchain can be set in any consensus node in the blockchain network.
  • an asynchronous account settlement device 500 for a blockchain includes: a first processing unit 502 , a second processing unit 504 and a persistence unit 506 .
  • the first processing unit 502 is configured to write each item of data contained in the block information corresponding to the block into the message queue corresponding to the item of data after the block reaches a consensus; the second processing unit 504 is configured to start the next round of block consensus process after writing the various pieces of data into the corresponding message queues respectively; the persistence unit 506 is configured to read from the message queues corresponding to the various pieces of data respectively The data is processed for persistence in the blockchain ledger.
  • the first processing unit is further configured to: write each item of data included in the block information corresponding to the block into a message corresponding to the item of data, respectively queue and cache.
  • the first processing unit 502 is further configured to: after the block reaches a consensus, write the block and the corresponding block execution result into a log; For the target block included in the log, after the data corresponding to the target block is persistently processed, the target block and the block execution result of the target block are deleted from the log.
  • the first processing unit 502 is further configured to: after the blockchain node restarts, obtain the block and block execution result contained in the log; The blocks and block execution results obtained in the log are persisted.
  • the first processing unit 502 is configured to: after the block and the corresponding block execution result are successfully written into the log, write the block corresponding to the block Items of data included in the block information are written into message queues corresponding to the items of data respectively.
  • the first processing unit 502 is further configured to: if writing the block and the corresponding block execution result to the log fails, perform retry processing, and when the block and the corresponding block execution result fail to be written into the log If the log is still not successfully written after the number of attempts reaches the set number, the account processing for the block is stopped and an alarm notification message is issued.
  • the second processing unit 504 is further configured to: after performing persistence processing on each item of data corresponding to the target block, delete the corresponding data of the target block from the cache of various data.
  • the first processing unit 502 is configured to: write the block header included in the block information into the queue and cache corresponding to the block header, and store the block header
  • the transaction data contained in the information is written into the queue and cache corresponding to the transaction data
  • the write set contained in the block information is written into the queue and cache corresponding to the write set, wherein the transaction data includes List of transaction information and transaction execution results.
  • the pieces of data included in the block information include: block header, transaction data and write set; the first processing unit 502 is configured to: use the block height as a key , block header data as the value, write the block header contained in the block information into the cache corresponding to the block header; take the transaction hash as the key and the transaction data as the value, write the block information containing The transaction data is written into the cache corresponding to the transaction data; the write set included in the block information is written into the cache corresponding to the write set with the table name and index as the key and the write data as the value.
  • the persistence unit 506 is configured to: monitor the message queues corresponding to the various pieces of data.
  • the target message queue is one of the message queues corresponding to the various pieces of data. message queue; if it is detected that the target message queue contains data, the data is sequentially read from the target message queue for persistence processing.
  • the persistence unit 506 is configured to: invoke a storage layer interface to perform persistence processing on the data sequentially read from the target message queue; if the persistence processing fails , the storage layer interface is called again to perform persistence processing on the data read from the target message queue until the persistence processing is successful.
  • the persistence unit 506 is configured to: start a monitoring task for each of the message queues; The corresponding message queue is monitored.
  • the second processing unit 504 is further configured to: respond to the service request by using the data stored in the cache before completing the persistent processing of the block information.
  • FIG. 6 shows a schematic structural diagram of a computer system suitable for implementing the electronic device according to the embodiment of the present application.
  • the computer system 600 includes a central processing unit (Central Processing Unit, CPU) 601, which can be loaded into a random device according to a program stored in a read-only memory (Read-Only Memory, ROM) 602 or from a storage part 608
  • CPU Central Processing Unit
  • ROM Read-Only Memory
  • RAM Random Access Memory
  • a program in a memory (Random Access Memory, RAM) 603 is accessed to perform various appropriate actions and processes, such as performing the methods described in the above embodiments.
  • RAM 603 Random Access Memory
  • various programs and data required for system operation are also stored.
  • the CPU 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604.
  • An Input/Output (I/O) interface 605 is also connected to the bus 604 .
  • the following components are connected to the I/O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc. ; a storage part 608 including a hard disk and the like; and a communication part 609 including a network interface card such as a LAN (Local Area Network) card, a modem, and the like.
  • the communication section 609 performs communication processing via a network such as the Internet.
  • a drive 610 is also connected to the I/O interface 605 as needed.
  • a removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is mounted on the drive 610 as needed so that a computer program read therefrom is installed into the storage section 608 as needed.
  • embodiments of the present application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program comprising a computer program for performing the method illustrated in the flowchart.
  • the computer program may be downloaded and installed from the network via the communication portion 609 and/or installed from the removable medium 611 .
  • CPU central processing unit
  • various functions defined in the system of the present application are executed.
  • the computer-readable medium shown in the embodiments of the present application may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the above two.
  • the computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or a combination of any of the above.
  • Computer readable storage media may include, but are not limited to, electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read only memory (ROM), erasable Erasable Programmable Read Only Memory (EPROM), flash memory, optical fiber, portable Compact Disc Read-Only Memory (CD-ROM), optical storage device, magnetic storage device, or any suitable of the above The combination.
  • a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
  • a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying a computer-readable computer program therein.
  • Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing.
  • a computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device .
  • a computer program embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to: wireless, wired, etc., or any suitable combination of the foregoing.
  • each block in the flowchart or block diagram may represent a module, program segment, or part of code, and the above-mentioned module, program segment, or part of code contains one or more executables for realizing the specified logical function instruction.
  • the functions noted in the blocks may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved.
  • the units involved in the embodiments of the present application may be implemented in software or hardware, and the described units may also be provided in a processor. Among them, the names of these units do not constitute a limitation on the unit itself under certain circumstances.
  • the present application also provides a computer-readable medium.
  • the computer-readable medium may be included in the electronic device described in the above embodiments; it may also exist alone without being assembled into the electronic device. middle.
  • the above-mentioned computer-readable medium carries one or more programs, and when the above-mentioned one or more programs are executed by an electronic device, enables the electronic device to implement the methods described in the above-mentioned embodiments.
  • the exemplary embodiments described herein may be implemented by software, or may be implemented by software combined with necessary hardware. Therefore, the technical solutions according to the embodiments of the present application may be embodied in the form of software products, and the software products may be stored in a non-volatile storage medium (which may be CD-ROM, U disk, mobile hard disk, etc.) or on the network , which includes several instructions to cause a computing device (which may be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the embodiments of the present application.
  • a computing device which may be a personal computer, a server, a touch terminal, or a network device, etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Computing Systems (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Environmental & Geological Engineering (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请的实施例提供了一种区块链的异步落账方法、装置、介质及电子设备。该区块链的异步落账方法包括:在区块达成共识之后,将区块所对应的区块信息中包含的各项数据分别写入所述各项数据对应的消息队列中;在将所述各项数据分别写入对应的消息队列中之后,开启下一轮的区块共识过程;分别从所述各项数据对应的消息队列中读取数据进行区块链账本的持久化处理。本申请实施例的技术方案降低了区块的落账延迟,并且实现了异步落账,提高了区块链网络的吞吐量,进而有效提升了区块链网络的处理性能。

Description

区块链的异步落账方法、装置、介质及电子设备
本申请要求于2020年12月28日提交中国专利局、申请号为202011577543.1、申请名称为“区块链的异步落账方法、装置、介质及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及计算机及通信技术领域,具体涉及区块链的异步落账。
背景技术
区块链网络在对区块达成共识之后,区块链节点需要将区块信息写入账本中,通常节点记账方法是将区块信息串行写入磁盘或者分布式存储,例如先将区块头写入磁盘或者分布式存储,等该步骤完成后继续将交易列表以及交易执行结果集写入磁盘或者分布式存储,等交易列表和交易执行结果集写完后,再将写集合写入磁盘或者分布式存储,当写集合写完后节点记账完成开始下一轮共识出块。
发明内容
本申请的实施例提供了一种区块链的异步落账方法、装置、介质及电子设备,进而至少在一定程度上可以降低区块的落账延迟,提升区块链网络的处理性能。
本申请的其他特性和优点将通过下面的详细描述变得显然,或部分地通过本申请的实践而习得。
根据本申请实施例的一个方面,提供了一种区块链的异步落账方法,包括:在区块达成共识之后,将所述区块所对应区块信息中包含的各项数据分别写入所述各项数据对应的消息队列中;在将所述各项数据分别写入对应的消息队列中之后,开启下一轮的区块共识过程;分别从所述各项数据对应的消息队列中读取数据进行区块链账本的持久化处理。
根据本申请实施例的一个方面,提供了一种区块链的异步落账装置,包括:第一处理单元,配置为在区块达成共识之后,将所述区块所对应区块信息中包含的各项数据分别写入所述各项数据对应的消息队列中;第二处理单元,配置为在将所述各项数据分别写入对应的消息队列中之后,开启下一轮的区块共识过程;持久化单元,配置为分别从所述各项数据对应的消息队列中读取数据进 行区块链账本的持久化处理。
在本申请的一些实施例中,基于前述方案,所述第一处理单元还配置为:将所述区块所对应区块信息中包含的各项数据分别写入所述各项数据对应的消息队列及缓存中。
在本申请的一些实施例中,基于前述方案,所述第一处理单元还配置为:在所述区块达成共识之后,将所述区块及对应的区块执行结果写入日志中;针对所述日志中包含的目标区块,在对所述目标区块对应的各项数据进行持久化处理之后,从所述日志中删除所述目标区块及所述目标区块的区块执行结果。
在本申请的一些实施例中,基于前述方案,所述第一处理单元还配置为:在区块链节点重启后,获取所述日志中所包含的区块及区块执行结果;根据从所述日志中获取到的区块及区块执行结果进行持久化处理。
在本申请的一些实施例中,基于前述方案,所述第一处理单元配置为:在将所述区块及对应的区块执行结果成功写入所述日志之后,将所述区块所对应区块信息中所包含的各项数据分别写入所述各项数据对应的消息队列中。
在本申请的一些实施例中,基于前述方案,所述第一处理单元还配置为:若将所述区块及对应的区块执行结果写入所述日志失败,则进行重试处理,当重试次数达到设定次数后仍未成功写入所述日志,停止对所述区块进行落账处理并发出告警通知消息。
在本申请的一些实施例中,基于前述方案,所述第二处理单元还配置为:在对目标区块对应的各项数据进行持久化处理之后,从所述缓存中删除所述目标区块对应的各项数据。
在本申请的一些实施例中,基于前述方案,所述第一处理单元配置为:将所述区块信息中所包含的区块头写入区块头对应的队列中及缓存中,将所述区块信息中所包含的交易数据写入交易数据对应的队列中及缓存中,将所述区块信息中所包含的写集合写入写集合对应的队列中及缓存中,其中,所述交易数据包括交易信息列表及交易执行结果。
在本申请的一些实施例中,基于前述方案,所述区块信息中包含的各项数据包括:区块头、交易数据及写集合;所述第一处理单元配置为:以区块高度作为关键字、区块头数据作为值,将所述区块信息中包含的区块头写入所述区 块头对应的缓存中;以交易哈希作为关键字、交易数据作为值,将所述区块信息中包含的交易数据写入所述交易数据对应的缓存中;以表名和索引作为关键字、写数据作为值,将所述区块信息中包含的写集合写入所述写集合对应的缓存中。
在本申请的一些实施例中,基于前述方案,所述持久化单元配置为:对所述各项数据对应的消息队列进行监听,目标消息队列为所述各项数据对应的消息队列中的一个消息队列;若监听到所述目标消息队列中包含有数据,则从所述目标消息队列中依次读取数据进行持久化处理。
在本申请的一些实施例中,基于前述方案,所述持久化单元配置为:调用存储层接口对从所述目标消息队列中依次读取出的数据进行持久化处理;若持久化处理失败,则重新调用所述存储层接口对从所述目标消息队列中读取出的数据进行持久化处理,直到持久化处理成功。
在本申请的一些实施例中,基于前述方案,所述持久化单元配置为:启动针对各个所述消息队列的监听任务;通过针对各个所述消息队列的监听任务,对所述各项数据对应的消息队列进行监听。
在本申请的一些实施例中,基于前述方案,所述第二处理单元还配置为:在对所述区块信息完成持久化处理之前,通过所述缓存中存储的数据对业务请求进行响应。
根据本申请实施例的一个方面,提供了一种计算机可读介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现如上述实施例中所述的区块链的异步落账方法。
根据本申请实施例的一个方面,提供了一种电子设备,包括:一个或多个处理器;存储装置,用于存储一个或多个程序,当所述一个或多个程序被所述一个或多个处理器执行时,使得所述一个或多个处理器实现如上述实施例中所述的区块链的异步落账方法。
根据本申请实施例的一个方面,提供了一种计算机程序产品或计算机程序,该计算机程序产品或计算机程序包括计算机指令,该计算机指令存储在计算机可读存储介质中。计算机设备的处理器从计算机可读存储介质读取该计算机指令,处理器执行该计算机指令,使得该计算机设备执行上述各种可选实施例中 提供的区块链的异步落账方法。
在本申请的一些实施例所提供的技术方案中,在区块达成共识之后,将达成共识的区块所对应的区块信息中包含的各项数据分别写入对应的消息队列中,并在将各项数据分别写入对应的消息队列中之后,开启下一轮的区块共识过程,然后分别从各项数据对应的消息队列中读取数据进行区块链账本的持久化处理。可见,本申请实施例的技术方案一方面通过并行的对区块信息中包含的各项数据进行处理,降低了区块的落账延迟;另一方面在将数据写入消息队列中之后就可以开启下一轮的区块共识过程,无需等待区块中的各项数据的持久化过程,提高了区块链网络的吞吐量,进而有效提升了区块链网络的处理性能。
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本申请。
附图说明
图1示出了区块链网络的结构示意图;
图2示出了区块链中各区块的连接关系示意图;
图3示出了生成一个区块的过程示意图;
图4示出了根据本申请的一个实施例的区块链的异步落账方法的流程图;
图5示出了根据本申请的一个实施例的区块链的异步落账装置的框图;
图6示出了适于用来实现本申请实施例的电子设备的计算机系统的结构示意图。
具体实施方式
现在将参考附图更全面地描述示例实施方式。然而,示例实施方式能够以多种形式实施,且不应被理解为限于在此阐述的范例;相反,提供这些实施方式使得本申请将更加全面和完整,并将示例实施方式的构思全面地传达给本领域的技术人员。
此外,所描述的特征、结构或特性可以以任何合适的方式结合在一个或更多实施例中。在下面的描述中,提供许多具体细节从而给出对本申请的实施例的充分理解。然而,本领域技术人员将意识到,可以实践本申请的技术方案而没有特定细节中的一个或更多,或者可以采用其它的方法、组元、装置、步骤 等。在其它情况下,不详细示出或描述公知方法、装置、实现或者操作以避免模糊本申请的各方面。
附图中所示的方框图仅仅是功能实体,不一定必须与物理上独立的实体相对应。即,可以采用软件形式来实现这些功能实体,或在一个或多个硬件模块或集成电路中实现这些功能实体,或在不同网络和/或处理器装置和/或微控制器装置中实现这些功能实体。
附图中所示的流程图仅是示例性说明,不是必须包括所有的内容和操作/步骤,也不是必须按所描述的顺序执行。例如,有的操作/步骤还可以分解,而有的操作/步骤可以合并或部分合并,因此实际执行的顺序有可能根据实际情况改变。
需要说明的是:在本文中提及的“多个”是指两个或两个以上。“和/或”描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。字符“/”一般表示前后关联对象是一种“或”的关系。
区块链(Blockchain)是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。区块链本质上是一个去中心化的数据库,是一串使用密码学方法相关联产生的数据块(即区块),每一个数据块中包含了一批次网络交易的信息,用于验证其信息的有效性(防伪)和生成下一个区块。区块链可以包括区块链底层平台、平台产品服务层以及应用服务层。
区块链底层平台可以包括用户管理、基础服务、智能合约以及运营监控等处理模块。其中,用户管理模块负责所有区块链参与者的身份信息管理,包括维护公私钥生成(账户管理)、密钥管理以及用户真实身份和区块链地址对应关系维护(权限管理)等,并且在授权的情况下,监管和审计某些真实身份的交易情况,提供风险控制的规则配置(风控审计);基础服务模块部署在所有区块链节点设备上,用来验证业务请求的有效性,并对有效请求完成共识后记录到存储上,对于一个新的业务请求,基础服务先对接口适配解析和鉴权处理(接口适配),然后通过共识算法将业务信息加密(共识管理),在加密之后完整一致的传输至共享账本上(网络通信),并进行记录存储;智能合约模块负责合约的注册发行以及合约触发和合约执行,开发人员可以通过某种编程语言 定义合约逻辑,发布到区块链上(合约注册),根据合约条款的逻辑,调用密钥或者其它的事件触发执行,完成合约逻辑,同时还提供对合约升级注销的功能;运营监控模块主要负责产品发布过程中的部署、配置的修改、合约设置、云适配以及产品运行中的实时状态的可视化输出,例如:告警、监控网络情况、监控节点设备健康状态等。
平台产品服务层提供典型应用的基本能力和实现框架,开发人员可以基于这些基本能力,叠加业务的特性,完成业务逻辑的区块链实现。应用服务层提供基于区块链方案的应用服务给业务参与方进行使用。
参见图1所示的区块链网络,该区块链网络中可以包括多个节点101,多个节点101可以是形成区块链网络的各个客户端。每个节点101在进行正常工作可以接收到输入信息,并基于接收到的输入信息维护该区块链网络内的共享数据。为了保证区块链网络内的信息互通,区块链网络中的每个节点之间可以存在信息连接,节点之间可以通过上述信息连接进行信息传输。例如,当区块链网络中的任意节点接收到输入信息时,区块链网络中的其它节点便根据共识算法获取该输入信息,将该输入信息作为共享数据进行存储,使得区块链网络中全部节点上存储的数据均一致。
对于区块链网络中的每个节点,均具有与其对应的节点标识,而且区块链网络中的每个节点均可以存储有其它节点的节点标识,以便后续根据其它节点的节点标识,将生成的区块广播至区块链网络中的其它节点。每个节点中可维护一个节点标识列表,将节点名称和节点标识对应存储至该节点标识列表中。其中,节点标识可为IP(Internet Protocol,网络之间互联的协议)地址以及其他任一种能够用于标识该节点的信息。
区块链网络中的每个节点均存储一条相同的区块链。区块链由多个区块组成,参见图2所示,区块链由多个区块组成,创始块中包括区块头和区块主体,区块头中存储有输入信息特征值、版本号、时间戳和难度值等,区块主体中存储有输入信息;创始块的下一区块以创始块为父区块,下一区块中同样包括区块头和区块主体,区块头中存储有当前区块的输入信息特征值、父区块的区块头特征值、版本号、时间戳和难度值等,并以此类推,使得区块链中每个区块中存储的区块数据均与父区块中存储的区块数据存在关联,保证了区块中输入 信息的安全性。
在生成区块链中的各个区块时,参见图3所示,区块链所在的节点在接收到输入信息时,对输入信息进行校验,完成校验后,将输入信息存储至内存池中,并更新其用于记录输入信息的哈希树;之后,将更新时间戳更新为接收到输入信息的时间,并尝试不同的随机数,多次进行特征值计算,使得计算得到的特征值可以满足下述公式:
SHA256(SHA256(version+prev_hash+merkle_root+ntime+nbits+x))<TARGET
其中,SHA256为计算特征值所用的特征值算法;version(版本号)为区块链中相关区块协议的版本信息;prev_hash为当前区块的父区块的区块头特征值;merkle_root为输入信息的特征值;ntime为更新时间戳的更新时间;nbits为当前难度,在一段时间内为定值,并在超出固定时间段后再次进行确定;x为随机数;TARGET为特征值阈值,该特征值阈值可以根据nbits确定得到。
这样,当计算得到满足上述公式的随机数时,便可将信息对应存储,生成区块头和区块主体,得到当前区块。随后,区块链所在节点根据数据共享系统中其它节点的节点标识,将新生成的区块分别发送给其所在的数据共享系统中的其它节点,由其它节点对新生成的区块进行校验,并在完成校验后将新生成的区块添加至其存储的区块链中。
区块链网络中各个节点可以是服务器,也可以是终端设备。服务器可以是独立的物理服务器,也可以是多个物理服务器构成的服务器集群或者分布式系统,还可以是提供云服务、云数据库、云计算(Cloud Computing)、云函数、云存储、网络服务、云通信、中间件服务、域名服务、安全服务、CDN(Content Delivery Network,内容分发网络)、以及大数据和人工智能平台等基础云计算服务的云服务器。终端设备可以是智能手机、平板电脑、笔记本电脑、台式计算机、智能音箱、智能手表等,但并不局限于此。各个节点之间可以通过有线或无线通信方式进行直接或间接地连接,本申请在此不做限制。
前述的云计算是指IT基础设施的交付和使用模式,具体指通过网络以按需、易扩展的方式获得所需资源;广义云计算指服务的交付和使用模式,指通过网络以按需、易扩展的方式获得所需服务。这种服务可以是IT和软件、互联网相关,也可是其他服务。云计算是网格计算(Grid Computing)、分布式计算 (Distributed Computing)、并行计算(Parallel Computing)、效用计算(Utility Computing)、网络存储(Network Storage Technologies)、虚拟化(Virtualization)、负载均衡(Load Balance)等传统计算机和网络技术发展融合的产物。随着互联网、实时数据流、连接设备多样化的发展,以及搜索服务、社会网络、移动商务和开放协作等需求的推动,云计算迅速发展起来。不同于以往的并行分布式计算,云计算的产生从理念上将推动整个互联网模式、企业管理模式发生革命性的变革。
其中,区块链网络在对区块达成共识之后,区块链节点需要将区块信息写入账本中,该区块信息包括区块以及区块执行结果,区块包括区块头、交易列表;区块执行结果包括执行交易结果集以及写集。
通常节点记账方法是将区块信息串行写入磁盘或者分布式存储,例如先将区块头写入磁盘或者分布式存储,等该步骤完成后继续将交易列表以及交易执行结果集写入磁盘或者分布式存储,等交易列表和交易执行结果集写完后,再将写集合写入磁盘或者分布式存储,当写集合写完后节点记账完成开始下一轮共识出块。但是,由于这种区块落账的方案整体采用串行方式,性能严重依赖I/O资源,导致每一轮区块落账延迟较大。
基于此,本申请的实施例提出了一种新的区块链的异步落账方案,以下对本申请实施例的技术方案的实现细节进行详细阐述:
图4示出了根据本申请的一个实施例的区块链的异步落账方法的流程图,该区块链的异步落账方法可以由区块链网络中的任意一个共识节点来执行。参照图4所示,该区块链的异步落账方法至少包括S410至S430,详细介绍如下:
在S410中,在区块达成共识之后,将区块所对应区块信息中包含的各项数据分别写入各项数据对应的消息队列中。
在本申请的一个实施例中,可以为区块信息中包含的各项数据分别设置一个消息队列,其中的消息队列用于存放需要进行持久化处理的数据。
同时,在一种可能的实现方式中,还可以为各项数据分别设置一个缓存,该缓存的作用是在对区块信息完成持久化处理之前,可以通过缓存中存储的数据对业务请求进行响应,比如通过缓存中存储的数据对查询请求进行响应等。
在本申请的一个实施例中,区块信息中包含的各项数据可以包括:区块头、 交易数据及写集合。其中,区块头中存储有区块的头信息,包含上一个区块的哈希值(PreHash)、本区块体的哈希值(Hash),以及时间戳(TimeStamp)等等。交易数据包括交易信息列表及交易执行结果消息。写集合中包含了背书节点在预执行交易的过程中对变量预写入的值,即该对变量的写入只是记录在写集合中,并未更改世界状态,写集合中也以键值对的形式进行记录。
基于前述实施例中区块信息所包含的各项数据,可以将区块头写入区块头对应的队列中及缓存中,将交易数据写入交易数据对应的队列中及缓存中,将写集合写入写集合对应的队列中及缓存中。
在本申请的一个实施例中,可以以区块高度作为关键字、区块头数据作为值,将区块信息中包含的区块头写入区块头对应的缓存中。
在本申请的一个实施例中,以交易哈希作为关键字、交易数据作为值,将区块信息中包含的交易数据写入交易数据对应的缓存中。
在本申请的一个实施例中,以表名和索引作为关键字、写数据作为值,将区块信息中包含的写集合写入写集合对应的缓存中。
继续参照图4所示,在S420中,在将各项数据分别写入对应的消息队列中之后,开启下一轮的区块共识过程。
在本申请的一个实施例中,当把区块信息中包含的各项数据分别写入对应的消息队列中之后,或者当把区块信息中包含的各项数据分别写入对应的消息队列及缓存中之后,区块链网络中的各个共识节点可以开启下一轮的区块共识过程,无需等待区块信息进行持久化处理之后再开启下一轮的共识过程,有效提高了区块链网络的共识性能。
继续参照图4所示,在S430中,分别从各项数据对应的消息队列中读取数据进行区块链账本的持久化处理。
在本申请的一个实施例中,可以对各项数据对应的消息队列进行监听,目标消息队列为所述各项数据对应的消息队列中的一个消息队列。如果监听到目标消息队列中包含有数据,则从目标消息队列中依次读取数据进行持久化处理。其中,目标消息队列是区块信息中的各项数据所对应的消息队列中包含有数据的消息队列。可选地,可以启动针对各个消息队列的监听任务,然后通过针对各个消息队列的监听任务,对各项数据对应的消息队列进行监听。
在本申请的一个实施例中,从目标消息队列中依次读取数据进行持久化处理的过程可以是调用存储层接口对从目标消息队列中依次读取出的数据进行持久化处理。如果持久化处理失败,则重新调用存储层接口对从目标消息队列中读取出的数据进行持久化处理,直到持久化处理成功。
在本申请的一个实施例中,在对目标区块对应的各项数据进行持久化处理之后,可以从缓存中删除目标区块对应的各项数据。该实施例的技术方案可以保证在区块对应的各项数据持久化处理之后,及时清理缓存,以释放缓存的存储空间。
基于图4所示实施例的技术方案,在本申请的一个实施例中,在区块达成共识之后,可以将达成共识的区块及对应的区块执行结果写入日志中,针对所述日志中包含的目标区块,可以在对目标区块对应的各项数据进行持久化处理之后,从日志中删除目标区块及目标区块的区块执行结果。该实施例的技术方案使得可以通过日志暂存达成共识的区块及对应的区块执行结果,进而使得区块链节点能够基于该日志确定是否有未进行持久化处理的区块信息,进而可以保证各区块链节点维护的区块高度一致。
在本申请的一个实施例中,基于前述实施例中的日志,使得区块链节点在重启后,可以获取日志中所包含的区块及区块执行结果,然后根据从日志中获取到的区块及区块执行结果进行持久化处理。该实施例的技术方案使得区块链节点在重启之后,能够基于对该日志的读取来确保所存储的区块信息的完整性。
作为本申请的一个实施例,当区块链网络中的区块达成共识之后,可以先将达成共识的区块及对应的区块执行结果写入日志,并且在写入日志成功之后,再将达成共识的区块所对应的区块信息中所包含的各项数据分别写入各项数据对应的消息队列中,或也写入缓存中。即在该实施例中,写入日志的优先级较高,只有在写入日志成功之后,再将区块信息中所包含的各项数据分别写入各项数据对应的消息队列中,或也写入缓存中。同时,在本申请的一个实施例中,若将达成共识的区块及对应的区块执行结果写入日志失败,则进行重试处理,当重试次数达到设定次数后仍未成功写入所述日志,停止进行落账处理并发出告警通知消息。
在本申请的一个实施例中,当区块链网络中的区块达成共识之后,将达成 共识的区块及对应的区块执行结果写入日志的过程,以及将达成共识的区块所对应的区块信息中所包含的各项数据分别写入各项数据对应的消息队列及缓存中的过程也可以是同时进行的;或者也可以先写入消息队列及缓存中,再写入日志中。并且可以在写入失败之后,都进行重试,当重试次数达到阈值之后,进行报警通知处理。
以下以一个具体的实施例,对本申请的实现细节进行详细阐述:
在本申请的一个实施例中,可以设置一个日志管理组件,该日志管理组件主要用于当节点在重启后进行重新落账时,防止账本数据与其它节点数据不一致。具体而言,该日志管理组件会保存若干个最新达成共识的区块以及区块执行结果,节点重启后账本模块会首先读取该日志管理组件中的区块以及区块执行结果,然后将读取到的数据重新写入磁盘或者分布式存储,以保证本节点数据的完备性以及与其它节点在相同区块高度上数据状态一致性。同时,日志管理组件中存储的区块及区块执行结果会进行删除,具体是节点在将某个区块的相关数据进行持久化处理之后,可以从该日志管理组件中删除已经进行了持久化处理的区块及区块执行结果。
在本申请的一个实施例中,可以设置三个不同的队列组件,一个队列为block queue用来存放区块头数据;一个队列为transaction queue用来存放交易数据(即交易信息列表以及交易执行结果);一个队列为writeset queue用来存放写集合。同时引入了三个任务,一个任务为persist block job用来实时监听block queue是否有区块头数据写入;一个任务为persist transaction job用来实时监听transaction queue是否有交易数据写入;一个任务为persist writeset job用来实时监听writeset queue是否有写集合写入。
在本申请的一个实施例中,还可以引入缓存管理组件,该缓存管理组件分别缓存和清理block cache中的区块头数据、transaction cache中的交易数据以及writeset cache中的写集合数据。其中,block cache用区块高度为关键字、区块头数据为值进行缓存;transaction cache用交易哈希为关键字、交易数据为值进行缓存;writeset cache用表名加索引为关键字、写数据为值进行缓存。
在本申请的一个实施例中,账本模块被调用写入新的区块数据时,首先将区块以及区块执行结果写入日志管理组件中,如果写入日志管理组件失败,则 账本模块基于失败原因决定是否重试,当重试达到一定次数后终止该区块的落账处理,并通知相关维护人员进行检查修复。
在本申请的一个实施例中,账本模块在将区块数据写入日志管理组件中之后,将采用并发执行逻辑分别将区块头、交易数据(即交易信息列表以及交易执行结果)、写集合同时写入操作。具体的写入操作如下,写入区块头数据会按照block queue的规范(如格式要求等)生成一个区块头消息写入block queue,然后按照缓存管理组件block cache的要求写入缓存;写入交易数据同理按照transaction queue的规范生成一个交易列表消息写入transaction queue,然后按照transaction cache的要求写入缓存;写入写集合同理按照writeset queue的规范写入队列,然后将写集合写入writeset cache。当上述三类数据分别写入队列和缓存中之后,可以认为记账结束,此时可以开启下一轮的区块共识过程。由于上述三类数据采用并发写入,记账延迟以其中某一类数据写入延迟为准,大大降低了记账延迟。
为了持久化账本数据,上述的三个实时任务分别对三个队列进行监听,persist block job监听block queue是否有区块头消息需要写入存储,persist transaction job监听transaction queue是否有交易数据需要写入存储,persist writeset job监听writeset queue是否有写集合数据需要写入存储。
如果persist block job任务监听到block queue有区块头数据需要写入存储,则从block queue依次读取区块头数据,由于区块头数据是按照区块高度顺序放入block queue的,所以该任务读取出来的区块头数据也是按照区块高区顺序,不需要额外的排序处理,当任务读取到区块头数据后,调用存储层接口持久化区块数据。类似地,如果persist transaction job任务监听到transaction queue有交易数据需要写入存储,则从transaction queue依次读取交易数据,当任务读取到交易数据后,调用存储层接口持久化区块数据。如果persist writeset job任务监听到writeset queue有写集合数据需要写入存储,则从writeset queue依次读取写集合数据,当任务读取到写集合数据后,调用存储层接口持久化区块数据。
为了持久化数据,上述的三个任务需要保证调用存储层持久化过程正确返回,如果尝试持久化失败后重新调用存储层接口重试,重试的过程能保证数据的幂等性,不管尝试多少次,存储的数据和第一次持久化后的数据一致。
在本申请的一个实施例中,如上所述,当对某个区块的相关数据进行持久化处理之后,可以从日志管理组件中删除已经进行了持久化处理的区块及区块执行结果,进而及时对日志管理组件中存储的数据进行清理。同时,当对某个区块的相关数据进行持久化处理之后,可以从缓存中删除已经进行了持久化处理的区块所对应的各项数据,以及时清理block cache中的区块头数据、transaction cache中的交易数据以及writeset cache中的写集合数据。
本申请上述实施例的技术方案通过并行的对区块信息中包含的各项数据进行处理,降低了区块的落账延迟;另一方面在将数据写入消息队列及缓存中之后就可以开启下一轮的区块共识过程,无需等待区块中的各项数据的持久化过程,实现了异步落账的过程,提高了区块链网络的吞吐量,进而有效提升了区块链网络的处理性能。
以下介绍本申请的装置实施例,可以用于执行本申请上述实施例中的区块链的异步落账方法。对于本申请装置实施例中未披露的细节,请参照本申请上述的区块链的异步落账方法的实施例。
图5示出了根据本申请的一个实施例的区块链的异步落账装置的框图,该区块链的异步落账装置可以设置在区块链网络中的任意一个共识节点内。
参照图5所示,根据本申请的一个实施例的区块链的异步落账装置500,包括:第一处理单元502、第二处理单元504和持久化单元506。
其中,第一处理单元502配置为在区块达成共识之后,将所述区块所对应区块信息中包含的各项数据分别写入所述各项数据对应的消息队列中;第二处理单元504配置为在将所述各项数据分别写入对应的消息队列中之后,开启下一轮的区块共识过程;持久化单元506配置为分别从所述各项数据对应的消息队列中读取数据进行区块链账本的持久化处理。
在本申请的一些实施例中,基于前述方案,所述第一处理单元还配置为:将所述区块所对应区块信息中包含的各项数据分别写入所述各项数据对应的消息队列及缓存中。
在本申请的一些实施例中,基于前述方案,第一处理单元502还配置为:在所述区块达成共识之后,将所述区块及对应的区块执行结果写入日志中;针对所述日志中包含的目标区块,在对所述目标区块对应的各项数据进行持久化 处理之后,从所述日志中删除所述目标区块及所述目标区块的区块执行结果。
在本申请的一些实施例中,基于前述方案,第一处理单元502还配置为:在区块链节点重启后,获取所述日志中所包含的区块及区块执行结果;根据从所述日志中获取到的区块及区块执行结果进行持久化处理。
在本申请的一些实施例中,基于前述方案,第一处理单元502配置为:在将所述区块及对应的区块执行结果成功写入所述日志之后,将所述区块所对应区块信息中所包含的各项数据分别写入所述各项数据对应的消息队列中。
在本申请的一些实施例中,基于前述方案,第一处理单元502还配置为:若将所述区块及对应的区块执行结果写入所述日志失败,则进行重试处理,当重试次数达到设定次数后仍未成功写入所述日志,停止对所述区块进行落账处理并发出告警通知消息。
在本申请的一些实施例中,基于前述方案,第二处理单元504还配置为:在对目标区块对应的各项数据进行持久化处理之后,从所述缓存中删除所述目标区块对应的各项数据。
在本申请的一些实施例中,基于前述方案,第一处理单元502配置为:将所述区块信息中所包含的区块头写入区块头对应的队列中及缓存中,将所述区块信息中所包含的交易数据写入交易数据对应的队列中及缓存中,将所述区块信息中所包含的写集合写入写集合对应的队列中及缓存中,其中,所述交易数据包括交易信息列表及交易执行结果。
在本申请的一些实施例中,基于前述方案,所述区块信息中包含的各项数据包括:区块头、交易数据及写集合;第一处理单元502配置为:以区块高度作为关键字、区块头数据作为值,将所述区块信息中包含的区块头写入所述区块头对应的缓存中;以交易哈希作为关键字、交易数据作为值,将所述区块信息中包含的交易数据写入所述交易数据对应的缓存中;以表名和索引作为关键字、写数据作为值,将所述区块信息中包含的写集合写入所述写集合对应的缓存中。
在本申请的一些实施例中,基于前述方案,所述持久化单元506配置为:对所述各项数据对应的消息队列进行监听目标消息队列为所述各项数据对应的消息队列中的一个消息队列;若监听到所述目标消息队列中包含有数据,则 从所述目标消息队列中依次读取数据进行持久化处理。
在本申请的一些实施例中,基于前述方案,所述持久化单元506配置为:调用存储层接口对从所述目标消息队列中依次读取出的数据进行持久化处理;若持久化处理失败,则重新调用所述存储层接口对从所述目标消息队列中读取出的数据进行持久化处理,直到持久化处理成功。
在本申请的一些实施例中,基于前述方案,所述持久化单元506配置为:启动针对各个所述消息队列的监听任务;通过针对各个所述消息队列的监听任务,对所述各项数据对应的消息队列进行监听。
在本申请的一些实施例中,基于前述方案,第二处理单元504还配置为:在对所述区块信息完成持久化处理之前,通过所述缓存中存储的数据对业务请求进行响应。
图6示出了适于用来实现本申请实施例的电子设备的计算机系统的结构示意图。
需要说明的是,图6示出的电子设备的计算机系统600仅是一个示例,不应对本申请实施例的功能和使用范围带来任何限制。
如图6所示,计算机系统600包括中央处理单元(Central Processing Unit,CPU)601,其可以根据存储在只读存储器(Read-Only Memory,ROM)602中的程序或者从存储部分608加载到随机访问存储器(Random Access Memory,RAM)603中的程序而执行各种适当的动作和处理,例如执行上述实施例中所述的方法。在RAM 603中,还存储有系统操作所需的各种程序和数据。CPU 601、ROM 602以及RAM 603通过总线604彼此相连。输入/输出(Input/Output,I/O)接口605也连接至总线604。
以下部件连接至I/O接口605:包括键盘、鼠标等的输入部分606;包括诸如阴极射线管(Cathode Ray Tube,CRT)、液晶显示器(Liquid Crystal Display,LCD)等以及扬声器等的输出部分607;包括硬盘等的存储部分608;以及包括诸如LAN(Local Area Network,局域网)卡、调制解调器等的网络接口卡的通信部分609。通信部分609经由诸如因特网的网络执行通信处理。驱动器610也根据需要连接至I/O接口605。可拆卸介质611,诸如磁盘、光盘、磁光盘、半导体存储器等等,根据需要安装在驱动器610上,以便于从其上读出的计算 机程序根据需要被安装入存储部分608。
特别地,根据本申请的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本申请的实施例包括一种计算机程序产品,其包括承载在计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的计算机程序。在这样的实施例中,该计算机程序可以通过通信部分609从网络上被下载和安装,和/或从可拆卸介质611被安装。在该计算机程序被中央处理单元(CPU)601执行时,执行本申请的系统中限定的各种功能。
需要说明的是,本申请实施例所示的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(Erasable Programmable Read Only Memory,EPROM)、闪存、光纤、便携式紧凑磁盘只读存储器(Compact Disc Read-Only Memory,CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本申请中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本申请中,计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的计算机程序。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读的信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的计算机程序可以用任何适当的介质传输,包括但不限于:无线、有线等等,或者上述的任意合适的组合。
附图中的流程图和框图,图示了按照本申请各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。其中,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,上述模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应 当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图或流程图中的每个方框、以及框图或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。
描述于本申请实施例中所涉及到的单元可以通过软件的方式实现,也可以通过硬件的方式来实现,所描述的单元也可以设置在处理器中。其中,这些单元的名称在某种情况下并不构成对该单元本身的限定。
作为另一方面,本申请还提供了一种计算机可读介质,该计算机可读介质可以是上述实施例中描述的电子设备中所包含的;也可以是单独存在,而未装配入该电子设备中。上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被一个该电子设备执行时,使得该电子设备实现上述实施例中所述的方法。
应当注意,尽管在上文详细描述中提及了用于动作执行的设备的若干模块或者单元,但是这种划分并非强制性的。实际上,根据本申请的实施方式,上文描述的两个或更多模块或者单元的特征和功能可以在一个模块或者单元中具体化。反之,上文描述的一个模块或者单元的特征和功能可以进一步划分为由多个模块或者单元来具体化。
通过以上的实施方式的描述,本领域的技术人员易于理解,这里描述的示例实施方式可以通过软件实现,也可以通过软件结合必要的硬件的方式来实现。因此,根据本申请实施方式的技术方案可以以软件产品的形式体现出来,该软件产品可以存储在一个非易失性存储介质(可以是CD-ROM,U盘,移动硬盘等)中或网络上,包括若干指令以使得一台计算设备(可以是个人计算机、服务器、触控终端、或者网络设备等)执行根据本申请实施方式的方法。
本领域技术人员在考虑说明书及实践这里公开的实施方式后,将容易想到本申请的其它实施方案。本申请旨在涵盖本申请的任何变型、用途或者适应性变化,这些变型、用途或者适应性变化遵循本申请的一般性原理并包括本申请未公开的本技术领域中的公知常识或惯用技术手段。
应当理解的是,本申请并不局限于上面已经描述并在附图中示出的精确结构,并且可以在不脱离其范围进行各种修改和改变。本申请的范围仅由所附的权利要求来限制。

Claims (17)

  1. 一种区块链的异步落账方法,所述方法由所述区块链中的共识节点执行,所述方法包括:
    在区块达成共识之后,将所述区块所对应区块信息中包含的各项数据分别写入所述各项数据对应的消息队列中;
    在将所述各项数据分别写入对应的消息队列中之后,开启下一轮的区块共识过程;
    分别从所述各项数据对应的消息队列中读取数据进行区块链账本的持久化处理。
  2. 根据权利要求1所述的方法,其中所述将所述区块所对应区块信息中包含的各项数据分别写入所述各项数据对应的消息队列中,包括:
    将所述区块所对应区块信息中包含的各项数据分别写入所述各项数据对应的消息队列及缓存中。
  3. 根据权利要求1所述的异步落账方法,其中所述异步落账方法还包括:
    在所述区块达成共识之后,将所述区块及对应的区块执行结果写入日志中;
    针对所述日志中包含的目标区块,在对所述目标区块对应的各项数据进行持久化处理之后,从所述日志中删除所述目标区块及所述目标区块的区块执行结果。
  4. 根据权利要求3所述的异步落账方法,其中所述异步落账方法还包括:
    在区块链节点重启后,获取所述日志中所包含的区块及区块执行结果;
    根据从所述日志中获取到的区块及区块执行结果进行持久化处理。
  5. 根据权利要求3所述的异步落账方法,其中所述将所述区块所对应区块信息中包含的各项数据分别写入所述各项数据对应的消息队列中,包括:
    在将所述区块及对应的区块执行结果成功写入所述日志之后,将所述区块所对应区块信息中所包含的各项数据分别写入所述各项数据对应的消息队列中。
  6. 根据权利要求5所述的异步落账方法,其中所述异步落账方法还包括:
    若将所述区块及对应的区块执行结果写入所述日志失败,则进行重试处理,当重试次数达到设定次数后仍未成功写入所述日志,停止对所述区块进行落账 处理并发出告警通知消息。
  7. 根据权利要求2所述的异步落账方法,其中所述异步落账方法还包括:
    在对目标区块对应的各项数据进行持久化处理之后,从所述缓存中删除所述目标区块对应的各项数据。
  8. 根据权利要求2所述的异步落账方法,其中所述将所述区块所对应区块信息中包含的各项数据分别写入所述各项数据对应的消息队列及缓存中,包括:
    将所述区块信息中所包含的区块头写入区块头对应的队列中及缓存中,将所述区块信息中所包含的交易数据写入交易数据对应的队列中及缓存中,将所述区块信息中所包含的写集合写入写集合对应的队列中及缓存中,其中,所述交易数据包括交易信息列表及交易执行结果。
  9. 根据权利要求2所述的异步落账方法,其中所述区块信息中包含的各项数据包括:区块头、交易数据及写集合;
    所述将所述区块所对应区块信息中包含的各项数据分别写入所述各项数据对应的缓存中,包括:
    以区块高度作为关键字、区块头数据作为值,将所述区块信息中包含的区块头写入所述区块头对应的缓存中;
    以交易哈希作为关键字、交易数据作为值,将所述区块信息中包含的交易数据写入所述交易数据对应的缓存中;
    以表名和索引作为关键字、写数据作为值,将所述区块信息中包含的写集合写入所述写集合对应的缓存中。
  10. 根据权利要求1所述的异步落账方法,其中所述分别从所述各项数据对应的消息队列中读取数据进行区块链账本的持久化处理,包括:
    对所述各项数据对应的消息队列进行监听,目标消息队列为所述各项数据对应的消息队列中的一个消息队列;
    若监听到所述目标消息队列中包含有数据,则从所述目标消息队列中依次读取数据进行持久化处理。
  11. 根据权利要求10所述的异步落账方法,其中所述从所述目标消息队列中依次读取数据进行持久化处理,包括:
    调用存储层接口对从所述目标消息队列中依次读取出的数据进行持久化处理;
    若持久化处理失败,则重新调用所述存储层接口对从所述目标消息队列中读取出的数据进行持久化处理,直到持久化处理成功。
  12. 根据权利要求10所述的异步落账方法,其中所述对所述各项数据对应的消息队列进行监听,包括:
    启动针对各个所述消息队列的监听任务;
    通过针对各个所述消息队列的监听任务,对所述各项数据对应的消息队列进行监听。
  13. 根据权利要求2所述的异步落账方法,其中所述异步落账方法还包括:
    在对所述区块信息完成持久化处理之前,通过所述缓存中存储的数据对业务请求进行响应。
  14. 一种区块链的异步落账装置,包括:
    第一处理单元,配置为在区块达成共识之后,将所述区块所对应区块信息中包含的各项数据分别写入所述各项数据对应的消息队列中;
    第二处理单元,配置为在将所述各项数据分别写入所述各项数据对应的消息队列中之后,开启下一轮的区块共识过程;
    持久化单元,配置为分别从所述各项数据对应的消息队列中读取数据进行区块链账本的持久化处理。
  15. 一种计算机可读介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现如权利要求1至13中任一项所述的区块链的异步落账方法。
  16. 一种电子设备,包括:
    一个或多个处理器;
    存储装置,用于存储一个或多个程序,当所述一个或多个程序被所述一个或多个处理器执行时,使得所述一个或多个处理器实现如权利要求1至13中任一项所述的区块链的异步落账方法。
  17. 一种包括指令的计算机程序产品,当其在计算机上运行时,使得所述计算机执行权利要求1至13中任一项所述的区块链的异步落账方法。
PCT/CN2021/130637 2020-12-28 2021-11-15 区块链的异步落账方法、装置、介质及电子设备 WO2022142781A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP21913524.1A EP4207688A4 (en) 2020-12-28 2021-11-15 ASYNCHRONOUS ACCOUNTING METHOD AND DEVICE FOR BLOCKCHAIN, MEDIUM AND ELECTRONIC DEVICE
US17/974,233 US20230052935A1 (en) 2020-12-28 2022-10-26 Asynchronous accounting method and apparatus for blockchain, medium and electronic device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011577543.1 2020-12-28
CN202011577543.1A CN112291372B (zh) 2020-12-28 2020-12-28 区块链的异步落账方法、装置、介质及电子设备

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US17/974,233 Continuation US20230052935A1 (en) 2020-12-28 2022-10-26 Asynchronous accounting method and apparatus for blockchain, medium and electronic device

Publications (1)

Publication Number Publication Date
WO2022142781A1 true WO2022142781A1 (zh) 2022-07-07

Family

ID=74426470

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/130637 WO2022142781A1 (zh) 2020-12-28 2021-11-15 区块链的异步落账方法、装置、介质及电子设备

Country Status (4)

Country Link
US (1) US20230052935A1 (zh)
EP (1) EP4207688A4 (zh)
CN (1) CN112291372B (zh)
WO (1) WO2022142781A1 (zh)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112291372B (zh) * 2020-12-28 2021-04-13 腾讯科技(深圳)有限公司 区块链的异步落账方法、装置、介质及电子设备
CN113220795B (zh) * 2021-02-19 2022-06-24 腾讯科技(深圳)有限公司 基于分布式存储的数据处理方法、装置、设备以及介质
CN113596010B (zh) * 2021-07-23 2023-04-28 腾讯科技(深圳)有限公司 一种数据处理方法、装置、节点设备及计算机存储介质
CN113326165B (zh) * 2021-08-04 2021-11-16 腾讯科技(深圳)有限公司 基于区块链的数据处理方法、设备及计算机可读存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160164884A1 (en) * 2014-12-05 2016-06-09 Skuchain, Inc. Cryptographic verification of provenance in a supply chain
US20170132615A1 (en) * 2015-11-11 2017-05-11 Bank Of America Corporation Block chain alias for person-to-person payments
CN108804112A (zh) * 2018-05-22 2018-11-13 上海分布信息科技有限公司 一种区块链落账处理方法及系统
CN110135178A (zh) * 2019-04-11 2019-08-16 贝克链区块链技术有限公司 区块链验证中的零延迟账本访问技术
CN112291372A (zh) * 2020-12-28 2021-01-29 腾讯科技(深圳)有限公司 区块链的异步落账方法、装置、介质及电子设备

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8627333B2 (en) * 2011-08-03 2014-01-07 International Business Machines Corporation Message queuing with flexible consistency options
CN107402824B (zh) * 2017-05-31 2020-06-02 创新先进技术有限公司 一种数据处理的方法及装置
US10761877B2 (en) * 2017-07-21 2020-09-01 Intel Corporation Apparatuses, methods, and systems for blockchain transaction acceleration
CN110581887B (zh) * 2019-09-02 2021-03-30 北京海益同展信息科技有限公司 数据处理方法、装置、区块链节点及存储介质
CN110659988B (zh) * 2019-09-10 2022-11-18 杭州秘猿科技有限公司 区块链共识与执行的并行处理方法、装置和电子设备
WO2019228568A2 (en) * 2019-09-12 2019-12-05 Alibaba Group Holding Limited Log-structured storage systems
CN110995776B (zh) * 2019-10-12 2021-11-02 平安科技(深圳)有限公司 区块链的区块分发方法、装置、计算机设备和存储介质
CN111222882A (zh) * 2020-01-03 2020-06-02 腾讯科技(深圳)有限公司 基于区块链的数据传输方法、装置、设备及可读存储介质
CN111556115B (zh) * 2020-04-22 2023-04-21 财付通支付科技有限公司 一种基于区块链的数据处理方法、装置、设备及存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160164884A1 (en) * 2014-12-05 2016-06-09 Skuchain, Inc. Cryptographic verification of provenance in a supply chain
US20170132615A1 (en) * 2015-11-11 2017-05-11 Bank Of America Corporation Block chain alias for person-to-person payments
CN108804112A (zh) * 2018-05-22 2018-11-13 上海分布信息科技有限公司 一种区块链落账处理方法及系统
CN110135178A (zh) * 2019-04-11 2019-08-16 贝克链区块链技术有限公司 区块链验证中的零延迟账本访问技术
CN112291372A (zh) * 2020-12-28 2021-01-29 腾讯科技(深圳)有限公司 区块链的异步落账方法、装置、介质及电子设备

Non-Patent Citations (1)

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

Also Published As

Publication number Publication date
EP4207688A1 (en) 2023-07-05
CN112291372B (zh) 2021-04-13
CN112291372A (zh) 2021-01-29
US20230052935A1 (en) 2023-02-16
EP4207688A4 (en) 2024-03-27

Similar Documents

Publication Publication Date Title
WO2022142781A1 (zh) 区块链的异步落账方法、装置、介质及电子设备
CN113711536B (zh) 从区块链网络中提取数据
CN110990182B (zh) 事务处理方法、装置、设备及存储介质
US11341121B2 (en) Peer partitioning
CN113254466B (zh) 一种数据处理方法、装置、电子设备和存储介质
US11188920B2 (en) Autocommit transaction management in a blockchain network
US10949413B2 (en) Method and system for supporting data consistency on an active standby database after DML redirection to a primary database
US9910881B1 (en) Maintaining versions of control plane data for a network-based service control plane
US20160048703A1 (en) Securing integrity and consistency of a cloud storage service with efficient client operations
US11627122B2 (en) Inter-system linking method and node
CN111694743A (zh) 业务系统的检测方法及装置
US9448827B1 (en) Stub domain for request servicing
CN112685499A (zh) 一种工作业务流的流程数据同步方法、装置及设备
US20220245146A1 (en) Systems, methods, and apparatuses for implementing off-stack batch querying for virtual entities using a bulk api
CN109189652A (zh) 一种封闭网络终端行为数据的采集方法及系统
CN112926981B (zh) 用于区块链的交易信息处理方法、装置、介质及电子设备
US11550692B2 (en) Integrated event processing and policy enforcement
US11340964B2 (en) Systems and methods for efficient management of advanced functions in software defined storage systems
JP7305898B2 (ja) 操作応答方法、操作応答装置、電子機器及び記憶媒体
US20230153450A1 (en) Privacy data management in distributed computing systems
US20230396448A1 (en) Client secure connections for database host
WO2022140948A1 (zh) 账户管理方法、系统、服务器及介质
CN117891794A (zh) 日志的生成方法、装置、终端设备及存储介质

Legal Events

Date Code Title Description
ENP Entry into the national phase

Ref document number: 2021913524

Country of ref document: EP

Effective date: 20230330

NENP Non-entry into the national phase

Ref country code: DE