WO2023011022A1 - 基于区块链的数据处理方法、设备及计算机可读存储介质 - Google Patents

基于区块链的数据处理方法、设备及计算机可读存储介质 Download PDF

Info

Publication number
WO2023011022A1
WO2023011022A1 PCT/CN2022/099782 CN2022099782W WO2023011022A1 WO 2023011022 A1 WO2023011022 A1 WO 2023011022A1 CN 2022099782 W CN2022099782 W CN 2022099782W WO 2023011022 A1 WO2023011022 A1 WO 2023011022A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
data storage
component
block
storage component
Prior art date
Application number
PCT/CN2022/099782
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 腾讯科技(深圳)有限公司
Publication of WO2023011022A1 publication Critical patent/WO2023011022A1/zh
Priority to US18/300,191 priority Critical patent/US20230259526A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1471Saving, restoring, recovering or retrying involving logging of persistent data for recovery
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1448Management of the data involved in backup or backup restore
    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0766Error or fault reporting or storing
    • G06F11/0787Storage of error reports, e.g. persistent data storage, storage using memory protection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1458Management of the backup or restore process
    • G06F11/1464Management of the backup or restore process for networked environments
    • 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/2365Ensuring data consistency and integrity
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/64Protecting data integrity, e.g. using checksums, certificates or signatures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0655Vertical data movement, i.e. input-output transfer; data movement between one or more hosts and one or more storage devices
    • G06F3/0656Data buffering arrangements
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/067Distributed or networked storage systems, e.g. storage area networks [SAN], network attached storage [NAS]
    • 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
    • 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]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0894Escrow, recovery or storing of secret information, e.g. secret key escrow or cryptographic key storage
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/50Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using hash chains, e.g. blockchains or hash trees
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2201/00Indexing scheme relating to error detection, to error correction, and to monitoring
    • G06F2201/81Threshold

