Block processing method and apparatus, and blockchain-based data query method and apparatus
Patent Information
- Application Number
- KR1020227015836
- Authority / Receiving Office
- KR · KR
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2020-02-18
- Filing Date
- 2020-11-04
- Publication Date
- 2026-09-23
- Estimated Expiration
- 2040-11-04
Smart Images

Figure 112022049937718-PCT00003_ABST
Abstract
Description
Technology Field
[0001] The present disclosure claims priority to Chinese patent application No. 202010099538.8, filed on February 18, 2020, under the title “BLOCK PROCESSING METHOD AND APPARATUS, AND BLOCKCHAIN-BASED DATA QUERY METHOD AND APPARATUS,” which is incorporated herein by reference in its entirety.
[0002] The present disclosure relates to the field of blockchain technologies, and in particular to a block processing method, a blockchain-based data query method and apparatus, a computer device, and a storage medium. Background Technology
[0003] A blockchain is essentially a decentralized database containing multiple blocks connected in series. In existing blockchain configuration methods, blocks reaching consensus are connected in the order of their creation time to form the blockchain, and newly created blocks reaching consensus can be connected to the tail of the blockchain.
[0004] Embodiments of the present disclosure provide a block processing method and apparatus, a blockchain-based data query method and apparatus, a computer device, and a storage medium. Technical solutions are as follows:
[0005] According to the embodiment, a block processing method is provided, and the method is:
[0006] A step of obtaining a time interval stored in the root block of a target blockchain based on the creation of a block;
[0007] A step of determining as a target subchain a subchain satisfying target conditions from subchains of a first target quantity connected to the root block, based on the transaction occurrence time of a transaction included in the block being within a time interval; and
[0008] It includes the step of adding the block to the target subchain of the target blockchain based on the consensus reached for the block.
[0009] According to the modality, a blockchain-based data query method is provided, and the method is:
[0010] A step of obtaining the block index table of the target blockchain based on a query command for a target block in the target blockchain - the query command returns the transaction occurrence time of the transaction included in the target block, and data storage units in the block index table are configured to record storage location information of the blocks in the target blockchain, and one data storage unit corresponds to one time identifier -;
[0011] Step of determining the target data storage unit from the block index table - the time identifier of the target data storage unit matches the transaction occurrence time -; and
[0012] It includes the step of searching for a target blockchain for a target block based on storage location information in a target data storage unit.
[0013] According to an embodiment, a block processing device is provided, and the device is:
[0014] An acquisition module configured to acquire a time interval stored within the root block of a target blockchain based on the creation of a block;
[0015] A subchain determination module configured to determine as a target subchain a subchain satisfying target conditions from subchains of a first target quantity connected to a root block, based on whether the transaction occurrence time of a transaction included in a block is within a time interval; and
[0016] It includes an additional module configured to add a block to a target subchain of the target blockchain based on the consensus reached for the block.
[0017] In a possible implementation, the first target quantity is determined based on the average block consensus time and block generation cycle in the blockchain system to which the target blockchain belongs.
[0018] In a possible implementation, the subchain determination module is:
[0019] Determine the quantity of blocks included within the subchains;
[0020] Based on the different quantities of blocks included within the subchains, the subchain having the minimum quantity of blocks is determined as the target subchain; and
[0021] It is configured to randomly determine one of the subchains as the target subchain based on the equal quantities of blocks contained within the subchains.
[0022] In a possible implementation example, the additional module is:
[0023] Determine the block number of a block based on the subchain number of the target subchain and the sequence number of a block in the target subchain - the sequence number is used to indicate the arrangement order of blocks in the target subchain, and the block number is used to indicate the storage location of a block in the target blockchain -; and
[0024] It is configured to add a block that returns a block number to the target subchain.
[0025] In a possible implementation example, the additional module is:
[0026] To obtain the block sequence number, add 1 to the sequence number of the block having the maximum block height in the target subchain; and
[0027] To obtain the block number of a block in the target blockchain, it is configured to splice the subchain number of the target subchain and the sequence number of the block.
[0028] In a possible embodiment, the device is:
[0029] A block determination module configured to determine the previous block of a block as a candidate block; and
[0030] It further includes a comparison module configured to redetermine the additional location of a block based on the fact that the sequence number of a candidate block and the sequence number of a block are not continuously incremented, and to perform the operation of adding the block to a target subchain.
[0031] In a possible embodiment, the device is:
[0032] It further includes an information storage module configured to store block storage location information of a block in a block index table of a target blockchain—the block index table is used to record block information of each block in the target blockchain.
[0033] In a possible embodiment, the block index table includes data storage units for a second target quantity, and one data storage unit corresponds to one time identifier.
[0034] In a possible implementation example, the information storage module is:
[0035] The block's storage location information is configured to be stored in the target data storage unit of the block index table, and the time identifier of the target data storage unit matches the transaction occurrence time of the transaction included within the block.
[0036] According to the mode, a blockchain-based data query device is provided, and the device is:
[0037] An acquisition module configured to acquire the block index table of the target blockchain based on a query command for a target block in the target blockchain - the query command returns the transaction occurrence time of the transaction included in the target block, and data storage units in the block index table are configured to record storage location information of the blocks in the target blockchain, and one data storage unit corresponds to one time identifier -;
[0038] A decision module configured to determine the target data storage unit from the block index table - the time identifier of the target data storage unit aligns with the transaction occurrence time -; and
[0039] It includes a search module configured to search the target blockchain for the target block based on storage location information in the target data storage unit.
[0040] In a possible implementation, the decision module is:
[0041] Obtain the time interval stored within the root block of the target blockchain;
[0042] Determine the time offset of the transaction occurrence time for the start moment of the time interval; and
[0043] It is configured to determine a data storage unit as a target data storage unit based on whether the time identifier of an arbitrary data storage unit is the same as the time offset.
[0044] According to an exemplary embodiment, a computer device comprising one or more processors and one or more memories for storing at least one computer program is provided, wherein the at least one computer program is loaded and executed by one or more processors to implement operations performed in a block processing method or a blockchain-based data query method.
[0045] According to an exemplary embodiment, a computer-readable storage medium is provided for storing at least one computer program, and at least one computer program is loaded and executed by a processor to implement operations performed in a block processing method or a blockchain-based data query method. Brief explanation of the drawing
[0046] To more clearly explain the technical solutions in the embodiments of the present disclosure, the following is a brief description of the accompanying drawings required to describe the embodiments. Clearly, the accompanying drawings in the following description illustrate only some embodiments of the present disclosure, and a person skilled in the art can still derive other drawings from these accompanying drawings without creative effort. FIG. 1 is a schematic diagram of a blockchain system (100) according to an embodiment of the present disclosure. FIG. 2 is a functional architecture diagram of a node device according to an embodiment of the present disclosure. FIG. 3 is a flowchart of a block processing method according to an embodiment of the present disclosure. FIG. 4 is a schematic diagram of a target blockchain according to an embodiment of the present disclosure. FIG. 5 is a schematic diagram of the data structure of a target blockchain according to an embodiment of the present disclosure. FIG. 6 is a schematic structural diagram of a target blockchain and a block index table according to an embodiment of the present disclosure. FIG. 7 is a flowchart of a blockchain-based data query method according to an embodiment of the present disclosure. FIG. 8 is a schematic structural diagram of a block processing device according to an embodiment of the present disclosure. FIG. 9 is a schematic diagram of a blockchain-based data query device according to an embodiment of the present disclosure. FIG. 10 is a schematic structural diagram of a terminal according to an embodiment of the present disclosure. FIG. 11 is a schematic structural diagram of a server according to an embodiment of the present disclosure. Specific details for implementing the invention
[0047] To further clarify the purposes, technical solutions, and advantages of the present disclosure, embodiments of the present disclosure are further described below in detail with reference to the accompanying drawings.
[0048] Blockchain is a novel application mode of computer technologies such as distributed data storage, peer-to-peer (P2P) transmission, consensus mechanisms, and cryptographic algorithms. A blockchain is essentially a decentralized database and a string of data blocks generated through association using cryptographic methods. Each data block contains information about a batch of network transactions, and this information is used to verify the validity of the data block's information (anti-counterfeiting) and to generate the next data block. A blockchain may include a blockchain underlying platform, a platform product service layer, and an application service layer.
[0049] The blockchain underlying platform may include processing modules such as a user management module, a basic service module, a smart contract module, and an operation monitoring module. The user management module is responsible for managing the identity information of all blockchain participants, including maintaining public-private key generation (account management), key management, and maintaining correspondence between the user's actual identity and blockchain address (permission management); supervising and auditing transactions of some actual identities through authorization; and providing the configuration of risk control rules (risk control auditing). The basic service module is deployed on all blockchain node devices and is configured to validate service requests and, after reaching a consensus on a valid request, record the valid request in storage. For a new service request, the basic service module first performs adaptive parsing and authentication processing on the interface (interface adaptation), then encrypts service information using a consensus algorithm (consensus management), transmits the complete and consistent service information after encryption to a shared ledger (network communication), and performs recording and storage. The smart contract module is responsible for contract registration and publication, contract triggering, and contract execution. Developers can define contract logic using a programming language and deploy the contract logic onto the blockchain (contract registration). According to the logic of the contract clauses, a key or other event is invoked to trigger execution in order to complete the contract logic. Additionally, functions to upgrade or cancel the contract are provided.The operation monitoring module is primarily responsible for deployment, configuration modification, contract setup, and cloud adaptation during product deployment, as well as visualized outputs of real-time status during product operation, such as issuing alerts, monitoring network status, and monitoring the health status of node devices.
[0050] The platform product service layer provides the fundamental capabilities and implementation frameworks of typical applications. Based on these fundamental capabilities, developers can layer service characteristics and complete the blockchain implementation of service logic. The application service layer provides blockchain solution-based application services for use by service participants.
[0051] During blockchain construction, the time cycles required to add blocks vary; therefore, adding blocks to the blockchain can take a relatively long time due to timeouts of specific transactions within the block. To ensure the correct access order of blocks in the blockchain, if a block is created but has not reached consensus and has not been added to the blockchain, multiple blocks created after it cannot be accessed, even if they have reached consensus. Consequently, a large number of blocks cannot be added to the blockchain within the allotted time, which may affect the normal operation of the blockchain system.
[0052] Therefore, during blockchain construction, how to process blocks to add blocks that reach consensus within a timely manner and to ensure the normal operation of the blockchain system is an important direction of research.
[0053] An embodiment of the present disclosure provides a blockchain system (100) implemented based on blockchain technologies, and the system architecture of the blockchain system is described below.
[0054] FIG. 1 is a schematic diagram of a blockchain system (100) according to an embodiment of the present disclosure. Referring to FIG. 1, the blockchain system (100) may include a plurality of node devices (101). Additionally, the blockchain system (100) may further include at least one client.
[0055] A node device (101) may be any form in the network, for example, a computing device that is a server, a host, or a user terminal. Data may be shared among the node devices (101). A P2P network may be established among the node devices (101) based on a P2P protocol. The P2P protocol is an application-layer protocol that operates over the transmission control protocol (TCP).
[0056] In some embodiments, the device type of the node device (101) may include at least one of a smartphone, a tablet computer, an e-book reader, a moving picture experts group audio layer III (MP3) player, a moving picture experts group audio layer IV (MP4) player, a laptop portable computer, a desktop computer, etc.
[0057] Each node device (101) can receive input information during normal operation and maintain shared data in the blockchain system based on the received input information. To ensure that information is exchanged in the blockchain system, there may be information connections between node devices in the blockchain system, and the node devices can transmit information to each other through the information connections. For example, when any node device in the blockchain system receives input information, another node device in the blockchain system can also acquire the input information and store the input information as data in the stored data, so that consistent data is stored in all node devices in the blockchain system.
[0058] The functional architecture of the node device (101) is described below.
[0059] FIG. 2 is a functional architecture diagram of a node device according to an embodiment of the present disclosure. The node device (101) may be functionally divided into a hardware layer, an intermediate layer, an operating system layer, and an application layer, and the functions involved may specifically be as follows:
[0060] (1) Routing is a basic function of a node device and is used to support communication between node devices.
[0061] In addition to routing capabilities, the node device may have the following additional features:
[0062] (2) The application is deployed on the blockchain and, in accordance with actual service requirements, implements specific services and records data related to the implementation of functions to form recorded data, adds a digital signature to the recorded data to represent the source of the task data, and is used to transmit the recorded data to another node device in the blockchain system. When the other node device successfully verifies the source and integrity of the recorded data, it adds the recorded data to a temporary block.
[0063] For example, services implemented by an application include the following:
[0064] (2.1) A wallet is used to provide the function of performing a transaction with electronic money, including initiating a transaction (i.e., the transaction record of the current transaction is transmitted to another node device in the blockchain system, and after the other node device successfully verifies the transaction record, the recorded data of the transaction is written into a temporary block of the blockchain in response to acknowledging that the transaction is valid). In some embodiments, the wallet further supports querying the remaining electronic money at an electronic money address.
[0065] (2.2) The shared ledger is used to provide functions for operations such as storing, querying, and modifying account data. The recorded data of operations on account data is transmitted to another node device in the blockchain system. After the other node device verifies that the account data is valid, in response to acknowledging that the account data is valid, it may write the recorded data into a temporary block and additionally transmit an acknowledgment to the node device initiating the operations.
[0066] (2.3) A smart contract is a computerized protocol that can be used to execute the terms of a contract and is implemented by using code that is deployed on a shared ledger and executed when conditions are met. According to practical service requirements, the code is used to complete automated transactions, for example, to query the delivery status of goods purchased by a buyer and to transfer the buyer's electronic money to the store's address after the buyer signs for the goods. A smart contract is not limited to executing a contract used for a transaction, but may execute a contract used to process received information.
[0067] (3) A blockchain contains a series of blocks in chronological order of creation. Once a block is added to the blockchain, it is no longer removed. A block records recorded data submitted by a node device in the blockchain system.
[0068] It may be understood that the methods provided in the embodiments of the present disclosure can be implemented by a node device. A node device is a computer device including, but not limited to, a server or a terminal.
[0069] FIG. 3 is a flowchart of a block processing method according to an embodiment of the present disclosure. In this embodiment of the present disclosure, the method is described by using an example in which it is applied to a node device in the blockchain system mentioned above. Referring to FIG. 3, the method may specifically include the following.
[0070] In operation (301), the node device obtains a time interval stored in the root block of the target blockchain in response to the creation of any new block.
[0071] In this embodiment of the disclosure, the “new block” involved refers to a block generated in the blockchain system at the most recent moment, and any newly generated block is referred to as a “new block.” In this embodiment of the disclosure, the “root block” involved refers to the first block generated in the blockchain system, also referred to as a “genesis block.” That is, in operation (301), the node device obtains a time interval stored in the root block of the target blockchain in response to the generation of any block.
[0072] A node device may be any node device in a blockchain system, but is not limited thereto. A node device may be a terminal, a server, etc. A target blockchain belongs to a blockchain system. In some embodiments, the blockchain system may further include another blockchain. This is not limited to this embodiment of the disclosure. FIG. 4 is a schematic diagram of a target blockchain according to an embodiment of the disclosure. The target blockchain (401) is a tree structure, that is, the target blockchain (401) includes a root block (402) and a plurality of subchains connected to the root block (402). As illustrated in FIG. 4, subchains (403), (404), and (405) may be connected to the root block (402), and one subchain may include at least one block. In this embodiment of the disclosure, the blockchain system may include at least one blockchain, and the structure of each blockchain is identical to the structure of the target blockchain.
[0073] In this embodiment of the disclosure, time intervals are stored within the root block of the target blockchain. Time intervals can be used to limit the transaction occurrence time of each block included within the target blockchain, and transaction data for the transaction occurrence time within the time interval can be stored within the target blockchain. Generally, a blockchain system can generate blocks according to a block creation cycle, and a new block can be generated in each block creation cycle. Each block creation cycle can correspond to a transaction occurrence time period, and transactions occurring within a transaction occurrence time period are all recorded within the same block. For example, a transaction occurring within the first second is recorded in one block, and a transaction occurring within the second second is recorded in another block. Therefore, to control the data storage capacity of the blockchain, the number of blocks included within the target blockchain can be determined according to the time intervals stored within the root block. Time intervals stored within different root blocks may have the same or different lengths. That is, the number of blocks included within different blockchains may be the same or different. A block creation cycle can be used to indicate the packaging cycle of transaction data in a blockchain system. For example, transaction data generated per second is packed into one block; that is, the block creation cycle refers to generating one block per second. The block creation cycle can be set by a developer. This is not limited to this embodiment of the disclosure.
[0074] In a possible embodiment, the root block may not store transaction data. Therefore, in a blockchain system, the root block of each blockchain may be created prior to the current time interval. That is, the root block may be created before the time interval corresponding to the root block ends. For example, when the time interval corresponding to the root block is from 23:00 to 24:00, the blockchain system may create the root block at any moment prior to 23:00. The random moment may be determined randomly or based on the operational status of the blockchain system. For example, the root block may be created when the data processing pressure is relatively low. The specific moment of creation of the root block is not limited to this embodiment of the disclosure.
[0075] In operation (302), the node device traverses the first target quantity of subchains connected to the root block when the transaction occurrence time of a transaction included in a new block is within the time interval in order to determine the quantity of blocks included in the subchains.
[0076] In this embodiment of the disclosure, the first target quantity may be determined based on the average block consensus time and block creation cycle in the blockchain system to which the target blockchain belongs. For example, the first target quantity may be determined based on the result of an operation that divides the average block consensus time by one block creation cycle. When the result of the operation is an integer, the first target quantity is equal to the result of the operation, and when the result of the operation is not an integer, the first target quantity is equal to the result of the operation plus 1. The average block consensus time may be determined by collecting statistics on the time to reach consensus for each block in the blockchain system.
[0077] In a possible embodiment, the quantity of blocks included within subchains may be determined based on the block number of each block. Each block in the target blockchain may correspond to a block number, and the block number may be used to indicate the storage location of the block in the target blockchain. The block number of a block may consist of the subchain number of the subchain to which the block belongs and the sequence number of the block in the subchain, where the sequence number is the arrangement order of the blocks in the subchain to which the block belongs. For example, the block number of a block may be 2.3, and the subchain number of the block in the subchain to which the block belongs is 2. The block is the third block in the subchain to which the block belongs. In this embodiment of the disclosure, when traversing each subchain, the node device may obtain the block number of the last block in each subchain, and the quantity of blocks included within each subchain is determined based on the sequence number of the block number of the last block. The maximum value of the subchain number is equal to the first target quantity.
[0078] In this embodiment of the disclosure, the blockchain may include a plurality of subchains, and blocks may be added to all subchains to improve the efficiency of adding blocks and to improve the concurrent processing capability of the system.
[0079] In operation (303), the node device determines the target subchain based on the number of blocks included in the subchains.
[0080] In a possible embodiment, a subchain having the minimum number of blocks is determined as the target subchain when the number of blocks included in the subchains differs; and one of the subchains is randomly determined as the target subchain when the number of blocks included in the subchains are the same. In this embodiment of the disclosure, the subchain containing the fewest blocks, i.e., the subchain having the shortest length, is used as the target subchain, and since subsequent operations to add blocks are performed on the target subchain, the lengths of the subchains in the target blockchain can be balanced, and the lengths of the subchains can be substantially the same in terms of a relatively long cycle.
[0081] In other words, the node device determines the subchain having the minimum number of blocks as the target subchain in response to different quantities of blocks contained within the subchains. Alternatively, the node device randomly determines one of the subchains as the target subchain in response to identical quantities of blocks contained within the subchains.
[0082] Operations (302) and (303) are operations of traversing a first target quantity of subchains connected to a root block when the transaction occurrence time of a transaction included in a new block is within a time interval, and determining a subchain satisfying the target condition as the target subchain. A new block refers to any block generated in the blockchain system at the most recent moment. In other words, operations (302) and (303) are possible implementations in which a node device determines a subchain satisfying the target condition from a first target quantity of subchains connected to a root block as the target subchain when the transaction occurrence time of a transaction included in any block is within a time interval.
[0083] Target conditions may be set by the developer. This is not limited to this embodiment of the disclosure. For example, in this embodiment of the disclosure, the target condition may be set such that the subchain contains a minimum number of blocks. In the technical solutions mentioned above, subchains are blocked based on the target condition to determine the target subchain for adding a new block. According to this method for determining the target subchain, the structure of the blockchain may be more appropriate. For example, when the target condition is that the subchain contains a minimum number of blocks, the lengths of the subchains in the blockchain may be in a relatively balanced state.
[0084] In operation (304), when the node device reaches consensus on a new block, it adds the new block to the target subchain of the target blockchain.
[0085] A new block refers to any block generated in the blockchain system at the most recent moment. That is, in operation (304), when the node device reaches consensus on any block, it adds the random block to the target subchain of the target blockchain.
[0086] In this embodiment of the disclosure, a node device in a blockchain system may determine the block number of a new block based on the subchain number of a target subchain and the sequence number of a block in the target subchain, and may add a new block to the target subchain that returns the block number. The node device may be a leading node device in a consensus node device.
[0087] A new block refers to a random block generated in the blockchain system at the most recent moment. In other words, the node device determines the block number of a random block based on the target subchain's subchain number and the sequence number of the block in the target subchain, and adds the random block with the returned block number to the target subchain.
[0088] In a possible implementation, the node device may add a block number to the new block when it reaches consensus on the new block, that is, when it is determined that the new block can be stored in the target subchain. Optionally, the node device may add 1 to the sequence number of the block having the maximum block height in the target subchain to obtain the sequence number of the new block; and may splice the subchain number of the target subchain and the sequence number of the new block to obtain the block number of the new block in the target blockchain.
[0089] A new block refers to any block generated in the blockchain system at the most recent moment. In other words, to obtain the sequence number of any block, the node device adds 1 to the sequence number of the block with the maximum block height in the target subchain; and to obtain the block number of any block in the target blockchain, it splices the subchain number of the target subchain and the sequence number of any block.
[0090] For example, when the subchain number of the target subchain is 2 and the sequence number of the block having the maximum block height in the target subchain is 3, the block number of the new block may be 2.4. The sequence number is used to indicate the arrangement order of blocks in the target subchain, and the block number is used to indicate the storage location of the new block in the target blockchain. In this embodiment of the disclosure, after the block numbers are generated, a consensus node device in the blockchain system may verify the block number of each block based on the block number generation rules. The above-mentioned description of the method for constructing the block numbers is merely illustrative, and no specific method for constructing the block numbers is adopted in this embodiment of the disclosure.
[0091] FIG. 5 is a schematic diagram of the data structure of a target blockchain according to an embodiment of the present disclosure. The target blockchain illustrated in FIG. 5 is used as an example to explain the block number generation process. The root block (500) in the target blockchain stores a time interval, and when the block generation cycle in the blockchain system is set to 1 second and the average block consensus time is 3 seconds, the first target quantity corresponding to the target blockchain is 3, that is, the quantity of included subchains is 3. When the first block (501) is generated within the time interval, if there is no other block added to the target blockchain other than the root block, the first block (501) that reaches consensus can be connected to the root block to form a subchain. The subchain number of the subchain is 1, and the block number of the first block (501) is 1.1. After a consensus is reached for the second block (502), the first block (501) is added to the target blockchain, and if the number of subchains in the target blockchain has not reached the first target quantity, the second block (502) may be connected to the root block to form one subchain. The subchain number of the subchain is 2, and the block number of the second block (502) is 2.1. The block addition process of the third block (503) is the same as the block addition process of the second block (502), and the details are not repeated in this specification. After the fourth block (504) is created, if the target blockchain contains the target quantity of subchains and the number of blocks in the subchains is the same, the fourth block (504) may randomly select one subchain to complete the block addition process. For example, the fourth block (504) may select a subchain having a subchain number of 1, and the block number of the fourth block (504) is 1.2. The block addition process of the fifth block (505) is the same as the block addition process of the fourth block (504), and the details are not repeated in this specification.After the 6th block (506) is created, if the subchain with subchain number 3 has the shortest length in the current target blockchain, the 6th block (506) needs to be added to the subchain with subchain number 3 after consensus is reached for the 6th block (506). The consensus process for the 6th block (506) takes a relatively long time, and consensus is reached for the 6th block (506) after consensus is reached for the 7th block (507). Therefore, when consensus is reached for the 7th block (507), if the subchain with subchain number 3 still has the shortest length in the current target blockchain, the 7th block (507) is added to the target blockchain and connected to the subchain with subchain number 3, and the block number of the 7th block (507) is 3.2. The 6th block (506) that reaches consensus is also connected to a subchain having a subchain number of 3, and the block number of the 6th block (506) is 3.3.
[0092] In this embodiment of the disclosure, a new block is added to the tail of a target subchain. Specifically, the location of the new block's addition may be further verified after the new block is connected to a block having the maximum block height in the target subchain. In a possible embodiment, a node device may determine the previous block of the new block as a candidate block; compare the sequence number of the candidate block with the sequence number of the new block; and when the sequence number of the candidate block and the sequence number of the new block are not sequentially incremented, i.e., when the new block is not connected to the tail of the target subchain, the node device may redetermine the location of the new block's addition and perform the operation of adding the new block to the target subchain. This verification mechanism can ensure that the sequence numbers of blocks in the subchains are sequentially incremented in order to avoid subchain fork and block disorder.
[0093] A new block refers to any block generated in the blockchain system at the most recent moment. In other words, the verification mechanism of the node device refers to: determining the block preceding the arbitrary block as a candidate block; and, when the sequence number of the candidate block and the sequence number of the arbitrary block are not consecutively incremented, re-determining the additional location of the arbitrary block and performing the action of adding the arbitrary block to the target subchain.
[0094] The specific method for adding a new block to a target subchain is not limited to this embodiment of the disclosure.
[0095] In the technical solutions mentioned above, since sequence numbers are added to blocks and the storage locations of blocks are verified based on the sequence numbers, block disorder in subchains can be effectively avoided and subchain forking can be avoided, thereby ensuring the correct storage location of each block and smooth data query and verification processes in the blockchain system.
[0096] In the technical solutions provided in this embodiment of the present disclosure, a time interval stored within the root block of a target blockchain is obtained in response to the creation of any new block; when the transaction occurrence time of a transaction included in the new block falls within the time interval, a subchain satisfying the target condition is determined as the target subchain by traversing a first target quantity of subchains connected to the root block; and when consensus is reached for the new block, the new block is added to the target subchain of the target blockchain. In the technical solutions mentioned above, blocks are added to the blockchain according to the consensus time of the blocks without waiting for the completion of consensus of previously created blocks. Since the blockchain is configured in a tree structure and includes multiple subchains, and blocks can be added to multiple subchains simultaneously, block addition efficiency is improved, and blocks can be added to the blockchain within a time, thereby ensuring the normal operation of the blockchain system.
[0097] Generally, when the number of blocks in a blockchain reaches a certain quantity, the efficiency of data queries can be affected, which may impact system operation. In the blockchain system described above, each blockchain is composed of a tree structure including a root block and multiple subchains. The number of blocks in each blockchain can be flexibly controlled based on the time interval stored within the root block of each blockchain, thereby avoiding an increase in the difficulty of data queries caused by an excessive number of blocks stored within a single blockchain and ensuring good system operation. Based on the technical solutions described above, each root block can be indexed. Specifically, a root block index table can be maintained in the blockchain system, and the index table is used to record information such as the storage location and time interval of each root block. The specific configuration method for the root block index table is not limited to this embodiment of the disclosure.
[0098] The embodiments mentioned above primarily describe a method for configuring a blockchain. Since a tree-shaped blockchain comprising multiple subchains is configured, block addition efficiency can be improved, and the concurrent processing capability of the blockchain system can be improved. In this embodiment of the disclosure, during the blockchain configuration, a block index table associated with a target blockchain can be maintained in the blockchain system. The block index table can record information on the storage locations of blocks in the target blockchain, thereby facilitating data querying regarding the target blockchain.
[0099] In this embodiment of the present disclosure, when a node device reaches consensus on a new block, it may store the storage location information of the new block in a block index table of the target blockchain. The block index table is used to record block information for each block in the target blockchain. The storage location information may be a block number.
[0100] A new block refers to a random block generated in the blockchain system at the most recent moment. In other words, the node device stores the storage location information of the random block in the block index table of the target blockchain.
[0101] In a possible embodiment, the block index table includes data storage units for a second target quantity, and one data storage unit corresponds to a time identifier. One data storage unit may store data of a fixed length, and block information, such as storage location information of blocks, may be stored within the data of the fixed length. The length of the data stored within the data storage unit may be adjusted as the block information to be stored in the block index table increases or decreases. Specific values for the second target quantity and the fixed length may be set by the developer. This is not limited to this embodiment of the disclosure. For example, when the block generation cycle generates one block per second, the second target quantity may be set to 60, and the block index table includes 60 data storage units. That is, blocks generated per minute are stored within the same block index table.
[0102] In an embodiment of the present disclosure, the node device determines any data storage unit as a target data storage unit when the time identifier of any data storage unit in a block index table matches the transaction occurrence time of a transaction included in a new block; and stores storage location information of the new block in the target data storage unit of the block index table.
[0103] A new block refers to any block generated in the blockchain system at the most recent moment. In other words, the node device stores the storage location information of the arbitrary block in the target data storage unit of the block index table. The time identifier of the target data storage unit corresponds to the transaction occurrence time of the transaction stored within the arbitrary block.
[0104] In a possible embodiment, the time identifier may be a time offset for the start moment of a time interval. For example, when the time interval is from 23:00 to 24:00 and the time identifier is 00:01, that is, when the time offset for 23:00 is 00:01, the transaction occurrence time 23:01 may correspond to the time identifier, and the storage location information of the block storing transaction data generated at 23:01 may be recorded in a data storage unit corresponding to the time identifier 00:01. FIG. 6 is a schematic structural diagram of a target blockchain and a block index table according to an embodiment of the present disclosure. When the time interval is from 23:00 to 24:00, the storage location information of the block (603) generated at 23:01 may be stored in a data storage unit (602) in the block index table (601). The above description of the method for storing block information in a block index table is merely illustrative, and the specific storage method adopted is not limited to this embodiment of the disclosure. Alternatively, the time identifier may be set as a specific moment within a time interval. For example, the time identifier may be set to 23:01. The specific form of the time identifier is not limited to this embodiment of the disclosure.
[0105] In some embodiments, the data storage unit may additionally store data information of the blocks, for example, hash values of the blocks. This is not limited to this embodiment of the disclosure.
[0106] Since the block index table is maintained in the blockchain system, block information for each block, such as the storage location of each block, can be recorded in the order of the transaction occurrence times of the transactions included within each block, thereby facilitating querying and verification of each block in the blockchain system.
[0107] Based on the technical solutions mentioned above, when data in a target blockchain is queried, the queried block storage location can be determined based on a block index table corresponding to the target blockchain. FIG. 7 is a flowchart of a blockchain-based data query method according to an embodiment of the present disclosure. Referring to FIG. 7, in a possible embodiment, the method may specifically include the following operations.
[0108] In operation (701), the node device obtains the block index table of the target blockchain in response to a query command for the target block in the target blockchain.
[0109] In a possible embodiment, a query command may return the transaction occurrence time of a transaction included in a target block, and data storage units in a block index table are configured to record storage location information of blocks in a target blockchain, and one data storage unit corresponds to one time identifier. The configuration method of the block index table in this specification is the same as the configuration method of the block index table in the embodiments mentioned above, and details are not described again in this specification.
[0110] In operation (702), the node device aligns the time identifiers of the data storage units with the transaction occurrence time, and determines the data storage unit corresponding to the time identifier that successfully aligns with the transaction occurrence time as the target data storage unit.
[0111] That is, operation (702) is a possible implementation example in which a node device determines a target data storage unit from a block index table. The time identifier of the target data storage unit corresponds to the transaction occurrence time.
[0112] In a possible implementation, a time identifier may be set as a time offset for the start moment of a time interval. When the time identifier aligns with the transaction occurrence time of a transaction included in a block, the node device may obtain the time interval stored in the root block of the target blockchain; and determine the time offset of the transaction occurrence time for the start moment of the time interval. When any time identifier is equal to the time offset, the node device determines that the any time identifier successfully aligns with the transaction occurrence time; and determines the data storage unit corresponding to the any time identifier as the target data storage unit.
[0113] In other words, in the process mentioned above, the node device obtains a time interval stored within the root block of the target blockchain; determines a time offset of the transaction occurrence time relative to the start moment of the time interval; and determines the arbitrary data storage unit as the target data storage unit when the time identifier of the arbitrary data storage unit is the same as the time offset.
[0114] In a possible implementation, a single data storage unit can store data of a fixed length, and a specific value of the fixed length can be set by the developer. In a block index table, block information for each block is stored in the order of the transaction occurrence times of the transactions included within each block. When a time identifier aligns with the transaction occurrence time of a block, the node device can determine the time offset of the transaction occurrence time relative to the start moment of the time interval and determine the storage location of the block information of the target block in the block index table; that is, by multiplying the time offset by the fixed length, the target data storage unit storing the block information can be determined.
[0115] The above description regarding the determination of a target data storage unit is merely illustrative, and the specific method adopted for determining a data storage unit is not limited to this embodiment of the disclosure.
[0116] In this embodiment of the present disclosure, a data storage unit stores block information of a block. Since the data storage unit is located according to the transaction occurrence time of a transaction included in the block, the accuracy of the acquired block information can be guaranteed, that is, the storage locations of the blocks can be accurately acquired, thereby improving the accuracy of the data query results.
[0117] In operation (703), the node device searches for the target blockchain for the target block based on the storage location information in the target data storage unit.
[0118] In a possible embodiment, storage location information may be represented as a block number. Specifically, after obtaining the block number, the node device can determine the subchain to which the target block belongs based on the subchain number in the block number, and determine the arrangement order of the target block in the subchain based on the sequence number in the block number, thereby locating the target block in the subchain and obtaining data information from the target block.
[0119] In some embodiments, the data storage unit may additionally store the hash value of the target block, and the node device may verify the target block based on the hash value and data information in the target block.
[0120] In the technical solutions mentioned above, since the storage locations of blocks are recorded by using a block index table associated with the blockchain, data difficulties caused by block disorder in the blockchain can be effectively avoided, thereby improving the efficiency and accuracy of data queries.
[0121] Any combination of the arbitrary technical solutions mentioned above may be used to form any embodiment of the present disclosure. Details are not described again herein.
[0122] FIG. 8 is a schematic structural diagram of a block processing device according to an embodiment of the present disclosure. Referring to FIG. 8, the device comprises:
[0123] A acquisition module (801) configured to acquire a time interval stored within the root block of a target blockchain in response to the creation of an arbitrary new block,
[0124] - That is, the acquisition module (801) is configured to acquire a time interval stored within the root block of the target blockchain in response to the creation of an arbitrary block -;
[0125] A subchain determination module (802) configured to determine a subchain satisfying a target condition as a target subchain by traversing subchains of a first target quantity connected to a root block when the transaction occurrence time of a transaction included in a new block is within a time interval,
[0126] - That is, the subchain determination module (802) is configured to determine as the target subchain a subchain that satisfies the target condition from the first target quantity of subchains connected to the root block when the transaction occurrence time of the transaction included in the block is within the time interval -; and
[0127] An additional module (803) configured to add the new block to the target subchain of the target blockchain when a consensus is reached on the new block,
[0128] - That is, the additional module (803) is configured to add the block to the target subchain of the target blockchain when a consensus is reached on the block - includes.
[0129] In a possible implementation, the first target quantity is determined based on the average block consensus time and block generation cycle in the blockchain system to which the target blockchain belongs.
[0130] In a possible implementation, the subchain determination module (802) is:
[0131] Determine the quantity of blocks included within the subchains;
[0132] In response to different quantities of blocks contained within the subchains, the subchain having the minimum quantity of blocks is determined as the target subchain; and
[0133] It is configured to randomly determine one of the subchains as the target subchain in response to equal quantities of blocks contained within the subchains.
[0134] That is, the subchain determination module (802) is:
[0135] Determine the quantity of blocks included within the subchains;
[0136] In response to different quantities of blocks contained within the subchains, the subchain having the minimum quantity of blocks is determined as the target subchain; and
[0137] It is configured to randomly determine one of the subchains as the target subchain in response to equal quantities of blocks contained within the subchains.
[0138] In a possible implementation, the additional module (803) is:
[0139] Determine the block number of a new block based on the subchain number of the target subchain and the sequence number of a block in the target subchain - the sequence number is used to indicate the arrangement order of blocks in the target subchain, and the block number is used to indicate the storage location of a new block in the target blockchain -; and
[0140] It is configured to add a new block to the target subchain that returns the block number.
[0141] That is, the additional module (803) is:
[0142] Determine the block number of a new block based on the subchain number of the target subchain and the sequence number of a block in the target subchain - the sequence number is used to indicate the arrangement order of blocks in the target subchain, and the block number is used to indicate the storage location of a new block in the target blockchain -; and
[0143] It is configured to add a new block to the target subchain that returns the block number.
[0144] In a possible implementation, the additional module (803) is:
[0145] To obtain the sequence number of a new block, add 1 to the sequence number of the block with the maximum block height in the target subchain; and
[0146] To obtain the block number of a new block in the target blockchain, it is configured to splice the subchain number of the target subchain and the sequence number of the new block.
[0147] That is, the additional module (803) is:
[0148] To obtain the block sequence number, add 1 to the sequence number of the block having the maximum block height in the target subchain; and
[0149] To obtain the block number of a block in the target blockchain, it is configured to splice the subchain number of the target subchain and the sequence number of the block.
[0150] In a possible embodiment, the device is:
[0151] A block determination module configured to determine the previous block of a new block as a candidate block,
[0152] - That is, the block decision module is configured to determine the block's previous block as a candidate block -; and
[0153] A comparison module configured to compare the sequence number of a candidate block with the sequence number of a new block; and when the sequence number of the candidate block and the sequence number of the new block are not consecutively incremented, to re-determine the additional location of the new block and perform the operation of adding the new block to a target subchain,
[0154] - That is, the comparison module is configured to re-determine the additional location of the block and perform the operation of adding the block to the target subchain when the sequence number of the candidate block and the sequence number of the block are not consecutively incremented - further includes
[0155] In a possible embodiment, the device is:
[0156] It further includes an information storage module configured to store the storage location information of a new block in the block index table of the target blockchain—the block index table is used to record block information of each block in the target blockchain.
[0157] That is, the information storage module is configured to store the block storage location information of the block in the block index table of the target blockchain, and the block index table is used to record the block information of each block in the target blockchain.
[0158] In a possible embodiment, the block index table includes data storage units for a second target quantity, and one data storage unit corresponds to one time identifier.
[0159] In a possible implementation example, the information storage module is:
[0160] When the time identifier of any data storage unit in a block index table matches the transaction occurrence time of a transaction included in a new block, the arbitrary data storage unit is determined as the target data storage unit; and
[0161] It is configured to store the storage location information of the new block in the target data storage unit of the block index table.
[0162] In other words, the information storage module is:
[0163] The block's storage location information is configured to be stored in the target data storage unit of the block index table, and the time identifier of the target data storage unit matches the transaction occurrence time of the transaction included within the block.
[0164] In the apparatus provided in this embodiment of the present disclosure, a time interval stored within the root block of a target blockchain is obtained in response to the creation of any new block; when the transaction occurrence time of a transaction included in the new block falls within the time interval, a subchain satisfying the target condition is determined as the target subchain by traversing a first target quantity of subchains connected to the root block; and when consensus is reached for the new block, the new block is added to the target subchain of the target blockchain. By using the apparatus described above, blocks are connected to the blockchain according to the consensus time of the blocks without waiting for the completion of consensus of previously created blocks. Since the blockchain includes a plurality of subchains and blocks can be added to a plurality of subchains simultaneously, block addition efficiency is improved, and blocks can be added to the blockchain within a time, thereby ensuring the normal operation of the blockchain system.
[0165] When the block processing device provided in the above-mentioned embodiment performs block processing, only the division of the functional modules mentioned above is used as an example for illustrative purposes. In actual applications, functions may be assigned to different functional modules and implemented by different functional modules according to requirements. That is, the internal structure of the device is divided into different functional modules to implement all or part of the functions described above. Additionally, the embodiments of the block processing device and block processing method provided in the above-mentioned embodiment belong to the same concept. For a specific implementation process, reference may be made to the embodiments of the block processing method, and details are not described again in this specification.
[0166] FIG. 9 is a schematic diagram of a blockchain-based data query device according to an embodiment of the present disclosure. Referring to FIG. 9, the device comprises:
[0167] An acquisition module (901) configured to acquire a block index table of a target blockchain in response to a query command for a target block in a target blockchain - the query command returns the transaction occurrence time of a transaction included in the target block, and each data storage unit in the block index table is configured to record storage location information of each block in the target blockchain, and one data storage unit corresponds to one time identifier, that is, the data storage units in the block index table are configured to record storage location information of blocks in the target blockchain -;
[0168] A matching module (902) configured to match the time identifiers of data storage units with the transaction occurrence time;
[0169] A decision module (903) configured to determine a data storage unit corresponding to a time identifier that successfully matches the transaction occurrence time as a target data storage unit,
[0170] - That is, the decision module (903) is configured to determine the target data storage unit from the block index table, and the time identifier of the target data storage unit is consistent with the transaction occurrence time -; and
[0171] It includes a search module (904) configured to search for a target blockchain for a target block based on storage location information in a target data storage unit.
[0172] In a possible implementation, the matching module (902) is:
[0173] Obtain the time interval stored within the root block of the target blockchain;
[0174] Determine the time offset of the transaction occurrence time for the start moment of the time interval; and
[0175] When an arbitrary time identifier is equal to a time offset, it is configured to determine that the arbitrary time identifier successfully matches the transaction occurrence time.
[0176] That is, the decision module (903) is:
[0177] Obtain the time interval stored within the root block of the target blockchain;
[0178] Determine the time offset of the transaction occurrence time for the start moment of the time interval; and
[0179] It is configured to determine a data storage unit as a target data storage unit when the time identifier of an arbitrary data storage unit is the same as the time offset.
[0180] When the blockchain-based data query device provided in the above-mentioned embodiments performs data querying based on the blockchain, only the division of the functional modules mentioned above is used as an example for illustrative purposes. In actual applications, functions may be assigned to different functional modules and implemented by different functional modules according to requirements. That is, the internal structure of the device is divided into different functional modules to implement all or part of the functions described above. Additionally, the embodiments of the blockchain-based data query device and the blockchain-based data query method provided in the above-mentioned embodiments belong to the same concept. For specific implementation processes, reference may be made to the embodiments of the blockchain-based data query method, and details are not described again in this specification.
[0181] The node device provided in the technical solutions mentioned above may be implemented as a terminal or a server. For example, FIG. 10 is a schematic diagram of a terminal according to an embodiment of the present disclosure. The terminal (1000) may be a smartphone, a tablet computer, an MP3 player, an MP4 player, a laptop computer, or a desktop computer. The terminal (1000) may also be referred to as user equipment, a portable terminal, a laptop terminal, a desktop terminal, or by any other name.
[0182] Generally, the terminal (1000) includes one or more processors (1001) and one or more memories (1002).
[0183] The processor (1001) may include one or more processing cores, for example, a 4-core processor or a 10-core processor. The processor (1001) may be implemented by using at least one hardware form among a digital signal processing (DSP), a field-programmable gate array (FPGA), and a programmable logic array (PLA). Alternatively, the processor (1001) may include a main processor and a coprocessor. The main processor is configured to process data in an active state and is also referred to as a central processing unit (CPU). The coprocessor is a low-power processor configured to process data in a standby state. In some embodiments, the processor (1001) may be integrated with a graphics processing unit (GPU). The GPU is configured to render and draw content that needs to be displayed on a display screen. In some embodiments, the processor (1001) may further include an AI processor. The AI processor is configured to process computing operations related to ML.
[0184] The memory (1002) may include one or more computer-readable storage media. The computer-readable storage media may be non-transient. The memory (1002) may further include high-speed random access memory (RAM), and one or more non-volatile memory such as magnetic disk storage devices and flash storage devices. In some embodiments, the non-transitory computer-readable storage media in the memory (1002) is configured to store at least one computer program, and at least one computer program is configured to be executed by the processor (1001) to implement the block processing method and the blockchain-based data query method provided in the method embodiments of the present disclosure.
[0185] In some embodiments, the terminal (1000) may optionally include a peripheral interface (1003) and at least one peripheral. The processor (1001), memory (1002), and peripheral interface (1003) may be connected by using a bus or a single cable. Each peripheral may be connected to the peripheral interface (1003) by using a bus, a signal line, or a circuit board. Optionally, the peripheral includes at least one of: a radio frequency (RF) circuit (1004), a display screen (1005), a camera component (1006), an audio circuit (1007), a positioning component (1008), or a power supply (1009).
[0186] The peripheral interface (1003) may be configured to connect at least one peripheral device related to input / output (I / O) to the processor (1001) and memory (1002). In some embodiments, the processor (1001), memory (1002), and peripheral interface (1003) are integrated on the same chip or the same circuit board. In some other embodiments, any or both of the processor (1001), memory (1002), and peripheral interface (1003) may be implemented on independent chips or circuit boards. This is not limited to this embodiment.
[0187] The RF circuit (1004) is configured to receive and transmit an RF signal, also referred to as an electromagnetic signal. The RF circuit (1004) communicates with a communication network and other communication devices by utilizing the electromagnetic signal. The RF circuit (1004) converts an electrical signal into an electromagnetic signal for transmission, or converts a received electromagnetic signal into an electrical signal. Optionally, the RF circuit (1004) includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chip set, a subscriber identity module card, etc. The RF circuit (1004) may communicate with another terminal by utilizing at least one wireless communication protocol. Wireless communication protocols include, but are not limited to, metropolitan area networks, generations of mobile communication networks (2G, 3G, 4G, and 5G), wireless local area networks, and / or Wi-Fi networks. In some embodiments, the RF circuit (1004) may further include a circuit related to NFC, and this is not limited to the present disclosure.
[0188] A display screen (1005) is configured to display a user interface (UI). The UI may include graphs, text, icons, videos, and any combination thereof. When the display screen (1005) is a touch display screen, the display screen (1005) may also collect touch signals on or above the surface of the display screen (1005). The touch signals may be used as control signals to be input to the processor (1001) for processing. In this case, the display screen (1005) may be further configured to provide virtual buttons and / or a virtual keyboard, also referred to as soft buttons and / or a soft keyboard. In some embodiments, there may be one display screen (1005) positioned on the front panel of the terminal (1000). In other embodiments, there may be at least two display screens (1005) that are each positioned or folded on different surfaces of the terminal (1000). In some embodiments, the display screen (1005) may be a flexible display screen positioned on a curved or folded surface of the terminal (1000). Furthermore, the display screen (1005) may be additionally set in a non-rectangular irregular pattern, i.e., may be a special-shaped screen. The display screen (1005) may be made of materials such as a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc.
[0189] The camera component (1006) is configured to collect images or videos. Optionally, the camera component (1006) includes a front-facing camera and a rear-facing camera. Generally, the front-facing camera is positioned on the front panel of the terminal, and the rear-facing camera is positioned on the rear surface of the terminal. In some embodiments, there are at least two rear-facing cameras, each of which is any of a main camera, a depth-of-field camera, a wide-angle camera, and a telephoto camera, to implement background blur through the fusion of a main camera and a depth-of-field camera, panoramic photographing and virtual reality (VR) photography through the fusion of a main camera and a wide-angle camera, or other fused photography functions. In some embodiments, the camera component (1006) may further include a flash. The flash may be a single color temperature flash or a double color temperature flash. A double color temperature flash refers to a combination of a warm flash and a cold flash and may be configured to perform light ray compensation at different color temperatures.
[0190] The audio circuit (1007) may include a microphone and a loudspeaker. The microphone is configured to acquire sound waves from the user and the environment and to convert the sound waves into electrical signals for input to the processor (1001) for processing or input to the RF circuit (1004) to implement voice communication. For the purpose of stereo acquisition or noise reduction, there may be multiple microphones each placed in different parts of the terminal (1000). Alternatively, the microphone may be an array microphone or an omni-directional acquisition type microphone. The loudspeaker is configured to convert electrical signals from the processor (1001) or the RF circuit (1004) into sound waves. The loudspeaker may be a conventional thin-film loudspeaker or a piezoelectric ceramic loudspeaker. When the speaker is a piezoelectric ceramic speaker, the speaker can not only convert electrical signals into sound waves audible to humans, but also convert electrical signals into sound waves inaudible to humans for range measurement and other purposes. In some embodiments, the audio circuit (1007) may also include an earphone jack.
[0191] The positioning component (1008) is configured to determine the current geographical location of the terminal (1000) in order to implement navigation or location-based services (LBS). The positioning component (1008) may be a positioning component based on the global positioning system (GPS) of the United States, the COMPASS system of China, the GLONASS system of Russia, or the GALILEO system of the European Union.
[0192] The power supply unit (1009) is configured to supply power to components in the terminal (1000). The power supply unit (1009) may be an AC-current power supply unit, a DC-current power supply unit, a disposable battery, or a rechargeable battery. When the power supply unit (1009) includes a rechargeable battery, the rechargeable battery may be a wired rechargeable battery or a wireless rechargeable battery. The rechargeable battery may be further configured to support fast charging technology.
[0193] In some embodiments, the terminal (1000) further includes one or more sensors (1010). The one or more sensors (1010) include, but are not limited to, an accelerometer (1011), a gyroscope (1012), a pressure sensor (1013), a fingerprint sensor (1014), an optical sensor (1015), and a proximity sensor (1016).
[0194] The acceleration sensor (1011) can detect the magnitude of acceleration on three coordinate axes of the established coordinate system with the terminal (1000). For example, the acceleration sensor (1011) can be configured to detect components of gravitational acceleration on three coordinate axes. The processor (1001) can control the display screen (1005) to display the UI in a landscape view or portrait view according to the gravitational acceleration signal collected by the acceleration sensor (1011). The acceleration sensor (1011) can be further configured to collect data of game or user movement.
[0195] The gyroscope sensor (1012) can detect the body orientation and the rotation angle of the terminal (1000), and together with the accelerometer sensor (1011), can collect the user's 3D actions on the terminal (1000). The processor (1001) can implement the following functions based on the data acquired by the gyroscope sensor (1012): motion detection (such as changing the UI based on the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.
[0196] A pressure sensor (1013) may be positioned on the side frame of the terminal (1000) and / or on the lower layer of the display screen (1005). When the pressure sensor (1013) is positioned on the side frame of the terminal (1000), a user's holding signal for the terminal (1000) may be detected. The processor (1001) performs left and right recognition or rapid operation according to the holding signal acquired by the pressure sensor (1013). When the pressure sensor (1013) is positioned on the lower layer of the display screen (1005), the processor (1001) controls operable controls on the UI according to the user's pressure operation on the display screen (1005). Operable controls include at least one of button control, scroll-bar control, icon control, and menu control.
[0197] A fingerprint sensor (1014) is configured to collect a user's fingerprint, and a processor (1001) identifies the user's identity based on the fingerprint collected by the fingerprint sensor (1014), or the fingerprint sensor (1014) identifies the user's identity based on the collected fingerprint. When the user's identity is identified as a trusted identity, the processor (1001) authorizes the user to perform a related sensitive action. Sensitive actions include unlocking a screen, observing encrypted information, downloading software, making payments, changing settings, etc. The fingerprint sensor (1014) may be placed on the front surface, rear surface, or side surface of the terminal (1000). When a physical button or vendor logo is placed on the terminal (1000), the fingerprint sensor (1014) may be integrated with the physical button or vendor logo.
[0198] The optical sensor (1015) is configured to collect ambient light intensity. In an embodiment, the processor (1001) can control the display luminance of the display screen (1005) according to the ambient light intensity collected by the optical sensor (1015). Optionally, specifically, when the ambient light intensity is relatively high, the display brightness of the display (1005) is increased. When the ambient light intensity is relatively low, the display brightness of the display screen (1005) is decreased. In another embodiment, the processor (1001) can also dynamically adjust the camera parameters of the camera component (1006) according to the ambient light intensity collected by the optical sensor (1015).
[0199] A proximity sensor (1016), also referred to as a distance sensor, is typically positioned on the front panel of the terminal (1000). The proximity sensor (1016) is configured to collect the distance between the user and the front surface of the terminal (1000). In an embodiment, when the proximity sensor (1016) determines that the distance between the user and the front surface of the terminal (1000) is gradually decreasing, the display screen (1005) is controlled by the processor (1001) to switch from a screen-on state to a screen-off state. When the proximity sensor (1016) detects that the distance between the user and the front surface of the terminal (1000) is gradually increasing, the display screen (1005) is controlled by the processor (1001) to switch from a screen-off state to a screen-on state.
[0200] A person skilled in the art can understand that the structure illustrated in FIG. 10 does not constitute a limitation on the terminal (1000), and that the terminal may include more or fewer components, combinations of some components, or different arrangements of components than those illustrated in the drawing.
[0201] FIG. 11 is a schematic diagram of a server according to an embodiment of the present disclosure. The server (1100) may vary significantly as its configuration or performance varies and may include one or more central processing units (CPUs) (1101) and one or more memories (1102). One or more memories (1102) store at least one computer program, and at least one computer program is loaded and executed by one or more processors (1101) to implement the methods provided in the various method embodiments mentioned above. In some embodiments, the server (1100) may also have a wired or wireless network interface, a keyboard, an I / O interface, and other components to facilitate I / O. The server (1100) may also include other components to implement device functions. Details are not described again in this specification.
[0202] In some embodiments, the node device mentioned above refers to a computer device. The computer device includes one or more processors and one or more memories for storing at least one computer program, and at least one computer program performs the following operations:
[0203] Receiving a time interval stored within the root block of a target blockchain in response to the creation of an arbitrary block;
[0204] Determining as a target subchain a subchain satisfying target conditions from subchains of a first target quantity connected to the root block when the transaction occurrence time of a transaction included in the block is within a time interval; and
[0205] When a consensus is reached for a block, it is loaded and executed by one or more processors to implement adding the block to the target subchain of the target blockchain.
[0206] In some embodiments, the first target quantity is determined based on the average block consensus time and block generation cycle in the blockchain system to which the target blockchain belongs.
[0207] In some embodiments, at least one computer program performs the following operations:
[0208] Determining the quantity of blocks included within subchains;
[0209] Determining the subchain having the minimum number of blocks as the target subchain in response to different numbers of blocks included within the subchains; and
[0210] It is loaded and executed by one or more processors to implement randomly determining one of the subchains as a target subchain in response to equal quantities of blocks contained within the subchains.
[0211] In some embodiments, at least one computer program performs the following operations:
[0212] Determining the block number of a block based on the subchain number of the target subchain and the sequence number of a block in the target subchain—the sequence number is used to indicate the arrangement order of blocks in the target subchain, and the block number is used to indicate the storage location of a block in the target blockchain—; and
[0213] It is loaded and executed by one or more processors to implement adding a block that returns a block number to a target subchain.
[0214] In some embodiments, at least one computer program performs the following operations:
[0215] To obtain the sequence number of a block, adding 1 to the sequence number of the block having the maximum block height in the target subchain; and
[0216] To obtain the block number of a block in the target blockchain, one or more processors are loaded and executed to implement splicing the subchain number of the target subchain and the sequence number of the block.
[0217] In some embodiments, at least one computer program performs the following operations:
[0218] Determining the previous block of the block as a candidate block; and
[0219] When the sequence number of a candidate block and the sequence number of a block are not incremented consecutively, it is loaded and executed by one or more processors to implement the operation of re-determining the additional location of the block and adding the block to the target subchain.
[0220] In some embodiments, at least one computer program performs the following operations:
[0221] To implement storing block storage location information in the block index table of the target blockchain—the block index table is used to record block information for each block in the target blockchain—it is loaded and executed by one or more processors.
[0222] In some embodiments, the block index table includes data storage units for a second target quantity, and one data storage unit corresponds to one time identifier.
[0223] In some embodiments, at least one computer program performs the following operations:
[0224] To implement storing the block's storage location information in the target data storage unit of the block index table—where the time identifier of the target data storage unit matches the transaction occurrence time of the transaction included in the block—it is loaded and executed by one or more processors.
[0225] In some other embodiments, the node device mentioned above refers to a computer device. The computer device includes one or more processors and one or more memories for storing at least one computer program, and at least one computer program performs the following operations:
[0226] Retrieving the block index table of the target blockchain in response to a query command for a target block in the target blockchain - the query command returns the transaction occurrence time of the transaction included within the target block, and the data storage units in the block index table are configured to record the storage location information of the blocks in the target blockchain, and one data storage unit corresponds to one time identifier -;
[0227] Determining the target data storage unit from the block index table - the time identifier of the target data storage unit aligns with the transaction occurrence time -; and
[0228] It is loaded and executed by one or more processors to implement searching the target blockchain for a target block based on storage location information in the target data storage unit.
[0229] In some other embodiments, at least one computer program performs the following operations:
[0230] Obtaining a time interval stored within the root block of the target blockchain;
[0231] Determining the time offset of the transaction occurrence time relative to the start moment of the time interval; and
[0232] One or more processors are loaded and executed to implement determining a data storage unit as a target data storage unit when the time identifier of an arbitrary data storage unit is the same as the time offset.
[0233] In an exemplary embodiment, a computer-readable storage medium, for example, memory comprising at least one computer program, is further provided. The at least one computer program may be executed by a processor to implement the block processing method or the blockchain-based data query method provided in the embodiments described above. For example, the computer-readable storage medium may be read-only memory (ROM), RAM, compact disc ROM (CD-ROM), magnetic tape, floppy disk, or optical data storage device.
[0234] In some embodiments, at least one computer program performs the following operations:
[0235] Receiving a time interval stored within the root block of a target blockchain in response to the creation of an arbitrary block;
[0236] Determining as a target subchain a subchain satisfying target conditions from subchains of a first target quantity connected to the root block when the transaction occurrence time of a transaction included in the block is within a time interval; and
[0237] When a consensus is reached for a block, it is loaded and executed by the processor to implement adding the block to the target subchain of the target blockchain.
[0238] In some embodiments, the first target quantity is determined based on the average block consensus time and block generation cycle in the blockchain system to which the target blockchain belongs.
[0239] In some embodiments, at least one computer program performs the following operations:
[0240] Determining the quantity of blocks included within subchains;
[0241] Determining the subchain having the minimum number of blocks as the target subchain in response to different numbers of blocks included within the subchains; and
[0242] It is loaded and executed by a processor to implement randomly determining one of the subchains as a target subchain in response to the same quantity of blocks contained within the subchains.
[0243] In some embodiments, at least one computer program performs the following operations:
[0244] Determining the block number of a block based on the subchain number of the target subchain and the sequence number of a block in the target subchain—the sequence number is used to indicate the arrangement order of blocks in the target subchain, and the block number is used to indicate the storage location of a block in the target blockchain—; and
[0245] It is loaded and executed by the processor to implement adding a block that returns a block number to the target subchain.
[0246] In some embodiments, at least one computer program performs the following operations:
[0247] To obtain the sequence number of a block, adding 1 to the sequence number of the block having the maximum block height in the target subchain; and
[0248] To obtain the block number of a block in the target blockchain, it is loaded and executed by the processor to implement splicing the subchain number of the target subchain and the sequence number of the block.
[0249] In some embodiments, at least one computer program performs the following operations:
[0250] Determining the previous block of the block as a candidate block; and
[0251] When the sequence number of the candidate block and the sequence number of the block are not incremented consecutively, it is loaded and executed by the processor to implement the operation of re-determining the additional location of the block and adding the block to the target subchain.
[0252] In some embodiments, at least one computer program performs the following operations:
[0253] To implement storing the block storage location information of the block in the block index table of the target blockchain—the block index table is used to record the block information of each block in the target blockchain—it is loaded and executed by the processor.
[0254] In some embodiments, the block index table includes data storage units for a second target quantity, and one data storage unit corresponds to one time identifier.
[0255] In some embodiments, at least one computer program performs the following operations:
[0256] It is loaded and executed by the processor to implement storing the block's storage location information in the target data storage unit of the block index table—where the time identifier of the target data storage unit matches the transaction occurrence time of the transaction included in the block.
[0257] In some other embodiments, at least one computer program performs the following operations:
[0258] Retrieving the block index table of the target blockchain in response to a query command for a target block in the target blockchain - the query command returns the transaction occurrence time of the transaction included within the target block, and the data storage units in the block index table are configured to record the storage location information of the blocks in the target blockchain, and one data storage unit corresponds to one time identifier -;
[0259] Determining the target data storage unit from the block index table - the time identifier of the target data storage unit aligns with the transaction occurrence time -; and
[0260] It is loaded and executed by the processor to implement searching the target blockchain for the target block based on storage location information in the target data storage unit.
[0261] In some other embodiments, at least one computer program performs the following operations:
[0262] Obtaining a time interval stored within the root block of the target blockchain;
[0263] Determining the time offset of the transaction occurrence time relative to the start moment of the time interval; and
[0264] When the time identifier of an arbitrary data storage unit is the same as the time offset, it is loaded and executed by the processor to implement determining the data storage unit as the target data storage unit.
[0265] In some embodiments, a computer program or computer program product comprising at least one program code is further provided, and when the computer program or computer program product is operated on a computer device, the computer device enables any possible implementation of the block processing method or blockchain-based data query method provided in the embodiments above. Details are not described again in this specification.
[0266] A person skilled in the art will understand that all or part of the operations of the above-described embodiments may be implemented by hardware or by a computer program that commands the related hardware. The computer program may be stored in a computer-readable storage medium. The storage medium may be a ROM, a magnetic disk, an optical disk, etc.
[0267] The foregoing descriptions are embodiments of the present disclosure, but are not intended to limit the present disclosure. Any modification, equivalent substitution, or improvement made within the spirit and principles of the present disclosure shall be within the scope of protection of the present disclosure.
Claims
Claim 1 A block processing method executed by a node device of a blockchain system, comprising: a step of obtaining a time interval stored within a root block of a target blockchain based on the creation of a block; a step of determining as a target subchain a subchain satisfying a target condition from subchains of a first target quantity connected to the root block based on the fact that the transaction occurrence time of a transaction included in the block falls within the time interval - the first target quantity is determined based on the average block consensus time and block creation cycle in the blockchain system to which the target blockchain belongs - ; A method comprising the step of adding the block to the target subchain of the target blockchain based on a consensus reached for the block, wherein the step of adding the block to the target subchain of the target blockchain based on a consensus reached for the block comprises: a step of determining the block number of the block based on a subchain number of the target subchain and a sequence number of the block in the target subchain, wherein the sequence number is used to indicate the arrangement order of the block in the target subchain and the block number is used to indicate the storage location of the block in the target blockchain; and a step of adding the block to the target subchain that returns the block number. Claim 2 delete Claim 3 A method according to claim 1, wherein the step of determining a subchain satisfying the target condition from a first target quantity of subchains connected to the root block as the target subchain comprises: determining the quantities of blocks included in the subchains; determining a subchain having the minimum quantity of blocks as the target subchain based on different quantities of blocks included in the subchains; and randomly determining one of the subchains as the target subchain in response to identical quantities of blocks included in the subchains. Claim 4 delete Claim 5 A method according to claim 1, wherein the step of determining the block number of the block based on the subchain number of the target subchain and the sequence number of the block in the target subchain comprises: adding 1 to the sequence number of the block having the maximum block height in the target subchain to obtain the sequence number of the block; and splicing the subchain number of the target subchain and the sequence number of the block to obtain the block number of the block in the target blockchain. Claim 6 A method according to claim 5, further comprising: a step of determining a previous block of the block as a candidate block; and a step of re-determining an additional location of the block based on the fact that the sequence number of the candidate block and the sequence number of the block are not continuously incremented, and performing an operation of adding the block to the target subchain. Claim 7 A method according to claim 1, further comprising the step of storing storage location information of the block in a block index table of the target blockchain—the block index table is used to record block information of each block in the target blockchain. Claim 8 In claim 7, the block index table comprises data storage units for a second target quantity, and one data storage unit corresponds to one time identifier, a method. Claim 9 In claim 8, the step of storing the storage location information of the block in the block index table of the target blockchain comprises: the step of storing the storage location information of the block in the target data storage unit of the block index table - wherein the time identifier of the target data storage unit matches the transaction occurrence time of the transaction included in the block. Claim 10 A blockchain-based data query method comprising: a step of obtaining a block index table of a target blockchain based on a query command for a target block in the target blockchain, wherein the query command returns the transaction occurrence time of a transaction included in the target block, and data storage units in the block index table are configured to record storage location information of blocks in the target blockchain, and one data storage unit corresponds to one time identifier; a step of determining a target data storage unit from the block index table, wherein the time identifier of the target data storage unit matches the transaction occurrence time; and a step of searching the target blockchain for the target block based on storage location information in the target data storage unit, wherein the step of determining the target data storage unit from the block index table comprises: a step of obtaining a time interval stored in the root block of the target blockchain; a step of determining a time offset of the transaction occurrence time for the start moment of the time interval; and a step of determining the data storage unit as the target data storage unit based on the fact that the time identifier of any data storage unit is the same as the time offset. Claim 11 delete Claim 12 A block processing device comprising: an acquisition module configured to acquire a time interval stored within a root block of a target blockchain based on the creation of a block; a subchain determination module configured to determine as a target subchain a subchain satisfying a target condition from subchains of a first target quantity connected to the root block based on the transaction occurrence time of a transaction included in the block being within the time interval, wherein the first target quantity is determined based on the average block consensus time and block creation cycle in the blockchain system to which the target blockchain belongs; and an addition module configured to add the block to the target subchain of the target blockchain based on a consensus reached for the block, wherein the addition module determines the block number of the block based on the subchain number of the target subchain and the sequence number of the block in the target subchain, wherein the sequence number is used to indicate the arrangement order of the block in the target subchain, and the block number is used to indicate the storage location of the block in the target blockchain. A block processing device further configured to add the block that returns the block number to the target subchain. Claim 13 A blockchain-based data query device comprises: an acquisition module configured to acquire a block index table of a target blockchain based on a query command for a target block in the target blockchain, wherein the query command returns the transaction occurrence time of a transaction included in the target block, and data storage units in the block index table are configured to record storage location information of blocks in the target blockchain, and one data storage unit corresponds to one time identifier; a determination module configured to determine a target data storage unit from the block index table, wherein the time identifier of the target data storage unit is consistent with the transaction occurrence time; and a search module configured to search the target blockchain for the target block based on storage location information in the target data storage unit, wherein the blockchain-based data query device further comprises a matching module, wherein the matching module acquires a time interval stored in the root block of the target blockchain; and determines a time offset of the transaction occurrence time with respect to the start moment of the time interval; A blockchain-based data query device configured to determine that the time identifier has successfully matched the occurrence time when the time identifier is the same as the time offset. Claim 14 A computer device comprising one or more processors and one or more memories for storing at least one computer program, wherein the at least one computer program is loaded and executed by the one or more processors to implement operations performed in a block processing method according to any one of claims 1, 3, 5 to 9. Claim 15 A computer device comprising one or more processors and one or more memories for storing at least one computer program, wherein the at least one computer program is loaded and executed by the one or more processors to implement operations performed in the blockchain-based data query method according to claim 10. Claim 16 A computer-readable storage medium for storing at least one computer program, wherein the at least one computer program is loaded and executed by a processor to implement operations performed in a block processing method according to any one of claims 1, 3, 5 through 9. Claim 17 A computer-readable storage medium for storing at least one computer program, wherein the at least one computer program is loaded and executed by a processor to implement operations performed in a blockchain-based data query method according to claim 10.
Citation Information
Patent Citations
Data query method and apparatus, and electronic device
CN108304475A
System and method for detecting replay attack
WO2019072312A2
Method and apparatus for determining main chain of blockchain, device, and storage medium
WO2019210711A1
A block chain inquiry method and a device
CN109213797A