WO2021012903A1 - Data storage method and apparatus, computer device, and storage medium - Google Patents

Data storage method and apparatus, computer device, and storage medium Download PDF

Info

Publication number
WO2021012903A1
WO2021012903A1 PCT/CN2020/099213 CN2020099213W WO2021012903A1 WO 2021012903 A1 WO2021012903 A1 WO 2021012903A1 CN 2020099213 W CN2020099213 W CN 2020099213W WO 2021012903 A1 WO2021012903 A1 WO 2021012903A1
Authority
WO
WIPO (PCT)
Prior art keywords
block
current
current block
deleted
generation time
Prior art date
Application number
PCT/CN2020/099213
Other languages
French (fr)
Chinese (zh)
Inventor
刘恩科
王梦寒
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2021012903A1 publication Critical patent/WO2021012903A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • 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/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2471Distributed queries
    • 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

Definitions

  • This application relates to the field of computer technology, in particular to a data storage method, device, computer equipment and storage medium.
  • a data storage method, device, computer equipment, and storage medium are provided.
  • a data storage method includes:
  • the current block includes the block generation time and the current identification value corresponding to the current block;
  • a data storage device includes:
  • the current block receiving module is used to store the data to be recorded in the current block, the current block includes the current block generation time and the current identification value corresponding to the current block;
  • the extraction module is used to query the target ending block associated with the current block, and extract the current blockchain according to the target ending block;
  • the first obtaining module is used to obtain the block connection time range corresponding to the current block chain, and query whether the current block generation time is within the block connection time range;
  • the second obtaining module is used to obtain the identification value to be queried corresponding to the target ending block contained in the current block when the current block generation time is not within the block connection time range;
  • the calculation module is used to change the identification value to be queried into the target value, and calculate the target identification value corresponding to the current block according to the pre-stored target value and the data to be recorded;
  • the modification module is used to change the current identification value to the target identification value, making the current block as the initial block, and generating and updating the blockchain according to the initial block.
  • a computer device including a memory and one or more processors, the memory stores computer readable instructions, when the computer readable instructions are executed by the processor, the one or more processors execute The following steps:
  • the current block includes the block generation time and the current identification value corresponding to the current block;
  • One or more computer-readable storage media storing computer-readable instructions.
  • the one or more processors execute the following steps:
  • the current block includes the block generation time and the current identification value corresponding to the current block;
  • Fig. 1 is an application scenario diagram of a data storage method according to one or more embodiments.
  • Fig. 2 is a schematic flowchart of a data storage method according to one or more embodiments.
  • FIG. 3 is a schematic flowchart of a block deletion step according to one or more embodiments.
  • Fig. 4 is a structural block diagram of a data storage device according to one or more embodiments.
  • Fig. 5 is an internal structure diagram of a computer device according to one or more embodiments.
  • the data storage method provided in this application can be applied to the application environment as shown in FIG. 1.
  • the blockchain system 100 includes different nodes, which may include a recording node 102, an endorsing node 104, etc.
  • the blockchain system 100 stores the data to be recorded in the current block through the recording node 102 included therein. Contains the current block generation time and the current identification value corresponding to the current block, and then obtains the block connection time corresponding to the current blockchain through the recording node 102, and compares the current block generation time with the block connection time.
  • the recording node 102 extracts the identification value to be queried corresponding to the target ending block corresponding to the current block contained in the current block, and the recording node 102 changes the identification value to be queried Is the pre-stored target value, and then the recording node 102 calculates the target identification value corresponding to the current block according to the target value and the data to be recorded, and changes the current identification value to the target identification value so that the current block is the initial block and is based on the initial Block generation updates the blockchain, where the recording node 102 and the endorsing node 104 can use independent servers, and the blockchain system 100 can be a distributed storage system that includes different nodes, and can connect blocks generated by different nodes. Form a blockchain.
  • a data storage method is provided. Taking the method applied to the recording node 102 in FIG. 1 as an example for description, the method includes the following steps:
  • S202 Store the data to be recorded in the current block, where the current block includes the block generation time and the current identification value corresponding to the current block.
  • the data to be recorded refers to data that needs to be stored in the blockchain to avoid data tampering.
  • the data to be recorded can be corresponding business data, transaction data, insurance data, or environmental data.
  • the block generation time refers to the specific time of recording the generated blocks included in the block generated by the node, that is, according to the time, different blocks can be connected in sequence to generate a blockchain.
  • the current identification value refers to the identification value calculated from the stored data and the information of the blocks that need to be connected to each other in the current block according to the corresponding encryption algorithm.
  • the current identification value is the recording node according to the hash algorithm and
  • the current hash value corresponding to the current block obtained by calculating the data to be recorded and the hash value of the block to be connected, where the block to be connected can be the ending block of different blockchains stored in the blockchain system .
  • the recording node in the blockchain system receives the block generation instruction, and executes the query according to the block generation to the current system time, and then the recording node queries the ending block in all the stored blockchains as the pending connection Block, and then the recording node can extract the generation time of the block to be connected from different blocks to be connected, and then the recording node calculates the difference according to the generation time of the block to be connected and the instruction receiving time of the block generation instruction received, and select The block to be connected with the smallest difference is regarded as the target end block, and then the recording node can first query the detailed data contained in the target end block, and calculate the end hash value of the target end block.
  • the recording node uses a hash algorithm to calculate the current identification value corresponding to the current block, and then when the recording node stores the data to be recorded in the current block and calculates the current identification value, it can also record the current system time as the block Generation time. Therefore, the recording node in the blockchain system stores the data to be recorded in the current block.
  • the current block includes the block generation time and the current identification value corresponding to the current block.
  • the record node refers to the node included in the blockchain system that can record data. It can be that the record node is the node included in the blockchain system to generate different blocks, so that the generated block is sent to the endorsement node Endorsement is performed, that is, sent to the endorsing node for verification.
  • S204 Query the target ending block associated with the current block, and extract the current blockchain according to the target ending block.
  • the target end block refers to the block with the smallest difference between the generation time and the current system time that receives the block generation instruction, which is selected from the end blocks contained in different stored blockchains.
  • the current block chain refers to the block chain that is stored in different nodes in the block chain system and queries whether the current block is connected to the end block according to the block connection time range.
  • the recording node in the blockchain system queries the selected target end block as the target end block associated with the current block according to the received block generation instruction time, and then selects the block containing the target end block
  • the chain is the current blockchain. It can be that the recording node in the blockchain system extracts the ending block from all the stored blockchains as the block to be connected, and then the recording node calculates the difference between the generation time of the block to be connected and the instruction receiving time. The block to be connected with the smallest difference is selected as the target ending block, so the recording node queries the target ending block associated with the current associated block, and the recording node uses the blockchain containing the target ending block as the current blockchain .
  • S206 Obtain the block connection time range corresponding to the current block chain, and query whether the current block generation time is within the block connection time range.
  • the block connection time range refers to the time range of the block stored in the current blockchain, that is, only when the current block generation time is within this time range, can the current block be compared with the current block chain.
  • the target ending block is connected.
  • the recording node in the blockchain system obtains the block connection time range corresponding to the current blockchain, and then the current block generation time of the current block obtained by the recording node storing the data to be recorded will query the current zone Whether the block generation time is within the block connection time range.
  • the recording node in the blockchain system obtains the initial block contained in the current blockchain, queries the initial block generation time of the initial block, and then the recording node extracts the year information according to the initial block generation time.
  • the year information obtains the block connection time range of the current blockchain, and then records whether the node queries whether the current block generation time is within the block connection time range.
  • the recording node queries the initial block contained in the current blockchain, and then extracts the initial block generation time of the initial block, and the recording node extracts the year information from the initial block generation time, then the year information is Block connection time range, that is, the year information extracted by the recording node from the initial block generation time corresponding to the initial block is 2018, and the block connection time range of the current blockchain obtained by the recording node is 2018 From January 2010 to December 2018, the record node in the blockchain system queries whether the current block generation time falls within the current blockchain block connection time range.
  • the identification value to be queried refers to the end block hash value corresponding to the end block, that is, the end block hash value generated by the recording node that records the end block according to the corresponding encryption algorithm.
  • the record node in the blockchain system queries that the current block generation time is not within the block connection time range, it queries the pending block contained in the current block and corresponds to the target ending block of the current blockchain. Query the identification value.
  • the record node in the blockchain system finds that the block generation time is not within the block connection time range, the current block needs to be used as the initial block, that is, the block needs to be stored in a new area
  • the record node in the blockchain system queries the field to be queried that is contained in the current block and corresponds to the target ending block of the current blockchain, and then the record node in the blockchain system queries the pending field.
  • the corresponding hash value in the query field is used as the identification value to be queried. For example, when the recording node in the blockchain system queries that the block generation time is not within the block connection time range, the recording node queries the current block corresponding to the target ending block of the current blockchain.
  • the query field that is, the indication that the current block is queried
  • the hash value of the target ending block can be found, such as "pre hash”
  • the blockchain system can query the corresponding hash through the field to be queried
  • the value is the identification value to be queried.
  • S210 Change the identification value to be queried to a pre-stored target value, and calculate the target identification value corresponding to the current block according to the target value and the data to be recorded.
  • the target value refers to the preset value of the hash value of the ending block contained in the current block as the initial block when the current block is the initial block, and the target value is pre-stored in different nodes The default value.
  • the target identification value refers to the hash value of the current block obtained by recalculating the hash value of the ending block in the current block. Specifically, when the record node in the blockchain system finds that the block generation time of the current block is not within the block connection time range corresponding to the current block chain, the current block does not need to be connected to the current block chain.
  • the ending blockchain that is, the current block needs to be used as the initial block
  • the record node in the blockchain system queries the identification value to be queried in the current block, and then queries the pre-stored in the record node, and
  • the target value corresponding to the initial block change the identification value to be queried to the target value, and then the recording node can directly calculate the hash value corresponding to the current block according to the encryption algorithm, according to the modified target value and the data to be recorded, as the target identification value .
  • the block generation time of the current block is January 2019, and the block connection time range is from January 2018 to December 2018, the block generation time of the current block is If the time is not within the range of the block connection, the current block is used as the initial block to generate a new block chain.
  • the block generation time of the block in the new block chain is from January 2019 to December 2019 Therefore, if the current block is used as the initial block, the hash value of the target ending block contained in the current block is changed according to the pre-stored target value. If the target value is 0, the hash value of the target ending block will be changed.
  • the hope value is changed to 0, and then the record node in the blockchain system can use a hash algorithm, such as the SHA-256 algorithm (secure hash algorithm) for calculation, to obtain the hash value of the current block as the initial block, as Target identification value.
  • a hash algorithm such as the SHA-256 algorithm (secure hash algorithm) for calculation, to obtain the hash value of the current block as the initial block, as Target identification value.
  • the hash algorithm can also use other algorithms, such as the SHA-512, SHA-224 algorithm, or MD algorithm in the secure hash algorithm.
  • S212 Change the current identification value to the target identification value, so that the current block is used as the initial block, and generate and update the blockchain according to the initial block.
  • updating the block chain refers to a new block chain whose block connection time is different from the different block chains stored in the block chain system.
  • the recording node changes the current identification value to the target identification value
  • the current block is used as the initial block, and the recording node in the blockchain system will change the current identification value contained in the current block to the target identification value.
  • the current block is used as the initial block, and according to the generation time of the initial block, the update block connection time range corresponding to the update block chain is obtained.
  • the block chain system When the block chain system generates a new block through the recording node, it can be based on The generation time of the new block is connected with the initial block to generate a new block chain.
  • not all data is generated according to the traditional block chain in a unified connection to generate a single block chain to avoid low processing efficiency when the amount of data is too large , Can improve processing efficiency, and avoid the need to upgrade hardware products in order to improve processing efficiency, and save costs.
  • the data to be recorded will involve different business data, such as environmental data, environmental data is used for environmental monitoring.
  • the single-chain method of storage causes a large amount of unused data cannot be deleted, so the applicability is not strong, and storage according to the block connection time can enhance the applicability.
  • the block deletion step is to change the current identification value to the target identification value, so that the current block is used as the initial block, and according to the initial block Block generation
  • it includes: extracting the blockchain generation time corresponding to different blockchains and obtaining the current system time; calculating the data storage duration according to the blockchain generation time and the current system time; when the data storage duration exceeds
  • the preset duration is set, the block to be deleted corresponding to the data storage duration exceeding the preset duration is queried, and the block to be deleted is deleted.
  • the block chain generation time refers to the generation time of different block chains stored in the block chain system, and the block chain generation time may be a detailed year, etc.
  • Data storage duration is the length of time that different blockchains are stored in the blockchain system.
  • Blocks to be deleted refer to different blocks included in the blockchain whose data storage time exceeds the preset time.
  • different blockchains stored in different nodes in the blockchain system correspond to the block connection time range
  • the block chain generation time represented by the block connection time range is extracted
  • the record node in the blockchain system obtains Store the block chain generation time of different block chains, and obtain the current system time, and then calculate the difference between the block chain generation time of different block chains and the current system time.
  • the difference is the data storage time
  • the record node in the blockchain system obtains the pre-stored preset duration, compares the data storage duration with the preset duration, selects the blockchain whose data storage duration exceeds the preset duration, and includes the blockchain As the block to be deleted, the block to be deleted is deleted.
  • the record node in the blockchain system obtains the block connection time range corresponding to different blockchains.
  • the block connection time range corresponding to the four blockchains is obtained.
  • the block connection time range is January 2015. To December 2015, January 2016 to December 2016, January 2017 to December 2017 and January 2018 to December 2018, and then extract each blockchain according to the time range of the block connection
  • the corresponding block chain generation time can be obtained according to the year information contained in the block connection time range.
  • the block chain generation time is 2015, 2016, 2017 and 2018, and then the district
  • the record node in the blockchain system obtains the current system time as 2019, and the record node in the blockchain system calculates the data storage duration based on the generation time of different blockchains and the current system time, that is, the data storage duration of the aforementioned blockchain Respectively 4 years, 3 years, 2 years and 1 year
  • the record node in the blockchain system obtains the preset duration, which is 3 years, and then compares the data storage duration with the preset duration.
  • the block in the blockchain is regarded as the block to be deleted, and the block to be deleted is deleted.
  • different nodes in the blockchain system may store blockchains at different times, and the preset duration may be set according to different application scenarios.
  • the recording node in the blockchain system stores different blockchains according to the corresponding storage time.
  • the recording node in the blockchain system can calculate the data storage duration according to the generation time of the blockchain and the current system time.
  • the data storage duration exceeds the preset duration
  • the query data storage duration exceeds the to-be-deleted block corresponding to the preset duration
  • the to-be-deleted block is deleted, that is, the space resource can be stored.
  • the initial block to be deleted is searched for the related block to be deleted connected to the initial block to be deleted; the initial block to be deleted and the related block to be deleted are deleted.
  • the initial block to be deleted refers to the initial block in the blockchain corresponding to the data storage duration exceeding the preset duration.
  • the associated block to be deleted refers to a different block connected to the initial block sequence in the blockchain corresponding to the data storage duration exceeding the preset duration.
  • the record node in the blockchain system queries that the data storage duration corresponding to the different blockchains for storage exceeds the preset duration, query the to-be-deleted blockchain corresponding to the data storage duration that exceeds the preset duration , And then query the initial block to be deleted contained in the blockchain to be deleted, and then query other blocks connected to the initial block to be deleted according to the initial block to be deleted, and the other connected blocks are related blocks to be deleted , And then use the initial block to be deleted and the associated block to be deleted as the block to be deleted, and delete the block to be deleted.
  • the record node in the blockchain system queries that the storage duration of the data corresponding to different blockchains in the storage exceeds the preset duration, then query the blockchain to be deleted corresponding to the data storage duration that exceeds the preset duration. Then query the field to be queried contained in the block chain to be deleted, and then query the block whose identification value to be queried corresponding to the field to be queried is the target value as the initial block to be deleted, and then query the target identification corresponding to the initial block to be queried Value, the next block is queried according to the target identification value, until the end block contained in the blockchain to be deleted is queried, then all the blocks queried sequentially according to the target identification value are regarded as the associated blocks to be deleted, and then The initial block to be deleted and the associated block to be deleted are deleted.
  • the record node in the blockchain system queries that the storage duration of data corresponding to different blockchains exceeds the preset duration, it will query the blockchain to be deleted corresponding to the data storage duration that exceeds the preset duration, then Query the query field of the previous block contained in each block in the blockchain to be deleted, and then query the field to be queried, such as "pre hash", and then query the hash value corresponding to the field to be queried.
  • the record node in the blockchain system queries the hash value of the current block corresponding to the initial block to be deleted, and then queries Other blocks in the block chain to be deleted contain the hash value of the current block as the next block, until the end block of the block chain to be deleted is queried, and the hash value corresponding to the initial block to be deleted
  • the related block found by the value query is regarded as the related block to be deleted, and both the initial block to be deleted and the related block to be deleted are deleted.
  • the recording node in the blockchain system can delete the blockchain whose data storage duration exceeds the preset duration, avoiding the need to expand storage resources and thus the need to continuously upgrade hardware products and reduce costs.
  • the first generation time refers to the generation time of the block included in the associated block to be deleted.
  • the second generation time refers to the generation time of the block included in the initial block to be deleted.
  • the record node in the blockchain system queries the to-be-deleted associated block, it obtains the to-be-deleted association
  • the first generation time included in the block, and then the second generation time included in the initial block to be deleted is obtained, and the difference between the first generation time and the second generation time is calculated, and when the difference is obtained, the difference is queried Whether it is within the preset difference range, when it is within the preset difference range, the associated block to be deleted can be used as the block to be deleted together with the initial block to be deleted, when the difference is not within the preset difference range
  • the time the corresponding check information is output, and you can check whether the wrong block is found.
  • the preset time range can be within 1 year, then the first generation time contained in the associated block to be deleted is obtained, and the second generation time contained in the initial block to be deleted is obtained, then the first generation time and the first generation time are calculated. 2. Generate the difference in time and query whether the difference is within the preset time range. When it is within the preset time range, the associated block to be deleted can be deleted as the block to be deleted together with the initial block to be deleted , When it is not within the preset time range, the corresponding verification information is output. The verification information can output the block identification value of the related block to be deleted within the preset time range, etc., query whether the wrong block is queried, etc. .
  • the record node in the blockchain system queries the initial block to be deleted and the associated block to be deleted, it obtains the first generation time corresponding to the associated block to be deleted, and obtains the location of the initial block to be deleted.
  • the second generation time is calculated according to the first generation time and the current system time to obtain the storage duration of the associated block, query whether the storage duration of the associated block exceeds the preset time, and then calculate the initial area based on the second generation time and the current system time Block storage duration, and query whether the initial block storage duration exceeds the preset duration, and then when the associated block storage duration and the initial block storage duration exceed the preset duration, then calculate the first generation time and the second generation time
  • the verification information is directly output, such as the corresponding block identification.
  • the recording node in the blockchain system selects the initial block to be deleted and the associated block to be deleted, further verification can be performed to ensure the accuracy of the blockchain deletion.
  • obtaining the block connection time range corresponding to the current blockchain, and querying whether the block generation time is after the current block connection time range includes: when the current block generation time is within the block connection time When it is within the range, the target end block in the current blockchain corresponding to the current block connection time range is obtained; the current block is connected with the target end block.
  • connecting the current block with the target ending block includes: sending the current block to the endorsing node for verification; receiving the verification result of the endorsing node verifying the current block; when the verification result is verification When passed, the current block is connected with the target ending block.
  • obtaining the block connection time range corresponding to the current blockchain and querying whether the current block generation time is within the block connection time range includes: when the current block generation time is within the block connection time When it is within the range, the target ending block in the current blockchain corresponding to the current block connection time range is obtained: the current block is sent to the endorsing node through the recording node for verification; the endorsing node is received by the recording node to perform the current block The verification result of the verification; when the verification result is passed, the current block is connected with the target ending block.
  • the endorsing node refers to the node server included in the blockchain system that can verify and sign the generated block.
  • the block can be combined with The ending block in the block chain to be connected is connected, that is, the current block enters the chain.
  • the current block can be directly connected to the current blockchain.
  • the recording node in the blockchain system obtains the target ending block in the current blockchain.
  • the recording node generates the current block according to the data to be recorded and the identification to be queried.
  • the current block contains the current identification value, and the current block Generation time and data to be recorded, etc., query the current block generation time within the block connection time range, the recording node will send the generated current block to the endorsing node, and when the endorsing node receives the current block, it will get it through the endorsing node Go to the identity of the recording node and query whether the identity is a trusted identity, that is, the identity can be matched with a pre-stored trusted identity.
  • the identity of the recording node is acceptable
  • the verification logic of the data to be recorded is obtained through the endorsement node, such as whether the query data contains false data, etc.
  • the data to be recorded is verified by the verification logic to be recorded, and then the verification logic of the recording node
  • the data verification generates the verification result, that is, when the identification of the recording node and the data to be recorded are verified, the verification result is passed.
  • the recording node connects the current block with the target ending block, and That is, the target ending block points to the current block, and the current block is used as the ending block in the current blockchain.
  • the current block when the block generation time is within the block connection time range, the current block can be connected to the ending block, and the current block needs to be verified by the endorsement node before the connection, so as to ensure the generation The accuracy and security of the block.
  • the following takes the storage of environmental protection data as an example.
  • different node servers may be included, such as the server corresponding to the recording node, and the server corresponding to the recording node may be different
  • the server of the environmental protection agency, the server corresponding to the enterprise that monitors environmental data can also be regarded as the environmental protection agency record node and the enterprise record node.
  • the corresponding data can be the environmental data of the monitored enterprise.
  • the blockchain system can also Contains the server corresponding to the endorsement node to endorse the environmental data of the monitored enterprise.
  • the enterprise record node records and detects the corresponding environmental data as an example for further explanation.
  • the enterprise record node generates the current block according to the environmental data.
  • the current block can contain the block generation time and the end block that needs to be connected.
  • the hash value and the hash value of the current block, and the enterprise record node included in the blockchain system can query the block connection time range corresponding to the current block chain.
  • the block connection time range is from January 2018 to In December 2018, that is, when the current block generation time is within this time range, the connection is made.
  • the enterprise record node queries that the current block generation time is January 1, 2019, and the block generation time is not in the zone.
  • the current block needs to be stored in the new blockchain, so the hash value of the ending block in the current block is modified to 0, so that the hash value of the current block is recalculated.
  • the current block is used as the initial block to generate an update block chain, and the block connection time range corresponding to the update block chain is from January 2019 to December 2019.
  • the enterprise record node can query the blockchains that store different environmental protection times, that is, query different blockchain generation times.
  • the blockchain generation time can be based on the block connection time range
  • the year of the data storage is determined, and the data storage duration is calculated according to the current system time and the generation time of the blockchain, and then the entire blockchain whose data storage duration exceeds the preset duration is deleted, such as the entire blockchain whose data storage duration exceeds 3 years
  • To delete that is, due to the real-time nature of environmental protection data, the reference value of environmental protection data over 3 years is low.
  • you can first query the corresponding initial block to be deleted.
  • the related block to be deleted query the related block to be deleted, and verify whether the generation time difference between the related block to be deleted and the initial block to be deleted is within the preset time range, for example, whether it is within the year corresponding to the block chain generation time.
  • the associated block to be deleted and the initial block to be deleted are deleted as the block to be deleted.
  • the block generation time of the current block queried by the enterprise record node is March 2018, then the block generation time is within the block connection time range, and the block can be directly connected to the block time
  • the target ending block in the blockchain ranging from January 2018 to December 2018 is connected, and before the connection, the enterprise record node can verify the current block through the endorsement node, such as verifying whether the environmental protection data contained therein There is fraud, such as environmental protection data with repeated date data, etc., to verify whether the identity of the recording node is a credible and true identity.
  • the current block can be connected to the end block.
  • the data in this embodiment may also be business data of other services to be processed.
  • a data storage device including: a current block receiving module 410, a first obtaining module 420, a second obtaining module 430, a calculation module 440, and a modification module 450, among them:
  • the current block receiving module 410 is configured to store the data to be recorded in the current block.
  • the current block includes the generation time of the current block and the current identification value corresponding to the current block.
  • the extraction module 420 is used for querying the target ending block associated with the current block, and extracting the current blockchain according to the target ending block.
  • the first obtaining module 430 is configured to obtain the block connection time range corresponding to the current block chain, and query whether the current block generation time is within the block connection time range.
  • the second obtaining module 440 is configured to obtain the identification value to be queried corresponding to the target ending block contained in the current block when the current block generation time is not within the block connection time range.
  • the calculation module 450 is configured to change the identification value to be queried into a pre-stored target value, and calculate the target identification value corresponding to the current block according to the target value and the data to be recorded.
  • the modification module 460 is used to change the current identification value to the target identification value, so that the current block is used as the initial block, and the block chain is generated and updated according to the initial block.
  • the data storage device 400 may further include:
  • the extraction module is used to extract the block chain generation time corresponding to different block chains and obtain the current system time.
  • the duration calculation module is used to calculate the data storage duration according to the generation time of the blockchain and the current system time.
  • the delete module is used to query the block to be deleted corresponding to the data storage duration exceeding the preset time when the data storage duration exceeds the preset duration, and delete the block to be deleted.
  • deleting the module includes:
  • the query unit is used to query the initial block to be deleted corresponding to the data storage duration exceeding the preset time length, and query the associated block to be deleted connected to the initial block to be deleted.
  • the deleting unit is used to delete the initial block to be deleted and the associated block to be deleted.
  • the deletion unit may include:
  • the time obtaining subunit is used to obtain the first generation time contained in the associated block to be deleted, and obtain the second generation time contained in the initial block to be deleted.
  • the judging subunit is used to judge whether the difference between the first generation time and the second generation time is within a preset difference range.
  • the output subunit is used to output the verification information when the difference is not within the preset difference range.
  • the data storage device 400 may further include:
  • the end block obtaining module is used to obtain the target end block in the current blockchain corresponding to the current block connection time range when the current block generation time is within the block connection time range.
  • the connection module is used to connect the current block with the target ending block.
  • connection module may include:
  • the verification result receiving unit is used to send the current block to the endorsement node for verification. It is also used to receive the verification result that the endorsing node verifies the current block.
  • the connecting unit is used to connect the current block with the target ending block when the verification result is passed.
  • Each module in the above-mentioned data storage device can be implemented in whole or in part by software, hardware, and a combination thereof.
  • the foregoing modules may be embedded in the form of hardware or independent of the processor in the computer device, or may be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the foregoing modules.
  • a computer device is provided.
  • the computer device may be a server, and its internal structure diagram may be as shown in FIG. 5.
  • the computer equipment includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide calculation and control capabilities.
  • the memory of the computer device includes a non-volatile or volatile storage medium and internal memory.
  • the non-volatile or volatile storage medium stores an operating system, computer readable instructions, and a database.
  • the internal memory provides an environment for the operation of the operating system and computer-readable instructions in the non-volatile storage medium.
  • the computer equipment database is used to store data.
  • the network interface of the computer equipment is used to communicate with external terminals through a network connection.
  • the computer-readable instructions are executed by the processor to realize a data storage method.
  • FIG. 5 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied.
  • the specific computer device may Including more or fewer parts than shown in the figure, or combining some parts, or having a different arrangement of parts.
  • a computer device including a memory and one or more processors, and computer-readable instructions are stored in the memory.
  • the one or more processors perform the following steps: store data to be recorded To the current block, the current block contains the generation time of the current block and the current identification value corresponding to the current block.
  • Query the target ending block associated with the current block and extract the current blockchain based on the target ending block.
  • Get the block connection time range corresponding to the current blockchain and query whether the current block generation time is within the block connection time range.
  • the identification value to be queried corresponding to the target ending block contained in the current block is obtained.
  • the identification value to be queried is changed to the target value, and the target identification value corresponding to the current block is calculated according to the target value and the data to be recorded. And change the current identification value to the target identification value, make the current block as the initial block, and generate and update the blockchain based on the initial block.
  • the processor when the processor executes the computer-readable instruction, the current identification value is changed to the target identification value, so that the current block is used as the initial block, and after the block chain is generated and updated according to the initial block, it includes: extracting Blockchain generation time corresponding to different blockchains, and get the current system time. Calculate the data storage duration based on the generation time of the blockchain and the current system time. When the data storage duration exceeds the preset duration, the block to be deleted corresponding to the data storage duration exceeding the preset duration is queried, and the block to be deleted is deleted.
  • the processor when the processor executes the computer-readable instructions, the processor can query the block to be deleted corresponding to the data storage duration that exceeds the preset duration, and delete the block to be deleted, including: querying the data that exceeds the preset duration
  • the initial block to be deleted corresponding to the storage duration is stored, and the associated block to be deleted connected to the initial block to be deleted is queried. And delete the initial block to be deleted and the associated block to be deleted.
  • the method includes: obtaining the first generation time contained in the associated block to be deleted, and obtaining The second generation time contained in the initial block to be deleted. It is determined whether the difference between the first generation time and the second generation time is within a preset difference range. And when the difference is not within the preset difference range, the verification information is output.
  • the processor when the processor executes the computer-readable instructions, it obtains the block connection time range corresponding to the current blockchain, and queries whether the current block generation time is after the block connection time range, including: When the block generation time is within the block connection time range, the target ending block in the current blockchain corresponding to the current block connection time range is obtained. And connect the current block with the target ending block.
  • the connection between the current block and the target ending block includes: sending the current block to the endorsing node for verification. Receive the verification result of the endorsement node verifying the current block. And when the verification result is that the verification is passed, the current block is connected with the target ending block.
  • One or more computer-readable storage media storing computer-readable instructions.
  • the one or more processors execute the following steps: store the data to be recorded in the current area Block, the current block contains the current block generation time and the current identification value corresponding to the current block.
  • Query the target ending block associated with the current block and extract the current blockchain based on the target ending block.
  • Get the block connection time range corresponding to the current blockchain and query whether the current block generation time is within the block connection time range.
  • the identification value to be queried corresponding to the target ending block contained in the current block is obtained.
  • the identification value to be queried is changed to a pre-stored target value, and the target identification value corresponding to the current block is calculated according to the target value and the data to be recorded. And change the current identification value to the target identification value, make the current block as the initial block, and generate and update the blockchain based on the initial block.
  • the current identification value when executed by the processor, the current identification value is changed to the target identification value, so that the current block is used as the initial block, and after the block chain is generated and updated according to the initial block, it includes: Extract the block chain generation time corresponding to different block chains, and get the current system time. Calculate the data storage duration based on the generation time of the blockchain and the current system time. And when the data storage duration exceeds the preset duration, the block to be deleted corresponding to the data storage duration exceeding the preset duration is queried, and the block to be deleted is deleted.
  • the query block to be deleted corresponding to the data storage duration exceeding the preset duration is realized, and the block to be deleted is deleted, including: querying the block to be deleted that exceeds the preset duration
  • the initial block to be deleted corresponding to the data storage time, and the related block to be deleted connected to the initial block to be deleted is queried. And delete the initial block to be deleted and the associated block to be deleted.
  • the method includes: obtaining the first generation time included in the associated block to be deleted, and Obtain the second generation time contained in the initial block to be deleted. It is determined whether the difference between the first generation time and the second generation time is within a preset difference range. And when the difference is not within the preset difference range, the verification information is output.
  • the block connection time range corresponding to the current blockchain is obtained, and the query whether the current block generation time is within the block connection time range, including: When the current block generation time is within the block connection time range, the target end block in the current blockchain corresponding to the current block connection time range is obtained. And connect the current block with the target ending block.
  • the connection between the current block and the end block is realized, including: sending the current block to the endorsing node for verification. Receive the verification result of the endorsement node verifying the current block. And when the verification result is that the verification is passed, the current block is connected with the target ending block.
  • Non-volatile memory may include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
  • Volatile memory may include random access memory (RAM) or external cache memory.
  • RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous chain Channel (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
  • SRAM static RAM
  • DRAM dynamic RAM
  • SDRAM synchronous DRAM
  • DDRSDRAM double data rate SDRAM
  • ESDRAM enhanced SDRAM
  • SLDRAM synchronous chain Channel
  • memory bus Radbus direct RAM
  • RDRAM direct memory bus dynamic RAM
  • RDRAM memory bus dynamic RAM

Abstract

A data storage method, relating to the field of block chain technology. Said method comprises: storing into a current block data to be recorded, the current block containing a current block generation time and a current identification value corresponding to the current block; querying a target end block associated with the current block, and extracting a current block chain according to the target end block; acquiring a block connection time range corresponding to the current block chain, and querying whether the current block generation time is within the block connection time range; when the current block generation time is not within the block connection time range, acquiring an identification value to be queried corresponding to the target end block, contained in the current block; changing the identification value to be queried into a pre-stored target value, and calculating, according to the target value and the data to be recorded, a target identification value corresponding to the current block; and changing the current identification value to the target identification value, so that the current block serves as an initial block, and generating an update block chain according to the initial block.

Description

数据存储方法、装置、计算机设备和存储介质Data storage method, device, computer equipment and storage medium
相关申请的交叉引用Cross references to related applications
本申请要求于2019年07月25日提交中国专利局,申请号为2019106775779,申请名称为“数据存储方法、装置、计算机设备和存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office on July 25, 2019, the application number is 2019106775779, and the application name is "Data storage methods, devices, computer equipment and storage media", the entire contents of which are incorporated by reference In this application.
技术领域Technical field
本申请涉及计算机技术领域,特别是涉及一种数据存储方法、装置、计算机设备和存储介质。This application relates to the field of computer technology, in particular to a data storage method, device, computer equipment and storage medium.
背景技术Background technique
随着计算机技术的发展,越来越多的业务可以通过计算机进行办理,而为了保证相应的业务数据的透明以及无法篡改,越来越多的业务数据是通过区块链进行存储与交互。With the development of computer technology, more and more businesses can be handled through computers, and in order to ensure the transparency of the corresponding business data and the inability to tamper with, more and more business data is stored and interacted through the blockchain.
然而发明人意识到,传统地,将所有数据按照传统区块链存储的方式进行顺序存储,由于涉及到的数据量大,则顺序存储对不同的节点服务器的处理速度要求高,因此,为了保证存储效率,则需要持续升级节点服务器,数据存储成本高。However, the inventor realizes that traditionally, all data is stored sequentially according to the traditional blockchain storage method. Due to the large amount of data involved, the sequential storage requires high processing speed for different node servers. Therefore, in order to ensure Storage efficiency requires continuous upgrade of node servers, and data storage costs are high.
发明内容Summary of the invention
根据本申请公开的各种实施例,提供一种数据存储方法、装置、计算机设备和存储介质。According to various embodiments disclosed in the present application, a data storage method, device, computer equipment, and storage medium are provided.
一种数据存储方法包括:A data storage method includes:
将待记录数据存储至当前区块,当前区块包含区块生成时间以及当前区块对应的当前标识值;Store the data to be recorded in the current block, the current block includes the block generation time and the current identification value corresponding to the current block;
查询与当前区块关联的目标结尾区块,根据所述目标结尾区块提取当前区块链;Query the target ending block associated with the current block, and extract the current blockchain according to the target ending block;
获取当前区块链对应的区块连接时间范围,并查询当前区块生成时间是否在区块连接时间范围内;Get the block connection time range corresponding to the current blockchain, and query whether the current block generation time is within the block connection time range;
当当前区块生成时间未在区块连接时间范围中时,则获取当前区块中包含的与目标结尾区块所对应的待查询标识值;When the current block generation time is not within the block connection time range, obtain the identification value to be queried corresponding to the target ending block contained in the current block;
将待查询标识值更改为预存储的目标值,根据目标值以及待记录数据计算当前区块对应的目标标识值;及Change the identification value to be queried to a pre-stored target value, and calculate the target identification value corresponding to the current block according to the target value and the data to be recorded; and
将当前标识值更改为目标标识值,使得当前区块作为初始区块,并根据初始区块生成更新区块链。Change the current identification value to the target identification value, make the current block as the initial block, and generate and update the blockchain based on the initial block.
一种数据存储装置包括:A data storage device includes:
当前区块接收模块,用于将待记录数据存储至当前区块,当前区块包含当前区块生成时 间以及当前区块对应的当前标识值;The current block receiving module is used to store the data to be recorded in the current block, the current block includes the current block generation time and the current identification value corresponding to the current block;
提取模块,用于查询与当前区块关联的目标结尾区块,根据目标结尾区块提取当前区块链;The extraction module is used to query the target ending block associated with the current block, and extract the current blockchain according to the target ending block;
第一获取模块,用于获取当前区块链对应的区块连接时间范围,并查询当前区块生成时间是否在区块连接时间范围内;The first obtaining module is used to obtain the block connection time range corresponding to the current block chain, and query whether the current block generation time is within the block connection time range;
第二获取模块,用于当当前区块生成时间未在区块连接时间范围中时,则获取当前区块中包含的与目标结尾区块所对应的待查询标识值;The second obtaining module is used to obtain the identification value to be queried corresponding to the target ending block contained in the current block when the current block generation time is not within the block connection time range;
计算模块,用于将待查询标识值更改为目标值,根据预存储的目标值以及待记录数据计算当前区块对应的目标标识值;及The calculation module is used to change the identification value to be queried into the target value, and calculate the target identification value corresponding to the current block according to the pre-stored target value and the data to be recorded; and
更改模块,用于将当前标识值更改为目标标识值,使得当前区块作为初始区块,并根据初始区块生成更新区块链。The modification module is used to change the current identification value to the target identification value, making the current block as the initial block, and generating and updating the blockchain according to the initial block.
一种计算机设备,包括存储器和一个或多个处理器,所述存储器中储存有计算机可读指令,所述计算机可读指令被所述处理器执行时,使得所述一个或多个处理器执行以下步骤:A computer device, including a memory and one or more processors, the memory stores computer readable instructions, when the computer readable instructions are executed by the processor, the one or more processors execute The following steps:
将待记录数据存储至当前区块,当前区块包含区块生成时间以及当前区块对应的当前标识值;Store the data to be recorded in the current block, the current block includes the block generation time and the current identification value corresponding to the current block;
查询与当前区块关联的目标结尾区块,根据目标结尾区块提取当前区块链;Query the target ending block associated with the current block, and extract the current blockchain based on the target ending block;
获取当前区块链对应的区块连接时间范围,并查询当前区块生成时间是否在区块连接时间范围内;Get the block connection time range corresponding to the current blockchain, and query whether the current block generation time is within the block connection time range;
当当前区块生成时间未在区块连接时间范围中时,则获取当前区块中包含的与目标结尾区块所对应的待查询标识值;When the current block generation time is not within the block connection time range, obtain the identification value to be queried corresponding to the target ending block contained in the current block;
将待查询标识值更改为预存储的目标值,根据目标值以及待记录数据计算当前区块对应的目标标识值;及Change the identification value to be queried to a pre-stored target value, and calculate the target identification value corresponding to the current block according to the target value and the data to be recorded; and
将当前标识值更改为目标标识值,使得当前区块作为初始区块,并根据初始区块生成更新区块链。Change the current identification value to the target identification value, make the current block as the initial block, and generate and update the blockchain based on the initial block.
一个或多个存储有计算机可读指令的计算机可读存储介质,计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行以下步骤:One or more computer-readable storage media storing computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the following steps:
将待记录数据存储至当前区块,当前区块包含区块生成时间以及当前区块对应的当前标识值;Store the data to be recorded in the current block, the current block includes the block generation time and the current identification value corresponding to the current block;
查询与当前区块关联的目标结尾区块,根据目标结尾区块提取当前区块链;Query the target ending block associated with the current block, and extract the current blockchain based on the target ending block;
获取当前区块链对应的区块连接时间范围,并查询当前区块生成时间是否在区块连接时间范围内;Get the block connection time range corresponding to the current blockchain, and query whether the current block generation time is within the block connection time range;
当当前区块生成时间未在区块连接时间范围中时,则获取当前区块中包含的与目标结尾区块所对应的待查询标识值;When the current block generation time is not within the block connection time range, obtain the identification value to be queried corresponding to the target ending block contained in the current block;
将待查询标识值更改为预存储的目标值,根据目标值以及待记录数据计算当前区块对应的目标标识值;及Change the identification value to be queried to a pre-stored target value, and calculate the target identification value corresponding to the current block according to the target value and the data to be recorded; and
将当前标识值更改为目标标识值,使得当前区块作为初始区块,并根据初始区块生成更 新区块链。Change the current identification value to the target identification value, make the current block as the initial block, and generate an updated blockchain based on the initial block.
上述数据存储方法、装置、计算机设备和存储介质,并非是单链存储,无需对硬件持续升级,降低成本。The above-mentioned data storage methods, devices, computer equipment and storage media are not single-chain storage, and there is no need to continuously upgrade the hardware to reduce costs.
本申请的一个或多个实施例的细节在下面的附图和描述中提出。本申请的其它特征和优点将从说明书、附图以及权利要求书变得明显。The details of one or more embodiments of the application are set forth in the following drawings and description. Other features and advantages of this application will become apparent from the description, drawings and claims.
附图说明Description of the drawings
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其它的附图。In order to more clearly describe the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings needed in the embodiments. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work.
图1为根据一个或多个实施例中数据存储方法的应用场景图。Fig. 1 is an application scenario diagram of a data storage method according to one or more embodiments.
图2为根据一个或多个实施例中数据存储方法的流程示意图。Fig. 2 is a schematic flowchart of a data storage method according to one or more embodiments.
图3为根据一个或多个实施例中区块删除步骤的流程示意图。FIG. 3 is a schematic flowchart of a block deletion step according to one or more embodiments.
图4为根据一个或多个实施例中数据存储装置的结构框图。Fig. 4 is a structural block diagram of a data storage device according to one or more embodiments.
图5为根据一个或多个实施例中计算机设备的内部结构图。Fig. 5 is an internal structure diagram of a computer device according to one or more embodiments.
具体实施方式Detailed ways
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。In order to make the purpose, technical solutions, and advantages of this application clearer, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the application, and not used to limit the application.
本申请提供的数据存储方法,可以应用于如图1所示的应用环境中。区块链系统100中包含有不同的节点,可以包含有记录节点102,以及背书节点104等,区块链系统100通过包含其中的记录节点102将待记录数据存储至当前区块,当前区块包含有当前区块生成时间以及当前区块对应的当前标识值,进而通过记录节点102获取当前区块链对应的区块连接时间,并比较当前区块生成时间与区块连接时间,当当前区块生成时间超过区块连接时间时,则记录节点102提取当前区块中包含的,与当前区块的对应的目标结尾区块所对应的待查询标识值,记录节点102将待查询标识值更改为预存储的目标值,进而记录节点102根据目标值以及待记录数据计算当前区块对应的目标标识值,将当前标识值更改为目标标识值,使得当前区块作为初始区块,并根据初始区块生成更新区块链,其中,记录节点102与背书节点104可以使用独立服务器,且区块链系统100可以是包含有不同的节点的分布式存储系统,可以连接不同节点生成的区块,形成区块链。The data storage method provided in this application can be applied to the application environment as shown in FIG. 1. The blockchain system 100 includes different nodes, which may include a recording node 102, an endorsing node 104, etc. The blockchain system 100 stores the data to be recorded in the current block through the recording node 102 included therein. Contains the current block generation time and the current identification value corresponding to the current block, and then obtains the block connection time corresponding to the current blockchain through the recording node 102, and compares the current block generation time with the block connection time. When the current zone When the block generation time exceeds the block connection time, the recording node 102 extracts the identification value to be queried corresponding to the target ending block corresponding to the current block contained in the current block, and the recording node 102 changes the identification value to be queried Is the pre-stored target value, and then the recording node 102 calculates the target identification value corresponding to the current block according to the target value and the data to be recorded, and changes the current identification value to the target identification value so that the current block is the initial block and is based on the initial Block generation updates the blockchain, where the recording node 102 and the endorsing node 104 can use independent servers, and the blockchain system 100 can be a distributed storage system that includes different nodes, and can connect blocks generated by different nodes. Form a blockchain.
在其中一个实施例中,如图2所示,提供了一种数据存储方法,以该方法应用于图1中的记录节点102为例进行说明,包括以下步骤:In one of the embodiments, as shown in FIG. 2, a data storage method is provided. Taking the method applied to the recording node 102 in FIG. 1 as an example for description, the method includes the following steps:
S202:将待记录数据存储至当前区块,当前区块包含区块生成时间以及当前区块对应的当前标识值。S202: Store the data to be recorded in the current block, where the current block includes the block generation time and the current identification value corresponding to the current block.
具体地,待记录数据是指需要存储在区块链中的数据,从而避免数据被篡改,待记录数 据可以是相应业务数据,可以是交易数据、保险数据或者环境数据等。区块生成时间是指记录节点生成区块中包含的生成的区块的具体时间,也即根据该时间可以顺序连接不同的区块从而生成区块链。当前标识值是指当前区块中根据相应加密算法,对存储的数据以及所需相互连接的区块的信息所计算得到的标识值,可以是,当前标识值是记录节点根据哈希算法,按照待记录数据以及待连接区块的哈希值进行计算得到的当前区块对应的当前哈希值,其中,待连接区块可以是存储在区块链系统中不同的区块链的结尾区块。Specifically, the data to be recorded refers to data that needs to be stored in the blockchain to avoid data tampering. The data to be recorded can be corresponding business data, transaction data, insurance data, or environmental data. The block generation time refers to the specific time of recording the generated blocks included in the block generated by the node, that is, according to the time, different blocks can be connected in sequence to generate a blockchain. The current identification value refers to the identification value calculated from the stored data and the information of the blocks that need to be connected to each other in the current block according to the corresponding encryption algorithm. It may be that the current identification value is the recording node according to the hash algorithm and The current hash value corresponding to the current block obtained by calculating the data to be recorded and the hash value of the block to be connected, where the block to be connected can be the ending block of different blockchains stored in the blockchain system .
具体地,区块链系统中的记录节点接收到区块生成指令,则根据区块生成执行查询到当前系统时间,进而记录节点查询到已存储的所有区块链中的结尾区块作为待连接区块,进而记录节点可以从不同的待连接区块中提取到待连接区块生成时间,进而记录节点根据待连接区块生成时间与接收到区块生成指令的指令接收时间计算差值,选取差值最小的待连接区块作为目标结尾区块,进而记录节点可以先查询目标结尾区块中包含的详细数据,计算得到目标结尾区块的结尾哈希值,根据该结尾哈希值以及待记录数据,记录节点采用哈希算法计算当前区块对应的当前标识值,进而当记录节点将待记录数据存储至当前区块并计算得到当前标识值时,可以同时记录当前的系统时间作为区块生成时间,因此,区块链系统中的记录节点将待记录数据存储至当前区块,当前区块包含区块生成时间以及当前区块对应的当前标识值。其中,记录节点是指包含在区块链系统中可以进行数据记录的节点,可以是,记录节点是包含在区块链系统中生成不同区块的节点,从而将生成的区块发送至背书节点进行背书,也即发送至背书节点进行验证。Specifically, the recording node in the blockchain system receives the block generation instruction, and executes the query according to the block generation to the current system time, and then the recording node queries the ending block in all the stored blockchains as the pending connection Block, and then the recording node can extract the generation time of the block to be connected from different blocks to be connected, and then the recording node calculates the difference according to the generation time of the block to be connected and the instruction receiving time of the block generation instruction received, and select The block to be connected with the smallest difference is regarded as the target end block, and then the recording node can first query the detailed data contained in the target end block, and calculate the end hash value of the target end block. According to the end hash value and the waiting block To record data, the recording node uses a hash algorithm to calculate the current identification value corresponding to the current block, and then when the recording node stores the data to be recorded in the current block and calculates the current identification value, it can also record the current system time as the block Generation time. Therefore, the recording node in the blockchain system stores the data to be recorded in the current block. The current block includes the block generation time and the current identification value corresponding to the current block. Among them, the record node refers to the node included in the blockchain system that can record data. It can be that the record node is the node included in the blockchain system to generate different blocks, so that the generated block is sent to the endorsement node Endorsement is performed, that is, sent to the endorsing node for verification.
S204:查询与当前区块关联的目标结尾区块,根据所述目标结尾区块提取当前区块链。S204: Query the target ending block associated with the current block, and extract the current blockchain according to the target ending block.
具体地,目标结尾区块是指从存储的不同区块链中包含的结尾区块进行选取得到的、生成时间与接收到区块生成指令的当前系统时间差值最小的区块。当前区块链是指区块链系统中存储在不同节点中的,且根据区块连接时间范围查询当前区块是否与结尾区块进行相连的区块链。Specifically, the target end block refers to the block with the smallest difference between the generation time and the current system time that receives the block generation instruction, which is selected from the end blocks contained in different stored blockchains. The current block chain refers to the block chain that is stored in different nodes in the block chain system and queries whether the current block is connected to the end block according to the block connection time range.
具体地,区块链系统中的记录节点根据接收区块生成指令时间,查询到选取的目标结尾区块作为与当前区块关联的目标结尾区块,进而将包含有目标结尾区块的区块链作为当前区块链。可以是,区块链系统中的记录节点从存储的所有区块链中提取到结尾区块作为待连接区块,进而记录节点根据不同的待连接区块生成时间与指令接收时间计算差值,选取差值最小的待连接区块作为目标结尾区块,因此记录节点查询到与当前关联区块关联的目标结尾区块,进而记录节点将包含目标结尾区块的区块链作为当前区块链。Specifically, the recording node in the blockchain system queries the selected target end block as the target end block associated with the current block according to the received block generation instruction time, and then selects the block containing the target end block The chain is the current blockchain. It can be that the recording node in the blockchain system extracts the ending block from all the stored blockchains as the block to be connected, and then the recording node calculates the difference between the generation time of the block to be connected and the instruction receiving time. The block to be connected with the smallest difference is selected as the target ending block, so the recording node queries the target ending block associated with the current associated block, and the recording node uses the blockchain containing the target ending block as the current blockchain .
S206:获取当前区块链对应的区块连接时间范围,并查询当前区块生成时间是否在区块连接时间范围内。S206: Obtain the block connection time range corresponding to the current block chain, and query whether the current block generation time is within the block connection time range.
具体地,区块连接时间范围是指当前区块链存储的区块的时间范围,也即只有当当前区块生成时间在该时间范围时,才可以将当前区块与当前区块链中的目标结尾区块进行连接。具体地,区块链系统中的记录节点获取到当前区块链对应的区块连接时间范围,进而将通过记录节点存储待记录数据得到的当前区块的当前区块生成时间,将查询当前区块生成时间是否在区块连接时间范围内。Specifically, the block connection time range refers to the time range of the block stored in the current blockchain, that is, only when the current block generation time is within this time range, can the current block be compared with the current block chain. The target ending block is connected. Specifically, the recording node in the blockchain system obtains the block connection time range corresponding to the current blockchain, and then the current block generation time of the current block obtained by the recording node storing the data to be recorded will query the current zone Whether the block generation time is within the block connection time range.
可以是,区块链系统中的记录节点获取到当前区块链中包含的初始区块,查询初始区块的初始区块生成时间,进而记录节点根据初始区块生成时间提取得到年份信息,根据年份信息得到当前区块链的区块连接时间范围,进而记录节点查询当前区块生成时间是否在区块连接时间范围内。例如,记录节点查询到当前区块链中包含的初始区块,进而提取到初始区块的初始区块生成时间,记录节点从初始区块生成时间中提取到年份信息,则该年份信息即为区块连接时间范围,也即可以是记录节点从初始区块对应的初始区块生成时间提取到的年份信息为2018年,则记录节点获取到的当前区块链的区块连接时间范围为2018年1月至2018年12月,进而区块链系统中的记录节点查询当前区块生成时间是否落在当前区块链的区块连接时间范围内。It can be that the recording node in the blockchain system obtains the initial block contained in the current blockchain, queries the initial block generation time of the initial block, and then the recording node extracts the year information according to the initial block generation time. The year information obtains the block connection time range of the current blockchain, and then records whether the node queries whether the current block generation time is within the block connection time range. For example, the recording node queries the initial block contained in the current blockchain, and then extracts the initial block generation time of the initial block, and the recording node extracts the year information from the initial block generation time, then the year information is Block connection time range, that is, the year information extracted by the recording node from the initial block generation time corresponding to the initial block is 2018, and the block connection time range of the current blockchain obtained by the recording node is 2018 From January 2010 to December 2018, the record node in the blockchain system queries whether the current block generation time falls within the current blockchain block connection time range.
S208:当当前区块生成时间未在区块连接时间范围中时,则提取当前区块中包含的与目标结尾区块所对应的待查询标识值。S208: When the current block generation time is not within the block connection time range, extract the identification value to be queried corresponding to the target ending block contained in the current block.
具体地,待查询标识值是指结尾区块所对应的结尾区块哈希值,也即是通过记录结尾区块的记录节点根据相应的加密算法生成的结尾区块哈希值。具体地,区块链系统中的记录节点查询当前区块生成时间未在区块连接时间范围中时,则查询当前区块中包含的,与当前区块链的目标结尾区块所对应的待查询标识值。Specifically, the identification value to be queried refers to the end block hash value corresponding to the end block, that is, the end block hash value generated by the recording node that records the end block according to the corresponding encryption algorithm. Specifically, when the record node in the blockchain system queries that the current block generation time is not within the block connection time range, it queries the pending block contained in the current block and corresponds to the target ending block of the current blockchain. Query the identification value.
可以是,当在区块链系统中的记录节点查询到区块生成时间未在区块连接时间范围中时,则当前区块需要作为初始区块,也即该区块需要存储在新的区块链中,区块链系统中的记录节点则查询到包含在当前区块中的、与当前区块链的目标结尾区块对应的待查询字段,进而区块链系统中的记录节点查询待查询字段中对应的哈希值作为待查询标识值。例如,当区块链系统中的记录节点查询到区块生成时间未在区块连接时间范围中时,则记录节点查询当前区块中的、与当前区块链的目标结尾区块对应的待查询字段,也即查询到当前区块中的指示可以查找到目标结尾区块的哈希值的标识,如“pre hash”,进而区块链系统通过该待查询字段,查询到对应的哈希值,也即为待查询标识值。It can be that when the record node in the blockchain system finds that the block generation time is not within the block connection time range, the current block needs to be used as the initial block, that is, the block needs to be stored in a new area In the blockchain, the record node in the blockchain system queries the field to be queried that is contained in the current block and corresponds to the target ending block of the current blockchain, and then the record node in the blockchain system queries the pending field. The corresponding hash value in the query field is used as the identification value to be queried. For example, when the recording node in the blockchain system queries that the block generation time is not within the block connection time range, the recording node queries the current block corresponding to the target ending block of the current blockchain. The query field, that is, the indication that the current block is queried, the hash value of the target ending block can be found, such as "pre hash", and the blockchain system can query the corresponding hash through the field to be queried The value is the identification value to be queried.
S210:将待查询标识值更改为预存储的目标值,根据目标值以及待记录数据计算当前区块对应的目标标识值。S210: Change the identification value to be queried to a pre-stored target value, and calculate the target identification value corresponding to the current block according to the target value and the data to be recorded.
具体地,目标值是指当当前区块为初始区块时,该作为初始区块的当前区块中包含的结尾区块哈希值的预设值,该目标值为预存储在不同节点中的预设值。目标标识值是指对当前区块中更改了结尾区块哈希值时,则重新进行计算得到的当前区块的哈希值。具体地,区块链系统中的记录节点当查询到当前区块的区块生成时间未在当前区块链对应的区块连接时间范围内时,则当前区块无需连接到当前区块链的结尾区块链,也即当前区块需要作为初始区块,也即区块链系统中的记录节点查询到当前区块中的待查询标识值,进而查询到预存储在记录节点中的,与初始区块对应的目标值,将待查询标识值更改为目标值,进而记录节点可以直接按照加密算法,根据修改的目标值以及待记录数据计算当前区块对应的哈希值,作为目标标识值。Specifically, the target value refers to the preset value of the hash value of the ending block contained in the current block as the initial block when the current block is the initial block, and the target value is pre-stored in different nodes The default value. The target identification value refers to the hash value of the current block obtained by recalculating the hash value of the ending block in the current block. Specifically, when the record node in the blockchain system finds that the block generation time of the current block is not within the block connection time range corresponding to the current block chain, the current block does not need to be connected to the current block chain. The ending blockchain, that is, the current block needs to be used as the initial block, that is, the record node in the blockchain system queries the identification value to be queried in the current block, and then queries the pre-stored in the record node, and The target value corresponding to the initial block, change the identification value to be queried to the target value, and then the recording node can directly calculate the hash value corresponding to the current block according to the encryption algorithm, according to the modified target value and the data to be recorded, as the target identification value .
例如,区块链系统中的记录节点查询到当前区块的区块生成时间为2019年1月,区块连接时间范围为2018年1月至2018年12月,则当前区块的区块生成时间未在区块连接范围内, 则当前区块作为初始区块,生成新的区块链,该新的区块链中的区块的区块生成时间为2019年1月至2019年12月,因此,当前区块作为初始区块,则将当前区块中包含的目标结尾区块的哈希值按照预存储的目标值进行更改,如目标值为0,则将目标结尾区块的哈希值更改为0,进而区块链系统中的记录节点可以采用哈希算法,如SHA-256算法(安全散列算法)进行计算,得到作为初始区块的当前区块的哈希值,作为目标标识值。需要说明的是,哈希算法还可以采用其他算法,如安全散列算法中的SHA-512、SHA-224算法,或者MD算法等。For example, if the record node in the blockchain system finds that the block generation time of the current block is January 2019, and the block connection time range is from January 2018 to December 2018, the block generation time of the current block is If the time is not within the range of the block connection, the current block is used as the initial block to generate a new block chain. The block generation time of the block in the new block chain is from January 2019 to December 2019 Therefore, if the current block is used as the initial block, the hash value of the target ending block contained in the current block is changed according to the pre-stored target value. If the target value is 0, the hash value of the target ending block will be changed. The hope value is changed to 0, and then the record node in the blockchain system can use a hash algorithm, such as the SHA-256 algorithm (secure hash algorithm) for calculation, to obtain the hash value of the current block as the initial block, as Target identification value. It should be noted that the hash algorithm can also use other algorithms, such as the SHA-512, SHA-224 algorithm, or MD algorithm in the secure hash algorithm.
S212:将当前标识值更改为目标标识值,使得当前区块作为初始区块,并根据初始区块生成更新区块链。S212: Change the current identification value to the target identification value, so that the current block is used as the initial block, and generate and update the blockchain according to the initial block.
具体地,更新区块链是指区块连接时间不同于存储在区块链系统中的不同区块链的新的区块链。记录节点将当前标识值更改为目标标识值时,则当前区块作为初始区块,区块链系统中的记录节点将包含在当前区块中的当前标识值进行更改,更改为目标标识值,当前区块则作为初始区块,进而根据初始区块的生成时间,得到更新区块链对应的更新区块连接时间范围,当区块链系统通过记录节点生成新的区块时,则可以根据生成新的区块的生成时间,与初始区块进行相连生成新的区块链。Specifically, updating the block chain refers to a new block chain whose block connection time is different from the different block chains stored in the block chain system. When the recording node changes the current identification value to the target identification value, the current block is used as the initial block, and the recording node in the blockchain system will change the current identification value contained in the current block to the target identification value. The current block is used as the initial block, and according to the generation time of the initial block, the update block connection time range corresponding to the update block chain is obtained. When the block chain system generates a new block through the recording node, it can be based on The generation time of the new block is connected with the initial block to generate a new block chain.
本实施例中,在对数据进行存储的过程中,并非是对所有的数据按照传统的区块链按照统一连接生成单一的区块链的方式,避免当数据量过大时,则处理效率低,可以提高处理效率,且避免为了提高处理效率,需要升级硬件产品,节省成本,另外,由于待记录数据会涉及到不同的业务数据,如环境数据,环境数据用于进行环境监测,而按照传统的单链的方式进行存储则造成大量无需使用的数据无法进行删除,从而适用性不强,而按照区块连接时间进行存储则可以增强适用性。In this embodiment, in the process of storing data, not all data is generated according to the traditional block chain in a unified connection to generate a single block chain to avoid low processing efficiency when the amount of data is too large , Can improve processing efficiency, and avoid the need to upgrade hardware products in order to improve processing efficiency, and save costs. In addition, because the data to be recorded will involve different business data, such as environmental data, environmental data is used for environmental monitoring. The single-chain method of storage causes a large amount of unused data cannot be deleted, so the applicability is not strong, and storage according to the block connection time can enhance the applicability.
在其中一个实施例中,请参见图3,提供一区块删除步骤的流程示意图,区块删除步骤,也即将当前标识值更改为目标标识值,使得当前区块作为初始区块,并根据初始区块生成更新区块链之后,包括:提取不同区块链对应的区块链生成时间,并获取当前系统时间;根据区块链生成时间以及当前系统时间计算数据存储时长;当数据存储时长超过预设时长时,则查询超过预设时长的数据存储时长所对应的待删除区块,并将待删除区块删除。In one of the embodiments, please refer to Figure 3, which provides a schematic flow diagram of the block deletion step. The block deletion step is to change the current identification value to the target identification value, so that the current block is used as the initial block, and according to the initial block Block generation After updating the blockchain, it includes: extracting the blockchain generation time corresponding to different blockchains and obtaining the current system time; calculating the data storage duration according to the blockchain generation time and the current system time; when the data storage duration exceeds When the preset duration is set, the block to be deleted corresponding to the data storage duration exceeding the preset duration is queried, and the block to be deleted is deleted.
具体地,区块链生成时间是指存储在区块链系统中的不同的区块链的生成时间,区块链生成时间可以是详细年份时间等。数据存储时长是不同的区块链存储在区块链系统中的时长。待删除区块是指数据存储时长超过预设时长的区块链中所包含的不同区块。Specifically, the block chain generation time refers to the generation time of different block chains stored in the block chain system, and the block chain generation time may be a detailed year, etc. Data storage duration is the length of time that different blockchains are stored in the blockchain system. Blocks to be deleted refer to different blocks included in the blockchain whose data storage time exceeds the preset time.
具体地,存储在区块链系统中不同节点中的不同区块链对应有区块连接时间范围,提取区块连接时间范围所表示的区块链生成时间,区块链系统中的记录节点获取存储的不同区块链的区块链生成时间,并获取当前系统时间,进而分别计算不同区块链的区块链生成时间与当前系统时间的差值,该差值即为数据存储时长,进而区块链系统中的记录节点获取到预存储的预设时长,并将数据存储时长与预设时长进行比较,选取数据存储时长超过预设时长的区块链,并将该区块链中包含的区块作为待删除区块,进而将查询到的待删除区块进行删除。Specifically, different blockchains stored in different nodes in the blockchain system correspond to the block connection time range, the block chain generation time represented by the block connection time range is extracted, and the record node in the blockchain system obtains Store the block chain generation time of different block chains, and obtain the current system time, and then calculate the difference between the block chain generation time of different block chains and the current system time. The difference is the data storage time, and then The record node in the blockchain system obtains the pre-stored preset duration, compares the data storage duration with the preset duration, selects the blockchain whose data storage duration exceeds the preset duration, and includes the blockchain As the block to be deleted, the block to be deleted is deleted.
可以是,区块链系统中的记录节点获取到不同区块链对应的区块连接时间范围,如获取到四条区块链对应区块连接时间范围,区块连接时间范围分别是2015年1月至2015年12月, 2016年1月至2016年12月,2017年1月至2017年12月以及2018年1月至2018年12月,进而根据区块连接时间范围,提取每条区块链对应的区块链生成时间,可以是根据区块连接时间范围中包含的年份信息得到区块链生成时间,如区块链生成时间分别为2015年、2016年、2017年与2018年,进而区块链系统中的记录节点获取到当前系统时间为2019年,区块链系统中的记录节点根据不同区块链生成时间与当前系统时间计算数据存储时长,也即上述区块链的数据存储时长分别为4年、3年、2年和1年,区块链系统中的记录节点获取到预设时长,预设时长为3年,进而将数据存储时长与预设时长进行比较,当数据存储时长超过预设时长时,则将该条区块链中的区块作为待删除区块,进而将待删除区块进行删除。且本实施例中,区块链系统中的不同节点可以存储有不同时间的区块链,且预设时长可以按照不同应用场景进行设置。It can be that the record node in the blockchain system obtains the block connection time range corresponding to different blockchains. For example, the block connection time range corresponding to the four blockchains is obtained. The block connection time range is January 2015. To December 2015, January 2016 to December 2016, January 2017 to December 2017 and January 2018 to December 2018, and then extract each blockchain according to the time range of the block connection The corresponding block chain generation time can be obtained according to the year information contained in the block connection time range. For example, the block chain generation time is 2015, 2016, 2017 and 2018, and then the district The record node in the blockchain system obtains the current system time as 2019, and the record node in the blockchain system calculates the data storage duration based on the generation time of different blockchains and the current system time, that is, the data storage duration of the aforementioned blockchain Respectively 4 years, 3 years, 2 years and 1 year, the record node in the blockchain system obtains the preset duration, which is 3 years, and then compares the data storage duration with the preset duration. When the data is stored When the duration exceeds the preset duration, the block in the blockchain is regarded as the block to be deleted, and the block to be deleted is deleted. Moreover, in this embodiment, different nodes in the blockchain system may store blockchains at different times, and the preset duration may be set according to different application scenarios.
本实施例中,区块链系统中的记录节点按照对应的存储时间存储有不同的区块链,区块链系统中的记录节点可以根据区块链生成时间以及当前系统时间计算得到数据存储时长,当数据存储时长超过预设时长时,则查询数据存储时长超过预设时长所对应的待删除区块,并将待删除区块进行删除,也即可以存储空间资源。In this embodiment, the recording node in the blockchain system stores different blockchains according to the corresponding storage time. The recording node in the blockchain system can calculate the data storage duration according to the generation time of the blockchain and the current system time. When the data storage duration exceeds the preset duration, the query data storage duration exceeds the to-be-deleted block corresponding to the preset duration, and the to-be-deleted block is deleted, that is, the space resource can be stored.
在其中一个实施例中,可继续参见图3,查询超过预设时长的数据存储时长所对应的待删除区块,并将待删除区块删除,包括:查询超过预设时长的数据存储时长对应的待删除初始区块,并查询与待删除初始区块连接的待删除关联区块;将待删除初始区块与待删除关联区块进行删除。In one of the embodiments, you can continue to refer to Figure 3, query the block to be deleted corresponding to the data storage duration exceeding the preset duration, and delete the block to be deleted, including: query the data storage duration corresponding to the data storage duration exceeding the preset duration The initial block to be deleted is searched for the related block to be deleted connected to the initial block to be deleted; the initial block to be deleted and the related block to be deleted are deleted.
具体地,待删除初始区块是指与超过预设时长的数据存储时长对应的区块链中的初始区块。待删除关联区块是指与超过预设时长的数据存储时长对应的区块链中,与初始区块顺序相连的不同区块。具体地,当区块链系统中的记录节点查询到进行存储的不同区块链对应的数据存储时长超过预设时长时,则查询超过预设时长的数据存储时长所对应的待删除区块链,进而查询待删除区块链中包含的待删除初始区块,进而按照待删除初始区块,查询与待删除初始区块相连接的其他区块,相连的其他区块为待删除关联区块,进而将待删除初始区块与待删除关联区块作为待删除区块,将待删除区块进行删除。Specifically, the initial block to be deleted refers to the initial block in the blockchain corresponding to the data storage duration exceeding the preset duration. The associated block to be deleted refers to a different block connected to the initial block sequence in the blockchain corresponding to the data storage duration exceeding the preset duration. Specifically, when the record node in the blockchain system queries that the data storage duration corresponding to the different blockchains for storage exceeds the preset duration, query the to-be-deleted blockchain corresponding to the data storage duration that exceeds the preset duration , And then query the initial block to be deleted contained in the blockchain to be deleted, and then query other blocks connected to the initial block to be deleted according to the initial block to be deleted, and the other connected blocks are related blocks to be deleted , And then use the initial block to be deleted and the associated block to be deleted as the block to be deleted, and delete the block to be deleted.
可以是,当区块链系统中的记录节点查询到存储的不同区块链对应的数据存储时长超过预设时长时,则查询超过预设时长的数据存储时长所对应的待删除区块链,进而查询待删除区块链中包含的待查询字段,进而查询待查询字段对应的待查询标识值为目标值的区块作为待删除初始区块,进而查询到待查询初始区块对应的目标标识值,根据该目标标识值查询到下一区块,直至查询到待删除区块链中包含的结尾区块,则根据目标标识值顺序查询到的所有区块作为待删除关联区块,进而将待删除初始区块与待删除关联区块进行删除。It can be that when the record node in the blockchain system queries that the storage duration of the data corresponding to different blockchains in the storage exceeds the preset duration, then query the blockchain to be deleted corresponding to the data storage duration that exceeds the preset duration. Then query the field to be queried contained in the block chain to be deleted, and then query the block whose identification value to be queried corresponding to the field to be queried is the target value as the initial block to be deleted, and then query the target identification corresponding to the initial block to be queried Value, the next block is queried according to the target identification value, until the end block contained in the blockchain to be deleted is queried, then all the blocks queried sequentially according to the target identification value are regarded as the associated blocks to be deleted, and then The initial block to be deleted and the associated block to be deleted are deleted.
例如,当区块链系统中的记录节点查询到存储的不同区块链对应的数据存储时长超过预设时长时,则查询超过预设时长的数据存储时长所对应的待删除区块链,则查询待删除区块链中每个区块中包含的上一区块的查询字段,进而查询到待查询字段时,如查询到“pre hash”,进而查询到待查询字段所对应哈希值,当查询到该字段对应的哈希值为0的区块作为待删除初始区块,进而区块链系统中的记录节点查询该待删除初始区块对应的当前区块的哈希值, 进而查询待删除区块链中其他区块中包含有当前区块的哈希值作为下一区块,直至查询到待删除区块链的结尾区块,从而将根据待删除初始区块对应的哈希值查询到的相关联的区块作为待删除关联区块,将待删除初始区块与待删除关联区块均进行删除。For example, when the record node in the blockchain system queries that the storage duration of data corresponding to different blockchains exceeds the preset duration, it will query the blockchain to be deleted corresponding to the data storage duration that exceeds the preset duration, then Query the query field of the previous block contained in each block in the blockchain to be deleted, and then query the field to be queried, such as "pre hash", and then query the hash value corresponding to the field to be queried. When the block with a hash value of 0 corresponding to this field is queried as the initial block to be deleted, the record node in the blockchain system queries the hash value of the current block corresponding to the initial block to be deleted, and then queries Other blocks in the block chain to be deleted contain the hash value of the current block as the next block, until the end block of the block chain to be deleted is queried, and the hash value corresponding to the initial block to be deleted The related block found by the value query is regarded as the related block to be deleted, and both the initial block to be deleted and the related block to be deleted are deleted.
本实施例中,区块链系统中的记录节点可以将数据存储时长超过预设时长的区块链进行删除,避免需要扩大存储资源从而需要持续升级硬件产品,降低成本。In this embodiment, the recording node in the blockchain system can delete the blockchain whose data storage duration exceeds the preset duration, avoiding the need to expand storage resources and thus the need to continuously upgrade hardware products and reduce costs.
在其中一个实施例中,可继续参见图3,查询与待删除初始区块连接的待删除关联区块之后,包括:获取待删除关联区块中包含的第一生成时间,并获取待删除初始区块中包含的第二生成时间;判断第一生成时间与第二生成时间的差值是否在预设差值范围内;当差值未在预设差值范围内时,则输出核查信息。In one of the embodiments, referring to Figure 3, after querying the associated block to be deleted connected to the initial block to be deleted, it includes: obtaining the first generation time contained in the associated block to be deleted, and obtaining the initial The second generation time included in the block; determine whether the difference between the first generation time and the second generation time is within the preset difference range; when the difference is not within the preset difference range, output verification information.
具体地,第一生成时间是指待删除关联区块中包含的区块的生成时间。第二生成时间是指待删除初始区块中包含的区块的生成时间。当区块链系统中的记录节点查询到待删除关联区块时,需要再次验证是否为待删除区块,区块链系统中的记录节点查询到待删除关联区块时,则获取待删除关联区块中包含的第一生成时间,进而获取待删除初始区块中包含的第二生成时间,计算第一生成时间与第二生成时间的差值,得到该差值时,则查询该差值是否在预设差值范围内,当在预设差值范围内,则该待删除关联区块可以与待删除初始区块共同作为待删除区块,当差值未在预设差值范围内时,则输出相应的核查信息,可以查询是否查询到错误的区块等。Specifically, the first generation time refers to the generation time of the block included in the associated block to be deleted. The second generation time refers to the generation time of the block included in the initial block to be deleted. When the record node in the blockchain system finds the associated block to be deleted, it needs to verify again whether it is the to-be-deleted block. When the record node in the blockchain system queries the to-be-deleted associated block, it obtains the to-be-deleted association The first generation time included in the block, and then the second generation time included in the initial block to be deleted is obtained, and the difference between the first generation time and the second generation time is calculated, and when the difference is obtained, the difference is queried Whether it is within the preset difference range, when it is within the preset difference range, the associated block to be deleted can be used as the block to be deleted together with the initial block to be deleted, when the difference is not within the preset difference range When the time, the corresponding check information is output, and you can check whether the wrong block is found.
例如,预设时间范围可以是1年内,则获取到待删除关联区块中包含的第一生成时间,并获取待删除初始区块中包含的第二生成时间,则计算第一生成时间与第二生成时间的差值,并查询该差值是否在预设时间范围内,当在预设时间范围内,则该待删除关联区块可以与待删除初始区块共同作为待删除区块进行删除,当未在预设时间范围内,则输出相应的核查信息,核查信息可以输出围在预设时间范围内的待删除关联区块的区块标识值等,查询是否查询到了错误的区块等。For example, the preset time range can be within 1 year, then the first generation time contained in the associated block to be deleted is obtained, and the second generation time contained in the initial block to be deleted is obtained, then the first generation time and the first generation time are calculated. 2. Generate the difference in time and query whether the difference is within the preset time range. When it is within the preset time range, the associated block to be deleted can be deleted as the block to be deleted together with the initial block to be deleted , When it is not within the preset time range, the corresponding verification information is output. The verification information can output the block identification value of the related block to be deleted within the preset time range, etc., query whether the wrong block is queried, etc. .
另外,当区块链系统中的记录节点查询到待删除初始区块与待删除关联区块时,则获取到待删除关联区块对应地第一生成时间,并获取到待删除初始区块地第二生成时间,则分别根据第一生成时间与当前系统时间计算得到关联区块存储时长,查询关联区块存储时长是否超过预设时长,进而根据第二生成时间与当前系统时间计算得到初始区块存储时长,并查询初始区块存储时长是否超过预设时长,进而当关联区块存储时长与初始区块存储时长均超过预设时长时,则再计算第一生成时间与第二生成时间的差值,当关联区块存储时长与初始区块存储时长中任一时长为超过预设时长,则直接输出核查信息,如输出相应的区块标识等。In addition, when the record node in the blockchain system queries the initial block to be deleted and the associated block to be deleted, it obtains the first generation time corresponding to the associated block to be deleted, and obtains the location of the initial block to be deleted. The second generation time is calculated according to the first generation time and the current system time to obtain the storage duration of the associated block, query whether the storage duration of the associated block exceeds the preset time, and then calculate the initial area based on the second generation time and the current system time Block storage duration, and query whether the initial block storage duration exceeds the preset duration, and then when the associated block storage duration and the initial block storage duration exceed the preset duration, then calculate the first generation time and the second generation time The difference, when any one of the associated block storage duration and the initial block storage duration exceeds the preset duration, the verification information is directly output, such as the corresponding block identification.
本实施例中,当区块链系统中的记录节点选择得到了待删除初始区块以及待删除关联区块时,则可以进一步进行验证,保证对区块链删除的准确性。In this embodiment, when the recording node in the blockchain system selects the initial block to be deleted and the associated block to be deleted, further verification can be performed to ensure the accuracy of the blockchain deletion.
在其中一个实施例中,获取当前区块链对应的区块连接时间范围,并查询区块生成时间是否在当前区块连接时间范围内之后,包括:当当前区块生成时间在区块连接时间范围内时,则获取当前区块连接时间范围对应的当前区块链中的目标结尾区块;将当前区块与目标结尾区块进行连接。In one of the embodiments, obtaining the block connection time range corresponding to the current blockchain, and querying whether the block generation time is after the current block connection time range, includes: when the current block generation time is within the block connection time When it is within the range, the target end block in the current blockchain corresponding to the current block connection time range is obtained; the current block is connected with the target end block.
在其中一个实施例中,将当前区块与目标结尾区块进行连接,包括:将当前区块发送至背书节点进行验证;接收背书节点对当前区块进行验证的验证结果;当验证结果为验证通过时,则将当前区块与目标结尾区块进行连接。In one of the embodiments, connecting the current block with the target ending block includes: sending the current block to the endorsing node for verification; receiving the verification result of the endorsing node verifying the current block; when the verification result is verification When passed, the current block is connected with the target ending block.
在其中一个实施例中,获取当前区块链对应的区块连接时间范围,并查询当前区块生成时间是否在区块连接时间范围内之后,包括:当当前区块生成时间在区块连接时间范围内时,则获取当前区块连接时间范围对应的当前区块链中的目标结尾区块:通过记录节点将当前区块发送至背书节点进行验证;通过记录节点接收背书节点对当前区块进行验证的验证结果;当验证结果为验证通过时,则将当前区块与目标结尾区块进行连接。In one of the embodiments, obtaining the block connection time range corresponding to the current blockchain and querying whether the current block generation time is within the block connection time range includes: when the current block generation time is within the block connection time When it is within the range, the target ending block in the current blockchain corresponding to the current block connection time range is obtained: the current block is sent to the endorsing node through the recording node for verification; the endorsing node is received by the recording node to perform the current block The verification result of the verification; when the verification result is passed, the current block is connected with the target ending block.
具体地,背书节点是指包含在区块链系统中可以对生成的区块进行验证,并进行签名的节点服务器,当生成的区块经过背书节点的背书操作时,则可以将该区块与待连接区块链中的结尾区块进行连接,也即当前区块入链。Specifically, the endorsing node refers to the node server included in the blockchain system that can verify and sign the generated block. When the generated block is endorsed by the endorsing node, the block can be combined with The ending block in the block chain to be connected is connected, that is, the current block enters the chain.
具体地,当区块链系统中的记录节点查询到区块生成时间在区块连接时间范围内时,则当前区块可以直接连接在当前区块链上。区块链系统中的记录节点获取到当前区块链中的目标结尾区块,记录节点根据待记录数据以及待查询标识,生成当前区块,当前区块中包含有当前标识值,当前区块生成时间以及待记录数据等,查询当前区块生成时间在区块连接时间范围内,则记录节点将生成的当前区块发送至背书节点,背书节点接收到当前区块时,则通过背书节点获取到记录节点的身份标识,查询该身份标识是否为可信身份标识,也即可以将该身份标识与预存储的可信身份标识进行匹配,当匹配成功时,则该记录节点的身份标识为可信身份标识,进而通过背书节点获取到相应的待记录数据验证逻辑,如查询数据中是否包含有虚假数据等,通过待记录验证逻辑对待记录数据进行验证,进而根据对记录节点身份标识与待记录数据验证生成验证结果,也即当记录节点身份标识以及待记录数据均验证通过时,验证结果为验证通过,当验证结果验证通过时,记录节点将当前区块与目标结尾区块进行连接,也即将目标结尾区块指向当前区块,当前区块作为当前区块链中的结尾区块。Specifically, when the recording node in the blockchain system finds that the block generation time is within the block connection time range, the current block can be directly connected to the current blockchain. The recording node in the blockchain system obtains the target ending block in the current blockchain. The recording node generates the current block according to the data to be recorded and the identification to be queried. The current block contains the current identification value, and the current block Generation time and data to be recorded, etc., query the current block generation time within the block connection time range, the recording node will send the generated current block to the endorsing node, and when the endorsing node receives the current block, it will get it through the endorsing node Go to the identity of the recording node and query whether the identity is a trusted identity, that is, the identity can be matched with a pre-stored trusted identity. When the matching is successful, the identity of the recording node is acceptable The verification logic of the data to be recorded is obtained through the endorsement node, such as whether the query data contains false data, etc., the data to be recorded is verified by the verification logic to be recorded, and then the verification logic of the recording node The data verification generates the verification result, that is, when the identification of the recording node and the data to be recorded are verified, the verification result is passed. When the verification result is verified, the recording node connects the current block with the target ending block, and That is, the target ending block points to the current block, and the current block is used as the ending block in the current blockchain.
本实施例中,当区块生成时间在区块连接时间范围内时,则可以将当前区块与结尾区块进行连接,且在连接之前需要通过背书节点对当前区块进行验证,从而保证生成的区块的准确与安全性。In this embodiment, when the block generation time is within the block connection time range, the current block can be connected to the ending block, and the current block needs to be verified by the endorsement node before the connection, so as to ensure the generation The accuracy and security of the block.
在其中一个实施例中,以下以环保数据的存储为例进行说明,其中,对于区块链系统中,可以包含有不同的节点服务器,如记录节点对应的服务器,记录节点对应的服务器可以由不同的环保机构的服务器,监测环境数据的企业对应的服务器构成,也即可以为环保机构记录节点以及企业记录节点,相应的数据可以是监控的企业的环境数据,另外,区块链系统中还可以包含有背书节点对应的服务器,对监控的企业的环境数据进行背书。In one of the embodiments, the following takes the storage of environmental protection data as an example. Among them, for the blockchain system, different node servers may be included, such as the server corresponding to the recording node, and the server corresponding to the recording node may be different The server of the environmental protection agency, the server corresponding to the enterprise that monitors environmental data, can also be regarded as the environmental protection agency record node and the enterprise record node. The corresponding data can be the environmental data of the monitored enterprise. In addition, the blockchain system can also Contains the server corresponding to the endorsement node to endorse the environmental data of the monitored enterprise.
具体地,以企业记录节点记录检测相应的环境数据为例进行进一步说明,企业记录节点根据环境数据生成当前区块,当前区块中可以包含有区块生成时间、所需连接的结尾区块的哈希值以及当前区块的哈希值,进而区块链系统中包含的该企业记录节点查询到当前区块链对应的区块连接时间范围,如区块连接时间范围为2018年1月至2018年12月,也即当前区块生成时间在该时间范围内的才进行连接,该企业记录节点查询到当前区块生成时间为2019 年1月1日,则该区块生成时间未在区块连接时间范围内,则当前区块需要存储在新的区块链中,因此将当前区块中的结尾区块的哈希值修改为0,从而重新计算当前区块的哈希值,将该当前区块作为初始区块,生成更新区块链,且该更新区块链对应有区块连接时间范围为2019年1月至2019年12月。Specifically, the enterprise record node records and detects the corresponding environmental data as an example for further explanation. The enterprise record node generates the current block according to the environmental data. The current block can contain the block generation time and the end block that needs to be connected. The hash value and the hash value of the current block, and the enterprise record node included in the blockchain system can query the block connection time range corresponding to the current block chain. For example, the block connection time range is from January 2018 to In December 2018, that is, when the current block generation time is within this time range, the connection is made. The enterprise record node queries that the current block generation time is January 1, 2019, and the block generation time is not in the zone. Within the block connection time range, the current block needs to be stored in the new blockchain, so the hash value of the ending block in the current block is modified to 0, so that the hash value of the current block is recalculated. The current block is used as the initial block to generate an update block chain, and the block connection time range corresponding to the update block chain is from January 2019 to December 2019.
当生成更新区块链时,该企业记录节点可以查询到存储有不同的环保时间的区块链,也即查询不同的区块链生成时间,区块链生成时间可以根据区块连接时间范围中的年份进行确定,进而根据当前系统时间以及区块链生成时间计算数据存储时长,进而将数据存储时长超过预设时长的区块链整体进行删除,如数据存储时长超过3年的区块链整体进行删除,也即由于环保数据的实时性,超过3年的环保数据参考价值较低,在区块链系统对相应的区块链进行删除时,可以先查询到对应的待删除初始区块,进而查询到待删除关联区块,并验证待删除关联区块与待删除初始区块生成时间差值是否是在预设时间范围内,例如是否是在区块链生成时间对应的年度内,当是在区块链生成时间对应的年度内,则将待删除关联区块以及待删除初始区块作为待删除区块进行删除。When generating and updating the blockchain, the enterprise record node can query the blockchains that store different environmental protection times, that is, query different blockchain generation times. The blockchain generation time can be based on the block connection time range The year of the data storage is determined, and the data storage duration is calculated according to the current system time and the generation time of the blockchain, and then the entire blockchain whose data storage duration exceeds the preset duration is deleted, such as the entire blockchain whose data storage duration exceeds 3 years To delete, that is, due to the real-time nature of environmental protection data, the reference value of environmental protection data over 3 years is low. When the blockchain system deletes the corresponding blockchain, you can first query the corresponding initial block to be deleted. Then query the related block to be deleted, and verify whether the generation time difference between the related block to be deleted and the initial block to be deleted is within the preset time range, for example, whether it is within the year corresponding to the block chain generation time. In the year corresponding to the block chain generation time, the associated block to be deleted and the initial block to be deleted are deleted as the block to be deleted.
另外,例如当企业记录节点查询到的当前区块的区块生成时间为2018年3月,则该区块生成时间在区块连接时间范围内,则可以直接将该区块与区块连接时间范围为2018年1月至2018年12月的区块链中的目标结尾区块相连,且在连接之前,企业记录节点可以通过背书节点对当前区块进行验证,如验证其中包含的环保数据是否有造假,比如环保数据有重复日期的数据等,进而验证记录节点的身份标识是否为可信真实的身份标识,当验证通过时,则可以将当前区块与结尾区块进行相连。需要说明的是,本实施例中的数据还可以是其他待处理业务的业务数据等。In addition, for example, when the block generation time of the current block queried by the enterprise record node is March 2018, then the block generation time is within the block connection time range, and the block can be directly connected to the block time The target ending block in the blockchain ranging from January 2018 to December 2018 is connected, and before the connection, the enterprise record node can verify the current block through the endorsement node, such as verifying whether the environmental protection data contained therein There is fraud, such as environmental protection data with repeated date data, etc., to verify whether the identity of the recording node is a credible and true identity. When the verification is passed, the current block can be connected to the end block. It should be noted that the data in this embodiment may also be business data of other services to be processed.
应该理解的是,虽然图2-3的流程图中的各个步骤按照箭头的指示依次显示,但是这些步骤并不是必然按照箭头指示的顺序依次执行。除非本文中有明确的说明,这些步骤的执行并没有严格的顺序限制,这些步骤可以以其它的顺序执行。而且,图2-3中的至少一部分步骤可以包括多个子步骤或者多个阶段,这些子步骤或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,这些子步骤或者阶段的执行顺序也不必然是依次进行,而是可以与其它步骤或者其它步骤的子步骤或者阶段的至少一部分轮流或者交替地执行。It should be understood that, although the various steps in the flowchart of FIGS. 2-3 are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless specifically stated in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least some of the steps in Figure 2-3 may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. These sub-steps or stages The execution order of is not necessarily performed sequentially, but may be performed alternately or alternately with at least a part of other steps or sub-steps or stages of other steps.
在其中一个实施例中,如图4所示,提供了一种数据存储装置,包括:当前区块接收模块410、第一获取模块420、第二获取模块430、计算模块440和更改模块450,其中:In one of the embodiments, as shown in FIG. 4, a data storage device is provided, including: a current block receiving module 410, a first obtaining module 420, a second obtaining module 430, a calculation module 440, and a modification module 450, among them:
当前区块接收模块410,用于将待记录数据存储至当前区块,当前区块包含当前区块生成时间以及当前区块对应的当前标识值。The current block receiving module 410 is configured to store the data to be recorded in the current block. The current block includes the generation time of the current block and the current identification value corresponding to the current block.
提取模块420,用于查询与当前区块关联的目标结尾区块,根据目标结尾区块提取当前区块链。The extraction module 420 is used for querying the target ending block associated with the current block, and extracting the current blockchain according to the target ending block.
第一获取模块430,用于获取当前区块链对应的区块连接时间范围,并查询当前区块生成时间是否在区块连接时间范围内。The first obtaining module 430 is configured to obtain the block connection time range corresponding to the current block chain, and query whether the current block generation time is within the block connection time range.
第二获取模块440,用于当当前区块生成时间未在区块连接时间范围中时,则获取当前区块中包含的目标结尾区块所对应的待查询标识值。The second obtaining module 440 is configured to obtain the identification value to be queried corresponding to the target ending block contained in the current block when the current block generation time is not within the block connection time range.
计算模块450,用于将待查询标识值更改为预存储的目标值,根据目标值以及待记录数据计算当前区块对应的目标标识值。The calculation module 450 is configured to change the identification value to be queried into a pre-stored target value, and calculate the target identification value corresponding to the current block according to the target value and the data to be recorded.
更改模块460,用于将当前标识值更改为目标标识值,使得当前区块作为初始区块,并根据初始区块生成更新区块链。The modification module 460 is used to change the current identification value to the target identification value, so that the current block is used as the initial block, and the block chain is generated and updated according to the initial block.
在其中一个实施例中,数据存储装置400,还可以包括:In one of the embodiments, the data storage device 400 may further include:
提取模块,用于提取不同区块链对应的区块链生成时间,并获取当前系统时间。The extraction module is used to extract the block chain generation time corresponding to different block chains and obtain the current system time.
时长计算模块,用于根据区块链生成时间以及当前系统时间计算数据存储时长。The duration calculation module is used to calculate the data storage duration according to the generation time of the blockchain and the current system time.
删除模块,用于当数据存储时长超过预设时长时,则查询超过预设时长的数据存储时长所对应的待删除区块,并将待删除区块删除。The delete module is used to query the block to be deleted corresponding to the data storage duration exceeding the preset time when the data storage duration exceeds the preset duration, and delete the block to be deleted.
在其中一个实施例中,删除模块,包括:In one of the embodiments, deleting the module includes:
查询单元,用于查询超过预设时长的数据存储时长对应的待删除初始区块,并查询与待删除初始区块连接的待删除关联区块。The query unit is used to query the initial block to be deleted corresponding to the data storage duration exceeding the preset time length, and query the associated block to be deleted connected to the initial block to be deleted.
删除单元,用于将待删除初始区块与待删除关联区块进行删除。The deleting unit is used to delete the initial block to be deleted and the associated block to be deleted.
在其中一个实施例中,删除单元,可以包括:In one of the embodiments, the deletion unit may include:
时间获取子单元,用于获取待删除关联区块中包含的第一生成时间,并获取待删除初始区块中包含的第二生成时间。The time obtaining subunit is used to obtain the first generation time contained in the associated block to be deleted, and obtain the second generation time contained in the initial block to be deleted.
判断子单元,用于判断第一生成时间与第二生成时间的差值是否在预设差值范围内。The judging subunit is used to judge whether the difference between the first generation time and the second generation time is within a preset difference range.
输出子单元,用于当差值未在预设差值范围内时,则输出核查信息。The output subunit is used to output the verification information when the difference is not within the preset difference range.
在其中一个实施例中,数据存储装置400,还可以包括:In one of the embodiments, the data storage device 400 may further include:
结尾区块获取模块,用于当当前区块生成时间在区块连接时间范围内时,则获取当前区块连接时间范围对应的当前区块链中的目标结尾区块。The end block obtaining module is used to obtain the target end block in the current blockchain corresponding to the current block connection time range when the current block generation time is within the block connection time range.
连接模块,用于将当前区块与目标结尾区块进行连接。The connection module is used to connect the current block with the target ending block.
在其中一个实施例中,连接模块,可以包括:In one of the embodiments, the connection module may include:
验证结果接收单元,用于将当前区块发送至背书节点进行验证。还用于接收背书节点对当前区块进行验证的验证结果。The verification result receiving unit is used to send the current block to the endorsement node for verification. It is also used to receive the verification result that the endorsing node verifies the current block.
连接单元,用于当验证结果为验证通过时,则将当前区块与目标结尾区块进行连接。The connecting unit is used to connect the current block with the target ending block when the verification result is passed.
关于数据存储装置的具体限定可以参见上文中对于数据存储方法的限定,在此不再赘述。上述数据存储装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。For the specific definition of the data storage device, please refer to the above definition of the data storage method, which will not be repeated here. Each module in the above-mentioned data storage device can be implemented in whole or in part by software, hardware, and a combination thereof. The foregoing modules may be embedded in the form of hardware or independent of the processor in the computer device, or may be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the foregoing modules.
在其中一个实施例中,提供了一种计算机设备,该计算机设备可以是服务器,其内部结构图可以如图5所示。该计算机设备包括通过系统总线连接的处理器、存储器、网络接口和数据库。其中,该计算机设备的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性或易失性存储介质、内存储器。该非易失性或易失性存储介质存储有操作系统、计算机可读指令和数据库。该内存储器为非易失性存储介质中的操作系统和计算机可读指令的运行提供环境。该计算机设备的数据库用于存储数据。该计算机设备的网络接口用于与外 部的终端通过网络连接通信。该计算机可读指令被处理器执行时以实现一种数据存储方法。In one of the embodiments, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. 5. The computer equipment includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide calculation and control capabilities. The memory of the computer device includes a non-volatile or volatile storage medium and internal memory. The non-volatile or volatile storage medium stores an operating system, computer readable instructions, and a database. The internal memory provides an environment for the operation of the operating system and computer-readable instructions in the non-volatile storage medium. The computer equipment database is used to store data. The network interface of the computer equipment is used to communicate with external terminals through a network connection. The computer-readable instructions are executed by the processor to realize a data storage method.
本领域技术人员可以理解,图5中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定,具体的计算机设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。Those skilled in the art can understand that the structure shown in FIG. 5 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may Including more or fewer parts than shown in the figure, or combining some parts, or having a different arrangement of parts.
一种计算机设备,包括存储器和一个或多个处理器,存储器中储存有计算机可读指令,计算机可读指令被处理器执行时,使得一个或多个处理器执行以下步骤:将待记录数据存储至当前区块,当前区块包含当前区块生成时间以及当前区块对应的当前标识值。查询与当前区块关联的目标结尾区块,根据目标结尾区块提取当前区块链。获取当前区块链对应的区块连接时间范围,并查询当前区块生成时间是否在区块连接时间范围内。当当前区块生成时间未在区块连接时间范围中时,则获取当前区块中包含的与目标结尾区块所对应的待查询标识值。将待查询标识值更改为目标值,根据目标值以及待记录数据计算当前区块对应的目标标识值。及将当前标识值更改为目标标识值,使得当前区块作为初始区块,并根据初始区块生成更新区块链。A computer device including a memory and one or more processors, and computer-readable instructions are stored in the memory. When the computer-readable instructions are executed by the processor, the one or more processors perform the following steps: store data to be recorded To the current block, the current block contains the generation time of the current block and the current identification value corresponding to the current block. Query the target ending block associated with the current block, and extract the current blockchain based on the target ending block. Get the block connection time range corresponding to the current blockchain, and query whether the current block generation time is within the block connection time range. When the current block generation time is not within the block connection time range, the identification value to be queried corresponding to the target ending block contained in the current block is obtained. The identification value to be queried is changed to the target value, and the target identification value corresponding to the current block is calculated according to the target value and the data to be recorded. And change the current identification value to the target identification value, make the current block as the initial block, and generate and update the blockchain based on the initial block.
在其中一个实施例中,处理器执行计算机可读指令时实现将当前标识值更改为目标标识值,使得当前区块作为初始区块,并根据初始区块生成更新区块链之后,包括:提取不同区块链对应的区块链生成时间,并获取当前系统时间。根据区块链生成时间以及当前系统时间计算数据存储时长。当数据存储时长超过预设时长时,则查询超过预设时长的数据存储时长所对应的待删除区块,并将待删除区块删除。In one of the embodiments, when the processor executes the computer-readable instruction, the current identification value is changed to the target identification value, so that the current block is used as the initial block, and after the block chain is generated and updated according to the initial block, it includes: extracting Blockchain generation time corresponding to different blockchains, and get the current system time. Calculate the data storage duration based on the generation time of the blockchain and the current system time. When the data storage duration exceeds the preset duration, the block to be deleted corresponding to the data storage duration exceeding the preset duration is queried, and the block to be deleted is deleted.
在其中一个实施例中,处理器执行计算机可读指令时实现查询超过预设时长的数据存储时长所对应的待删除区块,并将待删除区块删除,包括:查询超过预设时长的数据存储时长对应的待删除初始区块,并查询与待删除初始区块连接的待删除关联区块。及将待删除初始区块与待删除关联区块进行删除。In one of the embodiments, when the processor executes the computer-readable instructions, the processor can query the block to be deleted corresponding to the data storage duration that exceeds the preset duration, and delete the block to be deleted, including: querying the data that exceeds the preset duration The initial block to be deleted corresponding to the storage duration is stored, and the associated block to be deleted connected to the initial block to be deleted is queried. And delete the initial block to be deleted and the associated block to be deleted.
在其中一个实施例中,处理器执行计算机可读指令时实现查询与待删除初始区块连接的待删除关联区块之后,包括:获取待删除关联区块中包含的第一生成时间,并获取待删除初始区块中包含的第二生成时间。判断第一生成时间与第二生成时间的差值是否在预设差值范围内。及当差值未在预设差值范围内时,则输出核查信息。In one of the embodiments, after the processor executes the computer-readable instruction to query the associated block to be deleted connected to the initial block to be deleted, the method includes: obtaining the first generation time contained in the associated block to be deleted, and obtaining The second generation time contained in the initial block to be deleted. It is determined whether the difference between the first generation time and the second generation time is within a preset difference range. And when the difference is not within the preset difference range, the verification information is output.
在其中一个实施例中,处理器执行计算机可读指令时实现获取当前区块链对应的区块连接时间范围,并查询当前区块生成时间是否在区块连接时间范围内之后,包括:当当前区块生成时间在区块连接时间范围内时,则获取当前区块连接时间范围对应的当前区块链中的目标结尾区块。及将当前区块与目标结尾区块进行连接。In one of the embodiments, when the processor executes the computer-readable instructions, it obtains the block connection time range corresponding to the current blockchain, and queries whether the current block generation time is after the block connection time range, including: When the block generation time is within the block connection time range, the target ending block in the current blockchain corresponding to the current block connection time range is obtained. And connect the current block with the target ending block.
在其中一个实施例中,处理器执行计算机可读指令时实现将当前区块与目标结尾区块进行连接,包括:将当前区块发送至背书节点进行验证。接收背书节点对当前区块进行验证的验证结果。及当验证结果为验证通过时,则将当前区块与目标结尾区块进行连接。In one of the embodiments, when the processor executes the computer-readable instruction, the connection between the current block and the target ending block includes: sending the current block to the endorsing node for verification. Receive the verification result of the endorsement node verifying the current block. And when the verification result is that the verification is passed, the current block is connected with the target ending block.
一个或多个存储有计算机可读指令的计算机可读存储介质,计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行以下步骤:将待记录数据存储至当前区块,当前区块包含当前区块生成时间以及当前区块对应的当前标识值。查询与当前区块关联的目标 结尾区块,根据目标结尾区块提取当前区块链。获取当前区块链对应的区块连接时间范围,并查询当前区块生成时间是否在区块连接时间范围内。当当前区块生成时间未在区块连接时间范围中时,则获取当前区块中包含的与目标结尾区块所对应的待查询标识值。将待查询标识值更改为预存储的目标值,根据目标值以及待记录数据计算当前区块对应的目标标识值。及将当前标识值更改为目标标识值,使得当前区块作为初始区块,并根据初始区块生成更新区块链。One or more computer-readable storage media storing computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the following steps: store the data to be recorded in the current area Block, the current block contains the current block generation time and the current identification value corresponding to the current block. Query the target ending block associated with the current block, and extract the current blockchain based on the target ending block. Get the block connection time range corresponding to the current blockchain, and query whether the current block generation time is within the block connection time range. When the current block generation time is not within the block connection time range, the identification value to be queried corresponding to the target ending block contained in the current block is obtained. The identification value to be queried is changed to a pre-stored target value, and the target identification value corresponding to the current block is calculated according to the target value and the data to be recorded. And change the current identification value to the target identification value, make the current block as the initial block, and generate and update the blockchain based on the initial block.
在其中一个实施例中,计算机可读指令被处理器执行时实现将当前标识值更改为目标标识值,使得当前区块作为初始区块,并根据初始区块生成更新区块链之后,包括:提取不同区块链对应的区块链生成时间,并获取当前系统时间。根据区块链生成时间以及当前系统时间计算数据存储时长。及当数据存储时长超过预设时长时,则查询超过预设时长的数据存储时长所对应的待删除区块,并将待删除区块删除。In one of the embodiments, when the computer-readable instruction is executed by the processor, the current identification value is changed to the target identification value, so that the current block is used as the initial block, and after the block chain is generated and updated according to the initial block, it includes: Extract the block chain generation time corresponding to different block chains, and get the current system time. Calculate the data storage duration based on the generation time of the blockchain and the current system time. And when the data storage duration exceeds the preset duration, the block to be deleted corresponding to the data storage duration exceeding the preset duration is queried, and the block to be deleted is deleted.
在其中一个实施例中,计算机可读指令被处理器执行时实现查询超过预设时长的数据存储时长所对应的待删除区块,并将待删除区块删除,包括:查询超过预设时长的数据存储时长对应的待删除初始区块,并查询与待删除初始区块连接的待删除关联区块。及将待删除初始区块与待删除关联区块进行删除。In one of the embodiments, when the computer-readable instruction is executed by the processor, the query block to be deleted corresponding to the data storage duration exceeding the preset duration is realized, and the block to be deleted is deleted, including: querying the block to be deleted that exceeds the preset duration The initial block to be deleted corresponding to the data storage time, and the related block to be deleted connected to the initial block to be deleted is queried. And delete the initial block to be deleted and the associated block to be deleted.
在其中一个实施例中,计算机可读指令被处理器执行时实现查询与待删除初始区块连接的待删除关联区块之后,包括:获取待删除关联区块中包含的第一生成时间,并获取待删除初始区块中包含的第二生成时间。判断第一生成时间与第二生成时间的差值是否在预设差值范围内。及当差值未在预设差值范围内时,则输出核查信息。In one of the embodiments, after the computer-readable instruction is executed by the processor to query the associated block to be deleted connected to the initial block to be deleted, the method includes: obtaining the first generation time included in the associated block to be deleted, and Obtain the second generation time contained in the initial block to be deleted. It is determined whether the difference between the first generation time and the second generation time is within a preset difference range. And when the difference is not within the preset difference range, the verification information is output.
在其中一个实施例中,计算机可读指令被处理器执行时实现获取当前区块链对应的区块连接时间范围,并查询当前区块生成时间是否在区块连接时间范围内之后,包括:当当前区块生成时间在区块连接时间范围内时,则获取当前区块连接时间范围对应的当前区块链中的目标结尾区块。及将当前区块与目标结尾区块进行连接。In one of the embodiments, when the computer-readable instructions are executed by the processor, the block connection time range corresponding to the current blockchain is obtained, and the query whether the current block generation time is within the block connection time range, including: When the current block generation time is within the block connection time range, the target end block in the current blockchain corresponding to the current block connection time range is obtained. And connect the current block with the target ending block.
在其中一个实施例中,计算机可读指令被处理器执行时实现将当前区块与结尾区块进行连接,包括:将当前区块发送至背书节点进行验证。接收背书节点对当前区块进行验证的验证结果。及当验证结果为验证通过时,则将当前区块与目标结尾区块进行连接。In one of the embodiments, when the computer-readable instruction is executed by the processor, the connection between the current block and the end block is realized, including: sending the current block to the endorsing node for verification. Receive the verification result of the endorsement node verifying the current block. And when the verification result is that the verification is passed, the current block is connected with the target ending block.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机可读指令来指令相关的硬件来完成,所述的计算机可读指令可存储于一计算机可读取存储介质中,该计算机可读指令在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM (DRDRAM)、以及存储器总线动态RAM(RDRAM)等。Persons of ordinary skill in the art can understand that all or part of the processes in the methods of the foregoing embodiments can be implemented by instructing relevant hardware through computer-readable instructions. The computer-readable instructions can be stored in a computer-readable storage. In the medium, when the computer-readable instructions are executed, they may include the processes of the foregoing method embodiments. Wherein, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and/or volatile memory. Non-volatile memory may include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not a limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous chain Channel (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
以上实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction between the combinations of these technical features, they should It is considered as the range described in this specification.
以上所述实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对申请专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。The above-mentioned embodiments only express a few implementation modes of the present application, and their description is relatively specific and detailed, but they should not be understood as a limitation on the scope of the patent application. It should be pointed out that for those of ordinary skill in the art, without departing from the concept of this application, several modifications and improvements can be made, and these all fall within the protection scope of this application. Therefore, the scope of protection of the patent of this application shall be subject to the appended claims.

Claims (20)

  1. 一种数据存储方法,包括:A data storage method, including:
    将待记录数据存储至当前区块,所述当前区块包含当前区块生成时间以及当前区块对应的当前标识值;Storing the data to be recorded in a current block, the current block including the current block generation time and the current identification value corresponding to the current block;
    查询与当前区块关联的目标结尾区块,根据所述目标结尾区块提取当前区块链;Query the target ending block associated with the current block, and extract the current blockchain according to the target ending block;
    获取所述当前区块链对应的区块连接时间范围,并查询所述当前区块生成时间是否在所述区块连接时间范围内;Obtain the block connection time range corresponding to the current block chain, and query whether the current block generation time is within the block connection time range;
    当所述当前区块生成时间未在所述区块连接时间范围中时,则获取所述当前区块中包含的与所述目标结尾区块所对应的待查询标识值;When the current block generation time is not within the block connection time range, acquiring the identification value to be queried corresponding to the target end block included in the current block;
    将所述待查询标识值更改为预存储的目标值,根据所述目标值以及所述待记录数据计算所述当前区块对应的目标标识值;及Changing the identification value to be queried to a pre-stored target value, and calculating the target identification value corresponding to the current block according to the target value and the data to be recorded; and
    将所述当前标识值更改为所述目标标识值,使得所述当前区块作为初始区块,并根据所述初始区块生成更新区块链。The current identification value is changed to the target identification value, so that the current block is used as an initial block, and an update blockchain is generated according to the initial block.
  2. 根据权利要求1所述的方法,其中,所述将所述当前标识值更改为所述目标标识值,使得所述当前区块作为初始区块,并根据所述初始区块生成更新区块链之后,所述方法还包括:The method according to claim 1, wherein the changing the current identification value to the target identification value makes the current block an initial block, and an update blockchain is generated according to the initial block After that, the method further includes:
    提取不同区块链对应的区块链生成时间,并获取当前系统时间;Extract the block chain generation time corresponding to different block chains, and obtain the current system time;
    根据所述区块链生成时间以及当前系统时间计算数据存储时长;及Calculate the data storage duration according to the generation time of the blockchain and the current system time; and
    当所述数据存储时长超过预设时长时,则查询超过所述预设时长的所述数据存储时长所对应的待删除区块,并将所述待删除区块删除。When the data storage duration exceeds the preset duration, query the block to be deleted corresponding to the data storage duration that exceeds the preset duration, and delete the block to be deleted.
  3. 根据权利要求2所述的方法,其中,所述查询超过所述预设时长的所述数据存储时长所对应的待删除区块,并将所述待删除区块删除,包括:The method according to claim 2, wherein the querying the block to be deleted corresponding to the data storage duration exceeding the preset duration, and deleting the block to be deleted comprises:
    查询超过所述预设时长的所述数据存储时长对应的待删除初始区块,并查询与所述待删除初始区块连接的待删除关联区块;及Query the initial block to be deleted corresponding to the data storage duration that exceeds the preset duration, and query the associated block to be deleted connected to the initial block to be deleted; and
    将所述待删除初始区块与所述待删除关联区块进行删除。The initial block to be deleted and the associated block to be deleted are deleted.
  4. 根据权利要求3所述的方法,其中,所述查询与所述待删除初始区块连接的待删除关联区块之后,所述方法还包括:The method according to claim 3, wherein, after the query of the associated block to be deleted connected to the initial block to be deleted, the method further comprises:
    获取待删除关联区块中包含的第一生成时间,并获取待删除初始区块中包含的第二生成时间;Obtaining the first generation time contained in the associated block to be deleted, and obtaining the second generation time contained in the initial block to be deleted;
    判断所述第一生成时间与所述第二生成时间的差值是否在预设差值范围内;及Determine whether the difference between the first generation time and the second generation time is within a preset difference range; and
    当所述差值未在预设差值范围内时,则输出核查信息。When the difference value is not within the preset difference value range, output verification information.
  5. 根据权利要求1所述的方法,其中,所述获取所述当前区块链对应的区块连接时间范围,并查询所述当前区块生成时间是否在所述区块连接时间范围内之后,所述方法还包括:The method according to claim 1, wherein said obtaining the block connection time range corresponding to the current block chain, and querying whether the current block generation time is after the block connection time range, The method also includes:
    当所述当前区块生成时间在所述区块连接时间范围内时,则获取所述当前区块连接时间范围对应的当前区块链中的所述目标结尾区块;及When the current block generation time is within the block connection time range, acquiring the target end block in the current blockchain corresponding to the current block connection time range; and
    将所述当前区块与所述目标结尾区块进行连接。Connecting the current block with the target ending block.
  6. 根据权利要求5所述的方法,其中,所述将所述当前区块与所述目标结尾区块进行连接,包括:The method according to claim 5, wherein the connecting the current block with the target ending block comprises:
    将所述当前区块发送至背书节点进行验证;Sending the current block to the endorsing node for verification;
    接收所述背书节点对所述当前区块进行验证的验证结果;及Receiving the verification result of the endorsing node verifying the current block; and
    当所述验证结果为验证通过时,则将所述当前区块与所述目标结尾区块进行连接。When the verification result is that the verification is passed, the current block is connected with the target ending block.
  7. 一种数据存储装置,包括:A data storage device includes:
    当前区块接收模块,用于将待记录数据存储至当前区块,所述当前区块包含当前区块生成时间以及当前区块对应的当前标识值;The current block receiving module is configured to store the data to be recorded in the current block, the current block including the generation time of the current block and the current identification value corresponding to the current block;
    提取模块,用于查询与当前区块关联的目标结尾区块,根据所述目标结尾区块提取当前区块链;The extraction module is used to query the target ending block associated with the current block, and extract the current blockchain according to the target ending block;
    第一获取模块,用于获取所述当前区块链对应的区块连接时间范围,并查询所述当前区块生成时间是否在所述区块连接时间范围内;The first obtaining module is configured to obtain the block connection time range corresponding to the current block chain, and query whether the current block generation time is within the block connection time range;
    第二获取模块,用于当所述当前区块生成时间未在所述区块连接时间范围中时,则获取所述当前区块中包含的与目标结尾区块所对应的待查询标识值;The second obtaining module is configured to obtain the identification value to be queried corresponding to the target ending block contained in the current block when the current block generation time is not within the block connection time range;
    计算模块,用于将所述待查询标识值更改为预存储的目标值,根据所述目标值以及所述待记录数据计算所述当前区块对应的目标标识值;及A calculation module, configured to change the identification value to be queried into a pre-stored target value, and calculate the target identification value corresponding to the current block according to the target value and the data to be recorded; and
    更改模块,用于将所述当前标识值更改为所述目标标识值,使得所述当前区块作为初始区块,并根据所述初始区块生成更新区块链。The modification module is used to change the current identification value to the target identification value, so that the current block is used as the initial block, and an update blockchain is generated according to the initial block.
  8. 根据权利要求7所述的装置,其中,所述数据存储装置,包括:The device according to claim 7, wherein the data storage device comprises:
    提取模块,用于提取不同区块链对应的区块链生成时间,并获取当前系统时间;The extraction module is used to extract the block chain generation time corresponding to different block chains, and obtain the current system time;
    时长计算模块,用于根据所述区块链生成时间以及当前系统时间计算数据存储时长;及The duration calculation module is used to calculate the data storage duration according to the generation time of the blockchain and the current system time; and
    删除模块,用于当所述数据存储时长超过预设时长时,则查询超过所述预设时长的所述数据存储时长所对应的待删除区块,并将所述待删除区块删除。The deleting module is configured to, when the data storage duration exceeds the preset duration, query the block to be deleted corresponding to the data storage duration exceeding the preset duration, and delete the block to be deleted.
  9. 一种计算机设备,包括存储器及一个或多个处理器,所述存储器中储存有计算机可读指令,所述计算机可读指令被所述一个或多个处理器执行时,使得所述一个或多个处理器执行以下步骤:A computer device includes a memory and one or more processors. The memory stores computer-readable instructions. When the computer-readable instructions are executed by the one or more processors, the one or more Each processor performs the following steps:
    将待记录数据存储至当前区块,所述当前区块包含当前区块生成时间以及当前区块对应的当前标识值;Storing the data to be recorded in a current block, the current block including the current block generation time and the current identification value corresponding to the current block;
    查询与当前区块关联的目标结尾区块,根据所述目标结尾区块提取当前区块链;Query the target ending block associated with the current block, and extract the current blockchain according to the target ending block;
    获取所述当前区块链对应的区块连接时间范围,并查询所述当前区块生成时间是否在所述区块连接时间范围内;Obtain the block connection time range corresponding to the current block chain, and query whether the current block generation time is within the block connection time range;
    当所述当前区块生成时间未在所述区块连接时间范围中时,则获取所述当前区块中包含的与所述目标结尾区块所对应的待查询标识值;When the current block generation time is not within the block connection time range, acquiring the identification value to be queried corresponding to the target end block included in the current block;
    将所述待查询标识值更改为预存储的目标值,根据所述目标值以及所述待记录数据计算所述当前区块对应的目标标识值;及Changing the identification value to be queried to a pre-stored target value, and calculating the target identification value corresponding to the current block according to the target value and the data to be recorded; and
    将所述当前标识值更改为所述目标标识值,使得所述当前区块作为初始区块,并根据所 述初始区块生成更新区块链。The current identification value is changed to the target identification value, so that the current block is used as the initial block, and an update blockchain is generated according to the initial block.
  10. 根据权利要求9所述的计算机设备,其中,所述处理器执行所述计算机可读指令时还执行以下步骤:The computer device according to claim 9, wherein the processor further executes the following steps when executing the computer readable instruction:
    提取不同区块链对应的区块链生成时间,并获取当前系统时间;Extract the block chain generation time corresponding to different block chains, and obtain the current system time;
    根据所述区块链生成时间以及当前系统时间计算数据存储时长;及Calculate the data storage duration according to the generation time of the blockchain and the current system time; and
    当所述数据存储时长超过预设时长时,则查询超过所述预设时长的所述数据存储时长所对应的待删除区块,并将所述待删除区块删除。When the data storage duration exceeds the preset duration, query the block to be deleted corresponding to the data storage duration that exceeds the preset duration, and delete the block to be deleted.
  11. 根据权利要求10所述的计算机设备,其中,所述处理器执行所述计算机可读指令时还执行以下步骤:The computer device according to claim 10, wherein the processor further executes the following steps when executing the computer-readable instructions:
    查询超过所述预设时长的所述数据存储时长对应的待删除初始区块,并查询与所述待删除初始区块连接的待删除关联区块;及Query the initial block to be deleted corresponding to the data storage duration that exceeds the preset duration, and query the associated block to be deleted connected to the initial block to be deleted; and
    将所述待删除初始区块与所述待删除关联区块进行删除。The initial block to be deleted and the associated block to be deleted are deleted.
  12. 根据权利要求11所述的计算机设备,其中,所述处理器执行所述计算机可读指令时还执行以下步骤:The computer device according to claim 11, wherein the processor further executes the following steps when executing the computer readable instruction:
    获取待删除关联区块中包含的第一生成时间,并获取待删除初始区块中包含的第二生成时间;Obtaining the first generation time contained in the associated block to be deleted, and obtaining the second generation time contained in the initial block to be deleted;
    判断所述第一生成时间与所述第二生成时间的差值是否在预设差值范围内;及Determine whether the difference between the first generation time and the second generation time is within a preset difference range; and
    当所述差值未在预设差值范围内时,则输出核查信息。When the difference value is not within the preset difference value range, output verification information.
  13. 根据权利要求9所述的计算机设备,其中,所述处理器执行所述计算机可读指令时还执行以下步骤:The computer device according to claim 9, wherein the processor further executes the following steps when executing the computer readable instruction:
    当所述当前区块生成时间在所述区块连接时间范围内时,则获取所述当前区块连接时间范围对应的当前区块链中的所述目标结尾区块;及When the current block generation time is within the block connection time range, acquiring the target end block in the current blockchain corresponding to the current block connection time range; and
    将所述当前区块与所述目标结尾区块进行连接。Connecting the current block with the target ending block.
  14. 根据权利要求13所述的计算机设备,其中,所述处理器执行所述计算机可读指令时还执行以下步骤:The computer device according to claim 13, wherein the processor further executes the following steps when executing the computer readable instruction:
    将所述当前区块发送至背书节点进行验证;Sending the current block to the endorsing node for verification;
    接收所述背书节点对所述当前区块进行验证的验证结果;及Receiving the verification result of the endorsing node verifying the current block; and
    当所述验证结果为验证通过时,则将所述当前区块与所述目标结尾区块进行连接。When the verification result is that the verification is passed, the current block is connected with the target ending block.
  15. 一个或多个存储有计算机可读指令的计算机可读存储介质,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器执行以下步骤:One or more computer-readable storage media storing computer-readable instructions, which when executed by one or more processors, cause the one or more processors to perform the following steps:
    将待记录数据存储至当前区块,所述当前区块包含当前区块生成时间以及当前区块对应的当前标识值;Storing the data to be recorded in a current block, the current block including the current block generation time and the current identification value corresponding to the current block;
    查询与当前区块关联的目标结尾区块,根据所述目标结尾区块提取当前区块链;Query the target ending block associated with the current block, and extract the current blockchain according to the target ending block;
    获取所述当前区块链对应的区块连接时间范围,并查询所述当前区块生成时间是否在所述区块连接时间范围内;Obtain the block connection time range corresponding to the current block chain, and query whether the current block generation time is within the block connection time range;
    当所述当前区块生成时间未在所述区块连接时间范围中时,则获取所述当前区块中包含 的与所述目标结尾区块所对应的待查询标识值;When the current block generation time is not within the block connection time range, acquiring the identification value to be queried corresponding to the target ending block contained in the current block;
    将所述待查询标识值更改为预存储的目标值,根据所述目标值以及所述待记录数据计算所述当前区块对应的目标标识值;及Changing the identification value to be queried to a pre-stored target value, and calculating the target identification value corresponding to the current block according to the target value and the data to be recorded; and
    将所述当前标识值更改为所述目标标识值,使得所述当前区块作为初始区块,并根据所述初始区块生成更新区块链。The current identification value is changed to the target identification value, so that the current block is used as an initial block, and an update blockchain is generated according to the initial block.
  16. 根据权利要求15所述的存储介质,其中,所述计算机可读指令被所述处理器执行时还执行以下步骤:The storage medium according to claim 15, wherein the following steps are further performed when the computer-readable instructions are executed by the processor:
    提取不同区块链对应的区块链生成时间,并获取当前系统时间;Extract the block chain generation time corresponding to different block chains, and obtain the current system time;
    根据所述区块链生成时间以及当前系统时间计算数据存储时长;及Calculate the data storage duration according to the generation time of the blockchain and the current system time; and
    当所述数据存储时长超过预设时长时,则查询超过所述预设时长的所述数据存储时长所对应的待删除区块,并将所述待删除区块删除。When the data storage duration exceeds the preset duration, query the block to be deleted corresponding to the data storage duration that exceeds the preset duration, and delete the block to be deleted.
  17. 根据权利要求16所述的存储介质,其中,所述计算机可读指令被所述处理器执行时还执行以下步骤:The storage medium according to claim 16, wherein the following steps are further performed when the computer-readable instructions are executed by the processor:
    查询超过所述预设时长的所述数据存储时长对应的待删除初始区块,并查询与所述待删除初始区块连接的待删除关联区块;及Query the initial block to be deleted corresponding to the data storage duration that exceeds the preset duration, and query the associated block to be deleted connected to the initial block to be deleted; and
    将所述待删除初始区块与所述待删除关联区块进行删除。The initial block to be deleted and the associated block to be deleted are deleted.
  18. 根据权利要求17所述的存储介质,其中,所述计算机可读指令被所述处理器执行时还执行以下步骤:The storage medium according to claim 17, wherein the following steps are further performed when the computer-readable instructions are executed by the processor:
    获取待删除关联区块中包含的第一生成时间,并获取待删除初始区块中包含的第二生成时间;Obtaining the first generation time contained in the associated block to be deleted, and obtaining the second generation time contained in the initial block to be deleted;
    判断所述第一生成时间与所述第二生成时间的差值是否在预设差值范围内;及Determine whether the difference between the first generation time and the second generation time is within a preset difference range; and
    当所述差值未在预设差值范围内时,则输出核查信息。When the difference value is not within the preset difference value range, output verification information.
  19. 根据权利要求15所述的存储介质,其中,所述计算机可读指令被所述处理器执行时还执行以下步骤:The storage medium according to claim 15, wherein the following steps are further performed when the computer-readable instructions are executed by the processor:
    当所述当前区块生成时间在所述区块连接时间范围内时,则获取所述当前区块连接时间范围对应的当前区块链中的所述目标结尾区块;及When the current block generation time is within the block connection time range, acquiring the target end block in the current blockchain corresponding to the current block connection time range; and
    将所述当前区块与所述目标结尾区块进行连接。Connecting the current block with the target ending block.
  20. 根据权利要求19所述的存储介质,其中,所述计算机可读指令被所述处理器执行时还执行以下步骤:The storage medium according to claim 19, wherein the following steps are further performed when the computer-readable instructions are executed by the processor:
    将所述当前区块发送至背书节点进行验证;Sending the current block to the endorsing node for verification;
    接收所述背书节点对所述当前区块进行验证的验证结果;及Receiving the verification result of the endorsing node verifying the current block; and
    当所述验证结果为验证通过时,则将所述当前区块与所述目标结尾区块进行连接。When the verification result is that the verification is passed, the current block is connected with the target ending block.
PCT/CN2020/099213 2019-07-25 2020-06-30 Data storage method and apparatus, computer device, and storage medium WO2021012903A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910677577.9 2019-07-25
CN201910677577.9A CN110569240B (en) 2019-07-25 2019-07-25 Data storage method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
WO2021012903A1 true WO2021012903A1 (en) 2021-01-28

Family

ID=68773797

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/099213 WO2021012903A1 (en) 2019-07-25 2020-06-30 Data storage method and apparatus, computer device, and storage medium

Country Status (2)

Country Link
CN (1) CN110569240B (en)
WO (1) WO2021012903A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110569240B (en) * 2019-07-25 2023-04-07 平安科技(深圳)有限公司 Data storage method and device, computer equipment and storage medium
CN111552687B (en) * 2020-03-10 2023-08-04 远景智能国际私人投资有限公司 Time sequence data storage method, query method, device, equipment and storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107527285A (en) * 2016-06-20 2017-12-29 惠众商务顾问(北京)有限公司 The polymorphic link of community's block chain and Intelligent processing system
CN108985790A (en) * 2018-06-25 2018-12-11 平安科技(深圳)有限公司 Method for anti-counterfeit, system, computer equipment and storage medium based on block chain
CN109447635A (en) * 2018-10-15 2019-03-08 北京京东尚科信息技术有限公司 Information storage means and device for block chain
CN109472566A (en) * 2018-09-26 2019-03-15 平安科技(深圳)有限公司 Block dynamic creation method, device, computer equipment and storage medium
CN109815226A (en) * 2018-12-13 2019-05-28 平安科技(深圳)有限公司 Date storage method, device, equipment and storage medium based on block chain
CN109886693A (en) * 2019-03-13 2019-06-14 百度在线网络技术(北京)有限公司 Common recognition implementation method, device, equipment and the medium of block catenary system
CN110569240A (en) * 2019-07-25 2019-12-13 平安科技(深圳)有限公司 Data storage method and device, computer equipment and storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106651332B (en) * 2016-12-29 2020-11-06 成都质数斯达克科技有限公司 Method for generating new block in block chain and block chain

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107527285A (en) * 2016-06-20 2017-12-29 惠众商务顾问(北京)有限公司 The polymorphic link of community's block chain and Intelligent processing system
CN108985790A (en) * 2018-06-25 2018-12-11 平安科技(深圳)有限公司 Method for anti-counterfeit, system, computer equipment and storage medium based on block chain
CN109472566A (en) * 2018-09-26 2019-03-15 平安科技(深圳)有限公司 Block dynamic creation method, device, computer equipment and storage medium
CN109447635A (en) * 2018-10-15 2019-03-08 北京京东尚科信息技术有限公司 Information storage means and device for block chain
CN109815226A (en) * 2018-12-13 2019-05-28 平安科技(深圳)有限公司 Date storage method, device, equipment and storage medium based on block chain
CN109886693A (en) * 2019-03-13 2019-06-14 百度在线网络技术(北京)有限公司 Common recognition implementation method, device, equipment and the medium of block catenary system
CN110569240A (en) * 2019-07-25 2019-12-13 平安科技(深圳)有限公司 Data storage method and device, computer equipment and storage medium

Also Published As

Publication number Publication date
CN110569240B (en) 2023-04-07
CN110569240A (en) 2019-12-13

Similar Documents

Publication Publication Date Title
US11182366B2 (en) Comparing data stores using hash sums on disparate parallel systems
WO2019200756A1 (en) Data examination and approval method and apparatus, computer device and storage medium
CN109474578B (en) Message checking method, device, computer equipment and storage medium
WO2021012571A9 (en) Data processing method and apparatus, computer device, and storage medium
WO2021003980A1 (en) Blacklist sharing method and apparatus, computer device and storage medium
CN109492983B (en) Electronic seal signing method, device, equipment and medium based on block chain intelligent contract
WO2021203586A1 (en) Method and device for processing customs declaration data, computer device, and storage medium
CN111027295B (en) Data processing method, device, computer equipment and storage medium
WO2020244239A1 (en) Index creation method, apparatus and device based on service identifier
WO2019214080A1 (en) Approval information processing method and apparatus, computer device, and storage medium
WO2021164161A1 (en) Image data labeling method and apparatus, and computer device and storage medium
CN112035472B (en) Data processing method, device, computer equipment and storage medium
WO2021012903A1 (en) Data storage method and apparatus, computer device, and storage medium
CN111314172B (en) Block chain-based data processing method, device, equipment and storage medium
WO2019200741A1 (en) Project evaluation information processing method and apparatus, computer device, and storage medium
WO2019227576A1 (en) Invoice verification method and apparatus, computer device, and storage medium
CN111563365A (en) Test standard work order modification information processing method and device and computer equipment
CN110597820A (en) Block chain based information processing method and device, storage medium and equipment
CN110598475A (en) Block chain-based work attribute information acquisition method and device and computer equipment
CN109918451A (en) Data base management method and system based on block chain
CN111858467B (en) File data processing method, device, equipment and medium based on artificial intelligence
WO2019200754A1 (en) Data transmission risk evaluation method and apparatus, computer device, and storage medium
WO2020108106A1 (en) Blockchain-based resource object allocation method and apparatus and electronic device
CN116910820A (en) Data report processing method, device, computer equipment and storage medium
US11381401B2 (en) Blockchain transaction forwarding

Legal Events

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

Ref document number: 20844776

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20844776

Country of ref document: EP

Kind code of ref document: A1