Definitions

  • the present application relates to the field of Internet technologies, and in particular to a blockchain-based data processing method, device, and computer-readable storage medium.
  • the blockchain node After the blockchain network reaches a consensus on the block, the blockchain node needs to write the block and the information associated with the block into the ledger.
  • the existing node bookkeeping method is to associate the block and the block
  • the information is written serially into the ledger (which can include disk and distributed storage), for example, first write the block header in the block passed by the consensus to the disk or distributed storage, and after this step is completed, continue to write the transaction list and transaction execution
  • the result sets are written to disk or distributed storage respectively. After the transaction list and transaction execution result set are written, write the write set to disk or distributed storage. After the write set is written, the node bookkeeping is completed and the next round of consensus starts. Block out. At present, the block settlement process not only has the defect of poor performance, but also causes a large delay in each round of block settlement.
  • a blockchain-based data processing method, device, and computer-readable storage medium are provided.
  • an embodiment of the present application provides a blockchain-based data processing method executed by a computer device, including:
  • more than one data set to be accounted for perform data write operation on more than one data storage component in parallel, and obtain data storage results corresponding to more than one data storage component respectively; wherein, the number of data storage components and the data set to be accounted for The number is the same, and one data storage component is used to store a collection of data to be accounted for in one data category;
  • the block checkpoint corresponding to the block file If there is a data storage failure result in the data storage result, obtain the block checkpoint corresponding to the block file, and the component checkpoints corresponding to more than one data storage component respectively; the block checkpoint is the largest block in the block file height, the component checkpoint includes the respective maximum block heights in more than one data storage component; and
  • the block checkpoint and the component checkpoint determine the data storage component belonging to the abnormal state of the component in more than one data storage component, and perform data writing operation on the data storage component belonging to the abnormal state of the component according to the block file.
  • the embodiment of the present application provides a blockchain-based data processing device, including:
  • the first obtaining module is used to obtain the block file, and obtains more than one data set to be accounted for the block from the block file; the data categories of the more than one data set to be accounted are different from each other;
  • the second acquisition module is used to perform data write operations on more than one data storage component in parallel according to more than one data set to be accounted for, and acquire data storage results corresponding to more than one data storage component; wherein, the data storage component The number is the same as the number of data sets to be accounted for, and one data storage component is used to store data sets to be accounted for in one data category;
  • the second acquisition module is also used to obtain the block checkpoint corresponding to the block file and the component checkpoints corresponding to more than one data storage component if there is a data storage failure result in the data storage result;
  • the block checkpoint is the maximum block height in the block file, the component checkpoint includes the respective maximum block heights in more than one data storage component;
  • the first determination module is used to determine the data storage components belonging to the abnormal state of the component in more than one data storage component according to the block checkpoint and the component checkpoint, and perform data execution on the data storage component belonging to the abnormal state of the component according to the block file write operation.
  • One aspect of the present application provides a computer device, including: one or more processors, memory, and network interface; the above-mentioned one or more processors are connected to the above-mentioned memory and the above-mentioned network interface, wherein the above-mentioned network interface is used to provide data Communication function, the above-mentioned memory is used to store computer-readable instructions, and the above-mentioned processor is used to call the above-mentioned computer-readable instructions, so that the computer device executes the method in the embodiment of the present application.
  • the embodiments of the present application provide one or more non-volatile computer-readable storage media storing computer-readable instructions.
  • the computer-readable storage medium stores computer-readable instructions.
  • the computer-readable instructions are suitable for The method in the embodiment of the present application is loaded and executed by one or more processors.
  • Embodiments of the present application provide a computer program product on the one hand, where the computer program product includes computer-readable instructions, and the computer-readable instructions are stored in a computer-readable storage medium; a processor of a computer device reads from the computer-readable storage medium Taking the computer instruction, the processor executes the computer-readable instruction, so that the computer device executes the method in the embodiment of the present application.
  • FIG. 1 is a schematic diagram of a system architecture provided by an embodiment of the present application.
  • FIG. 2 is a schematic flow diagram of a blockchain-based data processing method provided by an embodiment of the present application.
  • FIG. 3a is a schematic diagram of a blockchain-based data processing scenario provided by an embodiment of the present application.
  • Fig. 3b is a schematic diagram of a blockchain-based data processing scenario provided by an embodiment of the present application.
  • FIG. 4 is a schematic flow diagram of a blockchain-based data processing method provided by an embodiment of the present application.
  • FIG. 5 is a schematic diagram of a blockchain-based data processing scenario provided by an embodiment of the present application.
  • FIG. 6 is a schematic structural diagram of a blockchain-based data processing device provided by an embodiment of the present application.
  • Fig. 7 is a schematic structural diagram of a computer device provided by an embodiment of the present application.
  • Block chain In a narrow sense, block chain is a chained data structure with block as the basic unit. The digital summary is used in the block to verify the transaction history obtained before, which is suitable for distributed Anti-tampering and scalability requirements in accounting scenarios; in a broad sense, blockchain also refers to distributed accounting technology implemented by blockchain structure, including distributed consensus, privacy and security protection, point-to-point communication technology, network protocol , smart contracts, etc. The goal of the blockchain is to implement a distributed data record ledger, which only allows addition and does not allow deletion.
  • the underlying structure of the ledger is a linear linked list. The linked list is composed of "blocks" in series. The hash (Hash) value of the previous block is recorded in the subsequent block.
  • each block (and the transaction in the block) is legal can be calculated by calculating the hash value. way for a quick check. If a node in the network proposes to add a new block, it must go through a consensus mechanism to reach a consensus on the block.
  • Block It is a data packet that carries transaction data on the blockchain network. It is a data structure marked with a timestamp and the hash value corresponding to the previous block. The block passes the consensus of the network Mechanisms verify and confirm transactions in blocks.
  • a block includes a block header (Block Header) and a block body (Block Body).
  • the block header can record the meta information of the current block, including the current version number, the hash value corresponding to the previous block, timestamp, random number, Data such as the hash value of the Merkle Root.
  • the block body can record detailed data generated over a period of time, including all transaction records or other information generated during the verification of the current block and the block creation process, which can be understood as a form of ledger.
  • the detailed data of the block body can include the hash process of the Merkle Tree to generate a unique Merkle Root record in the block header.
  • the predecessor block also known as the parent block (Parent Block)
  • the blockchain achieves time sorting by recording the hash value corresponding to the block and the hash value corresponding to the parent block in the block header.
  • Hash value Also known as information feature value or feature value, the hash value is generated by converting input data of any length into a password through a hash algorithm and performing fixed output. It cannot be decrypted by decrypting the hash value To retrieve the original input data, it is a one-way encryption function.
  • each block except the initial block contains the hash value of the previous block, the hash value is the potential core foundation and the most important aspect in the blockchain technology, it keeps the record And look at the authenticity of the data, and the integrity of the blockchain as a whole.
  • Smart Contract It is a computer protocol designed to disseminate, verify or execute contracts in an informational manner.
  • a smart contract (referred to as a contract) is a code that each node of the blockchain can understand and execute, and can execute arbitrary logic and obtain results.
  • smart contracts are managed and tested through transactions on the blockchain. Each transaction is equivalent to a Remote Procedure Call (RPC) request to the blockchain system.
  • RPC Remote Procedure Call
  • the blockchain is equivalent to an operating system that provides an operating environment.
  • the blockchain can contain multiple contracts, distinguished by contract account (Identity, ID), identification number or name.
  • Contract execution By initiating a transaction, the user can call the deployed contract on the blockchain. Each node in the blockchain system runs the same contract respectively. For contracts that need to read data, the node's own ledger will be accessed. In the end, each node will verify whether the execution results are consistent (consensus), and if the execution results are consistent, each node will store the necessary results in its own ledger and return the result to the user.
  • Read-write set the operation record of the node ledger data during the execution of the contract. It is divided into read set and write set, which respectively refer to the data read from the ledger and the data to be written into the ledger when the smart contract is executed.
  • Blockchain nodes The blockchain network divides nodes into consensus nodes (also called core nodes) and synchronization nodes (which may include data nodes and light nodes). Among them, the consensus node is responsible for the consensus business of the entire blockchain network; the synchronization node is responsible for synchronizing the ledger information of the consensus node, that is, synchronizing the latest block data. Whether it is a consensus node or a synchronization node, its internal structure includes network communication components, because the blockchain network is essentially a peer-to-peer (Peer to Peer, P2P) network, which needs to communicate with other nodes in the blockchain network through P2P components . The resources and services in the blockchain network are scattered on each node, and the transmission of information and the realization of services are carried out directly between nodes without the intervention of intermediate links or centralized servers (third parties).
  • P2P peer-to-peer
  • FIG. 1 is a schematic diagram of a system architecture provided by an embodiment of the present application.
  • the system architecture can be a blockchain network, wherein the blockchain network can include a consensus network 101 and a synchronization network 102; the nodes in the synchronization network 102 can be called synchronization nodes, and the synchronization nodes mainly perform business execution , do not participate in the bookkeeping consensus, and obtain block data from the consensus network 101 through identity authentication.
  • the consensus network 101 can also be called a core network, and the nodes in the consensus network 101 can be called consensus nodes, which have full data.
  • the consensus network 101 and the synchronization network 102 may be in different network environments.
  • the consensus network 101 is in a private network, while the synchronization network 102 is in a public network, and the two interact through routing boundaries.
  • the consensus network 101 may include a consensus node 1011 , a consensus node 1012 , . . . , a consensus node 1013 .
  • the aforementioned consensus network 101 may include one or more consensus nodes, and the number of consensus nodes will not be limited here.
  • the synchronization network 102 may include a synchronization node 1021 , a synchronization node 1022 , a synchronization node 1023 , . . . , a synchronization node 1024 and a synchronization node 1025 .
  • the synchronization network 102 may include one or more synchronization nodes, and the number of synchronization nodes will not be limited here.
  • Each node (including the consensus node in the consensus network 101 and the synchronization node in the synchronization network 102) can receive the transaction data (equivalent to the transaction information) sent by the client when it is working normally, and based on the received transaction data Generate a block, and then process the block on the chain.
  • there may be a data connection between each node for example, there is a data connection between the consensus node 1011 and the consensus node 1012, there is a data connection between the consensus node 1011 and the consensus node 1013, and the synchronization node 1021 There is a data connection with the synchronization node 1023 and so on.
  • there is a data connection between the consensus network 101 and the synchronization network 102 for example, there is a data connection between the consensus node 1011 and the synchronization node 1022, there is a data connection between the consensus node 1012 and the synchronization node 1023, and so on.
  • data or block transmission can be performed between nodes through the above-mentioned data connection.
  • the data connection between the above nodes can be based on the node identification.
  • each node in the blockchain network there is a node identification corresponding to it, and each of the above nodes can store the node identification of other nodes that are connected to itself , so that the obtained data or generated blocks can be broadcast to other nodes based on the node IDs of other nodes.
  • the consensus node 1011 can maintain a node ID list, which stores the node names and node IDs of other nodes . As shown in Table 1:
  • the node identification can be the Internet Protocol (IP) address between the networks and any other information that can be used to identify the nodes in the blockchain network.
  • IP Internet Protocol
  • Table 1 only uses the IP address as an example for illustration.
  • the consensus node 1011 can send a data synchronization request to the synchronization node 1021 through the node ID 117.114.151.183, and the synchronization node 1021 can know the data synchronization request through the node ID 117.116.156.425 is sent by the consensus node 1011; similarly, the synchronization node 1023 can send transaction data A to the consensus node 1011 through the node identification 117.116.156.425, and the consensus node 1011 can know that the transaction data A is synchronous through the node identification 119.250.485.362 What is sent by node 1023 is also the same for data transmission between other nodes.
  • IP Internet Protocol
  • the above-mentioned data connection is not limited to the connection method, it can be directly or indirectly connected by wired communication method, it can also be directly or indirectly connected by wireless communication method, and it can also be connected by other connection methods. No restrictions. Among them, the consensus node 1011, the consensus node 1012, ..., the consensus node 1013, the synchronization node 1021, the synchronization node 1022, the synchronization node 1023, ..., the synchronization node 1024, and the synchronization node 1025 in FIG. Computers, laptops, handheld computers, smart speakers, mobile internet devices (MID, mobile internet device), POS (Point Of Sales, point of sale) machines, wearable devices (such as smart watches, smart bracelets, etc.), etc.
  • MID mobile internet device
  • POS Point Of Sales, point of sale
  • the blockchain-based data processing method provided in the embodiment of the present application can be executed by a computer device, and the computer device includes but is not limited to a terminal or a server.
  • the above-mentioned server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, and can also provide cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, Cloud servers for basic cloud computing services such as middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms.
  • the aforementioned terminals may be smart phones, tablet computers, notebook computers, desktop computers, smart speakers, smart watches, vehicle-mounted terminals, and smart TVs, but are not limited thereto.
  • the terminal and the server may be connected directly or indirectly through wired or wireless communication, which is not limited in this application.
  • FIG. 2 is a schematic flowchart of a blockchain-based data processing method provided by an embodiment of the present application.
  • the blockchain-based data processing method can be executed by a computer device, and the computer device can include any consensus node in the consensus network 101 in FIG. 1 .
  • the data processing process may include:
  • Step S101 obtain a block file, and obtain more than one data set to be accounted for the block from the block file; the data types of the more than one data sets to be accounted are different from each other.
  • the number of data sets to be accounted for is more than one, such as m, where m is a positive integer greater than 1, and the respective data categories of each data set to be accounted for are different from each other.
  • the m data categories may include block category, status category and read/write category.
  • the computer device can obtain the block data associated with the block type from the block file, generate a block data set according to the block data; obtain the state data associated with the state type from the block file , generate a state data set according to the state data; obtain the read-write data associated with the read-write category from the block file, and generate a read-write data set according to the read-write data; according to the block data set, state data set, and read-write data set , generating m data sets to be accounted for. For each data category, an index pair can be constructed based on the data associated with the data category to generate a corresponding set of data to be accounted for.
  • the block data includes transaction information and block information
  • the block information includes a transaction identifier of the transaction information
  • an index pair can be constructed for the transaction information and the block information to generate a block data set.
  • the specific process of generating a block data set according to the block data may include: the computer device uses the transaction identifier as the first index key, uses the transaction information as the first index value, and determines the first index key and the first index value as the first index Yes; use the block height corresponding to the block information as the second index key, use the block information as the second index value, and determine the second index key and the second index value as the second index pair; use the block information corresponding to
  • the block identifier is used as the third index key, the block height corresponding to the block information is used as the third index value, and the third index key and the third index value are determined as the third index pair; the first index pair, the second index pair and the third index pair to generate a block data set.
  • the block height can be used to describe the position of the corresponding block in the
  • the corresponding block height constructs the third index pair, and generates the block data set according to the first index pair, the second index pair and the third index pair, so as to obtain the block data set including various block information, through the block Data collection can be written in parallel, which can improve the network performance of the blockchain and reduce the response time of external business.
  • the specific process of generating the state data set according to the state data may include: the computer device combines the contract identifier and the object identifier into a fourth index key, uses the state data as the fourth index value, and combines the fourth index key and the The four index values are determined as the fourth index pair; obtain the version identification corresponding to the historical state data of the object identification, and generate the corresponding version identification of the state data according to the version identification corresponding to the historical state data; use the state data and the version identification corresponding to the state data as the first For five index keys, the block height corresponding to the state data is used as the fifth index value, and the fifth index key and the fifth index value are determined as the fifth index pair; the fourth index pair and the fifth index pair are used to generate a state data set.
  • the fourth index pair is constructed by constructing the contract identifier, the object identifier, and the state data
  • the fifth index pair is constructed by constructing the state data, the version identifier corresponding to the state data, and the block height corresponding to the state data, and according to the fourth index
  • the pair and the fifth index pair generate a state data set, so as to obtain a state data set including various block information.
  • Parallel write processing can be performed through the state data set, which can improve the network performance of the blockchain and reduce the response time of external business.
  • the read and write data includes read data and write data; the specific process of generating the read and write data set according to the read and write data may include: the computer device uses the read data identifier of the read data as the sixth index key, and uses the read data as the sixth index key.
  • the sixth index value, the sixth index key and the sixth index value are determined as the sixth index pair; the write data identifier of the write data is used as the seventh index key, the write data is used as the seventh index value, and the seventh index key and The seventh index value is determined as the seventh index pair; the block height corresponding to the read data is used as the eighth index key, the read data identifier is used as the eighth index value, and the eighth index key and the eighth index value are determined as the eighth index Yes; use the block height corresponding to the write data as the ninth index key, use the write data identifier as the ninth index value, determine the ninth index key and the ninth index value as the ninth index pair; use the sixth index pair, the The seventh index pair, the eighth index pair, and the ninth index pair generate read and write data sets.
  • the sixth index pair of the read data identification and the read data of the read data by constructing the sixth index pair of the read data identification and the read data of the read data, constructing the seventh index pair of the write data identification and the write data of the write data, and combining the block height corresponding to the read data with the read data identification Construct the eighth index pair, construct the ninth index pair with the block height corresponding to the write data and the write data identifier, and generate the read and write data set according to the sixth index pair, the seventh index pair, the eighth index pair and the ninth index pair , thus including the read and write data sets of various block information, through which parallel write processing can be performed through the read and write data sets, which can improve the network performance of the blockchain and reduce the response time of external business.
  • FIG. 3a is a schematic diagram of a blockchain-based data processing scenario provided by an embodiment of the present application.
  • the consensus result of the block 20a in the blockchain network 20b is a consensus result, so the consensus node 20c can write the block 20a into the block file 20d.
  • the block 20a may include one or more blocks.
  • the block file 20d can be understood as a database of the consensus node 20c, which is used to store the block 20a, the read-write data and status data of the block 20a, etc., and can be used in the process of writing the data set to be accounted. after the recovery.
  • the block file 20a records the maximum block height as a block checkpoint. It can be understood that the maximum block height is generally the maximum block height in the block 20a.
  • the consensus node 20c may not add the new block first In the block file 20d, after the block 20a is written into the disk or distributed storage, a new block is added to the block file 20d. At this time, the block file 20d can record the newly added block The maximum block height for new block checkpoints.
  • the consensus node 20c can write the new The block is added to the block file 20d, but the block checkpoint is not updated temporarily, that is, the block checkpoint is the maximum block height in the block 20a, and the block is updated after the block 20a is successfully written into the ledger checking point.
  • the embodiment of this application adds a version identifier for each state in the ledger. Whenever the contract business that executes the transaction changes a certain state, the version identifier of the state can be increased by 1 and mapped to the changed block height at the same time. Indicates that the modification occurred in a certain block.
  • the state can be understood as an object in the ledger, such as a user account, etc.; the version identifier can be customized, and the embodiment of the present application does not limit the version identifier, which can be any kind of information that can be used to identify the state.
  • the consensus node 20c writes the block 20a into the block file 20d according to the relationship of the data index, that is, writes the data sets to be accounted into the block file 20d according to the data category; the consensus node 20a also The block 20a can be directly written into the block file 20d.
  • the data in the block 20a is classified according to the data category to generate m data sets to be accounted for.
  • the embodiment of the present application The generation time point of the m data sets to be accounted for is not limited, and can be set according to the actual application scenario. Wherein, the embodiment of the present application does not limit the data category, which can be set according to the actual application scenario.
  • the block category refers to the category corresponding to the block data.
  • the block data can include transaction information (ie, transaction details data) and block information.
  • the block information includes the transaction identification of the transaction information.
  • the transaction identification can be the corresponding transaction information. hash value.
  • the status category refers to the category corresponding to the status data.
  • the status data can include the current record or characteristics of an object. For example, the object a has performed a transaction d based on the contract c at the time stamp b.
  • the embodiment of this application does not limit the form of the status data, which can be Set according to the actual application scenario.
  • the read-write category refers to the category corresponding to the read-write data corresponding to the transaction information.
  • the consensus node 20c obtains from the block file 20d the data sets to be accounted for which are different from each other for the three data categories of the block 20a, as shown in FIG.
  • the data set 201e to be accounted for may be a block data set whose data type is a block type.
  • An index value, the first index key and the first index value are determined as the first index pair; further, the block height corresponding to the block information is used as the second index key, and the block information is used as the second index value, and the The second index key and the second index value are determined as the second index pair; further, the block identifier (which may be a block hash) corresponding to the block information is used as the third index key, and the block information corresponding to the block The height is used as the third index value, and the third index key and the third index value are determined as the third index pair; the consensus node 20c generates the block data set from the first index pair, the second index pair, and the third index pair.
  • the data set 202e to be accounted for may be a state data set whose data type is a state type, and the state data set is a data mapping table, specifically, the contract identifier and the object identifier may be combined as the fourth index key, and the state data may be used as the fourth index key.
  • the fourth index value determine the fourth index key and the fourth index value as the fourth index pair, where the contract identifier can be any kind of information that can identify the contract, such as the contract storage address, contract name, etc.
  • the object The identifier can be any kind of information that can identify the object, such as the object account number, etc.
  • the embodiment of this application does not limit the contract identifier and the object identifier; obtain the version identifier corresponding to the historical state data of the object identifier, according to the version corresponding to the historical state data Identify the version identifier corresponding to the generated status data; use the status data and the version identifier corresponding to the status data as the fifth index key, use the block height corresponding to the status data as the fifth index value, and determine the fifth index key and the fifth index value For the fifth index pair; the consensus node 20c generates a state data set for the fourth index pair and the fifth index pair.
  • the data set to be booked 203e may be a read-write data set whose data category is a read-write category. value) as the sixth index key, the read data as the sixth index value, the sixth index key and the sixth index value are determined as the sixth index pair; the write data identification of the write data (which can be the hash of the write data value) as the seventh index key, the write data as the seventh index value, the seventh index key and the seventh index value as the seventh index pair; the block height corresponding to the read data as the eighth index key, and the read The data identifier is used as the eighth index value, and the eighth index key and the eighth index value are determined as the eighth index pair; the block height corresponding to the write data is used as the ninth index key, and the write data identifier is used as the ninth index value, and the The ninth index key and the ninth index value are determined as the ninth index pair; the sixth index pair, the seventh index pair, the eighth index pair, and the ninth index pair are used to generate a read-write data set.
  • Step S102 according to more than one data set to be accounted, perform data write operations on more than one data storage component in parallel, and obtain data storage results corresponding to more than one data storage component respectively;
  • the number of account data sets is the same, and one data storage component is used to store a data set of a data category to be accounted for.
  • the data set to be billed performs a data write operation through the corresponding data storage component to store the data set to be billed.
  • a data write operation can be performed on the data storage component by a write command to realize the data to be billed.
  • the storage process of the set, and the corresponding data storage result is obtained.
  • Different data categories correspond to different data storage components, that is, for data sets to be accounted with different data categories, data write operations are respectively performed through the respective corresponding data storage components.
  • the m data sets to be billed may include batch data sets to be billed, such as the data set to be billed A b
  • the m data storage components include
  • the batch processing data storage component that stores the data set A b to be accounted for is specifically the data storage component C b , b is a positive integer, and b is less than or equal to m.
  • the processing step of executing the data write operation in parallel may include: the computer device acquires a batch processing data write instruction for the batch data set to be billed, that is, the data set A b to be billed; according to the batch data
  • the write instruction performs a data write operation on the batch data storage component, that is, the data storage component C b , and writes the data set A b to be accounted into the data storage component C b ; when performing a data write operation on the data storage component C b
  • the billing data collection, other data storage components include data storage components other than batch data storage components in more than one data storage components.
  • data write operations can be performed on (m-1) data storage components in parallel based on (m-1) data sets to be accounted for; (m-1) data sets to be accounted for include m data sets to be accounted for Among the data sets to be billed except the data set to be billed A b , the (m-1) data storage components include the data storage components except the data storage component C b among the m data storage components.
  • the network performance of the blockchain can be improved and the response time of external business can be reduced.
  • the ledger storage is divided into three major data storage components, please refer to Figure 3a together, the three major data storage components may include a data storage component 201f for storing block data, a data storage component for storing state data A data storage component 202f, and a data storage component 203f for storing read and write data.
  • the embodiment of the present application uses the asynchronous settlement method to store the three data sets to be accounted separately, so as to avoid the dependence on read and write resources and improve the overall performance of the blockchain network.
  • the data set to be accounted 201e While writing into the data storage component 201f, execute the data storage component 202f in parallel and the data write operation of the data storage component 203f, so that the data set 202e to be billed is written in the data storage component 202f, and the data set 203e to be billed is written into the data storage component 203f.
  • the data set 201e to be accounted is written into the data storage component 201f through a batch data write instruction
  • the data set 202e to be accounted is written into the data storage component 202f through a batch data write command
  • the data set to be accounted for 203e is written into the data storage component 203f through a batch data write instruction.
  • the consensus node 20c obtains the data storage results returned by the three data storage components respectively, wherein the data storage component 201f returns the data storage failure result 201g, the data storage component 202f returns the data storage success result 202g, and the data storage component 203f Return data storage success result 203g.
  • Step S103 if there is a data storage failure result in the data storage result, obtain the block checkpoint corresponding to the block file, and the component checkpoints corresponding to more than one data storage component respectively; the block checkpoint is the block file in the block file
  • the maximum block height, the component checkpoint includes the corresponding maximum block heights in more than one data storage component.
  • each data set to be accounted for is to perform data write operations in parallel to obtain the corresponding data storage results. If there is a data storage failure result in more than one data storage results, it indicates that the parallel data write operation is not completely successful, and it needs to be performed. rewrite.
  • the computer device determines the data storage component whose data storage result is a data storage failure result as the target data storage component; from the m data sets to be billed, Obtain the target data set to be accounted associated with the target data storage component; perform data write operations on the target data storage component according to the target data set to be accounted for, and obtain the data rewrite storage result of the target data storage component; if the data rewrite If the storage result is the result of data storage failure, count the number of data write operations performed by the target data storage component; when the number of operations is less than the threshold of the number of operations, re-execute the data write operation on the target data storage component according to the target data set to be billed ; When the number of operations is equal to the threshold of the number of operations, obtain the block checkpoint corresponding to the block file and the component checkpoints corresponding to the m data storage components respectively.
  • the target data storage component is the data storage component corresponding to the data storage failure result
  • the target data set to be billed is the data set to be billed associated with the target data storage component, that is, the data write operation execution of the target data set to be billed Fail, the target data set to be accounted for has not been successfully stored, then the computer device performs data write operation on the target data storage component according to the target data set to be accounted for, and obtains the data rewriting storage result, if the data rewriting storage result is still a data storage failure As a result, count the number of operations performed by the target data storage component for data writing operations.
  • the step of obtaining a block checkpoint corresponding to the block file and component checkpoints corresponding to more than one data storage component is executed.
  • the embodiment of this application will use a limited retry mechanism until the write is successful or the retry exceeds the range. Please refer to Fig. 3 a again, in Fig.
  • the example data storage component 201f fails to write the data set 201e to be billed, so the data storage component 201f returns the data storage failure result 201g, wherein the data storage success result 202g can represent the data to be billed
  • the set 202e is successfully written into the data storage component 202f, and the data storage success result 203g may represent that the data set 203e to be billed is successfully written into the data storage component 203f.
  • the consensus node 20c can determine the data storage component 201f as the target data storage component, and at the same time, determine the data set 201e to be accounted as the target to be accounted for collection of data.
  • the consensus node 20c re-executes the data write operation on the data storage component 201f according to the data set 201e to be accounted for, and obtains the data rewriting storage result of the data storage component 201f; it can be understood that if the data rewriting storage The result is a data storage failure result, then count the number of times the data storage component 201f is executed data write operations; when the number of operations is less than the threshold value of the number of operations, according to the data set 201e to be billed, perform the data write operation on the data storage component 201f again; When the number of operations is equal to the threshold of the number of operations, the consensus node 20c obtains the block checkpoint corresponding to the block file 20d and the component checkpoints corresponding to the three data storage components respectively. Wherein, the component checkpoint is the maximum block height recorded in the data storage component. It can be understood that the operation times threshold may be set according to actual application scenarios.
  • Step S104 according to the block checkpoint and the component checkpoint, determine the data storage component belonging to the abnormal state of the component among more than one data storage components, and perform data writing operation on the data storage component belonging to the abnormal state of the component according to the block file.
  • the component checkpoint corresponds to the data storage component, that is, each data storage component corresponds to a component checkpoint. If the number of data storage components is m, then in the m component checkpoints, the computer equipment will be smaller than the block
  • the component checkpoint of the checkpoint is determined as the component checkpoint to be updated; among the m data storage components, the data storage component corresponding to the component checkpoint to be updated is determined to be the data storage component to be restored; the component state of the data storage component to be restored It is the abnormal state of the component; according to the checkpoint of the component to be updated and the checkpoint of the block, determine the block height interval of the data storage component to be restored; from the block file, obtain the data set to be restored belonging to the block height interval to be restored ;
  • the data category corresponding to the data set to be recovered is the same as the data category corresponding to the data storage component to be recovered; according to the data set to be recovered, the data storage component to be recovered performs a data write operation.
  • the component checkpoints correspond to the data storage components, and each data storage component corresponds to one component checkpoint, that is, the number of component checkpoints is the same as the number of data storage components.
  • the component checkpoint to be updated is a component checkpoint smaller than the block checkpoint.
  • the computer device determines the data storage component to be restored from more than one data storage component, the data storage component to be restored is the data storage component corresponding to the checkpoint of the component to be updated, and the component state of the data storage component to be restored is a component abnormal state, that is, from Among the more than one data storage components, the data storage components to be restored are determined to be in an abnormal state, and the data storage components to be restored correspond to the checkpoints of the components to be updated.
  • the computer device determines the block height interval of the data storage component to be restored according to the checkpoint of the component to be updated and the checkpoint of the block. Specifically, the data storage component to be restored can be determined by querying the block checkpoint corresponding to the checkpoint of the component to be updated. The block height range to be restored. The computer device obtains the data set to be restored belonging to the block height range to be restored from the block file, and the data set to be restored has the same data type as the data storage component to be restored. The computer device can find the data set to be restored from the block file according to the block height range to be restored.
  • the computer device executes data writing operation on the data storage component to be recovered according to the data set to be recovered, so as to determine the data storage component to be recovered and The data set to be restored, and the data storage component to be restored is rewritten according to the data set to be restored, so as to ensure the consistency of the blockchain data and data security.
  • FIG. 3b is the implementation of this application
  • FIG. 3b is the implementation of this application
  • the block file 20d in Fig. 3b has the same meaning as the block file 20d in Fig. 3a.
  • the data storage component 201f, the data storage component 202f, the data storage component 203f and the data set to be billed in Fig. 3b The same is true for 201e.
  • the consensus node when the number of operations is equal to the threshold of the number of operations, the consensus node obtains the block checkpoint 201d corresponding to the block file 20d (equal to the maximum block height of the block 20a in Figure 3a), and three data storage components
  • the corresponding component checkpoints are, for example, the component checkpoint 2011f, the component checkpoint 2021f, and the component checkpoint 2031f shown in FIG. 3b.
  • the consensus node compares the above three component checkpoints with the block checkpoint 201d, and determines the component checkpoint smaller than the block checkpoint 201d as the component checkpoint to be updated, such as the component checkpoint 2011f shown in Figure 3b.
  • the block data in the block file 20d may include the block data corresponding to the block 20a, that is, the data set 201e to be accounted for.
  • the consensus node determines the data storage component corresponding to the checkpoint of the component to be updated as the data storage component to be restored.
  • the consensus node can determine the block height interval of the data storage component to be restored according to the checkpoint of the component to be updated and the block checkpoint; assuming that block 20a includes block 8, block 9 and block 10, the block check Point 201d is block height 10, assuming component checkpoint 2011f is block height 8, it can be determined that the block height range to be restored includes block height 9 to block height 10, so the consensus node can start from block file 20d, Obtain the data set 20h to be restored belonging to the height interval of the block to be restored, that is, obtain the block data in blocks 9 to 10, and then perform a data write operation on the data storage component to be restored according to the data set 20h to be restored.
  • the consensus node can use the block data corresponding to block 20a (that is, the block data corresponding to block 8 to block 10) as the data set to be restored, and write it into the data storage component 201f again.
  • the data storage component 201f deletes the block data corresponding to block 8, and then performs a write operation on the data set to be restored.
  • the data storage component can delete part of the written data, for example, the data storage component 201f is writing the process of the data set to be accounted for 201e , an exception occurs, and only part of the data in the data set to be billed 201e is written. At this time, the data storage component 201f can delete the part of the data that has already been written. It can be understood that, when the data set to be accounted for is successfully written, the data storage component can update the component checkpoint according to the newly written data set.
  • a block passed by the new consensus when a block passed by the new consensus is obtained, it can be added to the block file, and in the block file, more than one data types for the block are obtained.
  • Bookkeeping data collection further, according to more than one data collection to be bookkeeping, perform data write operations on the same number of data storage components in parallel, and obtain data storage results corresponding to the data storage components respectively.
  • the data storage components store data of different data categories, that is, one data storage component is used to store a data set of one data category to be accounted for; if there is a data storage failure result in more than one data storage result, it indicates that there is a pending The accounting data set is not successfully written to the data storage component.
  • the block checkpoint corresponding to the block file and the component checkpoint corresponding to more than one data storage component are obtained; through the block checkpoint and more than one Component checkpoint, can determine the data storage component that belongs to the abnormal state of the component in more than one data storage component, that is, the data storage component that has not successfully written the data set to be accounted for the corresponding data category, at this time, according to the zone Block files perform data write operations on data storage components belonging to component abnormal states.
  • the zone Block files perform data write operations on data storage components belonging to component abnormal states.
  • the embodiment of the present application can determine the data storage component belonging to the abnormal state of the component through the block checkpoint and more than one component checkpoint, And according to the block file, re-execute the data write operation of the data storage component belonging to the abnormal state of the component, so it can guarantee the cache (equal to more than one data collection to be accounted) and distributed storage (equivalent to more than one data storage component ) to avoid data loss.
  • the step of obtaining the block checkpoint corresponding to the block file and the component checkpoints respectively corresponding to more than one data storage component it further includes: storing the data as the data storage failure result Component, determined as the target data storage component; obtain the number of operations performed by the target data storage component for data writing operations; and when the number of operations is equal to the threshold of the number of operations, execute the block checkpoint corresponding to the obtained block file, and more than one data
  • the computer device obtains the number of operations performed on the target data storage component for the target data storage component of the data storage failure result, and the number of operations may be updated each time the target data storage component is subjected to a data write operation. If the number of operations is equal to the threshold value of the number of operations, and the threshold value of the number of operations is preset according to actual needs, then the computer device executes the step of obtaining block checkpoints corresponding to the block file and component checkpoints corresponding to more than one data storage component.
  • the data processing method based on the blockchain further includes: comparing the number of operations with the threshold of the number of operations; when the number of operations is less than the threshold of the number of operations, according to the target data set to be accounted, execute the target data storage component
  • the data write operation is to obtain the data rewriting storage result of the target data storage component;
  • the target data set to be billed is a data set to be billed that is associated with the target data storage component in more than one data set to be billed; and if the data
  • the overwrite store result is a datastore failure result, updates the operation count, and returns to the step of comparing the operation count with the operation count threshold.
  • the target data set to be accounted for is the data set to be accounted for in more than one data set to be accounted for and associated with the target data storage component.
  • the computer device obtains the number of operations performed on the target data storage component for the target data storage component of the data storage failure result, and the number of operations may be updated each time the target data storage component is subjected to a data write operation.
  • the computer device compares the number of operations with the threshold value of the number of operations, and if the number of operations is less than the threshold value of the number of operations, the computer device performs a data write operation on the target data storage component according to the target data set to be accounted for, and obtains the data rewriting of the target data storage component Store the result.
  • the computer device updates the number of operations, and returns to the step of comparing the number of operations with the threshold value of the number of operations to determine whether the maximum number of rewritings has been reached again. In this embodiment, if it indicates that the maximum number of rewriting times has not been reached, the rewriting operation will be performed, and it will be judged whether the number of updated operations has reached the maximum number of times, so as to ensure data consistency and avoid data loss.
  • FIG. 4 is a schematic flowchart of a blockchain-based data processing method provided by an embodiment of the present application.
  • the blockchain-based data processing method can be executed by a computer device, and the computer device can include any consensus node in the consensus network 101 in FIG. 1 .
  • the data processing process may include the following steps.
  • step S201 a block file is obtained, and m data sets to be accounted with different data types for the block are obtained from the block file; m is a positive integer greater than 1.
  • Step S202 according to the m data sets to be accounted, execute data write operations on m data storage components in parallel, and obtain the data storage results corresponding to the m data storage components respectively; wherein, one data storage component is used to store a data category A collection of data to be accounted for.
  • Step S203 if there is a data storage failure result in the m data storage results, then obtain the block checkpoint corresponding to the block file, and the component checkpoints corresponding to the m data storage components respectively; the block checkpoint is in the block file
  • the maximum block height of , the m component checkpoints include the maximum block heights corresponding to the m data storage components.
  • Step S204 determine the data storage component belonging to the abnormal state of the component among the m data storage components, and perform data writing operation on the data storage component belonging to the abnormal state of the component according to the block file.
  • step S201-step S204 please refer to the description in the embodiment corresponding to FIG. 2 above.
  • Step S205 when the system time reaches the data reconciliation cycle, obtain the accounted data set from the cache block file based on the component checkpoint F e ; the maximum block height corresponding to the accounted data set is equal to the component checkpoint F e ,
  • the data category corresponding to the accounted data set is the same as the data category of the data storage component De ; the cache block file refers to the block file stored in the cache layer.
  • the computer device obtains the accounted data set from the cache block file based on the first component checkpoint; the maximum block height corresponding to the accounted data set is equal to the first component checkpoint, and the accounted data set
  • the data category corresponding to the data set is the same as the data category of the first data storage component; the cache block file refers to the block file stored in the cache layer.
  • the more than one data storage component includes the first data storage component
  • the first data storage component may be any one of the more than one data storage components
  • the component checkpoint includes the first data storage component corresponding to the first data storage component Component checkpoint.
  • the m data storage components include the first data storage component, specifically the data storage component De
  • the m component checkpoints include the first component checkpoint corresponding to the first data storage component, specifically the data storage component De
  • e is a positive integer and e is less than or equal to m
  • the first data storage component may be any one of the m data storage components.
  • the data reconciliation cycle is used to periodically check the blockchain ledger globally to ensure the integrity of the blockchain ledger data. When the system time reaches the data reconciliation cycle, full reconciliation processing can be triggered.
  • the system time can be the time of the blockchain data processing system, or it can be the real time.
  • the accounted data set is the data that has been successfully stored in the blockchain account book that has completed the accounting process.
  • the embodiment of this application proposes a method to ensure the consistency of ledger data in the process of blockchain asynchronous settlement.
  • This method aims to achieve consensus nodes in caching and distribution through the following three guarantees when consensus nodes adopt asynchronous settlement.
  • the three guarantees can be summarized as follows: 1. When the data writing fails, limited retrying of the writing operation, the guarantee can be requested Refer to the description in step S103 in the embodiment corresponding to FIG. 2 above; 2.
  • the block file is used as a redo log to redo the data set to be restored.
  • the block file can also be used to generate the data to be restored when the data is lost during the active/standby switchover of the distributed storage.
  • the consensus node 20c can generate a cache block file 40a in the cache layer, and the stored data is consistent with the data in the block file described above.
  • FIG. 5 is a schematic diagram of a blockchain-based data processing scenario provided by an embodiment of the present application.
  • the consensus node 20c (equivalent to the consensus node 20c in Figure 2) can set a data reconciliation cycle, wherein the data reconciliation cycle is used to periodically verify the account book (full amount of data) of the consensus node 20c, That is, to check the integrity of the ledger data.
  • the data reconciliation period can be set according to actual application scenarios.
  • the data storage component 201f may include consensus The block data 2012f in the ledger corresponding to the node 20c, the data storage component 202f can include the status data 2022f in the ledger corresponding to the consensus node 20c, and the data storage component 203f can include the read and write data 2032f in the ledger corresponding to the consensus node 20c.
  • the ledger storage is divided into three major data storage components, that is, the data storage component 201f, the data storage component 202f and the data storage component 203f shown in FIG. 5 , wherein, the data storage component 201f can record a component checkpoint 2011f, the data storage component 202f can record a component checkpoint 2021f, and the data storage component 203f can record a component checkpoint 2031f, and the above three component checkpoints are normally, It should be the same. If the component state of a certain data storage component is component abnormal state, the above three component checkpoints will be different.
  • the consensus node 20c obtains the accounted data set 401b from the cache database 40a according to the component checkpoint 2011f recorded in the data storage component 201f. Assuming that the component checkpoint 2011f is block height 10, the accounted data set 401b may include The block data corresponding to the minimum block height in the block file 40 a is cached to the block data in the block 10 .
  • the consensus node 20c obtains the accounted data set 402b from the cache database 40a according to the component checkpoint 2021f recorded in the data storage component 202f. Assuming that the component checkpoint 2021f is block height 10, the accounted data set 402b may include The state data corresponding to the minimum block height in the block file 40 a is cached to the state data in the block 10 .
  • the consensus node 20c obtains the accounted data set 403b from the cache database 40a according to the component checkpoint 2031f recorded in the data storage component 203f. Assuming that the component checkpoint 2031f is block height 10, the accounted data set 403b may include The read/write data corresponding to the minimum block height in the block file 40 a is cached to the read/write data in the block 10 .
  • the cache block file 40a may not store the full amount of data.
  • the method can be deletion at regular intervals, or quantitative deletion of the cache block file 40a, for example, the cache block file only saves the data corresponding to the latest 10 blocks, or other methods can also be used.
  • Step S206 comparing the data in the data storage component De with the data in the accounted data set to obtain a first comparison result, and determine the component status of the data storage component De according to the first comparison result.
  • the computer device compares the data in the first data storage component with the data in the accounted data set to obtain a first comparison result, and determines the component status of the first data storage component according to the first comparison result. Specifically, by comparing the data in the data storage component De with the data in the accounted data set, such as by comparing the data identification, it can be determined whether the data in the data storage component De has been successfully stored, that is, whether The billing process has been successfully completed, thereby determining the component status of the data storage component De . When the first comparison result is the same, it can be determined that the component state of the data storage component De is a component normal state, otherwise it is a component abnormal state.
  • the data category includes a status category
  • the process of determining the component status of the first data storage component includes: when the data category corresponding to the first data storage component is a status category, obtaining the data in the first data storage component for the first The first version identifier of the status data, obtains the second version identifier for the first status data in the accounted data set; compares the first version identifier with the second version identifier to obtain the status comparison result; if the status comparison result indicates that the If the first version identifier is different from the second version identifier, it is determined that the component state of the first data storage component is a component abnormal state.
  • the data category corresponding to the first data storage component is a status category
  • the first version identifier for the first status data in the first data storage component and the first version identification for the first status data in the accounted data set are compared to determine the component status of the first data storage component according to the obtained status comparison result.
  • the comparison of the data in the first data storage component is realized by comparing the version identifiers of the same state data in the first data storage component and in the accounted data set,
  • the component state of the first data storage component can be accurately determined to ensure the integrity of the entire amount of data.
  • the data category includes a block category
  • the process of determining the component status of the first data storage component includes: when the first data storage component, such as the data category corresponding to the data storage component D e , is a block category, obtaining For the first block identification of the first block height in the data storage component D e , obtain the second block identification for the first block height in the accounted data set; combine the first block identification with the second block The identifications are compared to obtain the block comparison result; if the block comparison result indicates that the first block identification is different from the second block identification, then it is determined that the component status of the data storage component D e is an abnormal component status.
  • the first block identifier for the first block height in the first data storage component and the first zone in the accounted data set is compared to determine the component state of the first data storage component according to the obtained block comparison result.
  • the data in the first data storage component By comparison, the component state of the first data storage component can be accurately determined to ensure the integrity of the full amount of data.
  • the data category includes a read-write category
  • the process of determining the component status of the first data storage component includes: when the first data storage component, such as the data category corresponding to the data storage component D e , is a read-write category, obtaining For the first write data identification of the second block height in the data storage component D e , obtain the second write data identification for the second block height in the accounted data set; combine the first write data identification with the second write data The identification is compared to obtain the read-write comparison result; if the read-write comparison result indicates that the first written data identification is different from the second written data identification, then it is determined that the component state of the data storage component De is an abnormal state of the component.
  • the data category corresponding to the first data storage component is the read-write category
  • the data set for the second area in the accounted data set The second write data identifier of the block height is compared to determine the component state of the first data storage component according to the obtained read-write comparison result.
  • the data in the first data storage component By comparison, the component state of the first data storage component can be accurately determined to ensure the integrity of the full amount of data.
  • the consensus node 20c performs account reconciliation processing on the full amount of data in the ledger (including full block data, full state data, and full read/write data).
  • the consensus node 20c can transfer each second block in the data storage component 203f
  • the first write data identifiers corresponding to the heights are compared with the second write data identifiers corresponding to the second block height in the accounted data set 403b, as shown in Figure 5, the write data identifiers corresponding to the block height 1 A1 (assumed to be the first write data identifier in the data storage component 203f) is compared with the write data identifier A2 (assumed to be the second write data identifier in the accounted data set 403b), if the comparison result shows that the write data identifier A1 is the same as If the
  • the process for the consensus node 20c to determine the component status of the data storage component 201f is consistent with the process of determining the component status of the data storage component 203f, only the compared data is different, and the process of determining the component status of the data storage component 201f Among them, the first block identifier for each block height in the data storage component 201f is compared with the second block identifier for each block height in the accounted data set 401b. Similarly, the process of the consensus node 20c determining the component status of the data storage component 202f is consistent with the process of determining the component status of the data storage component 203f, only the data for comparison is different.
  • the first version identification corresponding to the state data is compared with the second version identification of the corresponding state data in the accounted data set 402b. If the comparison result shows that the two version identifications are inconsistent, it means that there is an abnormality in the data storage component 202f , needs to be restored. It can be understood that when the data category is other categories, appropriate data can be selected for reconciliation according to the actual data category.
  • the embodiment of the present application only uses the block category, status category, and read-write category as examples.
  • Step S207 when the component state of the data storage component De is abnormal, execute data write operation on the data storage component D e belonging to the component abnormal state according to the block file.
  • the computer device executes a data write operation on the first data storage component belonging to the component abnormal state according to the block file. Specifically, if the component state of the first data storage component is component abnormal state, then perform a data write operation on the first data storage component to rewrite the first data storage component to ensure that the data of the first data storage component can be successfully recorded. account. Specifically, please refer to FIG. 5 again.
  • the consensus node 20c can determine that the write data identifier A1 for block 1 in the data storage component 203f is wrong (abnormal) data, Furthermore, it can be determined that the component state of the data storage component 203f is a component abnormal state.
  • the consensus node 20c can obtain the write data identifier for the target block height (such as the above-mentioned block height 1) from the block file, and use the target block height as the new index key, and the write data identifier corresponding to the target block height is A new index value is used to generate a new index pair, and then the new index pair is written into the data storage component 203f to replace the written data identifier A1.
  • the target block height represents the block height corresponding to the abnormal write data flag in the data storage component 203f.
  • the consensus node 20c determines that the write data identifier A1 for block 1 in the data storage component 203f is wrong (abnormal) data, it can further determine the write data identifier corresponding to each transaction information in block 1 Whether it is accurate or not is compared with the written data identifier of the corresponding transaction information in block 1 in the accounted data set 403b, and the determination process is consistent with the determination process of determining the written data identifier corresponding to each block height in step S206.
  • the write data identifier corresponding to transaction information 1 in block 1 can be obtained from the block file, and the obtained write data identifier corresponding to transaction information 1 in block 1 can be used as a new index value, and the transaction number of transaction information 1 As a new index key, a new index pair is generated according to the new index value and the new index key, and the new index pair is written into the data storage component 203f to replace transaction information 1 in block 1 of the data storage component 203f Corresponding write data identification (that is, wrong data).
  • the data category corresponding to the data storage component is the read-write category as an example. It is understandable that when the data category corresponding to the data storage component is the state category or the block category, according to the block file, the consensus node pair belongs to The process of re-executing the write operation of the data storage component in the abnormal state of the component is consistent with the above description.
  • the timing and full amount reconciliation method is adopted. When the data reconciliation cycle is reached, the data in the data storage component is compared with the data in the accounted data set, so as to determine the data storage component according to the obtained comparison result.
  • Component state if the component state is component abnormal state, then the data storage component belonging to the component abnormal state will be written through the block file, so as to avoid the loss of data in the case of master-standby switchover in distributed storage, and ensure the full amount of data integrity.
  • the blockchain-based data processing method further includes: when the data reconciliation cycle is reached, sending a data reconciliation request for requesting ledger data reconciliation to the consensus network; the data reconciliation request carries a component checkpoint ; Obtain the data sets to be reconciled corresponding to the component checkpoints returned by the consensus nodes in the consensus network; the data category corresponding to a component checkpoint is the same as the data category corresponding to a data set to be reconciled; at least one data storage component Including a second data storage component, the data set to be reconciled includes a target data set to be reconciled, the data category corresponding to the second data storage component is the same as the data category corresponding to the target data set to be reconciled; the target data set to be reconciled
  • the data in the second data storage component is compared with the data in the second data storage component to obtain a second comparison result, and the component status of the second data storage component is determined according to the second comparison result; when the component status of the second data storage component is a component abnormal status , performing
  • the second data storage component may be any one of more than one data storage components, and the target data set to be reconciled corresponds to the second data storage component.
  • the data reconciliation request carries component checkpoints, and the data set to be reconciled can be obtained from the consensus network through the data reconciliation request, and the data in the target data set to be reconciled that belongs to the same data category as the second data storage component, and The data in the second data storage component is compared to determine the component status of the second data storage component.
  • the data reconciliation request when the system time reaches the data reconciliation cycle, send a data reconciliation request for requesting ledger data reconciliation to the consensus network; the data reconciliation request carries m component checkpoints; obtain the consensus node in the consensus network and return The m data sets to be reconciled; the data category corresponding to a component checkpoint is the same as the data category corresponding to a data set to be reconciled; the m data storage components include the data storage component H i , and the m data sets to be reconciled include For the data set to be reconciled J i , the data category corresponding to the data storage component H i is the same as the data category corresponding to the data set J i to be reconciled, i is a positive integer, and i is less than or equal to m; the data set to be reconciled J The data in i is compared with the data in the data storage component H i to obtain the second comparison result, and the component status of the data storage component H i is determined according to the second comparison result; when the
  • the data set to be reconciled is obtained from the consensus network through the data reconciliation request carrying the component checkpoint, and the target that belongs to the same data category as the second data storage component is waited for
  • the data in the reconciliation data set is compared with the data in the second data storage component to determine the component status of the second data storage component.
  • the second data storage component performs data writing operations, thereby avoiding data loss during active-standby switchover in distributed storage, and ensuring the integrity of the entire amount of data.
  • the specific process of performing a data write operation on the data storage component H i belonging to the component abnormal state according to the block file may include: when the second data storage component, that is, the component state of the data storage component H i is an abnormal state of the component, and there is data to be restored by the data storage component H i in the block file, according to the data storage component in the block file For the data to be restored of H i , perform a data write operation on the data storage component H i belonging to the component abnormal state; it may also include: when the component status of the data storage component H i is component abnormal state, and there is no data storage in the block file
  • the data to be restored of component H i is sent to the consensus network
  • a data recovery request for requesting recovery of ledger data is sent to the consensus network; the data recovery request carries the data identification of the data to be recovered by the data storage component H i ; the consensus
  • the data write operation is directly performed on the second data storage component through the data to be restored; if there is no corresponding data to be restored in the block file, the data identifier of the data to be restored is obtained from the consensus network through the data restoration request, and the data to be restored is obtained based on the data identifier to perform a data write operation on the second data storage component. In this way, it is possible to avoid data loss in the case of active/standby switchover in distributed storage, so as to ensure the integrity of the full amount of data.
  • the third version identifier for the second status data in the second data storage component and the target data set to be reconciled for the second status data is compared to determine the component state of the first data storage component according to the obtained second comparison result.
  • the comparison of the data in the second data storage component is realized by comparing the version identifiers of the same state data in the first data storage component and in the target data set to be reconciled , the component state of the second data storage component can be accurately determined to ensure the integrity of the full amount of data.
  • the data category corresponding to the second data storage component is a block category
  • the third block identifier for the third block data in the second data storage component, and the target data set to be reconciled for the third The fourth block identification of the block data is compared to determine the component state of the second data storage component according to the obtained second comparison result.
  • Data comparison can accurately determine the component status of the second data storage component to ensure the integrity of the full amount of data.
  • the second data storage component Data comparison can accurately determine the component status of the second data storage component to ensure the integrity of the full amount of data.
  • the cache block file may not store the full amount of data, so in order to reconcile the full amount of data in the ledger, the embodiment of this application can also obtain the ledger data of another consensus node in the consensus network. It is understandable that the process of reconciling the ledgers corresponding to the two consensus nodes is consistent with the process of reconciling the ledgers of a consensus node using cached block files, please refer to the description above.
  • the block passed by the new consensus when it is obtained, it can be added to the block file, and the m data types for the block are obtained in the block file. account data set; further, according to m data sets to be accounted for, execute data write operations on m data storage components in parallel, and obtain data storage results corresponding to m data storage components respectively.
  • m data storage components The components store data with different data categories, that is, one data storage component is used to store a data set of one data category to be billed; if there is a data storage failure result among the m data storage results, it indicates that there is data to be billed The set is not successfully written to the data storage component.
  • the block checkpoint corresponding to the block file and the component checkpoints corresponding to m data storage components are obtained; through the block checkpoint and m component checkpoints, you can Among the m data storage components, determine the data storage component that belongs to the abnormal state of the component, that is, the data storage component that has not successfully written the data set to be accounted for the corresponding data category. At this time, the abnormality of the component can be determined according to the block file
  • the stateful data store component performs data write operations. As can be seen from the above, in the embodiment of this application, by performing data write operations on m data storage components in parallel, m data sets to be accounted for can be written in parallel, so the network performance of the blockchain can be improved and the cost of external business can be reduced.
  • the embodiment of the present application can determine the data storage component belonging to the abnormal state of the component through the block checkpoint and m component checkpoints, and according to the block The file re-executes the data write operation on the data storage components belonging to the abnormal state of the components, so the data consistency between the cache (which can be equivalent to m data sets to be accounted for) and the distributed storage (equivalent to m data storage components) can be guaranteed , to avoid data loss.
  • FIG. 6 is a schematic structural diagram of a blockchain-based data processing device provided by an embodiment of the present application.
  • the above-mentioned block chain-based data processing device can be a computer-readable instruction (including program code) running in a computer device, for example, the data processing device is an application software; the device can be used to execute the corresponding steps in the method.
  • the data processing device 1 may include: a first obtaining module 11 , a second obtaining module 12 and a first determining module 13 .
  • the first acquiring module 11 is configured to acquire a block file, and acquire more than one data set to be accounted for a block from the block file; the data categories of the more than one data set to be accounted are different from each other ;
  • the second acquisition module 12 is configured to perform data write operations on more than one data storage component in parallel according to the more than one data set to be billed, and acquire data storage results respectively corresponding to the more than one data storage component; wherein , the number of the data storage components is the same as the number of the data sets to be accounted for, and one data storage component is used to store a data set to be accounted for in a data category;
  • the second obtaining module 12 is further configured to obtain the block checkpoint corresponding to the block file and the component checks corresponding to the more than one data storage components respectively if there is a data storage failure result in the data storage result point; the block checkpoint is the maximum block height in the block file, and the component checkpoint includes the respective maximum block heights in the more than one data storage components; and
  • the first determining module 13 is configured to determine, among the more than one data storage components, the data storage components belonging to the component abnormal state according to the block checkpoint and the component checkpoint, and according to the block file pair belonging to The data storage component in the abnormal state of the component executes a data write operation.
  • steps S101 - S104 for the implementation of specific functions of the first acquisition module 11 , the second acquisition module 12 and the first determination module 13 , reference may be made to steps S101 - S104 in the embodiment corresponding to FIG. 2 above.
  • the blockchain-based data processing device 1 may further include: a second determination module 14 and a third acquisition module 15 .
  • the second determination module 14 is used to determine the data storage component whose data storage result is the result of data storage failure as the target data storage component; the second determination module 14 is also used to obtain from more than one data set to be billed The target data set to be billed associated with the target data storage component; the third acquisition module 15 is used to perform data write operations on the target data storage component according to the target data set to be billed, and obtain the data rewriting of the target data storage component Store the result; the third acquisition module 15 is also used to count the number of times the target data storage component is executed for data write operations if the data rewrite storage result belongs to the data storage failure result; the third acquisition module 15 is also used for when the operation When the number of times is less than the threshold value of the number of operations, re-execute the data write operation on the target data storage component according to the target data set to be billed; and the third acquisition module 15 is also used
  • the second determination module 14 is used to determine the data storage component whose data storage result is the result of the data storage failure as the target data storage component; the second determination module 14 is also used to obtain the target The number of operations performed by the data storage component for data writing operations; the third acquisition module is also configured to notify the second acquisition module 12 to acquire the block checkpoint corresponding to the block file when the number of operations is equal to the threshold value of the number of operations, and component checkpoints respectively corresponding to the more than one data storage components.
  • the second determination module 14 is further configured to compare the number of operations with the threshold value of the number of operations; the third acquisition module 15 is also configured to, when the number of operations is less than the threshold value of the number of operations, according to The target data set to be accounted for is to perform a data write operation on the target data storage component, and obtain the data rewriting storage result of the target data storage component; the target data set to be accounted for is the more than one to be recorded The data set to be accounted associated with the target data storage component in the account data set; the third acquisition module 15 is also used to update the operation times if the data rewriting storage result belongs to the data storage failure result, and notify The second determination module 14 compares the number of operations with a threshold value of the number of operations.
  • the first determination module 13 may include: a first determination unit 131 , a second determination unit 132 , a first acquisition unit 133 and a first execution unit 134 .
  • the first determining unit 131 is configured to determine, among the component checkpoints, a component checkpoint smaller than the block checkpoint as the component checkpoint to be updated; Among the data storage components, the data storage component corresponding to the checkpoint of the component to be updated is determined as the data storage component to be restored; the component status of the data storage component to be restored is a component abnormal state; the second determination unit 132 is used to The checkpoint and the block checkpoint are used to determine the block height interval of the data storage component to be restored; the first obtaining unit 133 is used to obtain the data set to be restored belonging to the block height interval to be restored from the block file; The data type corresponding to the data set to be restored is the same as the data type corresponding to the data storage component to be restored; the first execution unit 134 is configured to perform a data write operation on the data
  • step S104 For the implementation of specific functions of the first determination unit 131 , the second determination unit 132 , the first acquisition unit 133 , and the first execution unit 134 , reference may be made to step S104 in the above-mentioned embodiment corresponding to FIG. 2 .
  • more than one data storage component includes a first data storage component, and the component checkpoint includes a first component checkpoint corresponding to the first data storage component; a blockchain-based data processing device 1 It may also include: a fourth acquisition module 16 and a third determination module 17 .
  • the fourth acquisition module 16 is used to obtain the accounted data set from the cache block file based on the first component checkpoint when the data reconciliation cycle is reached; the largest block corresponding to the accounted data set The height is equal to the checkpoint of the first component, and the data category corresponding to the accounted data set is the same as the data category of the first data storage component; the cache block file refers to the block file; a third determination module 17, configured to compare the data in the first data storage component with the data in the accounted data set to obtain a first comparison result, according to the first comparison As a result, the component state of the first data storage component is determined; the third determining module 17 is also configured to, when the component state of the first data storage component is a component abnormal state, according to the block file pair belonging to the component abnormal state The first data storage component performs a data write operation.
  • the specific function implementation manners of the fourth acquisition module 16 and the third determination module 17 can refer to step S205-step S206 in the above-mentioned embodiment corresponding to FIG. 4 .
  • the third determining module 17 may include: a second acquiring unit 171 and a first comparing unit 172 .
  • the second obtaining unit 171 is configured to obtain the first version identification of the first state data in the first data storage component when the data category corresponding to the first data storage component is a state category, and obtain the recorded The second version identification of the first state data in the account data set; the first comparison unit 172 is configured to compare the first version identification with the second version identification to obtain a state comparison result; the first comparison The unit 172 is further configured to determine that the component state of the first data storage component is a component abnormal state if the state comparison result indicates that the first version identifier is different from the second version identifier.
  • step S206 for the specific function implementation manners of the second acquiring unit 171 and the first comparing unit 172, reference may be made to step S206 in the above-mentioned embodiment corresponding to FIG. 4 .
  • the third determining module 17 may include: a third acquiring unit 173 and a second comparing unit 174 .
  • the third acquiring unit 173 is configured to acquire the first block identifier for the first block height in the first data storage component when the data category corresponding to the first data storage component is a block category, and acquire the The second block identifier for the first block height in the accounted data set;
  • the second comparison unit 174 is configured to compare the first block identifier with the second block identifier to obtain Block comparison result;
  • the second comparison unit 174 is further configured to determine the components of the first data storage component if the block comparison result indicates that the first block identifier is different from the second block identifier
  • the state is abnormal state of the component.
  • the third determining module 17 may include: a fourth acquiring unit 175 and a third comparing unit 176 .
  • the fourth acquiring unit 175 is configured to acquire the first write data identifier for the second block height in the first data storage component when the data category corresponding to the first data storage component is the read-write category, and acquire the The second write data identifier for the second block height in the accounted data set;
  • the third comparison unit 176 is configured to compare the first write data identifier with the second write data identifier to obtain Read-write comparison result: the third comparison unit 176 is further configured to determine the component of the first data storage component if the read-write comparison result indicates that the first write data identifier is different from the second write data identifier
  • the state is abnormal state of the component.
  • the blockchain-based data processing device 1 may further include: a fifth obtaining module 18 and a fourth determining module 19 .
  • the fifth acquisition module 18 is used to send a data reconciliation request for requesting book data reconciliation to the consensus network when the data reconciliation period is reached; the data reconciliation request carries a component checkpoint; the fifth acquisition module 18 also uses Obtaining the data sets to be reconciled respectively corresponding to the component checkpoints returned by the consensus nodes in the consensus network; the data category corresponding to a component checkpoint is the same as the data category corresponding to a data set to be reconciled;
  • the at least one data storage component includes a second data storage component, the data set to be reconciled includes a target data set to be reconciled, and the data category corresponding to the second data storage component corresponds to the target data set to be reconciled
  • the data categories are the same; the fourth determination module 19 is used to compare the data in the target data set to be reconciled with the data in the second data storage component to obtain a second comparison result, according
  • the second data storage component of the state performs a data write operation.
  • step S207 for the specific function implementation manners of the fifth acquiring module 18 and the fourth determining module 19, reference may be made to step S207 in the above-mentioned embodiment corresponding to FIG. 4 .
  • the fourth determination module 19 is specifically used for when the component state of the second data storage component is component abnormal state, and the data to be restored of the second data storage component exists in the block file , according to the data to be restored, perform a data write operation on the second data storage component that belongs to the abnormal state of the component; the fourth determination module 19 is also specifically configured to when the component state of the second data storage component is component In an abnormal state, and the data to be restored does not exist in the block file, send a data restoration request for requesting restoration of ledger data to the consensus network; the data restoration request carries the data identifier of the data to be restored The fourth determination module 19 is also specifically used to obtain the data to be restored of the second data storage component returned by the consensus node in the consensus network, and according to the data to be restored of the second data storage component, the data belonging to the The second data storage component in the component abnormal state performs a data write operation. Wherein, for the specific function implementation manner of the fourth determining module 19, reference may be made to step S207 in the
  • the fourth determining module 19 may include: a fifth acquiring unit 191 and a fourth comparing unit 192 .
  • the fifth obtaining unit 191 is configured to obtain the third version identifier for the second state data in the second data storage component when the data category corresponding to the second data storage component is a state category, and obtain the target pending A fourth version identifier for the second state data in the reconciliation data set; a fourth comparison unit 192, configured to compare the third version identifier with the fourth version identifier to obtain a second comparison result;
  • the four comparison unit 192 is further configured to determine that the component state of the second data storage component is a component abnormal state if the second comparison result indicates that the third version identifier is smaller than the fourth version identifier.
  • the fourth determining module 19 may include: a sixth acquiring unit 193 and a fifth comparing unit 194 .
  • the sixth acquiring unit 193 is configured to acquire the third block identifier for the third block data in the second data storage component when the data category corresponding to the second data storage component is the block category, and acquire the target data to be reconciled
  • the fourth block identifier for the third block data in the set ;
  • the fifth comparison unit 194 configured to compare the third block identifier with the fourth block identifier to obtain a second comparison result;
  • the fifth comparison unit 194 It is also used to determine that the component state of the second data storage component is a component abnormal state if the second comparison result is that the third block identifier is smaller than the fourth block identifier.
  • the fourth determining module 19 may include: a seventh acquiring unit 195 and a sixth comparing unit 196 .
  • the seventh acquiring unit 195 is configured to acquire the third write data identifier for the fourth block height in the second data storage component when the data category corresponding to the second data storage component is the read-write category, and acquire the target data to be reconciled
  • the sixth comparison unit 196 is used to compare the third write data identifier with the fourth write data identifier to obtain a second comparison result;
  • the sixth comparison unit 196 It is also used to determine that the component state of the second data storage component is a component abnormal state if the second comparison result is that the third write data identifier is smaller than the fourth write data identifier.
  • the data category includes a block category, a state category, and a read-write category
  • the first acquisition module 11 may include: a first generating unit 111, a second generating unit 112, a third generating unit 113, and a fourth generating unit 114.
  • the first generation unit 111 is used to obtain the block data associated with the block type from the block file, and generate a block data set according to the block data;
  • the second generation unit 112 is used to obtain the block data from the block file.
  • the state data associated with the state category generates a state data set according to the state data; the third generation unit 113 is used to obtain the read-write data associated with the read-write category from the block file, and generate a read-write data set according to the read-write data ;
  • the fourth generating unit 114 is configured to generate more than one data set to be accounted according to the block data set, the state data set and the read/write data set.
  • the block data includes transaction information and block information, and the block information includes a transaction identifier of the transaction information; the first generating unit 111 may include: a first determining subunit 1111 and a first generating subunit 1112 .
  • the first determination subunit 1111 is configured to use the transaction identifier as the first index key, the transaction information as the first index value, and determine the first index key and the first index value as the first index pair; the first determination subunit 1111 , is also used to use the block height corresponding to the block information as the second index key, the block information as the second index value, and determine the second index key and the second index value as the second index pair; the first determiner The unit 1111 is further configured to use the block identifier corresponding to the block information as the third index key, use the block height corresponding to the block information as the third index value, and determine the third index key and the third index value as the third index key and the third index value as the third index key.
  • the first generation subunit 1112 is configured to generate a block data set according to the first index pair, the second index pair and the third index pair.
  • the specific function implementation manners of the first determining subunit 1111 and the first generating subunit 1112 reference may be made to step S101 in the above-mentioned embodiment corresponding to FIG. 2 .
  • the second generating unit 112 may include: a second determining subunit 1121 and a second generating subunit 1122 .
  • the second determining subunit 1121 is configured to combine the contract identifier and the object identifier into a fourth index key, use the status data as a fourth index value, and determine the fourth index key and the fourth index value as a fourth index pair;
  • the second The determination subunit 1121 is also used to obtain the version identification corresponding to the historical state data of the object identification, and generates the version identification corresponding to the state data according to the version identification corresponding to the historical state data;
  • the second determination subunit 1121 is also used to combine the status data and
  • the version identification corresponding to the state data is used as the fifth index key, the block height corresponding to the state data is used as the fifth index value, and the fifth index key and the fifth index value are determined as the fifth index pair;
  • the second generating subunit 1122 It is used to generate a state data set according to the fourth index pair and the fifth index pair.
  • the read and write data includes read data and write data;
  • the third generating unit 113 may include: a third determining subunit 1131 and a third generating subunit 1132 .
  • the third determining subunit 1131 is configured to use the read data identifier of the read data as the sixth index key, use the read data as the sixth index value, and determine the sixth index key and the sixth index value as the sixth index pair;
  • the third The determination subunit 1131 is further configured to use the write data identifier of the write data as the seventh index key, the write data as the seventh index value, and determine the seventh index key and the seventh index value as the seventh index pair;
  • the third determination The subunit 1131 is further configured to use the block height corresponding to the read data as the eighth index key, use the read data identifier as the eighth index value, and determine the eighth index key and the eighth index value as the eighth index pair;
  • the third The determining subunit 1131 is also configured to use the block height corresponding to the write data as the ninth index key, use the write data
  • the more than one data set to be billed includes a batch data set to be billed
  • the more than one data storage component includes batch data for storing the batch data set to be billed Storage component
  • the first acquisition module 11 may include: an eighth acquisition unit 115 and a second execution unit 116 .
  • the eighth obtaining unit 115 is configured to obtain a batch processing data write instruction for the batch data set to be accounted for; the second execution unit 116 is configured to write the batch processing data according to the batch processing data writing instruction
  • the storage component executes a data write operation, and writes the batch processing to-be-accounted data set into the batch processing data storage component; the second execution unit 116 is also used to perform a data write operation on the batch processing data storage component
  • the other data sets to be accounted for include all the data sets to be accounted for except for the batch process to be accounted for
  • the other data storage components include the data storage components in the more than one data storage components except the batch processing data storage component.
  • FIG. 7 is a schematic structural diagram of a computer device provided by an embodiment of the present application.
  • the computer device 1000 may be the consensus node in the embodiment corresponding to FIG. 2 above, and the computer device 1000 may include: at least one processor 1001, such as a CPU, at least one network interface 1004, a user interface 1003, and a memory 1005.
  • the communication bus 1002 is used to realize connection and communication between these components.
  • the user interface 1003 may include a display screen (Display) and a keyboard (Keyboard), and the network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).
  • the memory 1005 can be a high-speed RAM memory, or a non-volatile memory, such as at least one disk memory.
  • the memory 1005 may optionally also be at least one storage device located far away from the aforementioned processor 1001 .
  • the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a device control application program.
  • the network interface 1004 can provide a network communication function;
  • the user interface 1003 is mainly used to provide an input interface for the user; and the processor 1001 can be used to call the device control application stored in the memory 1005 program to realize the above-mentioned blockchain-based data processing method.
  • the computer device 1000 described in the embodiment of the present application can execute the description of the blockchain-based data processing method in the previous embodiment corresponding to FIG. 2 and FIG. Description of the data processing apparatus 1.
  • the description of beneficial effects using the same method reference may also be made to the foregoing.
  • the present application provides a computer device, including: one or more processors, memory, and network interface; the above-mentioned one or more processors are connected to the above-mentioned memory and the above-mentioned network interface, wherein the above-mentioned network interface is used to provide data communication functions , the memory is used to store computer-readable instructions, and the processor is used to call the computer-readable instructions, so that the computer device executes the method in the embodiment of the present application.
  • the embodiment of the present application also provides one or more non-volatile computer-readable storage media storing computer-readable instructions.
  • the above-mentioned computer-readable storage medium stores computer-readable instructions.
  • the block chain-based data processing method provided by each step in FIG. 2 and FIG. 4 can be realized.
  • the above-mentioned computer-readable storage medium may be the blockchain-based data processing device provided in any of the foregoing embodiments or the internal storage unit of the above-mentioned computer equipment, such as the hard disk or memory of the computer equipment.
  • the computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk equipped on the computer device, a smart memory card (smart media card, SMC), a secure digital (secure digital, SD) card, Flash card (flash card), etc. Further, the computer-readable storage medium may also include both an internal storage unit of the computer device and an external storage device.
  • the computer-readable storage medium is used to store the computer program and other programs and data required by the computer device.
  • the computer-readable storage medium can also be used to temporarily store data that has been output or will be output.
  • the embodiment of the present application also provides a computer program product or computer program, where the computer program product or computer program includes computer-readable instructions, and the computer-readable instructions are stored in a computer-readable storage medium.
  • the processor of the computer device reads the computer-readable instructions from the computer-readable storage medium, and the processor executes the computer-readable instructions, so that the computer device can execute the blockchain-based A description of the data processing methods.
  • each flow and/or of the method flow charts and/or structural diagrams can be implemented by computer program instructions or blocks, and combinations of processes and/or blocks in flowcharts and/or block diagrams.
  • These computer program instructions may be provided to a general purpose computer, special purpose computer, embedded processor, or processor of other programmable data processing equipment to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing equipment produce a A device for realizing the functions specified in one or more steps of the flowchart and/or one or more blocks of the structural diagram.
  • These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the instructions
  • the device implements the functions specified in one or more blocks of the flowchart and/or one or more blocks of the structural schematic diagram.
  • These computer program instructions can also be loaded onto a computer or other programmable data processing device, causing a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process, thereby
  • the instructions provide steps for implementing the functions specified in one or more steps of the flowchart and/or one or more blocks in the structural illustration.

