CN110851535A - Data processing method and device based on block chain, storage medium and terminal - Google Patents

Data processing method and device based on block chain, storage medium and terminal Download PDF

Info

Publication number
CN110851535A
CN110851535A CN201911128883.3A CN201911128883A CN110851535A CN 110851535 A CN110851535 A CN 110851535A CN 201911128883 A CN201911128883 A CN 201911128883A CN 110851535 A CN110851535 A CN 110851535A
Authority
CN
China
Prior art keywords
block
target
full
node device
blocks
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201911128883.3A
Other languages
Chinese (zh)
Other versions
CN110851535B (en
Inventor
李茂材
蓝虎
王宗友
时一防
朱耿良
刘区城
杨常青
刘攀
黄焕坤
周开班
张劲松
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201911128883.3A priority Critical patent/CN110851535B/en
Publication of CN110851535A publication Critical patent/CN110851535A/en
Application granted granted Critical
Publication of CN110851535B publication Critical patent/CN110851535B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2255Hash tables

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the application discloses a data processing method, a device, a storage medium and a terminal based on a block chain, wherein the method comprises the following steps: determining block index information based on a locally stored target block set, wherein the target block set comprises at least one block read from target full-scale node equipment of a blockchain network, reading a reference block set used for verifying the target block set from first reference full-scale node equipment of the blockchain network according to the block index information, the first reference full-scale node equipment is full-scale node equipment except the target full-scale node equipment in the blockchain network, and verifying the validity of each block in the target block set by adopting the reference block set. By the method and the device, whether the block read from the block chain is the valid block or not can be verified, and the safety of the local storage block is improved.

Description

Data processing method and device based on block chain, storage medium and terminal
Technical Field
The present application relates to the field of blockchain technologies, and in particular, to a data processing method and apparatus based on a blockchain, a computer storage medium, and a terminal.
Background
The blockchain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission (P2P transmission), consensus mechanism, encryption algorithm, and the like, and specifically may be formed by a string of blocks generated by using a cryptographic method in association, where the blocks enable multiple parties to effectively store data and can read the stored data. In practice, it is found that there is a behavior that an illegal person gains profit through a forged block chain, that is, the forged block chain may be a behavior of storing an invalid block in a directed block chain; or, during the process of writing the blocks to the block chain, the invalid blocks are stored in the block chain due to poor network communication quality. An invalid block may refer to a block with missing data, inaccurate data, etc., so that a user cannot confirm whether the block read from the block chain is a valid block. If the invalid block in the block chain is read and used to perform the corresponding operation, it will cause inconvenience to the user. For example, a block in the blockchain stores bogus transaction address information, which may cause a resource transfer failure if the block storing the bogus transaction address information is read and used to perform the resource transfer. Therefore, how to verify whether the block read from the block chain is a valid block is a current urgent problem to be solved.
Disclosure of Invention
An embodiment of the present invention provides a data processing method, an apparatus, a storage medium, and a terminal based on a block chain, which can verify whether a block read from the block chain is a valid block.
In one aspect, an embodiment of the present application provides a data processing method based on a block chain, where the method includes:
determining block index information based on a locally stored target block set, wherein the target block set comprises at least one block read from a target full-scale node device of a blockchain network;
reading a reference block set used for verifying the target block set from a first reference full-scale node device of the blockchain network according to the block index information, wherein the first reference full-scale node device is a full-scale node device except the target full-scale node device in the blockchain network;
verifying the validity of each block in the target set of blocks using the reference set of blocks.
In one aspect, an embodiment of the present application provides a data processing apparatus based on a block chain, where the apparatus includes:
a determining unit, configured to determine block index information based on a locally stored target block set, where the target block set includes at least one block read from a target full-scale node device of a blockchain network;
a reading unit, configured to read, according to the block index information, a reference block set used for verifying the target block set from a first reference full-scale node device of the blockchain network, where the first reference full-scale node device is a full-scale node device of the blockchain network except for the target full-scale node device;
a verification unit configured to verify validity of each block in the target block set by using the reference block set.
In another aspect, an embodiment of the present application provides a terminal, including an input device and an output device, further including:
a processor adapted to implement one or more instructions; and the number of the first and second groups,
a computer storage medium storing one or more instructions adapted to be loaded by the processor and to perform the steps of:
determining block index information based on a locally stored target block set, wherein the target block set comprises at least one block read from a target full-scale node device of a blockchain network;
reading a reference block set used for verifying the target block set from a first reference full-scale node device of the blockchain network according to the block index information, wherein the first reference full-scale node device is a full-scale node device except the target full-scale node device in the blockchain network;
verifying the validity of each block in the target set of blocks using the reference set of blocks.
In yet another aspect, embodiments of the present application provide a computer storage medium having one or more instructions stored thereon, the one or more instructions adapted to be loaded by a processor and to perform the following steps:
determining block index information based on a locally stored target block set, wherein the target block set comprises at least one block read from a target full-scale node device of a blockchain network;
reading a reference block set used for verifying the target block set from a first reference full-scale node device of the blockchain network according to the block index information, wherein the first reference full-scale node device is a full-scale node device except the target full-scale node device in the blockchain network;
verifying the validity of each block in the target set of blocks using the reference set of blocks.
In the application, the terminal may determine the block index information based on the locally stored target block set, read the block with the block index information from the first reference full-scale node device, and add the read block with the block index information to the reference block set. And verifying the validity of each block in the target block set by adopting the reference block set, namely comparing the reference block in the reference block set with the target block in the target block set to verify the validity of the target block in the target block set. Here, the target block is any one of the blocks in the target block set, and the reference block and the target block have the same block index information. That is, by comparing the target block with the same index information with the reference block, it is possible to determine whether the block read from the block chain is a valid block, that is, it is possible to determine whether the data read from the block chain is valid data, thereby avoiding storing an invalid block in the terminal and improving the validity of storing the block in the terminal. In addition, the fraudulent behavior of storing invalid blocks in the block chain can be effectively identified, so that the loss (such as economic loss) brought to a user is avoided, the safety of the local storage block is improved, and the user can conveniently read data from the terminal.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1a is a block diagram of a data processing system according to an embodiment of the present disclosure;
fig. 1b is a schematic diagram of a block chain according to an embodiment of the present application;
fig. 2 is a schematic flowchart of a data processing method based on a block chain according to an embodiment of the present application;
fig. 3 is a schematic flowchart of a data processing method based on a block chain according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of a data processing apparatus based on a block chain according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of a terminal according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Based on the problem that a user cannot confirm whether a block read from a block chain is a valid block, the embodiment of the present application provides a data processing method based on a block chain, which can verify whether a block read from the block chain is a valid block. First, a data processing system according to an embodiment of the present application is introduced, as shown in fig. 1a, the data processing system includes a blockchain network and at least one terminal.
The blockchain network is an end-to-end decentralized network formed by a plurality of node devices, and each node device can receive input data during normal operation and maintain a blockchain based on the received input data. In order to ensure information intercommunication in the blockchain network, communication connection may exist between each node device in the blockchain network, and data transmission may be performed between the node devices through the communication connection. For example, when any node device in the blockchain network receives input data, other node devices in the blockchain network acquire the input data according to the consensus algorithm, and store the input data as data in the blockchain, so that the data stored in all the node devices in the blockchain network are consistent. That is, each node device in the blockchain network stores a complete blockchain, and the node device in the blockchain network for storing a complete blockchain is referred to as a full-scale node device (or a re-wallet node device). The full-scale node device may specifically refer to an independent server, a server cluster composed of a plurality of servers, or a cloud computing center.
The terminal stores part of data in the blockchain, and therefore, the terminal is also called as a lightweight node device or a common wallet node device; that is, the terminal may be used to read data from the blockchain stored by the quorum node device and to store the read data. For example, the blockchain includes transaction data, transaction certificate data, legal deposit data, and the like, the terminal belongs to a terminal managed by a public security organization or a court, and the terminal can read the legal deposit data from the blockchain and store the legal deposit data. The terminal can be specifically smart devices such as a smart phone, a tablet computer, a portable personal computer, a smart watch, a bracelet and a smart television.
The block chain is composed of a plurality of blocks, referring to fig. 1b, the block chain is composed of a plurality of blocks, the starting block includes a block header and a block body, and the block header stores a hash value, a version number, a timestamp and a random number of input data. The block main body stores input data; the next block of the starting block takes the starting block as a parent block, the next block also comprises a block head and a block main body, the block head stores the hash value of the input data of the current block, the hash value of the parent block head, the version number, the timestamp and the random number, and the like, so that the block data stored in each block in the block chain is associated with the block data stored in the parent block, and the safety of the input data in the block is ensured.
When each block in the block chain is generated, when each full-scale node device where the block chain is located receives input data, the input data is verified, after the verification is completed, the input data is stored in a memory pool, and a hash tree used for storing the input data is updated; and then, updating the time stamp to the time when the input data is received, trying different random numbers, and performing hash value calculation for multiple times, so that the calculated hash value can satisfy the following formula:
SHA256(SHA256(version+prev_hash+merkle_root+ntime+nbits+x))<TARGET
wherein, SHA256 is a hash value algorithm used for calculating the hash value; version is version information of the relevant block protocol in the block chain; prev _ hash is a parent block head hash value of the current block; merkle _ root is a hash value of the input data; ntime is the update time of the update timestamp; nbits is the current difficulty, is a fixed value within a period of time, and is determined again after exceeding a fixed time period; x is a random number; TARGET is a hash threshold, which can be determined from nbits.
Therefore, when the random number meeting the formula is obtained through calculation, the information can be correspondingly stored, and the block head and the block main body are generated to obtain the current block. And then, the full-scale node equipment respectively sends the newly generated blocks to other full-scale node equipment of the block chain network where the blocks are located, the other full-scale node equipment checks the newly generated blocks, and the newly generated blocks are added to the block chain stored in the full-scale node equipment after the check is finished.
Based on the description of fig. 1a and fig. 1b, the block chain-based data processing method provided by the present application may include: the terminal may determine the block index information based on the locally stored target block set, read the block with the block index information from the first reference full-scale node device, and add the read block with the block index information to the reference block set. And verifying the validity of each block in the target block set by adopting the reference block set, namely comparing the reference block in the reference block set with the target block in the target block set to verify the validity of the target block in the target block set. Here, the target block is any one of the blocks in the target block set, and the reference block and the target block have the same block index information. That is, by comparing the target block with the same index information with the reference block, it is possible to determine whether the block read from the block chain is a valid block, i.e., it is possible to determine whether the data read from the block chain is valid data; the invalid block is prevented from being stored in the terminal, and the effectiveness of storing the block in the terminal is improved. In addition, the fraudulent behavior of storing invalid blocks in the block chain can be effectively identified, so that the loss (such as economic loss) brought to a user is avoided, the safety of the local storage block is improved, and the user can conveniently read data from the terminal.
Based on the above description, the present embodiment provides a data processing method based on a block chain, which is applied to the terminal in fig. 1a, as shown in fig. 2, and the method may include the following steps S101 to S103.
S101, determining block index information based on a locally stored target block set, wherein the target block set comprises at least one block read from a target full-volume node device of a block chain network.
The target set of blocks includes at least one block to be verified, the at least one block to be verified being read from a target quorum node device of the blockchain network. Before the terminal uses the blocks to be verified, in order to prevent fraudulent behavior of recording invalid data into the block chain or prevent an event of storing invalid data into the block chain due to poor network communication quality in the process of recording data into the block chain, the blocks with verification need to be verified. Thus, the terminal may determine the tile index information based on the locally stored target tile set; where the block index information is used to indicate the position of each block in the target block set on the blockchain, the block index information may include at least one or more of a block height, a timestamp, a random number, and a field in the block for each block in the target block set.
And S102, reading a reference block set used for verifying the target block set from a first reference full-scale node device of the block chain network according to the block index information, wherein the first reference full-scale node device is a full-scale node device except the target full-scale node device in the block chain network.
Usually, the blocks having the same block index information in each of the quorum node devices are the same, i.e., the blocks at the same position on the blockchain in each of the quorum node devices are all the same. For example, the blockchain network includes two full-scale node devices, namely a target full-scale node device and a first reference full-scale node device, and a 10 th block (i.e. a block with a block height of 10) on the blockchain in the target full-scale node device is the same as a 10 th block on the blockchain in the first reference full-scale node device. Therefore, the target block set may be verified using the block with the block index information in other full-scale node devices, where the other full-scale node devices are full-scale node devices in the block chain network except the target full-scale node device. Specifically, the terminal may locate and read a reference block set for verifying the target block set from a first reference full-scale node device of the blockchain network according to the block index information, where the first reference full-scale node device is a full-scale node device of the blockchain network except for the target full-scale node device. For example, the first reference full-scale node device may be a full-scale node device with a trust degree greater than a trust degree threshold in the blockchain network, and the trust degree of the first reference full-scale node device may be determined according to the number of times that the block in the first reference full-scale node device is detected to be an invalid block. The more times of detecting that the block in the first reference full-scale node device is an invalid block, the higher the trust level of the first reference full-scale node device is; conversely, the less the number of times the block in the first reference full-scale node device is detected as an invalid block, the lower the trust level of the first reference full-scale node device is. Alternatively, the first reference full-scale node device may be any full-scale node device in the blockchain network except the target full-scale node device.
In one embodiment, the terminal may read the block with the block index information from the first full node reference device, and add the block with the block index information to the reference block set, so that the target block set can be verified by using all the blocks with the block index information in the first full node reference device, which may improve the accuracy of verifying the blocks. In another embodiment, the terminal may read the block with the block index information from the first full node reference device, select a block from the blocks with the block index information, and add the block to the reference block set, so that the target block set can be verified by using the partial blocks with the block index information in the first full node reference device, and the efficiency of verifying the block can be improved.
S103, verifying the validity of each block in the target block set by adopting the reference block set.
The terminal may compare the reference block in the reference block set with the target block in the target block set to verify the validity of the target block in the target block set. Here, the target block is any one of the blocks in the target block set, and the reference block and the target block have the same block index information. The target block is a valid block, which shows that the target block stored by the target full-scale node equipment is accurate; the target block is an invalid block, which indicates that the target block stored in the target full-scale node device has wrong data and missing data, that is, indicates that the target full-scale node device has poor network communication quality in the process of storing the target block on the block chain, or has a fraudulent behavior of storing invalid data on the block chain.
In one embodiment, the block head of the reference block is compared with the block head of the target block, and if the block head of the reference block is the same as the block head of the target block, the target block is determined to be a valid block; and if the block head of the reference block is not the same as the block head of the target block, determining the target block as an invalid block. In another embodiment, the block body of the reference block is compared with the block body of the target block, and if the block body of the reference block is the same as the block body of the target block, the target block is determined to be a valid block; and if the block body of the reference block is not the same as that of the target block, determining that the target block is an invalid block. In another embodiment, the block body of the reference block is compared with the block body of the target block, and the block head of the reference block is compared with the block head of the target block, if the block body of the reference block is the same as the block body of the target block and the block head of the reference block is the same as the block head of the target block, the target block is determined to be a valid block; and if the block body of the reference block is different from the block body of the target block, and the block head of the reference block is different from the block head of the target block, determining that the target block is an invalid block.
In the application, the terminal may determine the block index information based on the locally stored target block set, read the block with the block index information from the first reference full-scale node device, and add the read block with the block index information to the reference block set. And verifying the validity of each block in the target block set by adopting the reference block set, namely comparing the reference block in the reference block set with the target block in the target block set to verify the validity of the target block in the target block set. Here, the target block is any one of the blocks in the target block set, and the reference block and the target block have the same block index information. That is, by comparing the target block with the same index information with the reference block, it is possible to determine whether the block read from the block chain is a valid block, that is, it is possible to determine whether the data read from the block chain is valid data, thereby avoiding storing an invalid block in the terminal and improving the validity of storing the block in the terminal. In addition, the fraudulent behavior of storing invalid blocks in the block chain can be effectively identified, so that the loss (such as economic loss) brought to a user is avoided, the safety of the local storage block is improved, and the user can conveniently read data from the terminal.
In one embodiment, the block index information includes a target block height of each block in the target block set, and the following steps S11-S12 may be included before step S102.
s11, reading the tile having the target tile height from a first reference quorum node device of the blockchain network.
s12, adding the read block with the target block height to the reference block set.
In steps s 11-s 12, to improve the accuracy of verification of the target block, the terminal may read the block with the target block height from the first reference full-volume node device of the blockchain network, and add the read block with the target block height to the reference block set, i.e. add all blocks with the target block height in the first reference full-volume node device to the reference block set. In this way, the blocks in the target block set have a one-to-one correspondence with the blocks in the reference block set, so that the blocks in the target block set are verified one by using the respective blocks in the reference block set. For example, the target block set includes blocks with block heights [1, 20], and the target block heights [1, 20], then the blocks with block heights [1, 20] are read from the first reference full node device of the block chain network, and the blocks read from the first reference full node device are added to the reference block set. That is, the block with the block height of 1 in the target block set corresponds to the block with the block height of 1 in the reference block set, that is, the block with the block height of 1 in the reference block set can be used to verify the block with the block height of 1 in the target block set. Similarly, the block with the block height of 2 in the target block set corresponds to the block with the block height of 2 in the reference block set, i.e. the block with the block height of 2 in the reference block set can be used to verify the block with the block height of 2 in the target block set.
Optionally, the tile index information includes a target tile height of each tile in the target tile set, and the following steps S21 to S22 may be included before step S102.
s21, reading the tile having the target tile height from a first reference quorum node device of the blockchain network.
s22, randomly selecting blocks from the read blocks with the target block height, and adding the selected blocks to the reference block set; or selecting blocks from the read blocks with the target block height according to the height interval, and adding the blocks to the reference block set.
In steps s 21-s 22, to improve the efficiency of verification of the target block, the terminal may read the block with the target block height from the first reference full-node device in the blockchain network, and randomly select one or more blocks from the read blocks with the target block height to be added to the reference block set. Alternatively, the terminal may select blocks from the read blocks having the height of the target block at height intervals, and add the selected blocks to the reference block set. Here, the height interval may be determined according to the number of blocks in the target block set, or the height interval may be a default value in the terminal. At this time, the reference block set comprises a partial block with the height of the target block in the first reference full-scale node device, and the partial block with the height of the target block in the first reference full-scale node device is adopted to verify the corresponding partial block in the target block set, so that the blocks in the target block set do not need to be verified one by one, and the verification efficiency of the target block is improved. For example, the target block set includes blocks with a block height of [1, 20], and the target block height is [1, 20], then the blocks with the block height of [1, 20] are read from the first reference full-scale node device of the block chain network, and the blocks with the block height of 7, the blocks with the block height of 15, and the blocks with the block height of 18 are selected from the blocks read from the first reference full-scale node device and added to the reference block set. The block with the block height of 7, the block with the block height of 15 and the block with the block height of 18 in the reference block set can be used for respectively verifying the block with the block height of 7, the block with the block height of 15 and the block with the block height of 18 in the target block set, so that the verification results of the blocks with the block height of 7, the block height of 15 and the block height of 18 in the target block set are obtained, and the validity of other blocks in the target block set is determined according to the verification results. If the block with the block height of 7 in the target block set is a valid block, the block with the block height of [1, 6] in the target block set can be determined as a valid block.
In this embodiment, the first reference full-volume node device belongs to a reference full-volume node device set, the reference full-volume node device set includes at least one reference full-volume node device, each reference full-volume node device corresponds to one reference block set, and the step S103 may include the following steps S31 to S34.
s31, obtaining the first hash value of the target block in the target block set, and obtaining the second hash value of the reference block in each reference block set; the target block is any one of the target block set, and the reference block and the target block have the same block height.
s32, counting the number of second chunk head hash values different from the first chunk head hash value as the target number.
s33, if the target number is greater than the number threshold, determining the target block as an invalid block.
s34, if the target number is less than or equal to the number threshold, determining the target block as a valid block.
In steps s 31-s 34, in order to improve the accuracy of verifying the target block set, the terminal may obtain the reference block set from a plurality of reference full-scale node devices, that is, verify the target block using a plurality of reference blocks. Specifically, the terminal may obtain a first chunk header hash value of a target chunk in the target chunk set, and obtain a second chunk header hash value of a reference chunk in each reference chunk set; and comparing the first block head hash value with the second block head hash value to count the number of the second block head hash values different from the first block head hash value as the target number. And when the target number is larger than the number threshold, the target block stored in the target full-scale node equipment is different from the reference blocks stored in most of the reference full-scale node equipment, namely the target block is determined to be an invalid block. Here, the number threshold may be an integer greater than or equal to 1, and the number threshold may be determined according to the number of blocks in the target block set, or may be a default value of the terminal. When the target number is less than or equal to the number threshold, indicating that the target blocks stored in the target full-scale node device are different from the reference blocks stored in the fewer reference full-scale node devices; or, if the target block stored in the target full-scale node device is the same as the reference block stored in each reference full-scale node device in the at least one full-scale node device, determining that the target block is a valid block.
In this embodiment, the step s31 may include: and performing hash operation on the block head of the target block in the target block set to obtain a first block head hash value of the target block, and performing hash operation on the block head of the reference block in each reference block set to obtain a second block head hash value of each reference block.
The terminal may perform a hash operation on the block head of the target block in the target block set by using a hash algorithm to obtain a first block head hash value of the target block, and perform a hash operation on the block head of the reference block in each reference block set by using a hash algorithm to obtain a second block head hash value of each reference block. Here the hash algorithm includes but is not limited to: the MD4 algorithm, the MD5 algorithm, the SHA-1 algorithm, the SHA-256 algorithm, etc.
Optionally, the step s31 may include: reading the parent chunk header hash value of the next chunk of the target chunk from the target quorum node device as the first chunk header hash value, and reading the parent chunk header hash value of the next chunk of the reference chunk from each of the reference quorum node devices as the second chunk header hash value.
Since there is a chain connection relationship between blocks in the block chain, the hash value of the block head of the last block in the block chain is stored in the block head of the next block. Thus, the terminal may read the parent chunk header hash value of the next chunk of the target chunk from the target quorum node device as the first chunk header hash value, and read the parent chunk header hash value of the next chunk of the reference chunk from each of the reference quorum node devices as the second chunk header hash value.
In this embodiment, the step s33 may include: if the target number is greater than the number threshold, determining that the block in the target block set whose block height is greater than or equal to the block height of the target block is an invalid block.
Because the blocks in the block chain have chain connection relation, that is, the hash value of the head of the last block in the block chain is stored in the head of the next block, if the target block is an invalid block, it indicates that the hash value of the head of the target block is inaccurate, that is, the hash value of the head of the block corresponding to the block with the block height greater than the block height of the target block in the target block set is inaccurate. Therefore, if the target number of second chunk head hashes different from the first chunk head hash value is greater than the number threshold, it is determined that all chunks having a chunk height greater than or equal to the chunk height of the target chunk are invalid chunks. At this time, the block with the block height larger than that of the target block in the target block set does not need to be verified, and the verification efficiency of the block is improved.
In one embodiment, the step s34 may include: if the target number is less than or equal to the number threshold, determining a block in the target block set whose block height is less than or equal to the block height of the target block as a valid block.
Because the blocks in the block chain have chain connection relation, that is, the hash value of the head of the last block in the block chain is stored in the head of the next block, if the target block is a valid block, it indicates that the hash value of the head of the target block is accurate, that is, the hash value of the head of the block corresponding to the block with the block height smaller than the block height of the target block in the target block set is accurate. Therefore, if the target number of second chunk head hash values different from the first chunk head hash value is less than or equal to the number threshold, it is determined that all the chunks in the target chunk set whose chunk height is less than or equal to the chunk height of the target chunk are valid chunks. At this time, the block with the block height smaller than that of the target block in the target block set does not need to be verified, and the verification efficiency of the block is improved.
In this embodiment, after step s103, the method further comprises steps s 41-s 43 as follows.
s41, deleting the invalid blocks in the target block set.
s42, re-reading the block with the block height of the invalid block from the at least one reference full-volume node device as the block to be verified.
s43, after the validity of the block to be verified is verified, storing the block to be verified.
In steps s 41-s 43, the terminal may delete the invalid blocks in the target block set, and re-read the block height blocks with the invalid blocks from the at least one reference full node device as the blocks to be verified. Verifying the validity of the block to be verified, and storing the block to be verified after the validity of the block to be verified is verified, so that an invalid block can be prevented from being stored in the terminal, and the utilization rate of a storage space of the terminal is improved; the inconvenience brought to the user by adopting invalid data to execute corresponding operation can be avoided.
In an embodiment, a data processing method based on a block chain provided by the present application is described below by taking, as an example, a target block set including a block whose block height is [1, 20], a reference full-scale device set including 3 reference full-scale node devices, which are a first reference full-scale node device, a second reference full-scale node device, and a third reference full-scale node device, respectively. As shown in fig. 3, the method includes:
the terminal can obtain locally stored block index information of a target block set, wherein the block index information comprises target block heights of all blocks in the target block set, and the target block heights are located in [1, 20 ]; the method comprises the steps of reading blocks with target block heights from a first reference full-scale node device, a second reference full-scale node device and a third reference full-scale node device respectively, namely reading each block with the block height of [1, 20] from the first reference full-scale node device, the second reference full-scale node device and the third reference full-scale node device respectively, randomly selecting a block with the block height of 7, a block with the block height of 15 and a block with the block height of 18 from the blocks read from each reference full-scale node device, and adding the blocks into a reference block set. For convenience of description herein, the reference block sets read from the first, second, and third reference full-volume node devices may be referred to as a first, second, and third reference block set, respectively.
After the reference block set is obtained, the terminal may verify each block in the target block set by using each reference block set, that is, compare the second block head hash value of the reference block in each reference block set with the first block head hash value of the target block in the target block set to verify the validity of the target block. For example, the second bmt of each block with a block height of 7 in the first reference block set, the second reference block set, and the third reference block set may be respectively compared with the first bmt of the block with a block height of 7 in the target block set. If the target number of second chunk head hash values different from the first chunk head hash value of the chunk with the chunk height of 7 in the target chunk set is less than or equal to 1, determining the chunk with the chunk height of [1, 7] in the target chunk set as a valid chunk. Similarly, the second blt hash values of the blocks with the block height of 15 in the first reference block set, the second reference block set, and the third reference block set may be respectively compared with the first blt hash values of the blocks with the block height of 15 in the target block set. And if the target number of second block head hash values different from the first block head hash value of the block with the block height of 15 in the target block set is more than 1, determining that the block with the block height of [15, 20] in the target block set is an invalid block. At this time, the blocks with the block height [8, 14] may be randomly read from the first full node reference device, the second full node reference device, and the third full node reference device, and the validity of the block with the block height [8, 14] in the target block set may be verified by using the blocks with the block height [8, 14] read from the full node reference device. If the second chunk head hash value of the chunk with the chunk height of 14 read from each reference full-scale node device is compared with the first chunk head hash value of the chunk with the chunk height of 14 in the target chunk set, and if the target number of the second chunk head hash values different from the first chunk head hash value of the chunk with the chunk height of 14 is less than 1, determining that the chunk with the chunk height of [8, 14] in the target chunk set is a valid chunk.
After the validity of each block in the target block set is determined, deleting the block with the block height [15, 20] in the target block set, reading the block with the block height [15, 20] from the first reference full-scale node equipment as a block to be verified, verifying the validity of each block to be verified by adopting the method, and storing the block with the block height [15, 20] read from the first reference full-scale node equipment when each block to be verified passes verification.
An embodiment of the present application provides a data processing apparatus based on a block chain, where the data processing apparatus based on the block chain may be disposed in a terminal, please refer to fig. 4, and the apparatus includes:
a determining unit 401, configured to determine the chunk index information based on a locally stored target chunk set, where the target chunk set includes at least one chunk read from a target full-volume node device of the blockchain network.
A reading unit 402, configured to read, according to the block index information, a reference block set used for verifying the target block set from a first reference full-scale node device of the blockchain network, where the first reference full-scale node device is a full-scale node device of the blockchain network except the target full-scale node device.
A verifying unit 403, configured to verify validity of each block in the target block set by using the reference block set.
Optionally, the apparatus further comprises: a first adding unit 404, configured to read a block with the target block height from a first reference full-scale node device of the blockchain network; adding the read block with the target block height to the reference block set.
Optionally, the apparatus further comprises: a second adding unit 405, configured to read a block with the target block height from a first reference full-scale node device of the blockchain network; randomly selecting a block from the read blocks with the target block height, and adding the selected block to the reference block set; or selecting blocks from the read blocks with the target block height according to the height interval, and adding the blocks to the reference block set.
Optionally, the verifying unit 403 is specifically configured to obtain a first chunk header hash value of a target chunk in the target chunk set, and obtain a second chunk header hash value of a reference chunk in each reference chunk set; the target block is any block in the target block set, and the reference block and the target block have the same block height; counting the number of second block head hash values different from the first block head hash value as a target number; if the target number is larger than a number threshold, determining that the target block is an invalid block; and if the target number is less than or equal to the number threshold, determining that the target block is a valid block.
Optionally, the verifying unit 403 is specifically configured to determine, if the target number is greater than a number threshold, that a block in the target block set whose block height is greater than or equal to the block height of the target block is an invalid block; if the target number is less than or equal to the number threshold, determining a block in the target block set whose block height is less than or equal to the block height of the target block as a valid block.
Optionally, the verifying unit 403 is specifically configured to perform a hash operation on a block header of the target block in the target block set to obtain a first block header hash value of the target block, and perform a hash operation on a block header of the reference block in each reference block set to obtain a second block header hash value of each reference block; or, the parent block head hash value of the next block of the target block is read from the target full-scale node device as the first block head hash value, and the parent block head hash value of the next block of the reference block is read from each reference full-scale node device as the second block head hash value.
The device further comprises:
a storage unit 406, configured to delete an invalid block in the target block set; reading a block with the block height of the invalid block from the at least one reference full-scale node device again to serve as a block to be verified; and after the validity of the block to be verified is verified, storing the block to be verified.
In the application, the terminal may determine the block index information based on the locally stored target block set, read the block with the block index information from the first reference full-scale node device, and add the read block with the block index information to the reference block set. And verifying the validity of each block in the target block set by adopting the reference block set, namely comparing the reference block in the reference block set with the target block in the target block set to verify the validity of the target block in the target block set. Here, the target block is any one of the blocks in the target block set, and the reference block and the target block have the same block index information. That is, by comparing the target block with the same index information with the reference block, it is possible to determine whether the block read from the block chain is a valid block, that is, it is possible to determine whether the data read from the block chain is valid data, thereby avoiding storing an invalid block in the terminal and improving the validity of storing the block in the terminal. In addition, the fraudulent behavior of storing invalid blocks in the block chain can be effectively identified, so that the loss (such as economic loss) brought to a user is avoided, the safety of the local storage block is improved, and the user can conveniently read data from the terminal.
An embodiment of the present application provides a terminal, please refer to fig. 5. The terminal includes: the processor 151, the user interface 152, the network interface 154, and the storage device 155 are connected via a bus 153.
A user interface 152 for enabling human-computer interaction, which may include a display screen or a keyboard, among others. And a network interface 154 for communication connection with an external device. A storage device 155 is coupled to processor 151 for storing various software programs and/or sets of instructions. In particular implementations, storage 155 may include high speed random access memory and may also include non-volatile memory, such as one or more magnetic disk storage devices, flash memory devices, or other non-volatile solid state storage devices. The storage device 155 may store an operating system (hereinafter referred to simply as a system), such as an embedded operating system like ANDROID, IOS, WINDOWS, or LINUX. The storage 155 may also store a network communication program that may be used to communicate with one or more additional devices, one or more application servers, one or more network devices. The storage device 155 may further store a user interface program, which may vividly display the content of the application program through a graphical operation interface, and receive a user's control operation of the application program through input controls such as menus, dialog boxes, and buttons. The storage device 155 may also store video data and the like.
In one embodiment, the storage 155 may be used to store one or more instructions; the processor 151 may be capable of implementing a data processing method based on a blockchain when invoking the one or more instructions, and specifically, the processor 151 invokes the one or more instructions to perform the following steps:
determining block index information based on a locally stored target block set, wherein the target block set comprises at least one block read from a target full-scale node device of a blockchain network;
reading a reference block set used for verifying the target block set from a first reference full-scale node device of the blockchain network according to the block index information, wherein the first reference full-scale node device is a full-scale node device except the target full-scale node device in the blockchain network;
verifying the validity of each block in the target set of blocks using the reference set of blocks.
Optionally, the processor calls an instruction to perform the following steps:
reading a block having the target block height from a first reference quorum node device of the blockchain network;
adding the read block with the target block height to the reference block set.
Optionally, the processor calls an instruction to perform the following steps:
reading a block having the target block height from a first reference quorum node device of the blockchain network;
randomly selecting a block from the read blocks with the target block height, and adding the selected block to the reference block set; or selecting blocks from the read blocks with the target block height according to the height interval, and adding the blocks to the reference block set.
Optionally, the processor calls an instruction to perform the following steps:
acquiring a first block head hash value of a target block in the target block set, and acquiring a second block head hash value of a reference block in each reference block set; the target block is any block in the target block set, and the reference block and the target block have the same block height;
counting the number of second block head hash values different from the first block head hash value as a target number;
if the target number is larger than a number threshold, determining that the target block is an invalid block;
and if the target number is less than or equal to the number threshold, determining that the target block is a valid block.
Optionally, the processor calls an instruction to perform the following steps:
if the target number is larger than a number threshold, determining that a block in the target block set, the block having a block height larger than or equal to the block height of the target block, is an invalid block;
if the target number is less than or equal to the number threshold, determining that the target block is a valid block, including:
if the target number is less than or equal to the number threshold, determining a block in the target block set whose block height is less than or equal to the block height of the target block as a valid block.
Optionally, the processor calls an instruction to perform the following steps:
performing hash operation on the block head of the target block in the target block set to obtain a first block head hash value of the target block, and performing hash operation on the block head of the reference block in each reference block set to obtain a second block head hash value of each reference block; alternatively, the first and second electrodes may be,
reading, from the target quorum node device, a parent chunk header hash value of a chunk next to the target chunk as the first chunk header hash value, and reading, from each of the reference quorum node devices, a parent chunk header hash value of a chunk next to the reference chunk as the second chunk header hash value.
Optionally, the processor calls an instruction to perform the following steps:
deleting invalid blocks in the target block set;
reading a block with the block height of the invalid block from the at least one reference full-scale node device again to serve as a block to be verified;
and after the validity of the block to be verified is verified, storing the block to be verified.
In the application, the terminal may determine the block index information based on the locally stored target block set, read the block with the block index information from the first reference full-scale node device, and add the read block with the block index information to the reference block set. And verifying the validity of each block in the target block set by adopting the reference block set, namely comparing the reference block in the reference block set with the target block in the target block set to verify the validity of the target block in the target block set. Here, the target block is any one of the blocks in the target block set, and the reference block and the target block have the same block index information. That is, by comparing the target block with the same index information with the reference block, it is possible to determine whether the block read from the block chain is a valid block, that is, it is possible to determine whether the data read from the block chain is valid data, thereby avoiding storing an invalid block in the terminal and improving the validity of storing the block in the terminal. In addition, the fraudulent behavior of storing invalid blocks in the block chain can be effectively identified, so that the loss (such as economic loss) brought to a user is avoided, the safety of the local storage block is improved, and the user can conveniently read data from the terminal.
An embodiment and advantageous effects of the program for solving the problem may refer to the embodiment and advantageous effects of the data processing method based on the block chain described in fig. 2 and fig. 3, and repeated parts are not described again.
The above disclosure is only a few examples of the present application, and certainly should not be taken as limiting the scope of the present application, which is therefore intended to cover all modifications that are within the scope of the present application and which are equivalent to the claims.

Claims (10)

1. A data processing method based on a block chain is characterized by comprising the following steps:
determining block index information based on a locally stored target block set, wherein the target block set comprises at least one block read from a target full-scale node device of a blockchain network;
reading a reference block set used for verifying the target block set from a first reference full-scale node device of the blockchain network according to the block index information, wherein the first reference full-scale node device is a full-scale node device except the target full-scale node device in the blockchain network;
verifying the validity of each block in the target set of blocks using the reference set of blocks.
2. The method of claim 1, wherein the block index information comprises a target block height for each block in the target set of blocks, and wherein the method further comprises, prior to reading a reference set of blocks for validation of the target set of blocks from a first reference full-scale node device of the blockchain network according to the block index information:
reading a block having the target block height from a first reference quorum node device of the blockchain network;
adding the read block with the target block height to the reference block set.
3. The method of claim 1, wherein the block index information comprises a target block height for each block in the target set of blocks, and wherein the method comprises, prior to reading a reference set of blocks for validation of the target set of blocks from a first reference full-scale node device of the blockchain network based on the block index information:
reading a block having the target block height from a first reference quorum node device of the blockchain network;
randomly selecting a block from the read blocks with the target block height, and adding the selected block to the reference block set; or selecting blocks from the read blocks with the target block height according to the height interval, and adding the blocks to the reference block set.
4. The method of claim 2 or 3, wherein the first reference full-scale node device belongs to a set of reference full-scale node devices, the set of reference full-scale node devices including at least one reference full-scale node device, each reference full-scale node device corresponding to a set of reference blocks, the verifying validity of each block in the target set of blocks using the set of reference blocks comprising:
acquiring a first block head hash value of a target block in the target block set, and acquiring a second block head hash value of a reference block in each reference block set; the target block is any block in the target block set, and the reference block and the target block have the same block height;
counting the number of second block head hash values different from the first block head hash value as a target number;
if the target number is larger than a number threshold, determining that the target block is an invalid block;
and if the target number is less than or equal to the number threshold, determining that the target block is a valid block.
5. The method of claim 4, wherein determining that the target block is an invalid block if the target number is greater than a number threshold comprises:
if the target number is larger than a number threshold, determining that a block in the target block set, the block having a block height larger than or equal to the block height of the target block, is an invalid block;
if the target number is less than or equal to the number threshold, determining that the target block is a valid block, including:
if the target number is less than or equal to the number threshold, determining a block in the target block set whose block height is less than or equal to the block height of the target block as a valid block.
6. The method of claim 4, wherein obtaining a first chunk-head hash value for a target chunk of the target set of chunks and obtaining a second chunk-head hash value for a reference chunk of each reference set of chunks comprises:
performing hash operation on the block head of the target block in the target block set to obtain a first block head hash value of the target block, and performing hash operation on the block head of the reference block in each reference block set to obtain a second block head hash value of each reference block; alternatively, the first and second electrodes may be,
reading, from the target quorum node device, a parent chunk header hash value of a chunk next to the target chunk as the first chunk header hash value, and reading, from each of the reference quorum node devices, a parent chunk header hash value of a chunk next to the reference chunk as the second chunk header hash value.
7. The method of claim 4, wherein after verifying the validity of each block in the target set of blocks using the reference set of blocks, the method further comprises:
deleting invalid blocks in the target block set;
reading a block with the block height of the invalid block from the at least one reference full-scale node device again to serve as a block to be verified;
and after the validity of the block to be verified is verified, storing the block to be verified.
8. A blockchain-based data processing apparatus, comprising:
a determining unit, configured to determine block index information based on a locally stored target block set, where the target block set includes at least one block read from a target full-scale node device of a blockchain network;
a reading unit, configured to read, according to the block index information, a reference block set used for verifying the target block set from a first reference full-scale node device of the blockchain network, where the first reference full-scale node device is a full-scale node device of the blockchain network except for the target full-scale node device;
a verification unit configured to verify validity of each block in the target block set by using the reference block set.
9. A terminal comprising an input device and an output device, further comprising:
a processor adapted to implement one or more instructions; and the number of the first and second groups,
a computer storage medium having one or more instructions stored thereon, the one or more instructions adapted to be loaded by the processor and to perform the method of any of claims 1-7.
10. A computer storage medium, characterized in that the computer storage medium stores computer program instructions which, when executed, implement the method of any one of claims 1-7.
CN201911128883.3A 2019-11-18 2019-11-18 Data processing method and device based on block chain, storage medium and terminal Active CN110851535B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911128883.3A CN110851535B (en) 2019-11-18 2019-11-18 Data processing method and device based on block chain, storage medium and terminal

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911128883.3A CN110851535B (en) 2019-11-18 2019-11-18 Data processing method and device based on block chain, storage medium and terminal

Publications (2)

Publication Number Publication Date
CN110851535A true CN110851535A (en) 2020-02-28
CN110851535B CN110851535B (en) 2021-07-13

Family

ID=69602093

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911128883.3A Active CN110851535B (en) 2019-11-18 2019-11-18 Data processing method and device based on block chain, storage medium and terminal

Country Status (1)

Country Link
CN (1) CN110851535B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111444203A (en) * 2020-03-24 2020-07-24 腾讯科技(深圳)有限公司 Synchronous processing method, device, equipment and medium
CN111488626A (en) * 2020-04-09 2020-08-04 腾讯科技(深圳)有限公司 Data processing method, device, equipment and medium based on block chain
CN111541756A (en) * 2020-04-17 2020-08-14 腾讯科技(深圳)有限公司 Block generation method, block generation device, node equipment and storage medium
CN112037058A (en) * 2020-08-28 2020-12-04 平安科技(深圳)有限公司 Data verification method, device and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107729383A (en) * 2017-09-18 2018-02-23 联动优势科技有限公司 A kind of library generation method, data verification method, device and platform
WO2018119930A1 (en) * 2016-12-29 2018-07-05 深圳前海达闼云端智能科技有限公司 Transaction verification processing method, apparatus and node device
CN110020554A (en) * 2019-04-19 2019-07-16 腾讯科技(深圳)有限公司 Information processing method, device and computer readable storage medium based on block chain
CN110378694A (en) * 2018-05-21 2019-10-25 腾讯科技(深圳)有限公司 Block chain data processing method, device, computer equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018119930A1 (en) * 2016-12-29 2018-07-05 深圳前海达闼云端智能科技有限公司 Transaction verification processing method, apparatus and node device
CN107729383A (en) * 2017-09-18 2018-02-23 联动优势科技有限公司 A kind of library generation method, data verification method, device and platform
CN110378694A (en) * 2018-05-21 2019-10-25 腾讯科技(深圳)有限公司 Block chain data processing method, device, computer equipment and storage medium
CN110020554A (en) * 2019-04-19 2019-07-16 腾讯科技(深圳)有限公司 Information processing method, device and computer readable storage medium based on block chain

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111444203A (en) * 2020-03-24 2020-07-24 腾讯科技(深圳)有限公司 Synchronous processing method, device, equipment and medium
CN111488626A (en) * 2020-04-09 2020-08-04 腾讯科技(深圳)有限公司 Data processing method, device, equipment and medium based on block chain
CN111541756A (en) * 2020-04-17 2020-08-14 腾讯科技(深圳)有限公司 Block generation method, block generation device, node equipment and storage medium
CN111541756B (en) * 2020-04-17 2021-10-15 腾讯科技(深圳)有限公司 Block generation method, block generation device, node equipment and storage medium
CN112037058A (en) * 2020-08-28 2020-12-04 平安科技(深圳)有限公司 Data verification method, device and storage medium
WO2022041901A1 (en) * 2020-08-28 2022-03-03 平安科技(深圳)有限公司 Data verification method and apparatus, and storage medium
CN112037058B (en) * 2020-08-28 2024-03-26 平安科技(深圳)有限公司 Data verification method, device and storage medium

Also Published As

Publication number Publication date
CN110851535B (en) 2021-07-13

Similar Documents

Publication Publication Date Title
CN110851535B (en) Data processing method and device based on block chain, storage medium and terminal
CN110708171B (en) Block chain consensus voting method, device, equipment and storage medium
CN109902086B (en) Index creation method, device and equipment
EP3552343B1 (en) Method and apparatus for creating a finite blockchain
US20200412549A1 (en) Tampering detection system and method for detecting tampering
US11074139B2 (en) Dynamic block chain system using metadata for backing up data based on digest rules
US20210083856A1 (en) Improved hardware security module management
CN110431577B (en) System and method for detecting replay attacks
CN110597825B (en) Data processing method and device based on block chain and node equipment
US20210049715A1 (en) Blockchain-based data procesing method, apparatus, and electronic device
JPWO2018158936A1 (en) Blockchain management device, blockchain management method and program
CN109815746B (en) Data tamper-proofing method and system based on block chain technology
CN110245518B (en) Data storage method, device and equipment
CN110022315B (en) Weight management method, device and equipment in block chain type account book
US20200366504A1 (en) Signature verification for a blockchain ledger
CN110019278B (en) Data verification method, device and equipment
CN110008203B (en) Data clearing method, device and equipment
CN109995523B (en) Activation code management method and device and activation code generation method and device
CN110727679A (en) Cooperative tracking method, system, device and equipment for court case
CN110008210B (en) Index creation method, device and equipment
CN116610336A (en) Firmware upgrading method, system, device and readable storage medium
CN111292082B (en) Public key management method, device and equipment in block chain type account book
CN110717172B (en) Permission transfer method, device and equipment in block chain type account book
CN107948130B (en) File processing method, server and system
CN111125678A (en) Method, device and medium for managing Option ROM loading

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant