Dual-chain storage method, system, equipment, storage medium and program in cold chain logistics
By adopting dual-chain storage method and alliance chain sharding technology in the blockchain, a relational data table structure is established, which solves the performance bottleneck and insufficient data storage problems of single-chain blockchain in cold chain logistics, and achieves efficient data Query and traceability ensure the data credibility and consistency of cold chain logistics.
Patent Information
- Application Number
- CN202410236362.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-01
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2044-03-01
AI Technical Summary
Existing blockchain technology has performance bottlenecks in cold chain logistics. The single-chain blockchain structure causes performance degradation when transaction throughput increases, and cannot meet the rapid query and traceability needs of cold chain logistics.
Adopt a dual-chain storage method, allocate blocks and shards through the alliance chain, establish an off-chain relationship data table, map blocks and transaction relationships, form a relationship data table structure, and combine the Internet of Things and Internet technology to achieve real-time monitoring and traceability.
It improves the data query efficiency and storage capacity of cold chain logistics, meets business needs, ensures the credibility and consistency of data, and realizes the trusted transportation identification of cold chain logistics.
Smart Images

Figure CN118278839B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain technology, and in particular to a double-chain storage method, system, equipment, storage medium and program in cold chain logistics. Background Art
[0002] With the development of the economy, people's demand for cold chain logistics has gradually increased, involving specific transportation objects such as food, agricultural products, seafood, fresh products, pharmaceutical products, biological samples, etc., which are related to all aspects of people's lives. At the same time, the problems exposed are mainly reflected in the high proportion of broken chains (60%) and poor process supervision.
[0003] In essence, blockchain technology is a distributed, decentralized database system. Unlike traditional centralized databases, it does not have a central authority, but is maintained and managed by a network of many nodes. These nodes are equal, and no node can control the entire system, nor can any node unilaterally change data records. Therefore, each participant in the blockchain network needs to be responsible for his or her own behavior, which also means that the transaction data of the participants is non-repudiable, thereby achieving non-repudiation of transactions. In the blockchain, a variety of encryption algorithms are used to protect the security of account information and privacy in each node. The more common encryption algorithms use public and private keys to encrypt and decrypt information, which can ensure the security of information. This encryption method is also called asymmetric encryption. In addition, the blockchain also uses a consensus mechanism to ensure the reliability of transaction records. Only when a consensus is reached on a transaction on multiple nodes will the transaction be recognized and recorded in the blockchain, thereby ensuring the authenticity and validity of the transaction record.
[0004] Compared with the traditional Internet, the biggest difference of blockchain is its ability to transmit information. When blockchain is regarded as a means of storing information, it has a distributed feature compared with the traditional centralized database, which greatly reduces the possibility of data loss and ensures that the data is difficult to tamper with. Blockchain technology has strong scalability. It can be used in combination with various traditional disciplines to develop different application frameworks, improve the data and algorithms of the entire system, and raise the credibility to a higher level.
[0005] According to the existing patent documents, the blockchain technology used in the cold chain logistics transportation process mainly uses the blockchain technology based on the public chain, which is also a truly decentralized blockchain principle and method. This method uses a decentralized distributed accounting system, in which all participating nodes do not need to trust each other, and all maintain the same account book through a unique consensus rule. Unlike the B / S-based business system, all nodes in the blockchain are independent and each backs up a complete copy of the chain data history record information. At the same time, all transaction data will be re-verified by all nodes, forming a new peer-to-peer network (p2p) structure.
[0006] The main consensus mechanism of the public chain is the Proof of Work (POW) mechanism. The core of this algorithm is that after each node in the blockchain conducts transactions with other nodes, its transaction records must be recorded and stored by all nodes in the network. In order to ensure fairness among all nodes in the competition, the POW mechanism introduces the concept of risk-return ratio in economics. All nodes need to calculate a hash algorithm of a certain difficulty to prove their workload measurement before they can obtain the right to hang on the chain of the new block. Each node also needs to calculate the cumulative computing power of the longest chain before it can obtain this right. This is not applicable to the current timeliness and energy saving and efficiency improvement of the Internet of Things.
[0007] Another consensus mechanism is the Byzantine Fault Tolerance (BFT) mechanism based on the Byzantine Generals' Problem. The most widely used one is the Practical Byzantine Fault Tolerance (PBFT) mechanism. All nodes need to complete the negotiation process, which is divided into three stages: pre-preparation, preparation, and confirmation. By introducing a view concept, the transaction initiating node is set as the main (proposing) node, and the negotiation process between all nodes is completed under the same view. Obviously, with the surge in the number of nodes, the complexity of communication between nodes will surge, and the communication efficiency will be greatly reduced, which is also not suitable for the needs of the Internet of Things.
[0008] The above-mentioned POW mechanism and BFT mechanism both belong to the single-chain blockchain structure. Due to the characteristics of the single-chain structure, this type of ledger is prone to performance bottlenecks. The single-chain blockchain ledger uses a single-chain sequence to sort the transactions that occur. When the block size, consensus protocol, and network load are fixed, the scale of consensus messages in the system increases at O(n) with the transaction throughput. When the transactions sent exceed the system load, a large number of transactions will accumulate, causing a large number of transactions to wait for encapsulation into blocks, indirectly reducing the performance of the blockchain. Therefore, the single-chain blockchain ledger structure has become an important bottleneck for improving the performance of the alliance chain system. Summary of the invention
[0009] In view of this, an embodiment of the present disclosure provides a double-chain storage method in cold chain logistics, which at least partially solves the problems existing in the prior art.
[0010] In a first aspect, an embodiment of the present disclosure provides a double-chain storage method in cold chain logistics, the method comprising the following steps:
[0011] The cold chain logistics enterprise applies to join the alliance chain. After confirmation by the management agency, the CA certification is issued to the cold chain logistics enterprise. The alliance chain allocates a new block to the cold chain logistics enterprise and determines the shard where the block is located.
[0012] The newly added block and the detailed data of the cold chain logistics enterprise are stored in the user table of the off-chain relationship data table;
[0013] Establishing a mapping relationship between the newly added blocks and the transaction relationship;
[0014] When an intermodal delivery process occurs during cold chain transportation, it is equivalent to a transaction link in the blockchain, including: adding a new transaction record to the cold chain logistics transportation delivery data table with the primary key trad_id in the transaction table, and the primary key deli_id of the cold chain logistics transportation delivery data table in the transaction record corresponds to the primary key trad_id in the transaction table; at the same time, the user number user_id of the two parties to the transaction in this record is consistent with the user number in the transaction table, ensuring the consistency of the transaction object and the account book data of the dual data of this transaction.
[0015] According to a specific implementation of the embodiment of the present disclosure, a mapping relationship is established between the newly added block and the transaction relationship, including:
[0016] The timestamp, random number, and public key information in the newly added block header are combined and stored in the bloc_id field in the offline relational data table block table as the primary key PK. At the same time, the timestamp in the newly added block header is recorded in the bloc_time of the block table; the foreign key slice_id is added to the block table synchronously, mapped to the primary key CT_slice in the shard snapshot table CT_slice;
[0017] When logistics delivery occurs during cold chain transportation, transactions occur within or between consortium chain shards; the off-chain transaction data will be stored and mapped in the transaction table, and the merkle tree ledger record sequence value of each transaction will be decomposed from the on-chain block ledger and recorded in the primary key trad_id of the transaction table, representing a transaction; at the same time, in the transaction binary number, the bloc_id of the blocks of both parties to the transaction are recorded in the two foreign keys bloc_id_A and bloc_id_B of the transaction table, thereby forming a data mapping relationship between the relational data table block table and the transaction table;
[0018] When the sharded blockchain enters the snapshot period from the consensus period, the merkle tree root node sequence data recorded in the sharded ledger will be synchronously stored in the primary key slice_id in the off-chain relational data table shard snapshot table, and the shard snapshot timestamp data will be synchronously stored in the slice_time of the shard snapshot table; the sharded ledger data formed by the current slice snapshot content will be recorded in the snapshot field of the shard snapshot table;
[0019] During the shard block global snapshot synchronization period, after the global shard block consensus is confirmed, the newly formed global snapshot will be synchronously recorded and stored in the primary key field all_id of the global snapshot table of the off-chain relationship data table. The serial number of the merkle tree root node in the shard and the cross-shard merkle tree root node will be recorded in all_id. The generation timestamp all_time of the global snapshot will be stored synchronously, and the global ledger data of this global snapshot will be stored in the overall field of the global snapshot table.
[0020] According to a specific implementation of the embodiment of the present disclosure, storing the newly added block and the detailed data of the cold chain logistics enterprise in the user table of the off-chain relationship data table includes:
[0021] The CA authentication sequence data of the cold chain logistics enterprise is stored in the user table with the primary key user_id field, and the timestamp, random number and public key information in the newly added block header are fixed to form a unique user table user_id primary key data.
[0022] According to a specific implementation method of the embodiment of the present disclosure, the detailed data of the cold chain logistics enterprise includes: registration time, address, enterprise scale and registered capital.
[0023] According to a specific implementation method of an embodiment of the present disclosure, the off-chain relationship data table includes a business data table and an on-chain data and off-chain data relationship conversion table; wherein the business data table includes: a user table, a cargo table, a cold chain logistics transportation table, and a cold chain logistics transportation delivery data table; the on-chain data and off-chain data relationship conversion table includes: a block table, a transaction table, a shard snapshot table, and a global snapshot table.
[0024] According to a specific implementation method of an embodiment of the present disclosure, the transaction link in the blockchain is a transaction process between different nodes / blocks, including transactions within the same regional shard and cross-regional shard transactions.
[0025] In a second aspect, an embodiment of the present disclosure provides a double-chain storage system in cold chain logistics, the system comprising:
[0026] The chain module is configured to be used by cold chain logistics enterprises to apply to join the alliance chain. After confirmation by the management agency, the CA certification is issued to the cold chain logistics enterprise. The alliance chain allocates a new block to the cold chain logistics enterprise and determines the shard where the block is located; and
[0027] The newly added block and the detailed data of the cold chain logistics enterprise are stored in the user table of the off-chain relationship data table;
[0028] A mapping module, configured to establish a mapping relationship between the newly added block and the transaction relationship;
[0029] The synchronization module is configured to be used when an intermodal delivery process occurs during the cold chain transportation process, which is equivalent to the transaction link in the blockchain, including: adding a transaction record to the cold chain logistics transportation delivery data table with the primary key trad_id in the transaction table, and the primary key deli_id of the cold chain logistics transportation delivery data table in the transaction record corresponds to the primary key trali_id in the transaction table; at the same time, the user number user_id of the two parties to the transaction in this record is consistent with the user number in the transaction table, ensuring the consistency of the transaction object and the account book data of the dual data of this transaction.
[0030] In a third aspect, an embodiment of the present disclosure further provides an electronic device, the electronic device comprising:
[0031] at least one processor; and,
[0032] a memory communicatively connected to the at least one processor; wherein,
[0033] The memory stores instructions that can be executed by the at least one processor. When the instructions are executed by the at least one processor, the at least one processor implements the double-chain storage method in cold chain logistics as described in any one of the first aspect or any one of the implementations of the first aspect.
[0034] In a fourth aspect, an embodiment of the present disclosure further provides a non-transitory computer-readable storage medium, which stores computer instructions, and when the computer instructions are executed by at least one processor, the at least one processor executes the double-chain storage method in cold chain logistics in the aforementioned first aspect or any implementation of the first aspect.
[0035] In the fifth aspect, the embodiments of the present disclosure also provide a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer executes the double-chain storage method in cold chain logistics in the aforementioned first aspect or any implementation of the first aspect.
[0036] The dual-chain storage method in cold chain logistics in the disclosed embodiment, through the dual-chain storage technology based on the alliance chain, solves the problems that the alliance chain file structure data cannot support the most widely used relational database SQL query, does not support index, fuzzy query, aggregate query, TOPK query, etc., and solves the specific problems that the storage structure of the alliance chain cannot meet the needs of fast query and traceability, and the storage capacity cannot meet the actual business needs. By adding a dual-chain data storage mode to the blockchain layer of the alliance chain, by deconstructing the file data on the chain, a relational table of the data file on the chain is formed, and together with the cold chain transportation business relational data table under the chain, a package of relational data table structures is formed, which is used to process the alliance user identity identification contract, electronic waybill contract, and cold chain transportation process data in the cold chain transportation process. Since user identity, electronic waybills and transportation processes in cold chain transportation are quantifiable and calculable digital standard processes, the programmable characteristics of the application layer can be used to distribute and store the off-chain relationship data of the blockchain layer in the database server. Combined with the Internet of Things, Internet technology, cloud computing and other technologies, especially the real-time monitoring of the time, temperature, humidity and path of logistics objects collected by the Internet of Things sensing terminals during the transportation process, it is more conducive to the third-party monitoring agencies to carry out trusted transportation certification work in the cold chain logistics process. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] The above is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0038] Figure 1 A schematic diagram of a double-chain storage method in cold chain logistics provided by an embodiment of the present disclosure;
[0039] Figure 2 A flowchart of a double-chain storage method in cold chain logistics provided by an embodiment of the present disclosure;
[0040] Figure 3 A schematic diagram of the structure of a double-chain storage system in cold chain logistics provided by an embodiment of the present disclosure; and
[0041] Figure 4 A schematic diagram of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0042] The embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.
[0043] The following describes the embodiments of the present disclosure through specific examples, and those skilled in the art can easily understand other advantages and effects of the present disclosure from the contents disclosed in this specification. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, rather than all of the embodiments. The present disclosure can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present disclosure. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present disclosure.
[0044] It should be noted that various aspects of the embodiments within the scope of the appended claims are described below. It should be apparent that the aspects described herein may be embodied in a wide variety of forms, and any specific structure and / or function described herein is merely illustrative. Based on the present disclosure, it should be understood by those skilled in the art that an aspect described herein may be implemented independently of any other aspect, and two or more of these aspects may be combined in various ways. For example, any number of aspects described herein may be used to implement a device and / or practice a method. In addition, other structures and / or functionalities other than one or more of the aspects described herein may be used to implement this device and / or practice this method.
[0045] Additionally, in the following description, specific details are provided to facilitate a thorough understanding of the examples. However, it will be understood by those skilled in the art that the aspects described may be practiced without these specific details.
[0046] With the development of the economy, people's demand for cold chain logistics has gradually increased, involving specific transportation objects such as food, agricultural products, seafood, fresh products, pharmaceutical products, biological samples, etc., which are related to all aspects of people's lives. The problems exposed are mainly reflected in the high proportion of broken chains (60%) and poor process supervision. It is necessary to establish a national imported cold chain food traceability management platform to realize cold chain information sharing, so that the source of cold chain logistics can be traced, the process can be controlled, and the destination can be checked.
[0047] At present, a large number of modern information means and technologies are used in cold chain logistics to solve the digital management problems of temperature, humidity, temperature control, vehicle trajectory, and electronic bills in the logistics process. At the same time, a variety of communication means are used to collect data information content, and database technology and big data technology are combined to explore and analyze existing data. However, the main means is still to manage cold chain logistics information through a centralized data management model and implement supervision by enterprises and regulatory departments, and improve the intelligence level of cold chain logistics. However, in this type of centralized data solution, the management process is completed independently by cold chain logistics companies, and regulatory units only obtain enterprise data content through third-party interfaces, resulting in "trust issues" as the core problem:
[0048] 1. Data trust issues in the cold chain transportation process, such as data tampering and data falsification;
[0049] 2. Trust issues in operational data during cold chain transportation, such as falsifying sensor temperature, shutting down refrigerants, and creating pseudo full-process cold chains by OD point refrigeration in order to save costs;
[0050] 3. Trust issues in cold chain data storage. The ownership of data belongs to logistics companies, which makes it difficult for government regulatory authorities and third-party testing agencies to conduct convenient cold chain traceability management.
[0051] 4. Cold chain data islands emerge. From the perspective of the entire cold chain transportation industry chain, the transportation process data is owned by scattered cold chain transportation companies, and it is difficult to analyze the entire transportation process of a specific cold chain case from the perspective of a transportation company;
[0052] 5. The responsibility for production safety cannot be determined. Especially for multimodal transport and drop-and-hook container cold chain transport, once there are production problems in the transportation of cold chain goods, food, and medicine, it is difficult to determine the responsibility.
[0053] The safety of cold chain transportation is related to the health of the people and social trust. Blockchain technology can realize the traceability of the upstream and downstream supply chains of cold chain transportation products, which is of great significance in solving the safety problems of cold chain products. The decentralization and cryptographic basis of blockchain can build a secure database and network system for the entire supply chain, effectively prevent the forgery and tampering of information, provide reference and guidance for practical applications, enrich the cold chain logistics traceability system based on blockchain technology, and have strong theoretical innovation. At the same time, the decentralized, tamper-proof, open, transparent and multi-party consensus characteristics of blockchain fully make up for the isolated defects of the cold chain transportation Internet of Things: its decentralized and multi-centralized characteristics can not only effectively reduce the high operation and maintenance costs of the centralized architecture, but also avoid the manipulation caused by the monopoly of giants in the data network; the asymmetric encryption used by blockchain can not only effectively protect data privacy, but also effectively confirm data ownership, realize network identity authority management, and identify malicious nodes through multi-party consensus: blockchain relies on its chain structure to build traceable, tamper-proof, open and transparent electronic evidence, and uses multi-party consensus to ensure the accuracy, consistency and integrity of Internet of Things data; the distributed architecture and subject equality characteristics of blockchain not only help to weaken the security performance impact of centralized servers, but also help to break the shackles of information islands in the Internet of Things and promote horizontal data flow and multi-party collaboration.
[0054] The essence of the alliance chain data storage is a storage mode associated with the file system. The ordering relationship between blocks is determined by the uniqueness of the block header, which can be considered as a chain code relationship between block files. Therefore, the block header can be regarded as a key-value pair code chain file system of the relational database. The system forms a tree-structured data structure. The Merkle tree of the alliance chain structure is an important component of the definition of the chain code relationship in the block header, forming a binary tree structure of log files. With the expansion of the scale of the alliance chain, this type of file structure cannot support the most widely used SQL query, does not support indexing, fuzzy query, aggregation query, TOPK query, etc., so it is difficult to achieve complex business search, data analysis, data mining, etc. in relational databases for high-value applications.
[0055] On the other hand, the storage structure of blockchain determines that its data definition and storage capacity cannot meet the actual business needs, and it cannot provide rich support for multiple development interfaces, which greatly limits the actual application and business development of the alliance chain.
[0056] The present invention adds a dual-chain data storage mode to the blockchain layer of the alliance chain, and forms a relational table of the on-chain data file by deconstructing the on-chain file data, which together with the off-chain cold chain transportation business relational data table constitutes a package of relational data table structures, which are used to process the alliance user identity identification contract, electronic waybill contract, and cold chain transportation process data in the cold chain transportation process. Since the user identity, electronic waybill, and transportation process in cold chain transportation are quantifiable and calculable digital standard processes, the programmable characteristics of the application layer can be used to distribute the off-chain relational data of the blockchain layer and the database server, combined with the Internet of Things, Internet technology, cloud computing and other technologies, especially for the time, temperature, humidity, and path monitoring of logistics objects collected by the Internet of Things sensing terminal during the transportation process. It has real-time characteristics, which is more conducive to the third-party monitoring agency to carry out trusted transportation certification work for the cold chain logistics process.
[0057] The embodiment of the present invention provides a dual-chain storage method in cold chain logistics. Through the dual-chain storage technology based on the alliance chain, it solves the problems that the alliance chain file structure data cannot support the most widely used relational database SQL query, does not support indexing, fuzzy query, aggregation query, TOPK query, etc., and solves the specific problems that the storage structure of the alliance chain cannot meet the needs of fast query and traceability, and the storage capacity cannot meet the actual business needs.
[0058] The off-chain data of the alliance chain mainly completes the relational data transformation of the on-chain data and maintains persistent storage. From the perspective of the online data storage relationship of the alliance chain, it can be divided into static data and dynamic data. Static data includes block basic data, which represents the basic content of the corresponding alliance unit once it is on the chain; dynamic data includes block header data, delivery data, status data, etc.
[0059] From the perspective of relational database data table classification, the offline data tables of the alliance chain are divided into two categories: one is the business data table, including user table, cargo table, cold chain logistics transportation table, cold chain logistics transportation delivery data table, etc. This type of data is convenient for business expansion, providing complex business query operations of relational databases, and can expand the table structure according to business needs, perform complex SQL operations, and establish data warehouses, perform data mining and analysis, etc. The other is the conversion table between on-chain data and off-chain data, including block table, transaction table, shard snapshot table, global snapshot table, etc. This part of the data table mainly completes the table structure storage with on-chain data, and realizes the relationship mapping with offline relationship tables.
[0060] Figure 1 A schematic diagram of the process of a double-chain storage method in cold chain logistics provided in an embodiment of the present disclosure.
[0061] Figure 2 For Figure 1Corresponding flow chart of the double-chain storage method in cold chain logistics.
[0062] like Figure 1 As shown, at step S110, the cold chain logistics enterprise applies to join the alliance chain. After confirmation by the management agency, a CA certification is issued to the cold chain logistics enterprise. The alliance chain allocates a new block to the cold chain logistics enterprise and determines the shard where the block is located.
[0063] More specifically, in the chain stage, each cold chain logistics enterprise applies to join the alliance chain through the alliance chain management agency, and the management agency issues CA certification to the specific cold chain logistics enterprise after confirmation. During the registration process, the alliance chain will allocate a new block to the enterprise and determine the shard where the block is located. At the same time, the detailed data of the cold chain enterprise in the newly added block will be stored in the user table of the off-chain relationship data table. Specifically, the CA certification sequence data of the enterprise is stored in the user table with the primary key user_id field, and the timestamp, random number, and public key information in the newly added block header are fixed to form a unique user table user_id primary key data. This stage completes the relationship mapping between the newly added users off-chain and the newly added blocks in the blockchain, and also facilitates the collection of detailed information of specific users, including registration time, address, enterprise size, registered capital and other details, which facilitates the development and use of offline data.
[0064] More specifically, the process proceeds to step S120.
[0065] In step S120, the newly added block and the detailed data of the cold chain logistics enterprise are stored in the user table of the off-chain relationship data table.
[0066] In an embodiment of the present invention, the storing of the newly added block and the detailed data of the cold chain logistics enterprise in the user table of the off-chain relationship data table includes: storing the CA authentication sequence data of the cold chain logistics enterprise in the user table with the primary key user_id field, and at the same time fixing the timestamp, random number and public key information in the newly added block header to form a unique user table user_id primary key data.
[0067] In the embodiment of the present invention, the cold chain logistics enterprise detailed data includes: registration time, address, enterprise scale and registered capital.
[0068] In an embodiment of the present invention, the off-chain relationship data table includes a business data table and an on-chain data and off-chain data relationship conversion table; wherein the business data table includes: a user table, a cargo table, a cold chain logistics transportation table, and a cold chain logistics transportation delivery data table; the on-chain data and off-chain data relationship conversion table includes: a block table, a transaction table, a shard snapshot table, and a global snapshot table.
[0069] Next, go to step S130.
[0070] In step S130, a mapping relationship is established between the newly added block and the transaction relationship.
[0071] In an embodiment of the present invention, a mapping relationship is established between the newly added block and the transaction relationship, including: storing the timestamp, random number, and public key information in the newly added block header in the bloc_id field in the block table of the offline relationship data table as the primary key PK, and recording the timestamp in the newly added block header in the bloc_time of the block table; synchronously adding the foreign key slice_id in the block table, mapping it to the primary key CT_slice in the slice snapshot table CT_slice; when logistics delivery occurs during cold chain transportation, transactions occur within or between consortium chain slices; wherein, the off-chain transaction data will be stored and mapped in the transaction table, and the merkle tree ledger record sequence value of each transaction will be decomposed from the on-chain block ledger and recorded in the primary key trad_id of the transaction table, representing a transaction; at the same time, in the transaction binary number, the bloc_id of the blocks of the two parties to the transaction are respectively recorded in the two foreign keys bloc_id_A and bloc_id_B of the transaction table, thereby forming a relationship data table area. The data mapping relationship between the block table and the transaction table; when the sharded blockchain enters the snapshot period from the consensus period, the merkle tree root node sequence data recorded in the sharded ledger will be synchronously stored in the primary key slice_id in the off-chain relational data table shard snapshot table, and the shard snapshot timestamp data will be synchronously recorded and stored in the slice_time of the shard snapshot table; the sharded ledger data formed by the current shard snapshot content will be recorded in the snapshot field of the shard snapshot table; during the sharded block global snapshot synchronization period, after the global sharded block consensus confirmation is completed, the new global snapshot formed will be synchronously recorded and stored in the primary key field all_id of the off-chain relational data table global snapshot table, all_id will record the serial number of the merkle tree root node in the shard and the cross-shard merkle tree root node, and the generation timestamp all_time of the global snapshot will be synchronously stored, and the global ledger data of this global snapshot will be stored in the overall field of the global snapshot table.
[0072] More specifically, in the block and transaction relationship mapping stage, each block corresponds to a specific network node in the blockchain. When a new block node is added, the timestamp, random number, and public key information in the new block header are combined and stored in the bloc_id field in the offline relationship data table block table, which becomes the primary key PK. At the same time, the timestamp in the new block header is recorded in the bloc_time of the block table. The foreign key slice_id is added to the block table at the same time, mapped to the primary key CT_slice in the shard snapshot table CT_slice, so as to determine which shard a specific block belongs to. When a transaction occurs within or between consortium chain shards, specifically when logistics delivery occurs during cold chain transportation, the off-chain transaction data will be stored and mapped in the transaction table. The merkle tree ledger record sequence value of each transaction is decomposed from the on-chain block ledger and recorded in the transaction table primary key trad_id, representing a transaction. At the same time, in the transaction binary number, the bloc_id (block number) of the blocks of both parties to the transaction are recorded in the two foreign keys bloc_id_A and bloc_id_B of the transaction table, thereby forming a data mapping relationship between the relational data table block table and the transaction table. Corresponding to the storage period of the blockchain, if the sharded blockchain is in the consensus period, at a certain moment, a shard is taking a snapshot, the merkle tree root node sequence data recorded in a specific shard ledger at that moment will be synchronously stored in the primary key slice_id in the off-chain relationship data table shard snapshot table, and the shard snapshot timestamp data will be synchronously recorded and stored in the slice_time of the shard snapshot table; similarly, the shard ledger data formed by the current shard snapshot content will also be recorded in the snapshot field of the shard snapshot table.
[0073] During the shard block global snapshot synchronization period, after the global shard block consensus is confirmed, the newly formed global snapshot will be synchronously recorded and stored in the primary key field all_id of the global snapshot table of the off-chain relationship data table. The serial number of the merkle tree root node in the shard and the cross-shard merkle tree root node will be recorded in all_id. The generation timestamp all_time of the global snapshot will be stored synchronously, and the global ledger data of this global snapshot will be stored in the overall field of the global snapshot table.
[0074] To sum up, after the alliance chain sharding text data transformation, the key blocks, transactions, sharding snapshots, and global snapshots are split and disassembled into relational data tables, forming a relationship mapping between blockchain data, laying the foundation for the logical association of the data structure for the next step of rapid traceability query.
[0075] Next, go to step S140.
[0076] At step S140, when an intermodal delivery process occurs during the cold chain transportation process, it is equivalent to a transaction link in the blockchain, including: adding a new transaction record to the cold chain logistics transportation delivery data table with the primary key trad_id in the transaction table, wherein the primary key deli_id of the cold chain logistics transportation delivery data table in the transaction record corresponds to the primary key trad_id in the transaction table; at the same time, the user number user_id of the two transaction parties in the record is consistent with the user number in the transaction table, ensuring the consistency of the transaction object and the account book data of the dual data of this transaction.
[0077] In an embodiment of the present invention, the transaction link in the blockchain is the transaction process between different nodes / blocks, including transactions within the same regional shard and cross-regional shard transactions.
[0078] More specifically, in the cold chain transportation business stage, the cold chain transportation process involves a complex transportation process between transportation companies and regulatory agencies, and also involves the collaborative relationship between participating units. The business stage of cold chain transportation still uses the traditional relational database to record the overall transportation process. The specific relationship is as follows:
[0079] When a user obtains access through CA authentication, the user information will be stored in the user table. When a cold chain logistics transport occurs, the transported goods information is collected and stored in the goods table. When the cold chain goods are actually transported, real-time data of the cold chain transport process is collected through RFID, GPS, WIFI, Bluetooth, QR code and other communication methods, and the data is transmitted to the relational database server through the Internet using 4 / 5G technology, and stored in the cold chain logistics data table of the relational database, including the transport start / end point, transport start / end time, transported goods temperature and humidity data, vehicle driving trajectory data, door opening and closing and other data items.
[0080] If an intermodal delivery process occurs during cold chain transportation, it is equivalent to a transaction in the blockchain. This transaction may occur within the same regional shard or across regional shards. It is a transaction process between different nodes / blocks. When the delivery operation occurs, the cold chain logistics transportation delivery data table in the relationship data table will be associated with the transaction table 1:1, and the primary key trad_id in the transaction table will be added to a new transaction record in the cold chain logistics transportation delivery data table. The deli_id in this record corresponds to trad_id (such as Figure 2 Indicated by the red line in the middle); at the same time, the user ID of the transaction parties in this record is consistent with the user ID in the transaction table, ensuring the consistency of the transaction object and the account book data of the double data of this transaction. Furthermore, other detailed data items of this delivery process can be added to the cold chain logistics transportation delivery data table, including electronic waybill number, transport cargo number, delivery time, delivery location and other data content, to ensure the convenience of query in the traceability process.
[0081] In summary, through the association of relational database tables, the overall data table is divided into two parts: the offline business relationship table and the online blockchain relationship table, and the association between the two parts is completed using two key relationships:
[0082] First, use the user table to complete the mapping association between CA authentication registration information and newly added block nodes;
[0083] Secondly, by utilizing the correlation between the cold chain logistics transportation delivery data table and the transaction table, the relationship transformation of online and offline dual data can be realized.
[0084] The dual-chain storage method in cold chain logistics proposed in the present invention solves the problems that the alliance chain file structure data cannot support the most widely used relational database SQL query, does not support indexing, fuzzy query, aggregation query, TOPK query, etc. through the dual-chain storage technology based on the alliance chain. It also solves the specific problems that the storage structure of the alliance chain cannot meet the needs of fast query and traceability, and the storage capacity cannot meet the actual business needs.
[0085] The present invention adds a dual-chain data storage mode to the blockchain layer of the alliance chain, and forms a relational table of the on-chain data file by deconstructing the on-chain file data, which together with the off-chain cold chain transportation business relational data table constitutes a package of relational data table structures, which are used to process the alliance user identity identification contract, electronic waybill contract, and cold chain transportation process data in the cold chain transportation process. Since the user identity, electronic waybill, and transportation process in cold chain transportation are quantifiable and calculable digital standard processes, the programmability characteristics of the application layer can be used to store the off-chain relational data of the blockchain layer in a distributed manner in the database server, combined with the Internet of Things, Internet technology, cloud computing and other technologies, especially the monitoring of the time, temperature, humidity, and path of the logistics objects collected by the Internet of Things sensing terminal during the transportation process has real-time characteristics, which is more conducive to the third-party monitoring agency to carry out trusted transportation certification work for the cold chain logistics process.
[0086] Figure 3 The double-chain storage system 300 in the cold chain logistics provided by the present invention is shown, including an upstream module 310 , an upstream module 320 , a mapping module 320 and a synchronization module 330 .
[0087] The chain module 310 is used for cold chain logistics enterprises to apply to join the alliance chain. After confirmation by the management agency, the CA certification is issued to the cold chain logistics enterprise. The alliance chain allocates a new block to the cold chain logistics enterprise and determines the shard where the block is located; and stores the new block and the detailed data of the cold chain logistics enterprise in the user table of the off-chain relationship data table;
[0088] The mapping module 320 is used to establish a mapping relationship between the newly added block and the transaction relationship;
[0089] The synchronization module 330 is used when an intermodal delivery process occurs during the cold chain transportation process, which is equivalent to the transaction link in the blockchain, including: adding a new transaction record to the cold chain logistics transportation delivery data table with the primary key trad_id in the transaction table, and the primary key deli_id of the cold chain logistics transportation delivery data table in the transaction record corresponds to the primary key trad_id in the transaction table; at the same time, the user number user_id of the two transaction parties in this record is consistent with the user number in the transaction table, ensuring the consistency of the transaction object and the account book data of the dual data of this transaction.
[0090] See also Figure 4 The present disclosure also provides an electronic device 40, which includes:
[0091] at least one processor; and,
[0092] a memory communicatively connected to the at least one processor; wherein,
[0093] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the double-chain storage method in cold chain logistics in the aforementioned method embodiment.
[0094] The embodiments of the present disclosure also provide a non-transitory computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable the computer to execute the double-chain storage method in cold chain logistics in the aforementioned method embodiment.
[0095] An embodiment of the present disclosure also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer executes the double-chain storage method in cold chain logistics in the aforementioned method embodiment.
[0096] Reference below Figure 4 , which shows a schematic diagram of the structure of an electronic device 40 suitable for implementing the embodiment of the present disclosure. The electronic device in the embodiment of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 4 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0097] like Figure 4As shown, the electronic device 40 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 401, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 402 or a program loaded from a storage device 408 into a random access memory (RAM) 403. In the RAM 403, various programs and data required for the operation of the electronic device 40 are also stored. The processing device 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.
[0098] Typically, the following devices may be connected to the I / O interface 405: input devices 406 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; output devices 407 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 408 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 409. The communication device 409 may allow the electronic device 40 to communicate wirelessly or wired with other devices to exchange data. Although the electronic device 40 with various devices is shown in the figure, it should be understood that it is not required to implement or have all the devices shown. More or fewer devices may be implemented or have instead.
[0099] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 409, or installed from the storage device 408, or installed from the ROM402. When the computer program is executed by the processing device 401, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0100] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0101] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0102] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: obtains at least two Internet Protocol addresses; sends a node evaluation request including the at least two Internet Protocol addresses to a node evaluation device, wherein the node evaluation device selects an Internet Protocol address from the at least two Internet Protocol addresses and returns it; receives the Internet Protocol address returned by the node evaluation device; wherein the obtained Internet Protocol address indicates an edge node in a content distribution network.
[0103] Alternatively, the computer-readable medium carries one or more programs, and when the one or more programs are executed by the electronic device, the electronic device: receives a node evaluation request including at least two Internet Protocol addresses; selects an Internet Protocol address from the at least two Internet Protocol addresses; and returns the selected Internet Protocol address; wherein the received Internet Protocol address indicates an edge node in a content distribution network.
[0104] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0105] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0106] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of a unit does not limit the unit itself in some cases. For example, the first acquisition unit may also be described as a "unit for acquiring at least two Internet Protocol addresses".
[0107] It should be understood that various parts of the present disclosure may be implemented in hardware, software, firmware, or a combination thereof.
[0108] The above is only a specific implementation of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present disclosure should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A double-chain storage method in cold chain logistics, characterized in that: The method comprises the following steps: The cold chain logistics enterprise applies to join the alliance chain. After confirmation by the management agency, the CA certification is issued to the cold chain logistics enterprise. The alliance chain allocates a new block to the cold chain logistics enterprise and determines the shard where the block is located. The newly added block and the detailed data of the cold chain logistics enterprise are stored in the user table of the off-chain relationship data table, including: The CA authentication sequence data of the cold chain logistics enterprise is stored in the user table with the primary key user_id field, and the timestamp, random number and public key information in the newly added block are fixed to form a unique user table user_id primary key data; A mapping relationship is established between the newly added block and the transaction relationship, including: The timestamp, random number, and public key information in the newly added block header are combined and stored in the bloc_id field in the offline relational data table block table as the primary key PK. At the same time, the timestamp in the newly added block header is recorded in the bloc_time of the block table; the foreign key slice_id is added to the block table synchronously, mapped to the primary key CT_slice in the shard snapshot table CT_slice; When logistics delivery occurs during cold chain transportation, transactions occur within or between consortium chain shards; the off-chain transaction data will be stored and mapped in the transaction table, and the merkle tree ledger record sequence value of each transaction will be decomposed from the on-chain block ledger and recorded in the primary key trad_id of the transaction table, representing a transaction; at the same time, in the transaction binary number, the bloc_id of the blocks of both parties to the transaction are recorded in the two foreign keys bloc_id_A and bloc_id_B of the transaction table, thereby forming a data mapping relationship between the relational data table block table and the transaction table; When the sharded blockchain enters the snapshot period from the consensus period, the merkle tree root node sequence data recorded in the sharded ledger will be synchronously stored in the primary key slice_id in the off-chain relational data table shard snapshot table, and the shard snapshot timestamp data will be synchronously stored in the slice_time of the shard snapshot table; the sharded ledger data formed by the current slice snapshot content will be recorded in the snapshot field of the shard snapshot table; During the shard block global snapshot synchronization period, after the global shard block consensus is confirmed, the newly formed global snapshot will be synchronously recorded and stored in the primary key field all_id of the global snapshot table of the off-chain relationship data table. The serial number of the merkle tree root node in the shard and the cross-shard merkle tree root node will be recorded in all_id. The generation timestamp all_time of the global snapshot will be synchronously stored, and the global ledger data of this global snapshot will be stored in the overall field of the global snapshot table. When an intermodal delivery process occurs during cold chain transportation, it is equivalent to a transaction link in the blockchain, including: adding a new transaction record to the cold chain logistics transportation delivery data table with the primary key trad_id in the transaction table, and the primary key deli_id of the cold chain logistics transportation delivery data table in the transaction record corresponds to the primary key trad_id in the transaction table; at the same time, the user number user_id of the two parties to the transaction in this record is consistent with the user number in the transaction table, ensuring the consistency of the transaction object and the account book data of the dual data of this transaction.
2. The double-chain storage method in cold chain logistics according to claim 1, characterized in that: The detailed data of the cold chain logistics enterprise include: registration time, address, enterprise scale and registered capital.
3. The double-chain storage method in cold chain logistics according to claim 1, characterized in that: The off-chain relationship data table includes a business data table and an on-chain data and off-chain data relationship conversion table; wherein the business data table includes: a user table, a cargo table, a cold chain logistics transportation table, and a cold chain logistics transportation delivery data table; the on-chain data and off-chain data relationship conversion table includes: a block table, a transaction table, a shard snapshot table, and a global snapshot table.
4. The double-chain storage method in cold chain logistics according to claim 1, characterized in that: The transaction process in the blockchain is the transaction process between different nodes / blocks, including transactions within the same regional shard and cross-regional shard transactions.
5. A double-chain storage system in cold chain logistics, characterized in that: The system comprises: The chain module is configured to be used by cold chain logistics enterprises to apply to join the alliance chain. After confirmation by the management agency, the CA certification is issued to the cold chain logistics enterprise. The alliance chain allocates a new block to the cold chain logistics enterprise and determines the shard where the block is located; and The newly added block and the detailed data of the cold chain logistics enterprise are stored in the user table of the off-chain relationship data table, including: The CA authentication sequence data of the cold chain logistics enterprise is stored in the user table with the primary key user_id field, and the timestamp, random number and public key information in the newly added block are fixed to form a unique user table user_id primary key data; A mapping module is configured to establish a mapping relationship between the newly added block and the transaction relationship, including: The timestamp, random number, and public key information in the newly added block header are combined and stored in the bloc_id field in the offline relational data table block table as the primary key PK. At the same time, the timestamp in the newly added block header is recorded in the bloc_time of the block table; the foreign key slice_id is added to the block table synchronously, mapped to the primary key CT_slice in the shard snapshot table CT_slice; When logistics delivery occurs during cold chain transportation, transactions occur within or between consortium chain shards; the off-chain transaction data will be stored and mapped in the transaction table, and the merkle tree ledger record sequence value of each transaction will be decomposed from the on-chain block ledger and recorded in the primary key trad_id of the transaction table, representing a transaction; at the same time, in the transaction binary number, the bloc_id of the blocks of both parties to the transaction are recorded in the two foreign keys bloc_id_A and bloc_id_B of the transaction table, thereby forming a data mapping relationship between the relational data table block table and the transaction table; When the sharded blockchain enters the snapshot period from the consensus period, the merkle tree root node sequence data recorded in the sharded ledger will be synchronously stored in the primary key slice_id in the off-chain relational data table shard snapshot table, and the shard snapshot timestamp data will be synchronously stored in the slice_time of the shard snapshot table; the sharded ledger data formed by the current slice snapshot content will be recorded in the snapshot field of the shard snapshot table; During the shard block global snapshot synchronization period, after the global shard block consensus is confirmed, the newly formed global snapshot will be synchronously recorded and stored in the primary key field all_id of the global snapshot table of the off-chain relationship data table. The serial number of the merkle tree root node in the shard and the cross-shard merkle tree root node will be recorded in all_id. The generation timestamp all_time of the global snapshot will be synchronously stored, and the global ledger data of this global snapshot will be stored in the overall field of the global snapshot table. The synchronization module is configured to be used when an intermodal delivery process occurs during the cold chain transportation process, which is equivalent to the transaction link in the blockchain, including: adding a transaction record to the cold chain logistics transportation delivery data table with the primary key trad_id in the transaction table, and the primary key deli_id of the cold chain logistics transportation delivery data table in the transaction record corresponds to the primary key trali_id in the transaction table; at the same time, the user number user_id of the two parties to the transaction in this record is consistent with the user number in the transaction table, ensuring the consistency of the transaction object and the account book data of the dual data of this transaction.
6. An electronic device, characterized in that: The electronic device includes: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and when the instructions are executed by the at least one processor, the at least one processor executes the double-chain storage method in cold chain logistics as described in any one of claims 1 to 4.
7. A non-transitory computer-readable storage medium, characterized in that: The non-transitory computer-readable storage medium stores computer instructions, which, when executed by at least one processor, cause the at least one processor to execute the double-chain storage method in cold chain logistics as described in any one of claims 1 to 4.
8. A computer program product, characterized in that The computer program product includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer executes the double-chain storage method in cold chain logistics as described in any one of claims 1 to 4.