Abstract

一种基于区块链的数据处理方法,由计算机设备执行,包括:获取区块文件,从区块文件中获取多于一个待记账数据集合(S101);根据多于一个待记账数据集合,对多于一个数据存储组件并行执行数据写操作,获取多于一个数据存储组件分别对应的数据存储结果;一个数据存储组件用于存储一种数据类别的待记账数据集合(S102);若数据存储结果中存在数据存储失败结果,则获取区块文件对应的区块检查点,以及多于一个数据存储组件分别对应的组件检查点(S103);及根据区块检查点以及组件检查点,在多于一个数据存储组件中确定属于组件异常状态的数据存储组件,根据区块文件对属于组件异常状态的数据存储组件执行数据写操作(S104)。

Description

基于区块链的数据处理方法、设备及计算机可读存储介质
本申请要求于2021年08月04日提交中国专利局、申请号为2021108904131、发明名称为“基于区块链的数据处理方法、设备及计算机可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及互联网技术领域,尤其涉及一种基于区块链的数据处理方法、设备以及计算机可读存储介质。
背景技术
区块链网络在对区块达成共识之后,区块链节点需要将区块以及与区块相关联的信息写入账本中,现有的节点记账方法是将区块以及与区块相关联的信息串行写入账本(可以包括磁盘以及分布式存储),例如先将共识通过的区块中的区块头写入磁盘或者分布式存储,等该步骤完成后,继续将交易列表以及交易执行结果集分别写入磁盘或者分布式存储,等交易列表和交易执行结果集写完后,再将写集合写入磁盘或者分布式存储,当写集合写完后节点记账完成开始下一轮共识出块。目前,区块落账处理中不仅具有性能较差的缺陷,还会导致每一轮区块落账延迟较大。
发明内容
根据本申请的各种实施例,提供一种基于区块链的数据处理方法、设备以及计算机可读存储介质。
本申请实施例一方面提供了一种基于区块链的数据处理方法,由计算机设备执行,包括:
获取区块文件,从区块文件中获取针对区块的多于一个待记账数据集合;多于一个待记账数据集合的数据类别互不相同;
根据多于一个待记账数据集合,对多于一个数据存储组件并行执行数据写操作,获取多于一个数据存储组件分别对应的数据存储结果;其中,数据存储组件的数量与待记账数据集合的数量相同,一个数据存储组件用于存储一种数据类别的待记账数据集合;
若数据存储结果中存在数据存储失败结果,则获取区块文件对应的区块检查点,以及多于一个数据存储组件分别对应的组件检查点;区块检查点为区块文件中的最大区块高度,组件检查点包括多于一个数据存储组件中分别对应的最大区块高度;及
根据区块检查点以及组件检查点,在多于一个数据存储组件中确定属于组件异常状态的数据存储组件,根据区块文件对属于组件异常状态的数据存储组件执行数据写操作。
本申请实施例一方面提供了一种基于区块链的数据处理装置,包括:
第一获取模块,用于获取区块文件,从区块文件中获取针对区块的多于一个待记账数据集合;多于一个待记账数据集合的数据类别互不相同;
第二获取模块,用于根据多于一个待记账数据集合,对多于一个数据存储组件并行执行数据写操作,获取多于一个数据存储组件分别对应的数据存储结果;其中,数据存储组件的数量与待记账数据集合的数量相同,一个数据存储组件用于存储一种数据类别的待记账数据集合;
第二获取模块,还用于若数据存储结果中存在数据存储失败结果,则获取区块文件对应的区块检查点,以及多于一个数据存储组件分别对应的组件检查点;区块检查点为区块文件中的 最大区块高度,组件检查点包括多于一个数据存储组件中分别对应的最大区块高度;及
第一确定模块,用于根据区块检查点以及组件检查点,在多于一个数据存储组件中确定属于组件异常状态的数据存储组件,根据区块文件对属于组件异常状态的数据存储组件执行数据写操作。
本申请一方面提供了一种计算机设备,包括:一个或多个处理器、存储器、网络接口;上述一个或多个处理器与上述存储器、上述网络接口相连,其中,上述网络接口用于提供数据通信功能,上述存储器用于存储计算机可读指令,上述处理器用于调用上述计算机可读指令,以使得计算机设备执行本申请实施例中的方法。
本申请实施例一方面提供了一个或多个存储有计算机可读指令的非易失性计算机可读存储介质,上述计算机可读存储介质中存储有计算机可读指令,上述计算机可读指令适于由一个或多个处理器加载并执行本申请实施例中的方法。
本申请实施例一方面提供了一种计算机程序产品,该计算机程序产品包括计算机可读指令,该计算机可读指令存储在计算机可读存储介质中;计算机设备的处理器从计算机可读存储介质读取该计算机指令,处理器执行该计算机可读指令,使得该计算机设备执行本申请实施例中的方法。
本申请的一个或多个实施例的细节在下面的附图和描述中提出。本申请的其它特征、目的和优点将从说明书、附图以及权利要求书变得明显。
附图说明
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1是本申请实施例提供的一种系统架构示意图;
图2是本申请实施例提供的一种基于区块链的数据处理方法的流程示意图;
图3a是本申请实施例提供的一种基于区块链的数据处理的场景示意图;
图3b是本申请实施例提供的一种基于区块链的数据处理的场景示意图;
图4是本申请实施例提供的一种基于区块链的数据处理方法的流程示意图;
图5是本申请实施例提供的一种基于区块链的数据处理的场景示意图;
图6是本申请实施例提供的一种基于区块链的数据处理装置的结构示意图;
图7是本申请实施例提供的一种计算机设备的结构示意图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
为了便于理解,首先对部分名词进行以下简单解释:
1、区块链(Block chain):狭义上,区块链是一种以区块为基本单位的链式数据结构,区块中利用数字摘要对之前获取的交易历史进行校验,适合分布式记账场景下防篡改和可扩展性 的需求;广义上,区块链还指代区块链结构实现的分布式记账技术,包括分布式共识、隐私与安全保护、点对点通信技术、网络协议、智能合约等。区块链的目标是实现一个分布的数据记录账本,此账本只允许添加,不允许删除。账本底层的基本结构是一个线性的链表。链表由一个个“区块”串联组成,后继区块中记录前继区块的哈希(Hash)值,每个区块(以及区块中的交易)是否合法,可通过计算哈希值的方式进行快速检验。若网络中的节点提议添加一个新的区块,必须经过共识机制对区块达成共识确认。
2、区块(block):是在区块链网络上承载交易数据的数据包,是一种被标记上时间戳和前继区块对应的哈希值的数据结构,区块经过网络的共识机制验证并确认区块中的交易。区块包括区块头(Block Header)以及区块体(Block Body),区块头可以记录当前区块的元信息,包含当前版本号、前继区块对应的哈希值、时间戳、随机数、默克尔树根(Merkle Root)的哈希值等数据。区块体可以记录一段时间内所生成的详细数据,包括当前区块经过验证的、区块创建过程中生成的所有交易记录或是其他信息,可以理解为账本的一种表现形式。此外,区块体的详细数据可以包括通过默克尔树(Merkle Tree)的哈希过程,生成唯一的Merkle Root记录于区块头。前继区块,也称父区块(Parent Block),区块链通过在区块头记录区块对应的哈希值以及父区块对应的哈希值实现时间上的排序。
3、哈希值(hash):也称作信息特征值或特征值,哈希值是通过哈希算法将任意长度的输入数据转换为密码并进行固定输出而生成的,不能通过解密哈希值来检索原始输入数据,它是一个单向的加密函数。在区块链中,每个区块(除了初始区块)都包含前继区块的哈希值,哈希值是区块链技术中的潜力核心基础和最重要的方面,它保留了记录和查看数据的真实性,以及区块链作为一个整体的完整性。
4、智能合约(Smart Contract):是一种旨在以信息化方式传播、验证或执行合同的计算机协议。在区块链系统当中,智能合约(简称合约)是一种区块链各节点可以理解并执行的代码,可以执行任意逻辑并得到结果。在实际应用中,智能合约通过区块链上的交易来管理与试用。每条交易相当于对区块链系统的一个远程过程调用(Remote Procedure Call,RPC)请求。如果说智能合约相当于可执行程序,区块链就相当于提供运行环境的操作系统。区块链可以包含多个合约,以合约账号(Identity,ID)、标识号或名称来区分。
5、合约执行:通过发起一笔交易的方式,用户可以调用区块链上已经部署的合约。区块链系统中的各个节点分别运行同一个合约。对于需要读取数据的合约,会访问节点自己的账本。最终各节点会互相验证执行结果是否一致(共识),若执行结果一致各节点将必要结果存入各自账本中,并返回结果给用户。
6、读写集:合约在执行过程中对节点账本数据的操作记录。分为读集合与写集合,分别指智能合约在执行时,从账本读取的数据,和将要写入账本的数据。
7、区块链节点:区块链网络将节点区分为共识节点(也可以称作核心节点)以及同步节点(可以包括数据节点以及轻节点)。其中,共识节点负责区块链全网的共识业务;同步节点负责同步共识节点的账本信息,即同步最新的区块数据。无论是共识节点还是同步节点,其内部构造都包括网络通信组件,因为区块链网络本质是一个点对点(Peer to Peer,P2P)网络,需通过P2P组件与区块链网络中的其他节点进行通信。区块链网络中的资源和服务都分散在各个节点上,信息的传输和服务的实现都直接在节点之间进行,无需中间环节或中心化的服务器(第三 方)介入。
请参见图1,图1是本申请实施例提供的一种系统架构示意图。如图1所示,该系统架构可以为区块链网络,其中,区块链网络可以包括共识网络101以及同步网络102;同步网络102中的节点可以称为同步节点,同步节点主要进行业务执行,不参与记账共识,通过身份认证的方式从共识网络101中获得区块数据等。共识网络101也可以称作核心网络,共识网络101中的节点可以称为共识节点,共识节点拥有全量数据。其中,共识网络101和同步网络102可以处在不同网络环境下,通常来说,共识网络101处于私有网络中,而同步网络102处于共有网络中,二者通过路由边界进行交互。请再参见图1,共识网络101可以包括共识节点1011、共识节点1012、...、共识节点1013。可以理解的是,上述共识网络101可以包括一个或者多个共识节点,这里将不对共识节点的数量进行限制。请再参见图1,同步网络102可以包括同步节点1021、同步节点1022、同步节点1023、...、同步节点1024以及同步节点1025。可以理解的是,上述同步网络102可以包括一个或者多个同步节点,这里将不对同步节点的数量进行限制。
每个节点(包括共识网络101中的共识节点以及同步网络102中的同步节点)在进行正常工作时,可以接收到客户端发送的交易数据(等同于交易信息),并基于接收到的交易数据生成区块,然后进行区块上链处理。为了保证各个节点之间的数据互通,每个节点之间可以存在数据连接,例如共识节点1011与共识节点1012之间存在数据连接,共识节点1011与共识节点1013之间存在数据连接,同步节点1021与同步节点1023之间存在数据连接等等。进一步地,共识网络101与同步网络102之间存在数据连接,例如共识节点1011与同步节点1022之间存在数据连接,共识节点1012与同步节点1023之间存在数据连接等等。
可以理解的是,节点之间可以通过上述数据连接进行数据或者区块传输。上述节点之间的数据连接可以基于节点标识,对于区块链网络中的每个节点,均具有与其对应的节点标识,而且上述每个节点均可以存储与自身有相连关系的其他节点的节点标识,以便后续根据其他节点的节点标识,将获取到的数据或生成的区块广播至其他节点,例如共识节点1011可以维护一个节点标识列表,该节点标识列表保存着其他节点的节点名称和节点标识。如表1所示:
表1
节点名称 节点标识
共识节点1012 117.114.151.174
共识节点1013 117.116.189.145
同步节点1021 117.114.151.183
同步节点1022 117.116.189.125
同步节点1023 119.250.485.362
其中,节点标识可为网络之间互联的协议(Internet Protocol,IP)地址以及其他任意一种能够用于标识区块链网络中节点的信息,表1中仅以IP地址为例进行说明。假设共识节点1011的节点标识为117.116.156.425,则共识节点1011可以通过节点标识117.114.151.183,向同步节点1021发送数据同步请求,且同步节点1021通过节点标识117.116.156.425,可以知道该数据同步请求是共识节点1011所发送的;同理,同步节点1023可以通过节点标识 117.116.156.425,向共识节点1011发送交易数据A,且共识节点1011通过节点标识119.250.485.362,可以知道该交易数据A是同步节点1023所发送的,其他节点之间的数据传输亦如此。可以理解的是,上述的数据连接不限定连接方式,可以通过有线通信方式进行直接或间接地连接,也可以通过无线通信方式进行直接或间接地连接,还可以通过其他连接方式,本申请在此不做限制。其中,图1中的共识节点1011、共识节点1012、...、共识节点1013、同步节点1021、同步节点1022、同步节点1023、...、同步节点1024以及同步节点1025可以包括手机、平板电脑、笔记本电脑、掌上电脑、智能音响、移动互联网设备(MID,mobile internet device)、POS(Point Of Sales,销售点)机、可穿戴设备(例如智能手表、智能手环等)等。
可以理解的是,本申请实施例所提供的基于区块链的数据处理方法可以由计算机设备执行,计算机设备包括但不限于终端或服务器。上述服务器可以是独立的物理服务器,也可以是多个物理服务器构成的服务器集群或者分布式系统,还可以是提供云服务、云数据库、云计算、云函数、云存储、网络服务、云通信、中间件服务、域名服务、安全服务、CDN、以及大数据和人工智能平台等基础云计算服务的云服务器。上述终端可以是智能手机、平板电脑、笔记本电脑、台式计算机、智能音箱、智能手表、车载终端以及智能电视等,但并不局限于此。终端以及服务器可以通过有线或无线通信方式进行直接或间接地连接,本申请在此不做限制。
进一步地,请参见图2,图2是本申请实施例提供的一种基于区块链的数据处理方法的流程示意图。该基于区块链的数据处理方法可以由计算机设备执行,该计算机设备可以包括图1中的共识网络101中的任意一个共识节点。如图2所示,该数据处理过程可以包括:
步骤S101,获取区块文件,从区块文件中获取针对区块的多于一个待记账数据集合;多于一个待记账数据集合的数据类别互不相同。
具体的,待记账数据集合的数量多于1个,如可以为m个,m为大于1的正整数,每个待记账数据集合之间各自的数据类别互不相同。如m=3时,m个数据类别可以包括区块类别、状态类别以及读写类别。在一个实施例中,计算机设备可以从区块文件中获取与区块类别相关联的区块数据,根据区块数据生成区块数据集合;从区块文件中获取与状态类别相关联的状态数据,根据状态数据生成状态数据集合;从区块文件中获取与读写类别相关联的读写数据,根据读写数据生成读写数据集合;根据区块数据集合、状态数据集合以及读写数据集合,生成m个待记账数据集合。针对每个数据类别,可以基于数据类别相关联的数据构建索引对,以生成相应的待记账数据集合。本实施例中,通过将数据类别划分为区块类别、状态类别以及读写类别,以根据各自相关联的数据分别生成区块数据集合、状态数据集合、读写数据集合,并综合得到待记账数据集合,从而可以将待记账数据进行类别划分,有利于基于不同数据类别进行并行处理,提高区块链数据处理效率。
在一个实施例中,区块数据包括交易信息以及区块信息,区块信息包括交易信息的交易标识;可以针对交易信息和区块信息构建索引对,以生成区块数据集合。根据区块数据生成区块数据集合的具体过程可以包括:计算机设备将交易标识作为第一索引键,将交易信息作为第一索引值,将第一索引键以及第一索引值确定为第一索引对;将区块信息对应的区块高度作为第二索引键,将区块信息作为第二索引值,将第二索引键以及第二索引值确定为第二索引对;将区块信息对应的区块标识作为第三索引键,将区块信息对应的区块高度作为第三索引值,将第三索引键以及第三索引值确定为第三索引对;将第一索引对、第二索引对以及第三索引对生成区块 数据集合。区块高度可以用于描述相应区块在区块链中所处的位置。
本实施例中,通过将交易标识与交易信息构建第一索引对,将区块信息对应的区块高度与区块信息构建第二索引对,将区块信息对应的区块标识与区块信息对应的区块高度构建第三索引对,并根据第一索引对、第二索引对和第三索引对生成区块数据集合,从而得到包括各种区块信息的区块数据集合,通过区块数据集合可以进行并行写处理,可以提升区块链的网络性能以及降低对外业务的响应时间。
在一个实施例中,根据状态数据生成状态数据集合的具体过程可以包括:计算机设备将合约标识以及对象标识组合为第四索引键,将状态数据作为第四索引值,将第四索引键以及第四索引值确定为第四索引对;获取对象标识的历史状态数据对应的版本标识,根据历史状态数据对应的版本标识生成状态数据对应的版本标识;将状态数据以及状态数据对应的版本标识作为第五索引键,将状态数据对应的区块高度作为第五索引值,将第五索引键以及第五索引值确定为第五索引对;将第四索引对以及第五索引对生成状态数据集合。
本实施例中,通过将合约标识以及对象标识与状态数据构建第四索引对,将状态数据以及状态数据对应的版本标识与状态数据对应的区块高度构建第五索引对,并根据第四索引对和第五索引对生成状态数据集合,从而得到包括各种区块信息的状态数据集合,通过状态数据集合可以进行并行写处理,可以提升区块链的网络性能以及降低对外业务的响应时间。
在一个实施例中,读写数据包括读数据以及写数据;根据读写数据生成读写数据集合的具体过程可以包括:计算机设备将读数据的读数据标识作为第六索引键,将读数据作为第六索引值,将第六索引键以及第六索引值确定为第六索引对;将写数据的写数据标识作为第七索引键,将写数据作为第七索引值,将第七索引键以及第七索引值确定为第七索引对;将读数据对应的区块高度作为第八索引键,将读数据标识作为第八索引值,将第八索引键以及第八索引值确定为第八索引对;将写数据对应的区块高度作为第九索引键,将写数据标识作为第九索引值,将第九索引键以及第九索引值确定为第九索引对;将第六索引对、第七索引对、第八索引对以及第九索引对生成读写数据集合。
本实施例中,通过将读数据的读数据标识与读数据构建第六索引对,将写数据的写数据标识与写数据构建第七索引对,将读数据对应的区块高度与读数据标识构建第八索引对,将写数据对应的区块高度与写数据标识构建第九索引对,并根据第六索引对、第七索引对、第八索引对和第九索引对生成读写数据集合,从而包括各种区块信息的读写数据集合,通过读写数据集合可以进行并行写处理,可以提升区块链的网络性能以及降低对外业务的响应时间。
区块链网络中的每一个区块达成共识后,区块链网络中的共识节点需要将共识通过的区块(此时的区块可以理解为缓存区块,因为未写入账本)以及与区块相关联的数据(例如执行交易结果集以及读写数据集)写入账本。请一并参见图3a,图3a是本申请实施例提供的一种基于区块链的数据处理的场景示意图。如图3a所示,区块20a在区块链网络20b中的共识结果为共识通过结果,故共识节点20c可以将区块20a写入至区块文件20d。其中,区块20a可以包括一个或者多个区块,本申请实施例不对区块20a的数量进行限制,可以根据实际应用中区块链网络的区块共识方式进行设定。其中,区块文件20d可以理解为共识节点20c的一个数据库,用于存储区块20a、区块20a的读写数据以及状态数据等,可以用于待记账数据集合写入过程中,异常中断后的恢复。此外,区块文件20a将最大区块高度记录为区块检查点,可以理解的是,最大 区块高度一般为区块20a中的最大区块高度。若在将区块20a写入账本的同时,共识网络共识通过新的区块(该区块的区块高度大于区块20a的区块高度),共识节点20c可以先不将新的区块添加至区块文件20d中,在将区块20a写入磁盘或分布式存储后,再将新的区块添加至区块文件20d中,此时,区块文件20d可以记录新添加的区块中的最大区块高度为新的区块检查点。在具体应用中,若在将区块20a写入账本的同时,共识网络共识通过新的区块(该区块的区块高度大于区块20a的区块高度),共识节点20c可以将新的区块添加至区块文件20d中,但暂不更新区块检查点,即区块检查点为区块20a中的最大区块高度,在将区块20a成功写入账本后,再更新区块检查点。
本申请实施例针对账本里的每个状态增加版本标识,每当执行交易的合约业务改变某个状态后,该状态的版本标识可以加1,并同时映射到发生变化的区块高度,旨在标志该修改是在某个区块发生的。其中,状态可以理解为账本中的对象,例如用户账号等;版本标识可以自定义,本申请实施例不对版本标识进行限定,可以为任意一种能够用于标识状态的信息。
可以理解的是,共识节点20c是以数据索引的关系将区块20a写入区块文件20d中,即根据数据类别将待记账数据集合分别写入至区块文件20d中;共识节点20a也可以直接将区块20a写入至区块文件20d中,在将区块20a写入账本时,根据数据类别对区块20a中的数据分类,生成m个待记账数据集合,本申请实施例不限定m个待记账数据集合的生成时间点,可以根据实际应用场景进行设定。其中,本申请实施例不对数据类别进行限定,可以根据实际应用场景进行设定,本申请以区块类别、状态类别以及读写类别为例进行叙述。其中,区块类别是指区块数据对应的类别,区块数据可以包括交易信息(即交易详情数据)以及区块信息,区块信息包括交易信息的交易标识,交易标识可以为交易信息对应的哈希值。状态类别是指状态数据对应的类别,状态数据可以包括一个对象的当前记录或特征,例如对象a在时间戳b基于合约c进行了交易d,本申请实施例不对状态数据的形式进行限定,可以根据实际应用场景进行设定。读写类别是指交易信息对应的读写数据对应的类别。
请再参见图3a,本申请实施例以m=3为例进行叙述,共识节点20c从区块文件20d中获取针对区块20a的3个数据类别互不相同的待记账数据集合,即图3a中示例的待记账数据集合201e、待记账数据集合202e以及待记账数据集合203e。其中,待记账数据集合201e可以是数据类别为区块类别的区块数据集合,该区块数据集合为一个数据映射表,具体可以为将交易标识作为第一索引键,将交易信息作为第一索引值,将第一索引键以及第一索引值确定为第一索引对;进一步地,将区块信息对应的区块高度作为第二索引键,将区块信息作为第二索引值,将第二索引键以及第二索引值确定为第二索引对;进一步地,将区块信息对应的区块标识(可以为区块哈希)作为第三索引键,将区块信息对应的区块高度作为第三索引值,将第三索引键以及第三索引值确定为第三索引对;共识节点20c将第一索引对、第二索引对以及第三索引对生成区块数据集合。
其中,待记账数据集合202e可以是数据类别为状态类别的状态数据集合,该状态数据集合为一个数据映射表,具体可以为将合约标识以及对象标识组合为第四索引键,将状态数据作为第四索引值,将第四索引键以及第四索引值确定为第四索引对,其中,合约标识可以为任意一种能够标识合约的信息,例如合约存储地址、合约名称等,同理,对象标识可以为任意一种能够标识对象的信息,例如对象账号等,本申请实施例对合约标识以及对象标识不做限定;获取对象标 识的历史状态数据对应的版本标识,根据历史状态数据对应的版本标识生成状态数据对应的版本标识;将状态数据以及状态数据对应的版本标识作为第五索引键,将状态数据对应的区块高度作为第五索引值,将第五索引键以及第五索引值确定为第五索引对;共识节点20c将第四索引对以及第五索引对生成状态数据集合。
其中,待记账数据集合203e可以是数据类别为读写类别的读写数据集合,该读写数据集合为一个数据映射表,具体可以为将读数据的读数据标识(可以为读数据的哈希值)作为第六索引键,将读数据作为第六索引值,将第六索引键以及第六索引值确定为第六索引对;将写数据的写数据标识(可以为写数据的哈希值)作为第七索引键,将写数据作为第七索引值,将第七索引键以及第七索引值确定为第七索引对;将读数据对应的区块高度作为第八索引键,将读数据标识作为第八索引值,将第八索引键以及第八索引值确定为第八索引对;将写数据对应的区块高度作为第九索引键,将写数据标识作为第九索引值,将第九索引键以及第九索引值确定为第九索引对;将第六索引对、第七索引对、第八索引对以及第九索引对生成读写数据集合。
步骤S102,根据多于一个待记账数据集合,对多于一个数据存储组件并行执行数据写操作,获取多于一个数据存储组件分别对应的数据存储结果;其中,数据存储组件的数量与待记账数据集合的数量相同,一个数据存储组件用于存储一种数据类别的待记账数据集合。
具体的,待记账数据集合通过对应的数据存储组件执行数据写操作,以对待记账数据集合进行存储,实现时可以通过写入指令对数据存储组件执行数据写操作,以实现对待记账数据集合的存储处理,得到相应的数据存储结果。不同数据类别对应于不同的数据存储组件,即对于数据类别互不相同的待记账数据集合,通过各自对应的数据存储组件分别执行数据写操作。例如,待记账数据集合的数量为m个时,m个待记账数据集合可以包括批处理待记账数据集合,如可以为待记账数据集合A b,m个数据存储组件包括用于存储待记账数据集合A b的批处理数据存储组件,具体为数据存储组件C b,b为正整数,且b小于或等于m。
在一个实施例中,并行执行数据写操作的处理步骤可以包括:计算机设备获取针对批处理待记账数据集合,即针对待记账数据集合A b的批处理数据写入指令;根据批处理数据写入指令对批处理数据存储组件,即对数据存储组件C b执行数据写操作,将待记账数据集合A b写入至数据存储组件C b;在对数据存储组件C b执行数据写操作的同时,根据其他待记账数据集合,对其他数据存储组件并行执行数据写操作;其他待记账数据集合包括多于一个待记账数据集合中除了批处理待记账数据集合之外的待记账数据集合,其他数据存储组件包括多于一个数据存储组件中除了批处理数据存储组件之外的数据存储组件。具体可以根据(m-1)个待记账数据集合,对(m-1)个数据存储组件并行执行数据写操作;(m-1)个待记账数据集合包括m个待记账数据集合中除了待记账数据集合A b之外的待记账数据集合,(m-1)个数据存储组件包括m个数据存储组件中除了数据存储组件C b之外的数据存储组件。本实施例中,通过对多于一个数据存储组件并行执行数据写操作,可以实现并行写入多于一个待记账数据集合,故可以提升区块链的网络性能以及降低对外业务的响应时间。
在本申请实施例中,将账本存储分为三大数据存储组件,请一并参见图3a,该三大数据存储组件可以包括用于存储区块数据的数据存储组件201f、用于存储状态数据的数据存储组件202f,以及用于存储读写数据的数据存储组件203f。
本申请实施例采用异步落账方法对3个待记账数据集合分别进行存储,以避开对读写资源 的依赖以及提升区块链网络整体的性能,具体为在将待记账数据集合201e写入数据存储组件201f的同时,并行执行数据存储组件202f,以及数据存储组件203f的数据写操作,以将待记账数据集合202e写入数据存储组件202f中,将待记账数据集合203e写入数据存储组件203f中。其中,待记账数据集合201e是通过一条批处理数据写入指令,写入至数据存储组件201f中,待记账数据集合202e是通过一条批处理数据写入指令,写入至数据存储组件202f中,待记账数据集合203e是通过一条批处理数据写入指令,写入至数据存储组件203f中。
可以理解的是,当待记账数据集合成功写入至数据存储组件时,数据存储组件返回的数据存储结果为数据存储成功结果,当待记账数据集合没有成功写入至数据存储组件时,数据存储组件返回的数据存储结果为数据存储失败结果。如图3a所示,共识节点20c获取3个数据存储组件分别返回的数据存储结果,其中,数据存储组件201f返回数据存储失败结果201g,数据存储组件202f返回数据存储成功结果202g,数据存储组件203f返回数据存储成功结果203g。
步骤S103,若数据存储结果中存在数据存储失败结果,则获取区块文件对应的区块检查点,以及多于一个数据存储组件分别对应的组件检查点;区块检查点为区块文件中的最大区块高度,组件检查点包括多于一个数据存储组件中分别对应的最大区块高度。
具体的,每个待记账数据集合并行执行数据写操作,得到相应的数据存储结果,若多于一个的数据存储结果中存在数据存储失败结果,表明并行数据写操作未完全成功,则需要进行重写。具体地,若m个数据存储结果中存在数据存储失败结果,则计算机设备将数据存储结果为数据存储失败结果的数据存储组件,确定为目标数据存储组件;从m个待记账数据集合中,获取与目标数据存储组件相关联的目标待记账数据集合;根据目标待记账数据集合,对目标数据存储组件执行数据写操作,获取目标数据存储组件的数据重写存储结果;若数据重写存储结果为数据存储失败结果,则统计目标数据存储组件被执行数据写操作的操作次数;当操作次数小于操作次数阈值时,根据目标待记账数据集合,重新对目标数据存储组件执行数据写操作;当操作次数等于操作次数阈值时,获取区块文件对应的区块检查点,以及m个数据存储组件分别对应的组件检查点。
其中,目标数据存储组件是数据存储失败结果所对应的数据存储组件,目标待记账数据集合为与目标数据存储组件关联的待记账数据集合,即目标待记账数据集合的数据写操作执行失败,目标待记账数据集合未成功存储,则计算机设备根据目标待记账数据集合对目标数据存储组件执行数据写操作,得到数据重写存储结果,若数据重写存储结果仍属于数据存储失败结果,则统计目标数据存储组件被执行数据写操作的操作次数,若操作次数小于操作次数阈值,则再次对目标数据存储组件执行数据写操作,直至数据重写存储结果为存储成功。若操作次数等于操作次数阈值,则执行获取区块文件对应的区块检查点,以及多于一个数据存储组件分别对应的组件检查点的步骤。为了保证账本数据的一致性和完整性,在上述数据写入过程中,当发生任何一个数据存储组件写入失败时,本申请实施例将采用有限重试机制直至写成功或者重试超出范围。请再参见图3a,在图3a中示例数据存储组件201f写入待记账数据集合201e失败,故数据存储组件201f返回数据存储失败结果201g,其中,数据存储成功结果202g可以表征待记账数据集合202e成功写入至数据存储组件202f中,数据存储成功结果203g可以表征待记账数据集合203e成功写入至数据存储组件203f中。
由于待记账数据集合201e没有成功写入至数据存储组件201f中,故共识节点20c可以将 数据存储组件201f确定为目标数据存储组件,同时,将待记账数据集合201e确定为目标待记账数据集合。如图3a所示,共识节点20c根据待记账数据集合201e,重新对数据存储组件201f执行数据写操作,获取数据存储组件201f的数据重写存储结果;可以理解的是,若数据重写存储结果为数据存储失败结果,则统计数据存储组件201f被执行数据写操作的操作次数;当操作次数小于操作次数阈值时,根据待记账数据集合201e,重新对数据存储组件201f执行数据写操作;当操作次数等于操作次数阈值时,共识节点20c获取区块文件20d对应的区块检查点,以及3个数据存储组件分别对应的组件检查点。其中,组件检查点为数据存储组件中所记录的最大区块高度。可以理解的是,操作次数阈值可以根据实际应用场景进行设定。
步骤S104,根据区块检查点以及组件检查点,在多于一个数据存储组件中确定属于组件异常状态的数据存储组件,根据区块文件对属于组件异常状态的数据存储组件执行数据写操作。
具体的,组件检查点与数据存储组件对应,即每个数据存储组件对应于一个组件检查点,若数据存储组件的数量为m个,则在m个组件检查点中,计算机设备将小于区块检查点的组件检查点确定为待更新组件检查点;在m个数据存储组件中,将与待更新组件检查点对应的数据存储组件确定为待恢复数据存储组件;待恢复数据存储组件的组件状态为组件异常状态;根据待更新组件检查点以及区块检查点,确定待恢复数据存储组件的待恢复区块高度区间;从区块文件中,获取属于待恢复区块高度区间的待恢复数据集合;待恢复数据集合对应的数据类别与待恢复数据存储组件对应的数据类别相同;根据待恢复数据集合,对待恢复数据存储组件执行数据写操作。
其中,组件检查点与数据存储组件对应,每个数据存储组件对应于一个组件检查点,即组件检查点的数量与数据存储组件的数量相同。在各个组件检查点中,待更新组件检查点是小于所述区块检查点的组件检查点。计算机设备从多于一个数据存储组件中确定待恢复数据存储组件,待恢复数据存储组件是与待更新组件检查点对应的数据存储组件,待恢复数据存储组件的组件状态为组件异常状态,即从多于一个数据存储组件中确定组件异常状态的待恢复数据存储组件,该待恢复数据存储组件与待更新组件检查点对应。计算机设备根据待更新组件检查点以及区块检查点,确定待恢复数据存储组件的待恢复区块高度区间,具体可以通过查询待更新组件检查点对应的区块检查点,确定待恢复数据存储组件的待恢复区块高度区间。计算机设备从区块文件中获取属于待恢复区块高度区间的待恢复数据集合,待恢复数据集合与待恢复数据存储组件具有相同的数据类别。计算机设备可以按照待恢复区块高度区间,从区块文件中查找得到待恢复数据集合。计算机设备根据待恢复数据集合,对待恢复数据存储组件执行数据写操作,从而针对没有成功写入数据存储组件的待记账数据集合,通过区块检查点和组件检查点确定待恢复数据存储组件和待恢复数据集合,并根据待恢复数据集合对待恢复数据存储组件进行重写,以确保区块链数据的一致性,确保数据安全。
当存在没有成功写入数据存储组件的待记账数据集合时,共识节点还可以通过区块文件恢复待记账数据集合中的待恢复数据,请一并参见图3b,图3b是本申请实施例提供的一种基于区块链的数据处理的场景示意图。其中,图3b中的区块文件20d与图3a中的区块文件20d的含义一致,同理,图3b中的数据存储组件201f、数据存储组件202f、数据存储组件203f以及待记账数据集合201e亦如此。
如图3b所示,当操作次数等于操作次数阈值时,共识节点获取区块文件20d对应的区块检 查点201d(等于图3a中区块20a的最大区块高度),以及3个数据存储组件分别对应的组件检查点,如图3b示例的组件检查点2011f、组件检查点2021f以及组件检查点2031f。共识节点将上述3个组件检查点分别与区块检查点201d进行对比,将小于区块检查点201d的组件检查点确定为待更新组件检查点,如图3b所示例的组件检查点2011f,此时,可以确定区块文件20d中的区块数据没有被完整写入至数据存储组件201f中。其中,区块文件20d中的区块数据可以包括区块20a对应的区块数据,即待记账数据集合201e。
进一步地,共识节点将与待更新组件检查点对应的数据存储组件确定为待恢复数据存储组件,如图3b所示例的数据存储组件201f为待恢复数据存储组件,由于数据存储组件201f存在没有写入的区块数据,故可以将数据存储组件201f的组件状态确定为组件异常状态;可以理解的是,数据存储组件202f成功写完区块文件20d中的状态数据(如图3a示例的待记账数据集合202e),故可以确定数据存储组件202f的组件状态为组件正常状态,同理,数据存储组件203f成功写完待记账数据集合203e,故共识节点可以确定数据存储组件203f的组件状态为组件正常状态。
共识节点根据待更新组件检查点以及区块检查点,可以确定待恢复数据存储组件的待恢复区块高度区间;假设区块20a包括区块8、区块9以及区块10,则区块检查点201d为区块高度10,假设组件检查点2011f为区块高度8,则可以确定待恢复区块高度区间包括区块高度9至区块高度10,故共识节点可以从区块文件20d中,获取属于待恢复区块高度区间的待恢复数据集合20h,即获取区块9至区块10中的区块数据,然后根据待恢复数据集合20h,对待恢复数据存储组件执行数据写操作。具体实现时,共识节点可以将区块20a对应的区块数据(即区块8至区块10分别对应的区块数据)作为待恢复数据集合,再次写入数据存储组件201f中,此时,数据存储组件201f将区块8对应的区块数据进行删除,然后对待恢复数据集合执行写入操作。
在具体应用中,若在没有成功写入完整的待记账数据集合时,数据存储组件可以将部分已写入的数据进行删除,例如数据存储组件201f在写入待记账数据集合201e的过程中,出现异常,只写入待记账数据集合201e的部分数据,此时,数据存储组件201f可以将已写入的部分数据进行删除。可以理解的是,当成功写入待记账数据集合时,数据存储组件可以根据新写入的数据集合更新组件检查点。
在本申请实施例中,当获取到新共识通过的区块时,可以将其添加至区块文件中,在该区块文件中获取针对该区块的多于一个数据类别互不相同的待记账数据集合;进一步地,根据多于一个待记账数据集合,对相同数量的数据存储组件并行执行数据写操作,获取数据存储组件分别对应的数据存储结果,可以理解的是,多于一个数据存储组件分别存储数据类别互不相同的数据,即一个数据存储组件用于存储一种数据类别的待记账数据集合;若多于一个数据存储结果中存在数据存储失败结果,则表明存在待记账数据集合没有成功写入至数据存储组件,此时,获取区块文件对应的区块检查点,以及多于一个数据存储组件分别对应的组件检查点;通过区块检查点以及多于一个组件检查点,可以在多于一个数据存储组件中确定属于组件异常状态的数据存储组件,即没有将对应的数据类别的待记账数据集合成功写入的数据存储组件,此时,可以根据区块文件对属于组件异常状态的数据存储组件执行数据写操作。上述可知,在本申请实施例中,通过对多于一个数据存储组件并行执行数据写操作,可以实现并行写入多于一个待记账数据集合,故可以提升区块链的网络性能以及降低对外业务的响应时间;此外,在多于一个数 据存储结果中存在数据存储失败结果时,本申请实施例通过区块检查点以及多于一个组件检查点,可以确定属于组件异常状态的数据存储组件,并根据区块文件对属于组件异常状态的数据存储组件重新执行数据写操作,故可以保证缓存(可以等同于多于一个待记账数据集合)和分布式存储(等同于多于一个数据存储组件)之间的数据一致,避免数据丢失。
在一个实施例中,在获取区块文件对应的区块检查点,以及多于一个数据存储组件分别对应的组件检查点的步骤之前,还包括:将数据存储结果为数据存储失败结果的数据存储组件,确定为目标数据存储组件;获取目标数据存储组件被执行数据写操作的操作次数;及当操作次数等于操作次数阈值时,执行获取区块文件对应的区块检查点,以及多于一个数据存储组件分别对应的组件检查点的步骤。
具体地,计算机设备针对数据存储失败结果的目标数据存储组件,获取目标数据存储组件被执行数据写操作的操作次数,操作次数可以在目标数据存储组件每次被执行数据写操作时进行更新。若操作次数等于操作次数阈值,操作次数阈值根据实际需要进行预先设定,则计算机设备执行获取区块文件对应的区块检查点,以及多于一个数据存储组件分别对应的组件检查点的步骤。本实施例中,在操作次数等于操作次数阈值,表明达到重写最大次数,则执行获取区块检查点和组件检查点,针对组件异常状态的数据存储组件进行数据写操作的处理,以确保数据的一致,避免数据丢失。在一个实施例中,基于区块链的数据处理方法还包括:将操作次数与操作次数阈值进行比较;当操作次数小于操作次数阈值时,根据目标待记账数据集合,对目标数据存储组件执行数据写操作,获取目标数据存储组件的数据重写存储结果;目标待记账数据集合,是多于一个待记账数据集合中与目标数据存储组件相关联的待记账数据集合;及若数据重写存储结果属于数据存储失败结果,更新操作次数,并返回将操作次数与操作次数阈值进行比较的步骤。
其中,目标待记账数据集合,是多于一个待记账数据集合中与目标数据存储组件相关联的待记账数据集合。具体地,计算机设备针对数据存储失败结果的目标数据存储组件,获取目标数据存储组件被执行数据写操作的操作次数,操作次数可以在目标数据存储组件每次被执行数据写操作时进行更新。计算机设备将操作次数与操作次数阈值进行比较,若操作次数小于操作次数阈值,则计算机设备根据目标待记账数据集合,对目标数据存储组件执行数据写操作,获取目标数据存储组件的数据重写存储结果。若数据重写存储结果属于数据存储失败结果,则计算机设备更新操作次数,并返回将操作次数与操作次数阈值进行比较的步骤,以再次判定是否达到重写的最大次数。本实施例中,表明未达到重写最大次数,则执行重写的操作,并将判断更新后的操作次数是否达到最大次数,以确保数据的一致,避免数据丢失。
进一步地,请参见图4,图4是本申请实施例提供的一种基于区块链的数据处理方法的流程示意图。该基于区块链的数据处理方法可以由计算机设备执行,该计算机设备可以包括图1中的共识网络101中的任意一个共识节点。如图4所示,该数据处理过程可以包括如下步骤。
步骤S201,获取区块文件,从区块文件中获取针对区块的m个数据类别互不相同的待记账数据集合;m为大于1的正整数。
步骤S202,根据m个待记账数据集合,对m个数据存储组件并行执行数据写操作,获取m个数据存储组件分别对应的数据存储结果;其中,一个数据存储组件用于存储一种数据类别的待记账数据集合。
步骤S203,若m个数据存储结果中存在数据存储失败结果,则获取区块文件对应的区块检查点,以及m个数据存储组件分别对应的组件检查点;区块检查点为区块文件中的最大区块高度,m个组件检查点包括m个数据存储组件中分别对应的最大区块高度。
步骤S204,根据区块检查点以及m个组件检查点,在m个数据存储组件中确定属于组件异常状态的数据存储组件,根据区块文件对属于组件异常状态的数据存储组件执行数据写操作。步骤S201-步骤S204分别对应的具体过程,可以参见上文图2所对应的实施例中的描述。
步骤S205,当系统时间达到数据对账周期时,基于组件检查点F e从缓存区块文件中获取已记账数据集合;已记账数据集合对应的最大区块高度等于组件检查点F e,已记账数据集合对应的数据类别与数据存储组件D e的数据类别相同;缓存区块文件是指存储于缓存层中的区块文件。
当达到数据对账周期时,计算机设备基于第一组件检查点从缓存区块文件中获取已记账数据集合;已记账数据集合对应的最大区块高度等于第一组件检查点,已记账数据集合对应的数据类别与第一数据存储组件的数据类别相同;缓存区块文件是指存储于缓存层中的区块文件。其中,多于一个数据存储组件包括第一数据存储组件,第一数据存储组件可以是多于一个数据存储组件中的任意一个数据存储组件,组件检查点包括与第一数据存储组件对应的第一组件检查点。具体的,m个数据存储组件包括第一数据存储组件,具体为数据存储组件D e,m个组件检查点包括与第一数据存储组件对应的第一组件检查点,具体为数据存储组件D e对应的组件检查点F e,e为正整数且e小于或等于m,即第一数据存储组件可以是m个数据存储组件中的任意一个数据存储组件。数据对账周期用于周期性地对区块链账本进行全局检验,以确保区块链账本数据的完整性。当系统时间达到数据对账周期时,可以触发进行全量对账处理,系统时间可以是区块链数据处理系统的时间,具体可以为现实实际时间。已记账数据集合是区块链账本中已经完成记账处理,即已经成功存储的数据。
本申请实施例提出一种在区块链异步落账的过程中保证账本数据一致性的方法,该方法旨在共识节点采用异步落账的时候,通过如下三个保证达到共识节点在缓存和分布式存储之间的数据一致性,以及和其他共识节点的账本分布式存储的数据一致性,三个保证可以归纳为:1、数据写入失败时,有限重试写入操作,该保证可以请参见上文图2所对应的实施例中步骤S103中的描述;2、区块文件作为重做(redo)日志,重做待恢复数据集合,该待恢复数据集合的生成以及作用,请参见上述图2所对应的实施例中步骤S104中的描述,此外,区块文件还可以在分布式存储发生主备切换丢掉数据的情况下,用于生成待恢复数据,生成待恢复数据的过程请参见下文的描述;3、定时全量数据校验,即定时账本校验,请参见下文的描述。为了提高区块链的网络性能,如便于读取数据,共识节点20c可以在缓存层生成缓存区块文件40a,其存储的数据与上文描述的区块文件中的数据一致。
针对分布式存储发生主备切换丢掉数据的情况,本申请实施例采用定时全量对账方式。请一并参见图5,图5是本申请实施例提供的一种基于区块链的数据处理的场景示意图。如图5所示,共识节点20c(等同于图2中的共识节点20c)可以设置数据对账周期,其中数据对账周期用于周期性地对共识节点20c的账本(全量数据)进行核实,即检验账本数据的完整性。该数据对账周期可以根据实际应用场景进行设定。
假设数据存储组件201f用于存储属于区块类别的数据,数据存储组件202f用于存储属于状态类别的数据,数据存储组件203f用于存储属于读写类别的数据,则数据存储组件201f可 以包括共识节点20c对应的账本中的区块数据2012f,数据存储组件202f可以包括共识节点20c对应的账本中的状态数据2022f,数据存储组件203f可以包括共识节点20c对应的账本中的读写数据2032f。
根据上文图2所对应的实施例可知,在本申请实施例中,将账本存储分为三大数据存储组件,即图5所示例的数据存储组件201f、数据存储组件202f以及数据存储组件203f,其中,数据存储组件201f可以记录有组件检查点2011f,数据存储组件202f可以记录有组件检查点2021f,数据存储组件203f可以记录有组件检查点2031f,上述3个组件检查点在正常情况下,应该是相同的,若存在某个数据存储组件的组件状态为组件异常状态,则上述3个组件检查点会存在不相同的情况。
共识节点20c根据数据存储组件201f中所记录的组件检查点2011f,从缓存数据库40a中获取已记账数据集合401b,假设组件检查点2011f为区块高度10,则已记账数据集合401b可以包括缓存区块文件40a中最小区块高度对应的区块数据至区块10中的区块数据。共识节点20c根据数据存储组件202f中所记录的组件检查点2021f,从缓存数据库40a中获取已记账数据集合402b,假设组件检查点2021f为区块高度10,则已记账数据集合402b可以包括缓存区块文件40a中最小区块高度对应的状态数据至区块10中的状态数据。共识节点20c根据数据存储组件203f中所记录的组件检查点2031f,从缓存数据库40a中获取已记账数据集合403b,假设组件检查点2031f为区块高度10,则已记账数据集合403b可以包括缓存区块文件40a中最小区块高度对应的读写数据至区块10中的读写数据。
可以理解的是,缓存区块文件40a中可能没有存储全量数据,例如在将图3a所示例的区块20a进行数据存储时,缓存区块文件40a可能将前期已入账的数据进行删除,该删除方式可以是定时删除,也可以是缓存区块文件40a定量删除,例如缓存区块文件仅保存最新的10个区块分别对应的数据,还可以是其他方式等。
步骤S206,将数据存储组件D e中的数据,与已记账数据集合中的数据进行对比,得到第一对比结果,根据第一对比结果确定数据存储组件D e的组件状态。
计算机设备将第一数据存储组件中的数据,与已记账数据集合中的数据进行对比,得到第一对比结果,根据第一对比结果确定第一数据存储组件的组件状态。具体地,通过将数据存储组件D e中的数据与已记账数据集合中的数据进行对比,如通过将数据标识进行对比,可以确定数据存储组件D e中的数据是否已经存储成功,即是否已经成功完成记账处理,从而确定数据存储组件D e的组件状态。当第一对比结果为对比相同时,则可以确定数据存储组件D e的组件状态为组件正常状态,否则为组件异常状态。
在一个实施例中,数据类别包括状态类别;确定第一数据存储组件的组件状态的处理包括:当第一数据存储组件对应的数据类别为状态类别时,获取第一数据存储组件中针对第一状态数据的第一版本标识,获取已记账数据集合中针对第一状态数据的第二版本标识;将第一版本标识与第二版本标识进行对比,得到状态对比结果;若状态对比结果表示第一版本标识与第二版本标识不同,则确定第一数据存储组件的组件状态为组件异常状态。
具体地,若第一数据存储组件对应的数据类别为状态类别,则通过第一数据存储组件中针对第一状态数据的第一版本标识,与已记账数据集合中针对第一状态数据的第二版本标识进行对比,以根据得到的状态对比结果确定第一数据存储组件的组件状态。
本实施例中,针对状态类别的数据存储组件,通过对于相同状态数据在第一数据存储组件和在已记账数据集合中的版本标识进行对比,以实现第一数据存储组件中数据的对比,可以准确确定第一数据存储组件的组件状态,以确保全量数据的完整性。
在一个实施例中,数据类别包括区块类别;确定第一数据存储组件的组件状态的处理包括:当第一数据存储组件,如数据存储组件D e对应的数据类别为区块类别时,获取数据存储组件D e中针对第一区块高度的第一区块标识,获取已记账数据集合中针对第一区块高度的第二区块标识;将第一区块标识与第二区块标识进行对比,得到区块对比结果;若区块对比结果表示第一区块标识与第二区块标识不同,则确定数据存储组件D e的组件状态为组件异常状态。
具体地,若第一数据存储组件对应的数据类别为区块类别,则通过第一数据存储组件中针对第一区块高度的第一区块标识,与已记账数据集合中针对第一区块高度的第二区块标识进行对比,以根据得到的区块对比结果确定第一数据存储组件的组件状态。本实施例中,针对区块类别的数据存储组件,通过对于相同区块高度在第一数据存储组件和在已记账数据集合中的区块标识进行对比,以实现第一数据存储组件中数据的对比,可以准确确定第一数据存储组件的组件状态,以确保全量数据的完整性。
在一个实施例中,数据类别包括读写类别;确定第一数据存储组件的组件状态的处理包括:当第一数据存储组件,如数据存储组件D e对应的数据类别为读写类别时,获取数据存储组件D e中针对第二区块高度的第一写数据标识,获取已记账数据集合中针对第二区块高度的第二写数据标识;将第一写数据标识与第二写数据标识进行对比,得到读写对比结果;若读写对比结果表示第一写数据标识与第二写数据标识不同,则确定数据存储组件D e的组件状态为组件异常状态。
具体地,若第一数据存储组件对应的数据类别为读写类别,则通过第一数据存储组件中针对第二区块高度的第一写数据标识,与已记账数据集合中针对第二区块高度的第二写数据标识进行对比,以根据得到的读写对比结果确定第一数据存储组件的组件状态。本实施例中,针对读写类别的数据存储组件,通过对于相同区块高度在第一数据存储组件和在已记账数据集合中的写数据标识进行对比,以实现第一数据存储组件中数据的对比,可以准确确定第一数据存储组件的组件状态,以确保全量数据的完整性。
结合步骤S205以及图5,共识节点20c对账本中的全量数据(包括全量区块数据、全量状态数据以及全量读写数据)进行对账处理。在将已记账数据集合403b以及数据存储组件203f中的数据(等同于图5所示例的读写数据2032f)进行对账时,共识节点20c可以将数据存储组件203f中每个第二区块高度分别对应的第一写数据标识,与已记账数据集合403b中对应的第二区块高度的第二写数据标识进行对比,如图5所示,将区块高度1对应的写数据标识A1(假设为数据存储组件203f中的第一写数据标识)与写数据标识A2(假设为已记账数据集合403b中的第二写数据标识)进行对比,若对比结果表明写数据标识A1与写数据标识A2不同,则可以确定数据存储组件203中针对区块1的写数据标识A1是错误(异常)的数据,若两者相同,则可以确定数据存储组件203中针对区块1的写数据标识A1是准确(正常)的数据;同理,将区块高度2对应的写数据标识B1与写数据标识B2进行对比,若对比结果表明写数据标识B1与写数据标识B2不同,则可以确定数据存储组件203中针对区块2的写数据标识B1是错误(异常)的数据,若两者相同,则可以确定数据存储组件203中针对区块2的写数据标识B1是准确(正常)的数据;同理,将区块高度n对应的写数据标识N1与写数据标识N2进行对比,若对比结 果表明写数据标识N1与写数据标识N2不同,则可以确定数据存储组件203中针对区块n的写数据标识N1是错误(异常)的数据,若两者相同,则可以确定数据存储组件203中针对区块n的写数据标识N1是准确(正常)的数据。
上述是以数据存储组件203中的写数据标识以及已记账数据集合403b中的写数据标识进行对比为例叙述,可以理解的是,数据存储组件203中的读数据标识以及已记账数据集合403b中的读数据标识进行对比的过程与上述描述的过程一致。
针对区块高度1、区块高度2、…、区块高度n,当数据存储组件203中的写数据标识以及已记账数据集合403b中的写数据标识均相同,且数据存储组件203中的读数据标识以及已记账数据集合403b中的读数据标识均相同时,可以确定数据存储组件203f的组件状态为组件正常状态,当存在一个对比结果为不相同时,共识节点20c可以确定数据存储组件203f的组件状态为组件异常状态。
可以理解的是,共识节点20c确定数据存储组件201f的组件状态的过程,与确定数据存储组件203f的组件状态的过程一致,仅仅是对比的数据不同,在确定数据存储组件201f的组件状态的过程中,是将数据存储组件201f中针对每个区块高度的第一区块标识,与已记账数据集合401b中的每个区块高度的第二区块标识进行对比。同理,共识节点20c确定数据存储组件202f的组件状态的过程,与确定数据存储组件203f的组件状态的过程一致,仅仅是对比的数据不同,此处是将数据存储组件201f中的每个第一状态数据分别对应的第一版本标识,与已记账数据集合402b中对应的状态数据的第二版本标识进行对比,如果对比结果表示两个版本标识不一致,则表示数据存储组件202f存在异常情况,需要进行恢复。可以理解的是,当数据类别为其他类别时,可以根据实际的数据类别选择合适的数据进行对账,本申请实施例仅以区块类别、状态类别以及读写类别示例。
步骤S207,当数据存储组件D e的组件状态为组件异常状态时,根据区块文件对属于组件异常状态的数据存储组件D e执行数据写操作。
当第一数据存储组件的组件状态为组件异常状态时,计算机设备根据区块文件对属于组件异常状态的第一数据存储组件执行数据写操作。具体地,若第一数据存储组件的组件状态为组件异常状态,则对第一数据存储组件执行数据写操作,以对第一数据存储组件进行重写,确保第一数据存储组件数据能够成功记账。具体的,请再参见图5,若写数据标识A1与写数据标识A2不相同,则共识节点20c可以确定数据存储组件203f中针对区块1的写数据标识A1是错误(异常)的数据,进而可以确定数据存储组件203f的组件状态为组件异常状态。共识节点20c可以从区块文件中获取针对目标区块高度(如上述的区块高度1)的写数据标识,以目标区块高度为新的索引键,目标区块高度对应的写数据标识为新的索引值,生成新的索引对,然后将该新的索引对写入至数据存储组件203f中,以替换写数据标识A1。其中,目标区块高度表示数据存储组件203f中为异常写数据标识对应的区块高度。
在一个实施例中,共识节点20c在确定数据存储组件203f中针对区块1的写数据标识A1是错误(异常)的数据后,可以进一步确定区块1中各个交易信息分别对应的写数据标识是否准确,即与已记账数据集合403b中的区块1中对应的交易信息的写数据标识进行对比,其确定过程与步骤S206中确定各区块高度对应的写数据标识的确定过程一致。若共识节点20c确定数据存储组件203f中区块1中的交易信息1对应的写数据标识,与已记账数据集合403b中的区 块1中的交易信息1对应的写数据标识不一致,此时,可以从区块文件中获取区块1中交易信息1对应的写数据标识,将获取到的区块1中交易信息1对应的写数据标识作为新的索引值,将交易信息1的交易序号作为新的索引键,根据新的索引值以及新的索引键生成新的索引对,将新的索引对写入数据存储组件203f中,以替换数据存储组件203f中区块1中的交易信息1对应的写数据标识(即错误的数据)。
上述是以数据存储组件对应的数据类别为读写类别为例进行叙述,可以理解的是,当数据存储组件对应的数据类别为状态类别或区块类别时,根据区块文件,共识节点对属于组件异常状态的数据存储组件的重新执行写操作的过程,与上文描述的一致。本实施例中,采用定时全量对账方式,在达到数据对账周期时,将数据存储组件中的数据与已记账数据集合中的数据进行对比,以根据得到的对比结果确定数据存储组件的组件状态,若组件状态为组件异常状态,则通过区块文件对属于组件异常状态的数据存储组件执行数据写操作,从而可以避免分布式存储发生主备切换丢掉数据的情况,以确保全量数据的完整性。
在一个实施例中,基于区块链的数据处理方法还包括:当达到数据对账周期时,发送用于请求账本数据对账的数据对账请求至共识网络;数据对账请求携带组件检查点;获取处于共识网络中的共识节点返回的与组件检查点分别对应的待对账数据集合;一个组件检查点对应的数据类别与一个待对账数据集合对应的数据类别相同;至少一个数据存储组件包括第二数据存储组件,待对账数据集合包括目标待对账数据集合,第二数据存储组件对应的数据类别与目标待对账数据集合对应的数据类别相同;将目标待对账数据集合中的数据,与第二数据存储组件中的数据进行对比,得到第二对比结果,根据第二对比结果确定第二数据存储组件的组件状态;当第二数据存储组件的组件状态为组件异常状态时,根据区块文件对属于组件异常状态的第二数据存储组件执行数据写操作。
其中,第二数据存储组件可以是多于一个数据存储组件中的任意一个数据存储组件,目标待对账数据集合与第二数据存储组件对应。数据对账请求携带组件检查点,通过数据对账请求可以从共识网络中获得待对账数据集合,并将与第二数据存储组件属于相同数据类别的目标待对账数据集合中的数据,与第二数据存储组件中的数据进行对比,以确定第二数据存储组件的组件状态。
具体地,当系统时间达到数据对账周期时,发送用于请求账本数据对账的数据对账请求至共识网络;数据对账请求携带m个组件检查点;获取处于共识网络中的共识节点返回的m个待对账数据集合;一个组件检查点对应的数据类别与一个待对账数据集合对应的数据类别相同;m个数据存储组件包括数据存储组件H i,m个待对账数据集合包括待对账数据集合J i,数据存储组件H i对应的数据类别与待对账数据集合J i对应的数据类别相同,i为正整数,且i小于或等于m;将待对账数据集合J i中的数据,与数据存储组件H i中的数据进行对比,得到第二对比结果,根据第二对比结果确定数据存储组件H i的组件状态;当数据存储组件H i的组件状态为组件异常状态时,根据区块文件对属于组件异常状态的数据存储组件H i执行数据写操作。本实施例中,在达到数据对账周期时,通过携带组件检查点的数据对账请求,从共识网络中获取待对账数据集合,并将与第二数据存储组件属于相同数据类别的目标待对账数据集合中的数据,与第二数据存储组件中的数据进行对比,以确定第二数据存储组件的组件状态,若组件状态为组件异常状态,则通过区块文件对属于组件异常状态的第二数据存储组件执行数据写操作,从而可以避 免分布式存储发生主备切换丢掉数据的情况,以确保全量数据的完整性。
在一个实施例中,当数据存储组件H i,即第二数据存储组件的组件状态为组件异常状态时,根据区块文件对属于组件异常状态的数据存储组件H i执行数据写操作的具体过程可以包括:当第二数据存储组件,即数据存储组件H i的组件状态为组件异常状态,且区块文件中存在数据存储组件H i的待恢复数据时,根据区块文件中的数据存储组件H i的待恢复数据,对属于组件异常状态的数据存储组件H i执行数据写操作;还可以包括:当数据存储组件H i的组件状态为组件异常状态,且区块文件中不存在数据存储组件H i的待恢复数据时,发送用于请求恢复账本数据的数据恢复请求至共识网络;数据恢复请求携带数据存储组件H i的待恢复数据的数据标识;获取处于共识网络中的共识节点返回的数据存储组件H i的待恢复数据,根据数据存储组件H i的待恢复数据,对属于组件异常状态的数据存储组件H i执行数据写操作。
本实施例中,针对组件状态为组件异常状态的第二数据存储组件,若区块文件中存在相应的待恢复数据,则直接通过该待恢复数据对第二数据存储组件执行数据写操作;若区块文件中不存在相应的待恢复数据,则通过数据恢复请求向共识网络获取待恢复数据的数据标识,以基于数据标识获取待恢复数据对第二数据存储组件执行数据写操作。从而可以避免分布式存储发生主备切换丢掉数据的情况,以确保全量数据的完整性。
在一个实施例中,m个数据类别包括状态类别;根据第二对比结果确定数据存储组件H i的组件状态的具体过程可以包括:当第二数据存储组件,即数据存储组件H i对应的数据类别为状态类别时,获取数据存储组件H i中针对第二状态数据的第三版本标识,获取目标待对账数据集合,即待对账数据集合J i中针对第二状态数据的第四版本标识;将第三版本标识与第四版本标识进行对比,得到第二对比结果;若第二对比结果表示第三版本标识小于第四版本标识,则确定数据存储组件H i的组件状态为组件异常状态。
具体地,若第二数据存储组件对应的数据类别为状态类别,则通过第二数据存储组件中针对第二状态数据的第三版本标识,与目标待对账数据集合中针对第二状态数据的第四版本标识进行对比,以根据得到的第二对比结果确定第一数据存储组件的组件状态。本实施例中,针对状态类别的数据存储组件,通过对于相同状态数据在第一数据存储组件和在目标待对账数据集合中的版本标识进行对比,以实现第二数据存储组件中数据的对比,可以准确确定第二数据存储组件的组件状态,以确保全量数据的完整性。
在一个实施例中,m个数据类别包括区块类别;根据第二对比结果确定数据存储组件H i的组件状态的具体过程可以包括:当第二数据存储组件,即数据存储组件H i对应的数据类别为区块类别时,获取数据存储组件H i中针对第三区块数据的第三区块标识,获取目标待对账数据集合,即待对账数据集合J i中针对第三区块数据的第四区块标识;将第三区块标识与第四区块标识进行对比,得到第二对比结果;若第二对比结果为第三区块标识小于第四区块标识,则确定数据存储组件H i的组件状态为组件异常状态。
具体地,若第二数据存储组件对应的数据类别为区块类别,则通过第二数据存储组件中针对第三区块数据的第三区块标识,与目标待对账数据集合中针对第三区块数据的第四区块标识进行对比,以根据得到的第二对比结果确定第二数据存储组件的组件状态。本实施例中,针对区块类别的数据存储组件,通过对于相同区块数据在第二数据存储组件和在目标待对账数据集合中的区块标识进行对比,以实现第二数据存储组件中数据的对比,可以准确确定第二数据存储 组件的组件状态,以确保全量数据的完整性。
在一个实施例中,m个数据类别包括读写类别;根据第二对比结果确定数据存储组件H i的组件状态的具体过程可以包括:当第二数据存储组件,即数据存储组件H i对应的数据类别为读写类别时,获取数据存储组件H i中针对第四区块高度的第三写数据标识,获取目标待对账数据集合,即待对账数据集合J i中针对第四区块高度的第四写数据标识;将第三写数据标识与第四写数据标识进行对比,得到第二对比结果;若第二对比结果为第三写数据标识小于第四写数据标识,则确定数据存储组件H i的组件状态为组件异常状态。
具体地,若第二数据存储组件对应的数据类别为读写类别,则通过第二数据存储组件中针对第四区块高度的第三写数据标识,与目标待对账数据集合中针对第四区块高度的第四写数据标识进行对比,以根据得到的第二对比结果确定第二数据存储组件的组件状态。本实施例中,针对读写类别的数据存储组件,通过对于相同区块高度在第二数据存储组件和在目标待对账数据集合中的写数据标识进行对比,以实现第二数据存储组件中数据的对比,可以准确确定第二数据存储组件的组件状态,以确保全量数据的完整性。
上文已描述缓存区块文件可能不会存储全量的数据,故为了对账本中的全量数据进行对账处理,本申请实施例还可以在共识网络中获取另一个共识节点的账本数据。可以理解的是,两个共识节点分别对应的账本进行对账处理的过程,与一个共识节点利用缓存区块文件对自己的账本进行对账处理的过程是一致的,请参见上文的描述。
在本申请实施例中,当获取到新共识通过的区块时,可以将其添加至区块文件中,在该区块文件中获取针对该区块的m个数据类别互不相同的待记账数据集合;进一步地,根据m个待记账数据集合,对m个数据存储组件并行执行数据写操作,获取m个数据存储组件分别对应的数据存储结果,可以理解的是,m个数据存储组件分别存储数据类别互不相同的数据,即一个数据存储组件用于存储一种数据类别的待记账数据集合;若m个数据存储结果中存在数据存储失败结果,则表明存在待记账数据集合没有成功写入至数据存储组件,此时,获取区块文件对应的区块检查点,以及m个数据存储组件分别对应的组件检查点;通过区块检查点以及m个组件检查点,可以在m个数据存储组件中确定属于组件异常状态的数据存储组件,即没有将对应的数据类别的待记账数据集合成功写入的数据存储组件,此时,可以根据区块文件对属于组件异常状态的数据存储组件执行数据写操作。上述可知,在本申请实施例中,通过对m个数据存储组件并行执行数据写操作,可以实现并行写入m个待记账数据集合,故可以提升区块链的网络性能以及降低对外业务的响应时间;此外,在m个数据存储结果中存在数据存储失败结果时,本申请实施例通过区块检查点以及m个组件检查点,可以确定属于组件异常状态的数据存储组件,并根据区块文件对属于组件异常状态的数据存储组件重新执行数据写操作,故可以保证缓存(可以等同于m个待记账数据集合)和分布式存储(等同于m个数据存储组件)之间的数据一致,避免数据丢失。
进一步地,请参见图6,图6是本申请实施例提供的一种基于区块链的数据处理装置的结构示意图。上述基于区块链的数据处理装置可以是运行于计算机设备中的一个计算机可读指令(包括程序代码),例如该数据处理装置为一个应用软件;该装置可以用于执行本申请实施例提供的方法中的相应步骤。如图6所示,该数据处理装置1可以包括:第一获取模块11、第二获取模块12以及第一确定模块13。
第一获取模块11,用于获取区块文件,从所述区块文件中获取针对区块的多于一个待记账数据集合;所述多于一个待记账数据集合的数据类别互不相同;
第二获取模块12,用于根据所述多于一个待记账数据集合,对多于一个数据存储组件并行执行数据写操作,获取所述多于一个数据存储组件分别对应的数据存储结果;其中,所述数据存储组件的数量与所述待记账数据集合的数量相同,一个数据存储组件用于存储一种数据类别的待记账数据集合;
第二获取模块12,还用于若所述数据存储结果中存在数据存储失败结果,则获取所述区块文件对应的区块检查点,以及所述多于一个数据存储组件分别对应的组件检查点;所述区块检查点为所述区块文件中的最大区块高度,所述组件检查点包括所述多于一个数据存储组件中分别对应的最大区块高度;及
第一确定模块13,用于根据所述区块检查点以及所述组件检查点,在所述多于一个数据存储组件中确定属于组件异常状态的数据存储组件,根据所述区块文件对属于所述组件异常状态的数据存储组件执行数据写操作。
其中,第一获取模块11、第二获取模块12以及第一确定模块13的具体功能实现方式可以参见上述图2对应实施例中的步骤S101-步骤S104。
再请参见图6,基于区块链的数据处理装置1还可以包括:第二确定模块14以及第三获取模块15。第二确定模块14,用于将数据存储结果为数据存储失败结果的数据存储组件,确定为目标数据存储组件;第二确定模块14,还用于从多于一个待记账数据集合中,获取与目标数据存储组件相关联的目标待记账数据集合;第三获取模块15,用于根据目标待记账数据集合,对目标数据存储组件执行数据写操作,获取目标数据存储组件的数据重写存储结果;第三获取模块15,还用于若数据重写存储结果属于数据存储失败结果,则统计目标数据存储组件被执行数据写操作的操作次数;第三获取模块15,还用于当操作次数小于操作次数阈值时,根据目标待记账数据集合,重新对目标数据存储组件执行数据写操作;及第三获取模块15,还用于当操作次数等于操作次数阈值时,通知第二获取模块12获取所述区块文件对应的区块检查点,以及所述多于一个数据存储组件分别对应的组件检查点。其中,第二确定模块14以及第三获取模块15的具体功能实现方式可以参见上述图2对应实施例中的步骤S102。
在一个实施例中,第二确定模块14,用于将数据存储结果为所述数据存储失败结果的数据存储组件,确定为目标数据存储组件;第二确定模块14,还用于获取所述目标数据存储组件被执行数据写操作的操作次数;第三获取模块,还用于当所述操作次数等于操作次数阈值时,通知第二获取模块12获取所述区块文件对应的区块检查点,以及所述多于一个数据存储组件分别对应的组件检查点。
在一个实施例中,第二确定模块14,还用于将所述操作次数与操作次数阈值进行比较;第三获取模块15,还用于当所述操作次数小于所述操作次数阈值时,根据目标待记账数据集合,对所述目标数据存储组件执行数据写操作,获取所述目标数据存储组件的数据重写存储结果;所述目标待记账数据集合,是所述多于一个待记账数据集合中与所述目标数据存储组件相关联的待记账数据集合;第三获取模块15,还用于若所述数据重写存储结果属于数据存储失败结果,更新所述操作次数,通知第二确定模块14将所述操作次数与操作次数阈值进行比较。
再请参见图6,第一确定模块13可以包括:第一确定单元131、第二确定单元132、第一获 取单元133以及第一执行单元134。第一确定单元131,用于在各所述组件检查点中,将小于所述区块检查点的组件检查点确定为待更新组件检查点;第一确定单元131,还用于在多于一个数据存储组件中,将与待更新组件检查点对应的数据存储组件确定为待恢复数据存储组件;待恢复数据存储组件的组件状态为组件异常状态;第二确定单元132,用于根据待更新组件检查点以及区块检查点,确定待恢复数据存储组件的待恢复区块高度区间;第一获取单元133,用于从区块文件中,获取属于待恢复区块高度区间的待恢复数据集合;待恢复数据集合对应的数据类别与待恢复数据存储组件对应的数据类别相同;第一执行单元134,用于根据待恢复数据集合,对待恢复数据存储组件执行数据写操作。其中,第一确定单元131、第二确定单元132、第一获取单元133以及第一执行单元134的具体功能实现方式可以参见上述图2对应实施例中的步骤S104。
再请参见图6,多于一个数据存储组件包括第一数据存储组件,所述组件检查点包括与所述第一数据存储组件对应的第一组件检查点;基于区块链的数据处理装置1还可以包括:第四获取模快16以及第三确定模块17。第四获取模快16,用于当达到数据对账周期时,基于所述第一组件检查点从缓存区块文件中获取已记账数据集合;所述已记账数据集合对应的最大区块高度等于所述第一组件检查点,所述已记账数据集合对应的数据类别与所述第一数据存储组件的数据类别相同;所述缓存区块文件是指存储于缓存层中的所述区块文件;第三确定模块17,用于将所述第一数据存储组件中的数据,与所述已记账数据集合中的数据进行对比,得到第一对比结果,根据所述第一对比结果确定所述第一数据存储组件的组件状态;第三确定模块17,还用于当所述第一数据存储组件的组件状态为组件异常状态时,根据所述区块文件对属于组件异常状态的所述第一数据存储组件执行数据写操作。其中,第四获取模快16以及第三确定模块17的具体功能实现方式可以参见上述图4对应实施例中的步骤S205-步骤S206。
再请参见图6,第三确定模块17可以包括:第二获取单元171以及第一对比单元172。
第二获取单元171,用于当所述第一数据存储组件对应的数据类别为状态类别时,获取所述第一数据存储组件中针对第一状态数据的第一版本标识,获取所述已记账数据集合中针对所述第一状态数据的第二版本标识;第一对比单元172,用于将所述第一版本标识与所述第二版本标识进行对比,得到状态对比结果;第一对比单元172,还用于若所述状态对比结果表示所述第一版本标识与所述第二版本标识不同,则确定所述第一数据存储组件的组件状态为组件异常状态。其中,第二获取单元171以及第一对比单元172的具体功能实现方式可以参见上述图4对应实施例中的步骤S206。
再请参见图6,第三确定模块17可以包括:第三获取单元173以及第二对比单元174。第三获取单元173,用于当所述第一数据存储组件对应的数据类别为区块类别时,获取所述第一数据存储组件中针对第一区块高度的第一区块标识,获取所述已记账数据集合中针对所述第一区块高度的第二区块标识;第二对比单元174,用于将所述第一区块标识与所述第二区块标识进行对比,得到区块对比结果;第二对比单元174,还用于若所述区块对比结果表示所述第一区块标识与所述第二区块标识不同,则确定所述第一数据存储组件的组件状态为组件异常状态。其中,第三获取单元173以及第二对比单元174的具体功能实现方式可以参见上述图4对应实施例中的步骤S206。
再请参见图6,第三确定模块17可以包括:第四获取单元175以及第三对比单元176。第 四获取单元175,用于当所述第一数据存储组件对应的数据类别为读写类别时,获取所述第一数据存储组件中针对第二区块高度的第一写数据标识,获取所述已记账数据集合中针对所述第二区块高度的第二写数据标识;第三对比单元176,用于将所述第一写数据标识与所述第二写数据标识进行对比,得到读写对比结果;第三对比单元176,还用于若所述读写对比结果表示所述第一写数据标识与所述第二写数据标识不同,则确定所述第一数据存储组件的组件状态为组件异常状态。其中,第四获取单元175以及第三对比单元176的具体功能实现方式可以参见上述图4对应实施例中的步骤S206。
再请参见图6,基于区块链的数据处理装置1还可以包括:第五获取模块18以及第四确定模块19。第五获取模块18,用于当达到数据对账周期时,发送用于请求账本数据对账的数据对账请求至共识网络;数据对账请求携带组件检查点;第五获取模块18,还用于获取处于所述共识网络中的共识节点返回的与所述组件检查点分别对应的待对账数据集合;一个组件检查点对应的数据类别与一个待对账数据集合对应的数据类别相同;所述至少一个数据存储组件包括第二数据存储组件,所述待对账数据集合包括目标待对账数据集合,所述第二数据存储组件对应的数据类别与所述目标待对账数据集合对应的数据类别相同;第四确定模块19,用于将所述目标待对账数据集合中的数据,与所述第二数据存储组件中的数据进行对比,得到第二对比结果,根据所述第二对比结果确定所述第二数据存储组件的组件状态;第四确定模块19,还用于当所述第二数据存储组件的组件状态为组件异常状态时,根据所述区块文件对属于组件异常状态的所述第二数据存储组件执行数据写操作。其中,第五获取模块18以及第四确定模块19的具体功能实现方式可以参见上述图4对应实施例中的步骤S207。
再请参见图6,第四确定模块19,具体用于当所述第二数据存储组件的组件状态为组件异常状态,且所述区块文件中存在所述第二数据存储组件的待恢复数据时,根据所述待恢复数据,对属于组件异常状态的所述第二数据存储组件执行数据写操作;第四确定模块19,还具体用于当所述第二数据存储组件的组件状态为组件异常状态,且所述区块文件中不存在所述待恢复数据时,发送用于请求恢复账本数据的数据恢复请求至所述共识网络;所述数据恢复请求携带所述待恢复数据的数据标识;第四确定模块19,还具体用于获取处于所述共识网络中的共识节点返回的所述第二数据存储组件的待恢复数据,根据所述第二数据存储组件的待恢复数据,对属于组件异常状态的所述第二数据存储组件执行数据写操作。其中,第四确定模块19的具体功能实现方式可以参见上述图4对应实施例中的步骤S207。
再请参见图6,第四确定模块19可以包括:第五获取单元191以及第四对比单元192。第五获取单元191,用于当所述第二数据存储组件对应的数据类别为状态类别时,获取所述第二数据存储组件中针对第二状态数据的第三版本标识,获取所述目标待对账数据集合中针对所述第二状态数据的第四版本标识;第四对比单元192,用于将所述第三版本标识与所述第四版本标识进行对比,得到第二对比结果;第四对比单元192,还用于若所述第二对比结果表示所述第三版本标识小于所述第四版本标识,则确定所述第二数据存储组件的组件状态为组件异常状态。其中,第五获取单元191以及第四对比单元192的具体功能实现方式可以参见上述图7对应实施例中的步骤S207。
再请参见图6,第四确定模块19可以包括:第六获取单元193以及第五对比单元194。第六获取单元193,用于当第二数据存储组件对应的数据类别为区块类别时,获取第二数据存储组 件中针对第三区块数据的第三区块标识,获取目标待对账数据集合中针对第三区块数据的第四区块标识;第五对比单元194,用于将第三区块标识与第四区块标识进行对比,得到第二对比结果;第五对比单元194,还用于若第二对比结果为第三区块标识小于第四区块标识,则确定第二数据存储组件的组件状态为组件异常状态。其中,第六获取单元193以及第五对比单元194的具体功能实现方式可以参见上述图4对应实施例中的步骤S207。
再请参见图6,第四确定模块19可以包括:第七获取单元195以及第六对比单元196。第七获取单元195,用于当第二数据存储组件对应的数据类别为读写类别时,获取第二数据存储组件中针对第四区块高度的第三写数据标识,获取目标待对账数据集合中针对第四区块高度的第四写数据标识;第六对比单元196,用于将第三写数据标识与第四写数据标识进行对比,得到第二对比结果;第六对比单元196,还用于若第二对比结果为第三写数据标识小于第四写数据标识,则确定第二数据存储组件的组件状态为组件异常状态。其中,第七获取单元195以及第六对比单元196的具体功能实现方式可以参见上述图4对应实施例中的步骤S207。
再请参见图6,数据类别包括区块类别、状态类别以及读写类别;第一获取模块11可以包括:第一生成单元111、第二生成单元112、第三生成单元113以及第四生成单元114。第一生成单元111,用于从区块文件中获取与区块类别相关联的区块数据,根据区块数据生成区块数据集合;第二生成单元112,用于从区块文件中获取与状态类别相关联的状态数据,根据状态数据生成状态数据集合;第三生成单元113,用于从区块文件中获取与读写类别相关联的读写数据,根据读写数据生成读写数据集合;第四生成单元114,用于根据区块数据集合、状态数据集合以及读写数据集合,生成多于一个待记账数据集合。其中,第一生成单元111、第二生成单元112、第三生成单元113以及第四生成单元114的具体功能实现方式可以参见上述图2对应实施例中的步骤S101。
再请参见图6,区块数据包括交易信息以及区块信息,区块信息包括交易信息的交易标识;第一生成单元111可以包括:第一确定子单元1111以及第一生成子单元1112。第一确定子单元1111,用于将交易标识作为第一索引键,将交易信息作为第一索引值,将第一索引键以及第一索引值确定为第一索引对;第一确定子单元1111,还用于将区块信息对应的区块高度作为第二索引键,将区块信息作为第二索引值,将第二索引键以及第二索引值确定为第二索引对;第一确定子单元1111,还用于将区块信息对应的区块标识作为第三索引键,将区块信息对应的区块高度作为第三索引值,将第三索引键以及第三索引值确定为第三索引对;第一生成子单元1112,用于根据第一索引对、第二索引对以及第三索引对,生成区块数据集合。其中,第一确定子单元1111以及第一生成子单元1112的具体功能实现方式可以参见上述图2对应实施例中的步骤S101。
再请参见图6,第二生成单元112可以包括:第二确定子单元1121以及第二生成子单元1122。第二确定子单元1121,用于将合约标识以及对象标识组合为第四索引键,将状态数据作为第四索引值,将第四索引键以及第四索引值确定为第四索引对;第二确定子单元1121,还用于获取对象标识的历史状态数据对应的版本标识,根据历史状态数据对应的版本标识生成状态数据对应的版本标识;第二确定子单元1121,还用于将状态数据以及状态数据对应的版本标识作为第五索引键,将状态数据对应的区块高度作为第五索引值,将第五索引键以及第五索引值确定为第五索引对;第二生成子单元1122,用于根据第四索引对以及第五索引对,生成状态数 据集合。其中,第二确定子单元1121以及第二生成子单元1122的具体功能实现方式可以参见上述图2对应实施例中的步骤S101。
再请参见图6,读写数据包括读数据以及写数据;第三生成单元113可以包括:第三确定子单元1131以及第三生成子单元1132。第三确定子单元1131,用于将读数据的读数据标识作为第六索引键,将读数据作为第六索引值,将第六索引键以及第六索引值确定为第六索引对;第三确定子单元1131,还用于将写数据的写数据标识作为第七索引键,将写数据作为第七索引值,将第七索引键以及第七索引值确定为第七索引对;第三确定子单元1131,还用于将读数据对应的区块高度作为第八索引键,将读数据标识作为第八索引值,将第八索引键以及第八索引值确定为第八索引对;第三确定子单元1131,还用于将写数据对应的区块高度作为第九索引键,将写数据标识作为第九索引值,将第九索引键以及第九索引值确定为第九索引对;第三生成子单元1132,用于根据第六索引对、第七索引对、第八索引对以及第九索引对,生成读写数据集合。其中,第三确定子单元1131以及第三生成子单元1132的具体功能实现方式可以参见上述图2对应实施例中的步骤S101。
再请参见图6,所述多于一个待记账数据集合包括批处理待记账数据集合,所述多于一个数据存储组件包括用于存储所述批处理待记账数据集合的批处理数据存储组件;第一获取模块11可以包括:第八获取单元115以及第二执行单元116。第八获取单元115,用于获取针对所述批处理待记账数据集合的批处理数据写入指令;第二执行单元116,用于根据所述批处理数据写入指令对所述批处理数据存储组件执行数据写操作,将所述批处理待记账数据集合写入至所述批处理数据存储组件;第二执行单元116,还用于在对所述批处理数据存储组件执行数据写操作的同时,根据其他待记账数据集合,对其他数据存储组件并行执行数据写操作;所述其他待记账数据集合包括所述多于一个待记账数据集合中除了所述批处理待记账数据集合之外的待记账数据集合,所述其他数据存储组件包括所述多于一个数据存储组件中除了所述批处理数据存储组件之外的数据存储组件。其中,第八获取单元115以及第二执行单元116的具体功能实现方式可以参见上述图2对应实施例中的步骤S102。
进一步地,请参见图7,图7是本申请实施例提供的一种计算机设备的结构示意图。如图7所示,该计算机设备1000可以为上述图2对应实施例中的共识节点,该计算机设备1000可以包括:至少一个处理器1001,例如CPU,至少一个网络接口1004,用户接口1003,存储器1005,至少一个通信总线1002。其中,通信总线1002用于实现这些组件之间的连接通信。其中,用户接口1003可以包括显示屏(Display)、键盘(Keyboard),网络接口1004可选地可以包括标准的有线接口、无线接口(如WI-FI接口)。存储器1005可以是高速RAM存储器,也可以是非不稳定的存储器(non-volatile memory),例如至少一个磁盘存储器。存储器1005可选地还可以是至少一个位于远离前述处理器1001的存储装置。如图7所示,作为一种计算机存储介质的存储器1005可以包括操作系统、网络通信模块、用户接口模块以及设备控制应用程序。在图7所示的计算机设备1000中,网络接口1004可提供网络通讯功能;而用户接口1003主要用于为用户提供输入的接口;而处理器1001可以用于调用存储器1005中存储的设备控制应用程序,以实现上述基于区块链的数据处理方法。应当理解,本申请实施例中所描述的计算机设备1000可执行前文图2以及图4所对应实施例中对基于区块链的数据处理方法的描述,也可执行前文图6所对应实施例中对数据处理装置1的描述。另外,对采用相同方法的有益效果描述,也可参照 前文。
本申请提供了一种计算机设备,包括:一个或多个处理器、存储器、网络接口;上述一个或多个处理器与上述存储器、上述网络接口相连,其中,上述网络接口用于提供数据通信功能,上述存储器用于存储计算机可读指令,上述处理器用于调用上述计算机可读指令,以使得计算机设备执行本申请实施例中的方法。
本申请实施例还提供一个或多个存储有计算机可读指令的非易失性计算机可读存储介质,上述计算机可读存储介质中存储有计算机可读指令,该计算机可读指令被一个或多个处理器执行时实现图2以及图4中各个步骤所提供的基于区块链的数据处理方法,具体可参见上述图2以及图4各个步骤所提供的实现方式。上述计算机可读存储介质可以是前述任一实施例提供的基于区块链的数据处理装置或者上述计算机设备的内部存储单元,例如计算机设备的硬盘或内存。该计算机可读存储介质也可以是该计算机设备的外部存储设备,例如该计算机设备上配备的插接式硬盘,智能存储卡(smart media card,SMC),安全数字(secure digital,SD)卡,闪存卡(flash card)等。进一步地,该计算机可读存储介质还可以既包括该计算机设备的内部存储单元也包括外部存储设备。该计算机可读存储介质用于存储该计算机程序以及该计算机设备所需的其他程序和数据。该计算机可读存储介质还可以用于暂时地存储已经输出或者将要输出的数据。
本申请实施例还提供了一种计算机程序产品或计算机程序,该计算机程序产品或计算机程序包括计算机可读指令,该计算机可读指令存储在计算机可读存储介质中。计算机设备的处理器从计算机可读存储介质读取该计算机可读指令,处理器执行该计算机可读指令,使得该计算机设备可执行前文图2以及图4所对应实施例中对基于区块链的数据处理方法的描述。
本申请实施例的说明书和权利要求书及附图中的术语“第一”、“第二”等是用于区别不同对象,而非用于描述特定顺序。此外,术语“包括”以及它们任何变形,意图在于覆盖不排他的包含。例如包含了一系列步骤或单元的过程、方法、装置、产品或设备没有限定于已列出的步骤或模块,而是可选地还包括没有列出的步骤或模块,或可选地还包括对于这些过程、方法、装置、产品或设备固有的其他步骤单元。本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
本申请实施例提供的方法及相关装置是参照本申请实施例提供的方法流程图和/或结构示意图来描述的,具体可由计算机程序指令实现方法流程图和/或结构示意图的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。这些计算机程序指令可提供到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或结构示意图一个方框或多个方框中指定的功能的装置。这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个 流程或多个流程和/或结构示意图一个方框或多个方框中指定的功能。这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或结构示意一个方框或多个方框中指定的功能的步骤。以上所揭露的仅为本申请较佳实施例而已,当然不能以此来限定本申请之权利范围,因此依本申请权利要求所作的等同变化,仍属本申请所涵盖的范围。

Claims (20)

  1. 一种基于区块链的数据处理方法,由计算机设备执行,其特征在于,包括:
    获取区块文件,从所述区块文件中获取针对区块的多于一个待记账数据集合;所述多于一个待记账数据集合的数据类别互不相同;
    根据所述多于一个待记账数据集合,对多于一个数据存储组件并行执行数据写操作,获取所述多于一个数据存储组件分别对应的数据存储结果;其中,所述数据存储组件的数量与所述待记账数据集合的数量相同,一个数据存储组件用于存储一种数据类别的待记账数据集合;
    若所述数据存储结果中存在数据存储失败结果,则获取所述区块文件对应的区块检查点,以及所述多于一个数据存储组件分别对应的组件检查点;所述区块检查点为所述区块文件中的最大区块高度,所述组件检查点包括所述多于一个数据存储组件中分别对应的最大区块高度;及
    根据所述区块检查点以及所述组件检查点,在所述多于一个数据存储组件中确定属于组件异常状态的数据存储组件,根据所述区块文件对属于所述组件异常状态的数据存储组件执行数据写操作。
  2. 根据权利要求1所述的方法,其特征在于,在所述获取所述区块文件对应的区块检查点,以及所述多于一个数据存储组件分别对应的组件检查点的步骤之前,还包括:
    将数据存储结果为所述数据存储失败结果的数据存储组件,确定为目标数据存储组件;
    从所述多于一个待记账数据集合中,获取与所述目标数据存储组件相关联的目标待记账数据集合;
    根据所述目标待记账数据集合,对所述目标数据存储组件执行数据写操作,获取所述目标数据存储组件的数据重写存储结果;
    若所述数据重写存储结果属于数据存储失败结果,则统计所述目标数据存储组件被执行数据写操作的操作次数;
    当所述操作次数小于操作次数阈值时,根据所述目标待记账数据集合,重新对所述目标数据存储组件执行数据写操作;及
    当所述操作次数等于操作次数阈值时,执行所述获取所述区块文件对应的区块检查点,以及所述多于一个数据存储组件分别对应的组件检查点的步骤。
  3. 根据权利要求1所述的方法,其特征在于,在所述获取所述区块文件对应的区块检查点,以及所述多于一个数据存储组件分别对应的组件检查点的步骤之前,还包括:
    将数据存储结果为所述数据存储失败结果的数据存储组件,确定为目标数据存储组件;
    获取所述目标数据存储组件被执行数据写操作的操作次数;及
    当所述操作次数等于操作次数阈值时,执行所述获取所述区块文件对应的区块检查点,以及所述多于一个数据存储组件分别对应的组件检查点的步骤。
  4. 根据权利要求3所述的方法,其特征在于,所述方法还包括:
    将所述操作次数与操作次数阈值进行比较;
    当所述操作次数小于所述操作次数阈值时,根据目标待记账数据集合,对所述目标数据 存储组件执行数据写操作,获取所述目标数据存储组件的数据重写存储结果;所述目标待记账数据集合,是所述多于一个待记账数据集合中与所述目标数据存储组件相关联的待记账数据集合;及
    若所述数据重写存储结果属于数据存储失败结果,更新所述操作次数,并返回所述将所述操作次数与操作次数阈值进行比较的步骤。
  5. 根据权利要求1所述的方法,其特征在于,所述根据所述区块检查点以及所述组件检查点,在所述多于一个数据存储组件中确定属于组件异常状态的数据存储组件,根据所述区块文件对属于所述组件异常状态的数据存储组件执行数据写操作,包括:
    在各所述组件检查点中,将小于所述区块检查点的组件检查点确定为待更新组件检查点;
    在所述多于一个数据存储组件中,将与所述待更新组件检查点对应的数据存储组件确定为待恢复数据存储组件;所述待恢复数据存储组件的组件状态为组件异常状态;
    根据所述待更新组件检查点以及所述区块检查点,确定所述待恢复数据存储组件的待恢复区块高度区间;
    从所述区块文件中,获取属于所述待恢复区块高度区间的待恢复数据集合;所述待恢复数据集合对应的数据类别与所述待恢复数据存储组件对应的数据类别相同;及
    根据所述待恢复数据集合,对所述待恢复数据存储组件执行数据写操作。
  6. 根据权利要求1所述的方法,其特征在于,所述多于一个数据存储组件包括第一数据存储组件,所述组件检查点包括与所述第一数据存储组件对应的第一组件检查点;
    所述方法还包括:
    当达到数据对账周期时,基于所述第一组件检查点从缓存区块文件中获取已记账数据集合;所述已记账数据集合对应的最大区块高度等于所述第一组件检查点,所述已记账数据集合对应的数据类别与所述第一数据存储组件的数据类别相同;所述缓存区块文件是指存储于缓存层中的所述区块文件;
    将所述第一数据存储组件中的数据,与所述已记账数据集合中的数据进行对比,得到第一对比结果,根据所述第一对比结果确定所述第一数据存储组件的组件状态;及
    当所述第一数据存储组件的组件状态为组件异常状态时,根据所述区块文件对属于组件异常状态的所述第一数据存储组件执行数据写操作。
  7. 根据权利要求6所述的方法,其特征在于,所述将所述第一数据存储组件中的数据,与所述已记账数据集合中的数据进行对比,得到第一对比结果,根据所述第一对比结果确定所述第一数据存储组件的组件状态,包括:
    当所述第一数据存储组件对应的数据类别为状态类别时,获取所述第一数据存储组件中针对第一状态数据的第一版本标识,获取所述已记账数据集合中针对所述第一状态数据的第二版本标识;
    将所述第一版本标识与所述第二版本标识进行对比,得到状态对比结果;及
    若所述状态对比结果表示所述第一版本标识与所述第二版本标识不同,则确定所述第一数据存储组件的组件状态为组件异常状态。
  8. 根据权利要求6所述的方法,其特征在于,所述将所述第一数据存储组件中的数据, 与所述已记账数据集合中的数据进行对比,得到第一对比结果,根据所述第一对比结果确定所述第一数据存储组件的组件状态,包括以下至少一项:
    当所述第一数据存储组件对应的数据类别为区块类别时,获取所述第一数据存储组件中针对第一区块高度的第一区块标识,获取所述已记账数据集合中针对所述第一区块高度的第二区块标识;将所述第一区块标识与所述第二区块标识进行对比,得到区块对比结果;及若所述区块对比结果表示所述第一区块标识与所述第二区块标识不同,则确定所述第一数据存储组件的组件状态为组件异常状态;
    当所述第一数据存储组件对应的数据类别为读写类别时,获取所述第一数据存储组件中针对第二区块高度的第一写数据标识,获取所述已记账数据集合中针对所述第二区块高度的第二写数据标识;将所述第一写数据标识与所述第二写数据标识进行对比,得到读写对比结果;及若所述读写对比结果表示所述第一写数据标识与所述第二写数据标识不同,则确定所述第一数据存储组件的组件状态为组件异常状态。
  9. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    当达到数据对账周期时,发送用于请求账本数据对账的数据对账请求至共识网络;所述数据对账请求携带所述组件检查点;
    获取处于所述共识网络中的共识节点返回的与所述组件检查点分别对应的待对账数据集合;一个组件检查点对应的数据类别与一个待对账数据集合对应的数据类别相同;所述至少一个数据存储组件包括第二数据存储组件,所述待对账数据集合包括目标待对账数据集合,所述第二数据存储组件对应的数据类别与所述目标待对账数据集合对应的数据类别相同;
    将所述目标待对账数据集合中的数据,与所述第二数据存储组件中的数据进行对比,得到第二对比结果,根据所述第二对比结果确定所述第二数据存储组件的组件状态;及
    当所述第二数据存储组件的组件状态为组件异常状态时,根据所述区块文件对属于组件异常状态的所述第二数据存储组件执行数据写操作。
  10. 根据权利要求9所述的方法,其特征在于,所述当所述第二数据存储组件的组件状态为组件异常状态时,根据所述区块文件对属于组件异常状态的所述第二数据存储组件执行数据写操作,包括:
    当所述第二数据存储组件的组件状态为组件异常状态,且所述区块文件中存在所述第二数据存储组件的待恢复数据时,根据所述待恢复数据,对属于组件异常状态的所述第二数据存储组件执行数据写操作;
    所述方法还包括:
    当所述第二数据存储组件的组件状态为组件异常状态,且所述区块文件中不存在所述待恢复数据时,发送用于请求恢复账本数据的数据恢复请求至所述共识网络;所述数据恢复请求携带所述待恢复数据的数据标识;及
    获取处于所述共识网络中的共识节点返回的所述第二数据存储组件的待恢复数据,根据所述第二数据存储组件的待恢复数据,对属于组件异常状态的所述第二数据存储组件执行数据写操作。
  11. 根据权利要求9所述的方法,其特征在于,所述将所述目标待对账数据集合中的数 据,与所述第二数据存储组件中的数据进行对比,得到第二对比结果,根据所述第二对比结果确定所述第二数据存储组件的组件状态,包括:
    当所述第二数据存储组件对应的数据类别为状态类别时,获取所述第二数据存储组件中针对第二状态数据的第三版本标识,获取所述目标待对账数据集合中针对所述第二状态数据的第四版本标识;
    将所述第三版本标识与所述第四版本标识进行对比,得到第二对比结果;及
    若所述第二对比结果表示所述第三版本标识小于所述第四版本标识,则确定所述第二数据存储组件的组件状态为组件异常状态。
  12. 根据权利要求1所述的方法,其特征在于,所述数据类别包括区块类别、状态类别以及读写类别;所述从所述区块文件中获取针对区块的多于一个待记账数据集合,包括:
    从所述区块文件中获取与所述区块类别相关联的区块数据,根据所述区块数据生成区块数据集合;
    从所述区块文件中获取与所述状态类别相关联的状态数据,根据所述状态数据生成状态数据集合;
    从所述区块文件中获取与所述读写类别相关联的读写数据,根据所述读写数据生成读写数据集合;及
    根据所述区块数据集合、所述状态数据集合以及所述读写数据集合,生成多于一个待记账数据集合。
  13. 根据权利要求12所述的方法,其特征在于,所述区块数据包括交易信息以及区块信息,所述区块信息包括所述交易信息的交易标识;所述根据所述区块数据生成区块数据集合,包括:
    将所述交易标识作为第一索引键,将所述交易信息作为第一索引值,将所述第一索引键以及所述第一索引值确定为第一索引对;
    将所述区块信息对应的区块高度作为第二索引键,将所述区块信息作为第二索引值,将所述第二索引键以及所述第二索引值确定为第二索引对;
    将所述区块信息对应的区块标识作为第三索引键,将所述区块信息对应的区块高度作为第三索引值,将所述第三索引键以及所述第三索引值确定为第三索引对;及
    根据所述第一索引对、所述第二索引对以及所述第三索引对,生成区块数据集合。
  14. 根据权利要求12所述的方法,其特征在于,所述根据所述状态数据生成状态数据集合,包括:
    将合约标识以及对象标识组合为第四索引键,将所述状态数据作为第四索引值,将所述第四索引键以及所述第四索引值确定为第四索引对;
    获取所述对象标识的历史状态数据对应的版本标识,根据所述历史状态数据对应的版本标识生成所述状态数据对应的版本标识;
    将所述状态数据以及所述状态数据对应的版本标识作为第五索引键,将所述状态数据对应的区块高度作为第五索引值,将所述第五索引键以及所述第五索引值确定为第五索引对;及
    根据所述第四索引对以及所述第五索引对生成状态数据集合。
  15. 根据权利要求12所述的方法,其特征在于,所述读写数据包括读数据以及写数据;所述根据所述读写数据生成读写数据集合,包括:
    将所述读数据的读数据标识作为第六索引键,将所述读数据作为第六索引值,将所述第六索引键以及所述第六索引值确定为第六索引对;
    将所述写数据的写数据标识作为第七索引键,将所述写数据作为第七索引值,将所述第七索引键以及所述第七索引值确定为第七索引对;
    将所述读数据对应的区块高度作为第八索引键,将所述读数据标识作为第八索引值,将所述第八索引键以及所述第八索引值确定为第八索引对;
    将所述写数据对应的区块高度作为第九索引键,将所述写数据标识作为第九索引值,将所述第九索引键以及所述第九索引值确定为第九索引对;及
    根据所述第六索引对、所述第七索引对、所述第八索引对以及所述第九索引对,生成读写数据集合。
  16. 根据权利要求1至15任意一项所述的方法,其特征在于,所述多于一个待记账数据集合包括批处理待记账数据集合,所述多于一个数据存储组件包括用于存储所述批处理待记账数据集合的批处理数据存储组件;
    所述根据所述多于一个待记账数据集合,对多于一个数据存储组件并行执行数据写操作,包括:
    获取针对所述批处理待记账数据集合的批处理数据写入指令;
    根据所述批处理数据写入指令对所述批处理数据存储组件执行数据写操作,将所述批处理待记账数据集合写入至所述批处理数据存储组件;及
    在对所述批处理数据存储组件执行数据写操作的同时,根据其他待记账数据集合,对其他数据存储组件并行执行数据写操作;所述其他待记账数据集合包括所述多于一个待记账数据集合中除了所述批处理待记账数据集合之外的待记账数据集合,所述其他数据存储组件包括所述多于一个数据存储组件中除了所述批处理数据存储组件之外的数据存储组件。
  17. 一种基于区块链的数据处理装置,其特征在于,包括:
    第一获取模块,用于获取区块文件,从所述区块文件中获取针对区块的多于一个待记账数据集合;所述多于一个待记账数据集合的数据类别互不相同;
    第二获取模块,用于根据所述多于一个待记账数据集合,对多于一个数据存储组件并行执行数据写操作,获取所述多于一个数据存储组件分别对应的数据存储结果;其中,所述数据存储组件的数量与所述待记账数据集合的数量相同,一个数据存储组件用于存储一种数据类别的待记账数据集合;
    第二获取模块,还用于若所述数据存储结果中存在数据存储失败结果,则获取所述区块文件对应的区块检查点,以及所述多于一个数据存储组件分别对应的组件检查点;所述区块检查点为所述区块文件中的最大区块高度,所述组件检查点包括所述多于一个数据存储组件中分别对应的最大区块高度;及
    第一确定模块,用于根据所述区块检查点以及所述组件检查点,在所述多于一个数据存 储组件中确定属于组件异常状态的数据存储组件,根据所述区块文件对属于所述组件异常状态的数据存储组件执行数据写操作。
  18. 一种计算机设备,其特征在于,包括:一个或多个处理器、存储器以及网络接口;
    所述处理器与所述存储器、所述网络接口相连,其中,所述网络接口用于提供数据通信功能,所述存储器用于存储计算机可读指令,所述处理器用于调用所述计算机可读指令,以使得所述计算机设备执行权利要求1至16任一项所述的方法。
  19. 一种存储有计算机可读指令的非易失性计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有计算机可读指令,所述计算机可读指令适于由一个或多个处理器加载并执行,以使得具有所述处理器的计算机设备执行权利要求1-16任一项所述的方法。
  20. 一种计算机程序产品,其特征在于,所述计算机程序产品包括计算机可读指令,所述计算机可读指令存储在计算机可读存储介质中;计算机设备的处理器从所述计算机可读存储介质读取所述计算机指令,所述处理器执行所述计算机可读指令,使得所述计算机设备执行权利要求1-16任一项所述的方法。
PCT/CN2022/099782 2021-08-04 2022-06-20 基于区块链的数据处理方法、设备及计算机可读存储介质 WO2023011022A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US18/300,191 US20230259526A1 (en) 2021-08-04 2023-04-13 Block-chain-based data processing

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110890413.1 2021-08-04
CN202110890413.1A CN113326165B (zh) 2021-08-04 2021-08-04 基于区块链的数据处理方法、设备及计算机可读存储介质

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US18/300,191 Continuation US20230259526A1 (en) 2021-08-04 2023-04-13 Block-chain-based data processing

Publications (1)

Publication Number Publication Date
WO2023011022A1 true WO2023011022A1 (zh) 2023-02-09

Family

ID=77427060

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/099782 WO2023011022A1 (zh) 2021-08-04 2022-06-20 基于区块链的数据处理方法、设备及计算机可读存储介质

Country Status (3)

Country Link
US (1) US20230259526A1 (zh)
CN (1) CN113326165B (zh)
WO (1) WO2023011022A1 (zh)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113326165B (zh) * 2021-08-04 2021-11-16 腾讯科技(深圳)有限公司 基于区块链的数据处理方法、设备及计算机可读存储介质
CN113626260B (zh) * 2021-10-11 2022-02-22 腾讯科技(深圳)有限公司 区块链网络的数据处理方法、装置、设备及存储介质
CN115811526B (zh) * 2023-02-09 2023-05-05 北京奥星贝斯科技有限公司 分布式存储系统中的共识方法、计算节点和系统

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109165229A (zh) * 2018-08-23 2019-01-08 北京京东金融科技控股有限公司 本地区块同步的检验方法、装置、设备及存储介质
CN109636388A (zh) * 2018-12-07 2019-04-16 深圳市智税链科技有限公司 区块链网络中的数据处理方法、装置、介质及电子设备
US20190349188A1 (en) * 2017-06-12 2019-11-14 Tencent Technology (Shenzhen) Company Limited Service data storage method and apparatus, storage medium, and electronic device
CN112291372A (zh) * 2020-12-28 2021-01-29 腾讯科技(深圳)有限公司 区块链的异步落账方法、装置、介质及电子设备
CN112395300A (zh) * 2021-01-20 2021-02-23 腾讯科技(深圳)有限公司 基于区块链的数据处理方法、装置、设备及可读存储介质
CN112597153A (zh) * 2020-12-09 2021-04-02 杭州趣链科技有限公司 一种基于区块链的数据存储方法、装置及存储介质
CN112632080A (zh) * 2020-12-29 2021-04-09 杭州趣链科技有限公司 基于区块链的数据存储方法、装置及设备
CN113326165A (zh) * 2021-08-04 2021-08-31 腾讯科技(深圳)有限公司 基于区块链的数据处理方法、设备及计算机可读存储介质

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107315786B (zh) * 2017-06-12 2020-12-11 腾讯科技(深圳)有限公司 业务数据存储方法及装置
CN109447635B (zh) * 2018-10-15 2022-02-01 北京京东尚科信息技术有限公司 用于区块链的信息存储方法和装置
CN111352579B (zh) * 2018-12-24 2023-11-10 深圳市茁壮网络股份有限公司 数据存储方法及装置
CN110599321B (zh) * 2019-09-20 2023-09-29 腾讯科技(深圳)有限公司 税务数据处理方法、装置、服务器及存储介质
CN112100282B (zh) * 2020-11-17 2021-04-23 腾讯科技(深圳)有限公司 联盟链的数据同步方法、装置、可读介质及电子设备
CN112422341B (zh) * 2020-11-18 2021-09-28 腾讯科技(深圳)有限公司 区块链网络的故障检测方法及相关设备

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190349188A1 (en) * 2017-06-12 2019-11-14 Tencent Technology (Shenzhen) Company Limited Service data storage method and apparatus, storage medium, and electronic device
CN109165229A (zh) * 2018-08-23 2019-01-08 北京京东金融科技控股有限公司 本地区块同步的检验方法、装置、设备及存储介质
CN109636388A (zh) * 2018-12-07 2019-04-16 深圳市智税链科技有限公司 区块链网络中的数据处理方法、装置、介质及电子设备
CN112597153A (zh) * 2020-12-09 2021-04-02 杭州趣链科技有限公司 一种基于区块链的数据存储方法、装置及存储介质
CN112291372A (zh) * 2020-12-28 2021-01-29 腾讯科技(深圳)有限公司 区块链的异步落账方法、装置、介质及电子设备
CN112632080A (zh) * 2020-12-29 2021-04-09 杭州趣链科技有限公司 基于区块链的数据存储方法、装置及设备
CN112395300A (zh) * 2021-01-20 2021-02-23 腾讯科技(深圳)有限公司 基于区块链的数据处理方法、装置、设备及可读存储介质
CN113326165A (zh) * 2021-08-04 2021-08-31 腾讯科技(深圳)有限公司 基于区块链的数据处理方法、设备及计算机可读存储介质

Also Published As

Publication number Publication date
CN113326165A (zh) 2021-08-31
US20230259526A1 (en) 2023-08-17
CN113326165B (zh) 2021-11-16

Similar Documents

Publication Publication Date Title
US11431486B2 (en) System or method to implement consensus on read on distributed ledger/blockchain
WO2023011022A1 (zh) 基于区块链的数据处理方法、设备及计算机可读存储介质
US11501533B2 (en) Media authentication using distributed ledger
US11269864B2 (en) Blockchain data storage based on shared nodes and error correction code
EP4202694A1 (en) Node memory-based data processing method and apparatus, device, and medium
CN107391758B (zh) 数据库切换方法、装置及设备
CN111448781A (zh) 共享的区块链数据存储
TWI733514B (zh) 儲存系統、區塊鏈網路的網路節點以及基於區塊鏈的日誌結構儲存系統
CN111108478A (zh) 共享的区块链数据存储
US10275400B1 (en) Systems and methods for forming a fault-tolerant federated distributed database
CN111630507A (zh) 账户模型下的分布式区块链数据存储
WO2022134951A1 (zh) 一种数据同步方法、装置、设备以及计算机可读存储介质
JP6617253B1 (ja) 文書管理システム
US11100094B2 (en) Taking snapshots of blockchain data
US20230289782A1 (en) Smart contract-based data processing
CN111095218A (zh) 基于纠错编码存储共享的区块链数据
US11194792B2 (en) Taking snapshots of blockchain data
CN111033491A (zh) 基于纠错编码存储共享的区块链数据
JP7159348B2 (ja) 誤り訂正符号に基づく動的なブロックチェーンデータの記憶
WO2023020242A1 (zh) 基于区块链的数据处理方法、装置、计算机设备、计算机可读存储介质及计算机程序产品
Wang et al. Ess: An efficient storage scheme for improving the scalability of bitcoin network
WO2023207529A1 (zh) 数据处理方法、装置及设备、介质、产品
WO2023142605A1 (zh) 一种基于区块链的数据处理方法和相关装置
US20230353393A1 (en) Blockchain-based methods and apparatuses for processing data, devices and readable storage mediums
WO2024037117A1 (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: 22851738

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 2022851738

Country of ref document: EP

ENP Entry into the national phase

Ref document number: 2022851738

Country of ref document: EP

Effective date: 20240226

NENP Non-entry into the national phase

Ref country code: DE