Data writing method and device, equipment, storage medium and computer program product
By constructing feature vectors for IoT data and dividing the data into different links based on importance scores, the advantages of blockchain and databases are leveraged to solve the problem of insufficient security for important data in IoT data writing, achieving a balance between data security and efficiency.
Patent Information
- Application Number
- CN202511499363.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-20
- Publication Date
- 2026-01-23
AI Technical Summary
In existing IoT data writing solutions, the security of important data is poor, and administrators can directly modify or forge data, resulting in insufficient data security.
Extract multidimensional features from IoT data, construct feature vectors, determine the importance score of the data based on the feature vectors, divide the data into first data and second data, write the first data into the first link based on blockchain, and write the second data into the second link based on database.
By leveraging the immutability of blockchain and the efficiency of databases, the security and processing efficiency of critical data are ensured, achieving data security guarantees in scenarios involving the writing of massive amounts of data.
Smart Images

Figure CN121388018A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a data writing method, apparatus, device, storage medium, and computer program product. Background Technology
[0002] With the rapid development of IoT technology, various industries are undergoing unprecedented digital transformation. In the modern IoT ecosystem, a large number of heterogeneous devices constitute a complex and vast network system—from basic metering devices such as water and electricity meters, to various sensors and actuators on industrial production lines, to security cameras and infrared detection devices, as well as smart gateways as data aggregation points and various sub-devices based on the Zigbee protocol. These devices generate massive amounts of data every moment, and the authenticity, integrity, and traceability of this data are becoming increasingly important.
[0003] Currently, the most common data writing solution in the IoT industry adopts a centralized database architecture. In this architecture, various IoT devices upload data to the enterprise's central server via gateways or direct connections. After preprocessing, the data is written to relational databases (such as MySQL and Oracle) or time-series databases (such as InfluxDB). While this method achieves relatively efficient data writing, individuals with administrator privileges can directly modify, delete, or forge important data, resulting in poor data security. Therefore, ensuring the security of critical data in scenarios requiring the writing of massive amounts of data has become a pressing issue for the industry. Summary of the Invention
[0004] The main objective of this application is to provide a data writing method, apparatus, device, storage medium, and computer program product, which aims to solve the technical problem of how to ensure the security of important data when facing scenarios that require writing massive amounts of data.
[0005] To achieve the above objectives, this application provides a data writing method, the method comprising the following steps: Extract multidimensional features from IoT data and construct feature vectors based on the multidimensional features; The importance score of the IoT data is determined based on the feature vector, and the IoT data is divided into first data and second data based on the importance score, wherein the importance score of the first data is higher than that of the second data. The first data is written to the first link and the second link, and the second data is written to the second link. The first link is built on a blockchain, and the second link is built on a database.
[0006] In one embodiment, the step of determining the importance score of the IoT data based on the feature vector includes: Based on the feature vector, determine the anomaly score, business criticality score, and trend score of the IoT data; The importance score of the IoT data is obtained by weighting and summing the anomaly score, the business criticality score, and the trend score using preset weights. The anomaly score represents the degree of abnormal deviation of the IoT data, the business criticality score represents the impact of the IoT data on the business when abnormal deviation occurs, and the trend score represents the overall trend of the IoT data.
[0007] In one embodiment, the first data includes first urgent data and first temporary data, and the step of dividing the IoT data into first data and second data according to the importance score includes: If the importance score is greater than or equal to the first threshold, the corresponding IoT data is determined to be the first urgent data. The first threshold is the importance score threshold corresponding to the determination that the IoT data needs to be urgently uploaded to the blockchain. If the importance score is greater than the second threshold and less than the first threshold, then the corresponding IoT data is determined to be the first temporary data. The second threshold is the importance score threshold corresponding to the determination that the IoT data needs to be processed in batches. If the importance score is less than or equal to the second threshold, then the corresponding IoT data is determined to be the second data.
[0008] In one embodiment, the step of writing the first data into the first link and the second link includes: The first emergency data is completely written into the first link and the second link, and the first temporary data is divided into selected data and discarded data according to the batch optimization decision. The selected data is written to the first link, and the discarded data is written to the second link.
[0009] In one embodiment, the second link includes a Merkle tree structure based on the IoT data organization, and after the step of writing the first data into the first link and the second link, the method further includes: Calculate the anchor root hash value of the Merkle tree structure and submit the anchor root hash value to the first link; When a verification request for data to be verified is received, the Merkle path corresponding to the data to be verified is obtained from the Merkle tree structure. Calculate the hash value to be verified corresponding to the Merkel path, and perform data consistency verification on the data to be verified based on the hash value to be verified and the anchor root hash value.
[0010] In one embodiment, the data writing method further includes: Real-time monitoring is performed on the first link and the second link to obtain the health score and load status of each link. The data routing strategies for the first link and the second link are adjusted based on the health score and the load status.
[0011] Furthermore, to achieve the above objectives, this application also proposes a data writing device, which includes: The feature extraction module is used to extract multidimensional features from IoT data and construct feature vectors based on the multidimensional features. The data segmentation module is used to determine the importance score of the IoT data based on the feature vector, and to divide the IoT data into first data and second data based on the importance score, wherein the importance score of the first data is higher than the importance score of the second data. The data writing module is used to write the first data into the first link and the second link, and to write the second data into the second link. The first link is built on a blockchain and the second link is built on a database.
[0012] In addition, to achieve the above objectives, this application also proposes a data writing device, the device comprising: a memory, a processor, and a data writing program stored on the memory and executable on the processor, the data writing program being configured to implement the steps of the data writing method as described above.
[0013] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, and stores a data writing program thereon, which, when executed by a processor, implements the steps of the data writing method as described above.
[0014] In addition, to achieve the above objectives, the present invention also provides a computer program product, the computer program product including a data writing program, which, when executed by a processor, implements the steps of the data writing method as described above.
[0015] This application extracts multidimensional features from IoT data and constructs feature vectors based on these features. It then determines the importance score of the IoT data based on the feature vectors and divides the IoT data into first data and second data based on the importance score, with the first data having a higher importance score than the second data. The first data is written to a first link and a second link, and the second data is written to the second link. The first link is built on a blockchain, and the second link is built on a database. This method divides IoT data into first data (relatively high importance) and second data (relatively low importance) based on their importance scores. The first data is then written to the first link (based on blockchain) and the second link (based on database), and the second data is written to the second link (based on database), thus ensuring the security of important data in scenarios requiring the writing of massive amounts of data. Attached Figure Description
[0016] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0017] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is a system architecture diagram of the data writing system in the data writing method of this application; Figure 2 This is a flowchart illustrating the first embodiment of the data writing method of this application; Figure 3 This is a schematic diagram of the dual-chain parallel architecture of the data writing method in this application. Figure 4 This is a flowchart illustrating the second embodiment of the data writing method of this application; Figure 5 This is a flowchart illustrating the third embodiment of the data writing method of this application; Figure 6 This is a structural block diagram of the first embodiment of the data writing device of this application; Figure 7 This is a schematic diagram of the structure of the data writing device in the hardware operating environment involved in the embodiments of this application.
[0019] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0020] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of this application and are not intended to limit this application.
[0021] It should be noted that the executing entity of the embodiments of this application can be a computing service device with data processing, network communication, and program execution functions, such as a smart wearable device, a personal computer, or a mobile phone, or an electronic device capable of performing the above functions, such as the aforementioned data writing device. The following embodiments will be described using a data writing device as an example.
[0022] It should be understood that the aforementioned data writing device also operates a data writing system; please refer to [link / reference needed] for details. Figure 1 , Figure 1This is a system architecture diagram of the data writing system in the data writing method of this application. The device access layer connects various industrial field devices, including PLC controllers (Programmable Logic Controllers), SCADA (Supervisory Control and Data Acquisition) systems, various sensors, smart meters, industrial cameras, etc. These devices continuously collect various data from the production site and communicate with the upper layer through standardized industrial protocols to ensure that the data can be processed uniformly. When data is transmitted upward from the device layer, it first reaches the edge computing layer; multiple edge computing gateways are deployed; the received raw data is aggregated; heterogeneous data is converted into a unified format through a conversion protocol; multiple edge gateways can cooperate with each other to jointly verify the authenticity of the data; laying the foundation for subsequent blockchain notarization; preprocessed data first enters the Kafka message queue to ensure that data is not lost under high concurrency, then the time-series database TDengine is responsible for storing this time-stamped industrial data, and Redis memory cache provides high-speed data access capabilities. For large files or image data, the system uses IPFS (InterPlanetary File System) distributed storage for processing. The intelligent data filtering engine automatically identifies which data is important and needs to be permanently stored. The importance assessment module scores each data point based on multiple dimensions; the anomaly detection module identifies data deviating from the normal range; and the threshold optimization module dynamically adjusts the filtering criteria according to the system's complexity. Through intelligent filtering, the system avoids the enormous cost of putting all data on the blockchain, submitting only truly valuable data. The filtered key data enters the blockchain's notarization layer. This layer is built on the Hyperledger Fabric consortium blockchain and contains various types of nodes. The sorting nodes use the Raft consensus algorithm to sort transactions and package them into blocks; peer nodes use national cryptographic algorithms for data encryption and verification; and CA nodes manage identity authentication across the network based on the SM2 algorithm. This design ensures that data cannot be tampered with once it is on the blockchain, providing reliable notarization capabilities for industrial data. The top layer of the system is the application service layer, which directly provides various services to end users. The traceability service allows users to track the complete lifecycle of any data; the data analysis service can perform in-depth mining of historical data; the regulatory reporting service automatically generates various reports that meet regulatory requirements; and the API gateway provides standardized interfaces for third-party systems, enabling the entire system to be seamlessly integrated with the enterprise's existing information systems.
[0023] This application provides a data writing method, referring to... Figure 2 , Figure 2 This is a flowchart illustrating the first embodiment of the data writing method of this application.
[0024] In this embodiment, the data writing method includes the following steps: Step S10: Extract multi-dimensional features from IoT data and construct feature vectors based on the multi-dimensional features.
[0025] It is understandable that the aforementioned multidimensional features may include statistical features. Examples include mean, variance, skewness, kurtosis, etc.; time series characteristics. Examples include trends, periodicity, autocorrelation, and contextual features. For example, equipment status, production stage, and environmental conditions. In this case, the aforementioned feature vector can be constructed in the following form: Representing the eigenvector: .
[0026] It should be understood that raw data is generated when sensors detect temperature changes, PLCs record production parameters, or cameras capture production footage. This raw data comes in various formats: some are analog signals, some are digital signals, and some are image data. The first step of the system is to convert this heterogeneous raw data into a standardized format, assigning each data point a unique timestamp and device identifier, enabling it to flow smoothly within the system. The standardized data is then sent to edge computing nodes for aggregation. These edge nodes aggregate data from the same device or within the same time window, forming more meaningful data packets. Simultaneously, the edge nodes perform data quality checks, filtering out obvious outliers and correcting potential transmission errors to ensure that the data transmitted upwards (i.e., the aforementioned IoT data) is accurate and reliable. This approach of quality control at the data source significantly improves the overall data quality of the system.
[0027] Step S20: Determine the importance score of the IoT data based on the feature vector, and divide the IoT data into first data and second data based on the importance score, wherein the importance score of the first data is higher than the importance score of the second data.
[0028] It's important to note that in an Industrial Internet of Things (IIoT) environment, data exhibits the following characteristics: high frequency, generating tens or even hundreds of thousands of data points per second; variability, with 90% being routine data (i.e., the second type of data mentioned above) and 10% being critical data (i.e., a portion of the first type of data mentioned above); and timeliness, requiring rapid processing of routine data and permanent storage of critical data. The problem with traditional single-chain architectures is that all data must undergo the same consensus process, limiting overall throughput to the slowest link. Specifically, a typical industrial production line generates tens of thousands of sensor data points per second, including parameters such as temperature, pressure, flow rate, and vibration. Storing all this data on a blockchain would not only incur enormous storage costs but also fail to meet real-time requirements due to the latency of the blockchain consensus mechanism. However, within this massive amount of data, there exists a portion crucial for product quality traceability, such as abnormal changes in key process parameters, equipment malfunctions, and quality inspection results. This data must be stored immutably on a blockchain.
[0029] In practical implementation, the feature vectors can be output to a trained evaluation model, which then outputs an importance score for the aforementioned IoT data. The optimization objective of this evaluation model is: ; in, This indicates the overall predictive importance of the data. This indicates the importance analyzed according to expert criteria. Furthermore, the weights of the evaluation model can be optimized using gradient descent by employing historical labeled data, which can be specifically expressed as: ; in, This represents the optimized weights. This indicates the weight at the previous time step. This represents the weights derived from training with historical data. L Represents the loss function. η This represents the learning rate (which can be set to 0.01). Represents the loss function L Weights The partial derivatives of .
[0030] Step S30: Write the first data into the first link and the second link, and write the second data into the second link. The first link is built on a blockchain, and the second link is built on a database.
[0031] The dual-chain architecture designed in this embodiment divides data processing into two independent but coordinated processing chains: the audit traceability chain (i.e., the first chain mentioned above) is dedicated to handling critical data requiring immutability guarantees, providing legally-grade evidence preservation capabilities; the high-speed data chain (i.e., the second chain mentioned above) is responsible for processing large volumes of routine monitoring data, ensuring real-time performance and processing efficiency. The ingenuity of this design lies in allowing 90% of routine data to use the "highway," enjoying high-efficiency processing performance, while allowing 10% of critical data to use a "dedicated channel," obtaining the highest level of security. This ensures both the overall system's processing capacity and the credibility of critical data, providing a technological foundation for the full lifecycle traceability of industrial products.
[0032] The Audit Chain aims to store critical data and audit evidence. It uses the Raft consensus algorithm, achieving a performance of 800-1000 transactions per second and providing immutability guarantees. Built on the Hyperledger Fabric consortium blockchain, this choice is based on the specific needs of industrial applications. Unlike public blockchains, consortium blockchains are more suitable for scenarios in industrial environments where multi-party collaboration is required but access control is necessary. For example, in the automotive manufacturing supply chain traceability, OEMs, parts suppliers, logistics companies, and other parties need to participate in data sharing, but data cannot be completely open to everyone.
[0033] Speed Chain aims to process large volumes of routine data. Its consensus mechanism eliminates the need for traditional blockchain consensus, employing a distributed consensus protocol. Performance metrics include supporting 200,000 data writes per second and millisecond-level query response times. Speed Chain utilizes the distributed time-series database TDengine as its storage engine, a choice made after careful consideration. Data generated by industrial equipment exhibits significant time-series characteristics. Traditional relational databases are inefficient at processing this type of data, while TDengine is specifically optimized for time-series data, achieving millisecond-level query response times and hundreds of thousands of writes per second.
[0034] To further improve performance, the system employs a batch processing mechanism. Data is not processed one record at a time, but rather aggregated into batches for processing. Determining the batch size requires balancing network latency and processing overhead; the optimal balance is found through mathematical modeling. ; in, This represents the optimal batch size, which is the target value we are looking for in this embodiment, namely the batch size that minimizes the total latency. Indicates the solution when x When this expression takes its minimum value b The value; Represents network latency, which is the fixed time overhead required for data to be transmitted over the network, divided by... b This represents the average network latency per request. The larger the batch size, the smaller the network overhead per request. This represents the processing overhead, specifically the additional cost of processing each extra request. The meaning of this formula is intuitive: when the batch size is too small, the network latency is poorly amortized; when the batch size is too large, the cost of processing a single request increases. By solving this optimization problem, this embodiment can dynamically determine the optimal batch size, ensuring the system always operates at its best.
[0035] In the specific implementation, you can refer to Figure 3 , Figure 3 This diagram illustrates the dual-chain parallel architecture of the data writing method in this application. The core idea of the dual-chain parallel architecture originates from the "separation of concerns" design principle in distributed systems. Traditional blockchains face the well-known "blockchain trilemma": decentralization, security, and scalability are difficult to optimize simultaneously. The dual-chain parallel architecture in this embodiment cleverly circumvents this problem through separation of responsibilities.
[0036] Furthermore, this embodiment also incorporates a smart router between the two chains. This smart router serves as the scheduling core of the entire dual-chain architecture, and its working principle is as follows: First, data reception and buffering: When data is uploaded from the edge layer to the middle platform, it first enters a high-performance circular buffer. This buffer is designed based on lock-free concurrency theory, enabling multiple producers to write simultaneously and multiple consumers to read simultaneously. The capacity calculation formula for this buffer is: ; in, Indicates the buffer capacity. Indicates the data generation rate (data per second). Indicates processing delay (seconds). This represents the safety factor (usually 2-3).
[0037] The second step is real-time importance assessment: For each piece of data entering the buffer, the intelligent router immediately assesses its importance, generating an importance score between 0 and 1. The third step is dynamic routing decision: Based on the importance score, the router makes a routing decision. ; in, Representing data x Routing strategy, Indicates the second link. Indicates the first link and the second link. Representing data x Importance score This represents a dynamic threshold that is automatically adjusted based on system load, with a typical range of [0.6, 0.9].
[0038] Furthermore, in industrial IoT data traceability systems, the core challenge lies in accurately identifying the truly crucial data for product quality traceability from massive amounts of equipment data. This seemingly simple problem actually involves a deep understanding of industrial production processes and complex algorithm design. For example, consider the production process of a car engine: from raw material intake to parts processing and final assembly, the entire process generates millions of data points. Among these data are normal operating parameters of equipment, environmental monitoring data, quality inspection results, and records of abnormal events. For product traceability, quality inspection results and abnormal events are clearly more important than conventional temperature and humidity data, but determining this importance requires considering specific business scenarios and historical experience. The traditional approach is to establish fixed rules, such as considering all data exceeding a certain threshold as important. However, this method has significant limitations: setting the threshold too low can lead to a large amount of irrelevant data being misjudged as important, increasing storage costs; setting the threshold too high may miss truly critical information, affecting the completeness of traceability. More importantly, the industrial environment is dynamic, and fixed rules cannot adapt to this change. To address this complex data classification problem, this embodiment designs an intelligent data filtering engine, which serves as the "brain" of the entire system. It determines which data needs to be stored on the blockchain and which data can be processed solely on the high-speed blockchain. Through machine learning techniques and multi-objective optimization theory, it achieves automatic assessment and dynamic adjustment of data importance. This embodiment models the data filtering problem as a multi-objective optimization problem: ; Optimizing this problem requires making the objective function Minimum, Indicates storage cost, This indicates the risk of missed detection (loss of important data not being recorded on the blockchain). Indicates processing delay (milliseconds). =0.4, =0.4, =0.2. Increases when the data is highly important, and missed data could lead to significant losses or security incidents. The value can be fine-tuned based on subsequent actual production scenarios, especially in IoT and edge computing scenarios. The level cannot be too low; processing latency must be guaranteed. Therefore, the constraint can be set as follows: ; The total size of all selected data items to be uploaded to the blockchain must not exceed the blockchain's maximum storage capacity. This prevents storage overflow and ensures system reliability. The maximum storage capacity of a blockchain is: ; Representing data i Whether it was selected to be added to the chain (0 or 1); Representing data i Storage size; Representing data i Importance score. The sum of the importance of all data items not selected for on-chain processing must not exceed the allowed risk threshold. This controls the overall risk of missing important data and ensures that critical data is not overlooked. This represents the maximum permissible risk of missed detections (unit: consistent with the importance score). It is a constant set by business requirements or security policies. The total time for the entire data processing flow (including data selection and on-chain operations) must be completed before the deadline, ensuring that the system meets real-time requirements.
[0039] This embodiment extracts multidimensional features from IoT data and constructs feature vectors based on these features. It then determines the importance score of the IoT data based on the feature vectors and divides the IoT data into first data and second data based on the importance score, with the first data having a higher importance score than the second data. The first data is written to a first link and a second link, and the second data is written to the second link. The first link is built on a blockchain, and the second link is built on a database. This method divides IoT data into first data (relatively high importance) and second data (relatively low importance) based on their importance scores. The first data is then written to the first link (based on blockchain) and the second link (based on database), and the second data is written to the second link (based on database), thus ensuring the security of important data in scenarios requiring the writing of massive amounts of data.
[0040] Reference Figure 2 , Figure 2 This is a flowchart illustrating the second embodiment of the data writing method of this application.
[0041] In one feasible implementation, step S20 may include: Step S201: Determine the anomaly score, business criticality score, and trend score of the IoT data based on the feature vector.
[0042] Understandably, in industrial production, equipment typically operates under relatively stable conditions, with various parameters fluctuating within a normal range. When parameters deviate abnormally, it often indicates equipment failure, process abnormalities, or product quality issues. This abnormal data is crucial for subsequent problem tracing. The anomaly scoring algorithm in this embodiment is designed based on statistical principles, statistically analyzing the degree of anomaly of current data relative to historical data. The system first establishes a data distribution model under normal equipment operating conditions using a sliding window. For numerical parameters, it is assumed that they follow a normal distribution, and the mean and standard deviation are estimated using historical data. ; ; The sliding window size here The window size needs to be determined based on the device characteristics and data update frequency. A window that is too small will make the model overly sensitive to noise, while a window that is too large will reduce the response speed to real changes. The probability of this parameter occurring generally follows a normal distribution, and the probability conforms to: ; Assuming a certain temperature sensor's historical average value =25℃, standard deviation =2℃. Then the current temperature. hour, ≈0.31 (normal); current degree hour: ≈0.99 (abnormal). Among them, Representing data x The anomaly score is calculated based on the probability density of the current data within its historical distribution. ; The intuitive meaning of this formula is: the lower the probability of the current data appearing in the historical distribution, the higher its anomaly score. The advantage of this design is its adaptability to the normal operating modes of different devices, eliminating the need for manually setting fixed thresholds. For combined anomalies of multiple sensors, this embodiment uses Mahalanobis distance for detection. This method can detect situations where a single sensor appears normal, but multiple sensors combined are abnormal, which frequently occurs in industrial environments. The formula for calculating Mahalanobis distance is as follows: ; in, x This represents a vector containing current readings from multiple sensors. For example, for a system with three sensors (temperature, pressure, and flow rate), At this time This vector represents the mean values of the readings from each sensor under normal conditions, and signifies the center point of the system's normal operating condition. ; S This represents the covariance matrix of all sensor readings under normal conditions. The Mahalanobis distance (MD) is not simply a calculation of how far a point is from the center point, but rather how far a point is from an entire data distribution. Covariance matrix S It captures the interrelationships between sensors; for example, it knows that "under normal operating conditions, an increase in temperature is usually accompanied by an increase in pressure." If a new data point shows an increase in temperature and a sudden drop in pressure, even if neither value individually seems extreme, their combination violates historical patterns, resulting in a large MD value and detection as an anomaly. MD automatically handles the issue of different dimensions and scales of different sensors (e.g., temperature is in degrees Celsius, pressure is in megapascals). It transforms this data from different scales to a unified, unitless distance scale. Furthermore, the multivariate anomaly score can be calculated based on the following formula: ; Using the MD value directly as a score has a drawback: its threshold is not easy to set. By converting it into a probability (p-value), this embodiment obtains a standardized, statistically significant outlier score. This embodiment can directly set a significance level (e.g., 0.01) as the threshold: if it is greater than 0.99 (i.e., $P<0.01), it can be considered that a low-probability event has occurred, thus determining that the point is an outlier.
[0043] Anomaly scores only tell us whether data deviates from the normal pattern, but they don't tell us the extent of this deviation's impact on business. For example, a 5-degree temperature increase might be insignificant for routine environmental monitoring, but for precision manufacturing equipment, it could mean a product quality risk. This is where business criticality scoring comes in. This example categorizes equipment into five levels based on business importance: critical equipment (...) =1.0), which refers to the core equipment of the production line; a failure of this equipment will cause the entire line to stop operating; important equipment ( =0.8), which refers to key process equipment that affects product quality; general equipment ( =0.6), that is, conventional production equipment; auxiliary equipment ( =0.4), namely environmental monitoring and auxiliary production equipment; general equipment ( =0.2), i.e., other monitoring equipment. This embodiment establishes a hierarchy of equipment importance, classifying equipment into five levels according to their impact on the production process. Key equipment, such as core process equipment on the main production line, has an importance coefficient of 1.0; auxiliary equipment, such as environmental monitoring equipment, has an importance coefficient of 0.2. For different parameters of each piece of equipment, this embodiment establishes an importance matrix based on expert knowledge and historical failure analysis: ; Comprehensive business criticality assessment: ; The weights for business importance and parameter importance need to be fine-tuned based on the actual scenario. Consider contextual factors such as current production status and order urgency.
[0044] The trend dimension captures the dynamic characteristics of data changes and identifies trend changes that may foreshadow important events. In addition to focusing on the degree of anomaly and business importance of the current data, this embodiment also needs to pay attention to the data's changing trends. Some equipment failures do not occur suddenly but have a gradual process; if such trend changes can be identified, early warnings can be provided. Linear trend analysis uses linear regression to calculate the trend slope: ; This is a standard formula for the linear retracement slope, where x It's a point in time. y This corresponds to the sensor reading. The formula quantifies the overall direction and speed of data change, determining whether the current data sequence is in a stable upward or downward trend. The physical meaning of this formula is that a slow rise in bearing temperature may indicate lubrication failure or increased wear, while a decrease in pressure may indicate a leak in the production pipeline. The formula for calculating the rate of change is: ; in, This represents the current value of IoT data. This represents the historical average of IoT data within a time window. The rate of change measures the degree to which the current value deviates from recent normal levels, amplifying anomalies and short-term mutations. A sudden increase in this value indicates a jump or step change inconsistent with recent historical behavior: for example, a vibration value suddenly being 50% higher than the average of the past hour suggests that the system may have been impacted or a component may have loosened; the rate of change calculation compensates for the shortcomings of linear trends, capturing those sudden and abrupt changes with a gentle slope. Volatility analysis is based on the statistical characteristics of the data: ; This formula calculates the standard deviation of the percentage change, the fluctuation and instability of quantified data in the short term, without considering the direction of change, only the amplitude and frequency of the change. This is primarily used for processing signal data; for example, severe fluctuations in the valve opening signal indicate unreasonable controller parameters or a valve positioner malfunction. Based on the above, the trend score can be calculated using the following formula: ; Different scenarios have different weights, and this applies to devices that experience slow wear and tear. High, for processes requiring stable control It will be higher.
[0045] Step S202: The anomaly score, the business criticality score, and the trend score are weighted and summed using preset weights to obtain the importance score of the IoT data.
[0046] The anomaly score represents the degree of abnormal deviation of the IoT data, the business criticality score represents the impact of the IoT data on the business when abnormal deviation occurs, and the trend score represents the overall trend of the IoT data.
[0047] It should be understood that when data reaches the middle platform layer, it faces a data stream of 200,000 data entries per second. Recording all data on the blockchain would not only be costly but also severely impact system performance. Therefore, this embodiment introduces an intelligent filtering mechanism. The filtering engine performs a multi-dimensional importance assessment on each piece of data: whether the data deviates from the normal range, whether the device it comes from is critical, whether changes in this parameter will affect product quality, and whether there are regulatory requirements to record this type of data. Through comprehensive scoring, the system can accurately identify which data needs to be permanently stored and which only needs temporary storage. Important data that has been filtered is submitted to the blockchain for permanent storage. This process uses a batch submission method—the system packages multiple pieces of data into a single transaction, which improves efficiency and reduces costs. Each piece of data uploaded to the blockchain is encrypted, signed, and reaches consensus among multiple nodes through a consensus mechanism. Once the data is written to a block, it acquires the characteristic of immutability. Data that is not selected for upload to the blockchain is not discarded; it is stored in a time-series database for a certain period of time for daily querying and analysis.
[0048] In practice, the importance score mentioned above can be calculated based on the following formula: ; in, Indicates importance score, Indicates the anomaly score. Indicates the score of business criticality. The score indicates the trend of change. This represents the weights derived from training with historical data.
[0049] In one feasible implementation, the first data includes first emergency data and first temporary data, and step S20 may further include: Step S203: If the importance score is greater than or equal to the first threshold, then the corresponding IoT data is determined to be the first urgent data, where the first threshold is the importance score threshold corresponding to the determination that the IoT data needs to be urgently uploaded to the blockchain.
[0050] It should be noted that the first threshold mentioned above is the emergency on-chain threshold, which can be automatically adjusted according to the system load, for example, it can be adjusted to 0.9.
[0051] Step S204: If the importance score is greater than the second threshold and less than the first threshold, then the corresponding IoT data is determined to be the first temporary data. The second threshold is the importance score threshold corresponding to the determination that the IoT data needs to be processed in batches.
[0052] It should be noted that the second threshold mentioned above is the batch on-chain threshold, which can also be automatically adjusted according to the system load, for example, it can be adjusted to 0.6.
[0053] Step S205: If the importance score is less than or equal to the second threshold, then the corresponding IoT data is determined to be the second data.
[0054] In practical implementation, the specific type of IoT data can be determined based on the following formula: ; in, This indicates the aforementioned first emergency data. This refers to the first temporary data mentioned above. This refers to the second data mentioned above. Indicates importance score, Indicates the first threshold. This represents the second threshold. First, urgent data is extremely critical and needs to be written immediately and individually to the first link to ensure its immutability and auditability with minimal latency; examples include emergency shutdown signals and safety valve trigger signals. First, temporary data is relatively important but does not require immediate response; the system will temporarily store it for subsequent batch processing, such as general process parameter exceedances or efficiency decline trends. Second, data of lower value only needs to be written to the second link for short-term querying and analysis, without consuming the blockchain's storage and computing resources; examples include normal periodic status reports.
[0055] In one feasible implementation, step S30 may include: Step S301: Write all of the first emergency data into the first link and the second link, and divide the first temporary data into selected data and discarded data according to the batch optimization decision.
[0056] Step S302: Write the selected data into the first link and write the discarded data into the second link.
[0057] Understandably, for the initial temporary data, this embodiment employs batch optimization decision-making to improve overall efficiency: even after real-time filtering, the total amount of data to be uploaded to the blockchain may still exceed the blockchain's processing capacity (storage space limitation) within a single cycle. Therefore, it is necessary to select the best data from the batch data, storing the most valuable data within the limited blockchain space to maximize overall efficiency. Within the time window [ Internal collection of data for decision-making: ; The system will not wait indefinitely. A time window is set every 5 minutes, and all data arriving within this window that is marked as the first temporary data will be collected into the aforementioned set. The data awaiting processing focuses on improving throughput. Compared to processing data one item at a time on the blockchain, batch processing significantly reduces the number of interactions with the blockchain (transaction overhead), thereby greatly improving efficiency. Furthermore, batch optimization decisions also include the following global optimizations; ; This optimization means that there is a batch of items (data), each item has its own weight. and value We have a knapsack with a fixed capacity (the storage budget of a blockchain). How do we select items to put into the knapsack to maximize the total value of the items in the knapsack? Indicates on-chain decision-making. =1 indicates that the i-th data item is selected and added to the chain (i.e., the selected data mentioned above), and =0 indicates that the i-th data item is discarded (i.e., the discarded data mentioned above). The objective function... This represents the constraint that maximizes the total importance of the selected data. This means that the total size of the selected data cannot exceed the storage budget allocated by the blockchain for this batch. Indicating whether data i is selected to be added to the chain is a 0-1 knapsack problem, which is solved using dynamic programming in this embodiment: ; in, This represents the maximum sum of importance for the first i data items with a capacity of ω. This represents the size of the i-th data element. This represents the importance score of the i-th data point.
[0058] This embodiment determines the anomaly score, business criticality score, and trend score of the IoT data based on the feature vector; it then weights and sums these scores using preset weights to obtain the importance score of the IoT data; wherein the anomaly score represents the degree of abnormal deviation of the IoT data, the business criticality score represents the impact of the IoT data on the business when abnormal deviation occurs, and the trend score represents the overall trend of the IoT data; if the importance score is greater than or equal to a first threshold, the corresponding IoT data is determined to be the first urgent data, where the first threshold is the threshold for judgment. The method defines an importance score threshold for IoT data that needs to be urgently uploaded to the blockchain. If the importance score is greater than a second threshold and less than a first threshold, the corresponding IoT data is determined to be the first temporary data. The second threshold is the importance score threshold for determining that the IoT data needs to be processed in batches. If the importance score is less than or equal to the second threshold, the corresponding IoT data is determined to be the second data. The first urgent data is completely written into the first and second links, and the first temporary data is divided into selected data and discarded data according to batch optimization decisions. The selected data is written into the first link, and the discarded data is written into the second link. In this embodiment, the method calculates the importance score of IoT data based on the anomaly score, business criticality score, and trend score of the IoT data, thereby more accurately assessing the importance of IoT data. Then, based on the importance score, the IoT data is divided into first urgent data, first temporary data, and second data, and the first temporary data is divided into selected data and discarded data according to batch optimization decisions, thereby further refining the division of IoT data.
[0059] Reference Figure 4 , Figure 4 This is a flowchart illustrating the third embodiment of the data writing method of this application.
[0060] In one possible implementation, the following may be included after step S30: Step S40: Calculate the anchor root hash value of the Merkle tree structure and submit the anchor root hash value to the first link.
[0061] Understandably, the biggest technical challenge of a dual-chain architecture is ensuring data consistency between the two chains. Traditional database synchronization solutions are not applicable here because one is a high-performance database and the other is a blockchain, with completely different data structures and processing mechanisms. This embodiment innovatively proposes a Merkle tree anchoring mechanism solution, employing batch anchoring instead of anchoring one chain at a time, significantly reducing inter-chain synchronization costs. The high-speed data chain periodically organizes a batch of data into a Merkle tree structure, calculates a unique root hash value, and then submits this root hash to the blockchain for anchoring. The Merkle tree construction process is as follows.
[0062] The first step is to set the high-speed chain within the time window. The data generated internally is , , ,…, Calculate the hash of the leaf node: ), This represents a unique device identifier (such as DEV_001). Represents a timestamp (Unix time, accurate to milliseconds). Indicates the actual data value. The first step represents random numbers, increasing the uniqueness of the hash. These data are then concatenated together and hashed using a hash function. The second step involves constructing a tree structure, for non-leaf nodes: This means that the hash value of the parent node is the concatenation of the hash values of its left and right child nodes, plus the hash value of the child node. If the parent node has an odd number of child nodes, then... The last node replicates itself. The third step yields the Merkle root: That is, the Merkle root is the hash value of the root node for this number. The fourth step is to submit the Merkle root to the blockchain: ; in, It represents the hash value of the previous block, which includes the hash value of the previous block as a whole. Each block points to its previous block, forming an immutable chain. Indicates the Merkle root of the current block; Indicates the timestamp of block creation; This represents the random number used for proof of work.
[0063] Step S50: When a verification request for the data to be verified is received, the Merkle path corresponding to the data to be verified is obtained from the Merkle tree structure.
[0064] Step S60: Calculate the hash value to be verified corresponding to the Merkel path, and perform data consistency verification on the data to be verified based on the hash value to be verified and the anchor root hash value.
[0065] In this implementation, when a verification request for data to be verified is received, i.e., when the integrity of a certain piece of data needs to be verified, this embodiment uses the Merkel path for verification. The verification path is , ,.., The verification result is The verification process is as follows: ); in, This represents the hash sequence of sibling nodes (nodes on the verification path). This represents the hash of the data to be verified. This represents the root hash calculated through path verification. This represents the Merkle root stored in the blockchain. When verifying the integrity of a piece of data, it's not necessary to download the entire dataset; only the data item and its corresponding Merkle path are required. The verification process involves recalculating the hash path from the leaf node to the root node. If the calculated result matches the root hash stored on the blockchain, the data has not been tampered with. The security of this verification method relies on the one-way and collision-resistant properties of the hash function. Assuming the hash function has a security strength of 256 bits, the probability of forging a valid Merkle path is... This is computationally infeasible. This provides a mathematical-level security guarantee for industrial data traceability.
[0066] In addition to using Merkle tree anchoring, the system is designed with a cross-validation mechanism to further ensure data consistency. The system performs cross-validation every [period]. A cross-validation is performed once to verify the consistency of data with the same timestamp in the two chains. When the consistency falls below a threshold, a data repair process is triggered. The validation function is: ; in, This represents the dataset shared by both chains. Data sets representing high-speed data links, The dataset representing the audit traceability chain, when When the value is less than 0.95, the data repair process is triggered.
[0067] Furthermore, for data that exists on both chains simultaneously, real-time validation is performed on each query. RealTimeCheck(id) = { Pass, if Hashspeed(id) == Hashaudit(id) AND TimestampDiff(id) <T_threshold AND SignatureValid(id) == true Alert, otherwise } Here, id represents the data identifier, Hashspeed(id) represents the hash value of the data corresponding to id in the high-speed data chain, Hashaudit(id) represents the hash value of the data corresponding to id in the audit traceability chain, TimestampDiff(id) represents the timestamp difference of the same data in the two chains, T_threshold represents the time difference threshold (such as 5 seconds), SignatureValid(id) represents the digital signature verification function, and Alert represents issuing a warning when the verification fails. This function is used to verify in real time whether the data of the same id in the two chains is consistent and trustworthy each time the data is queried again, including three dimensions: hash consistency (data integrity) requires that the hash values of the data of the same id in the high-speed chain and the audit chain must be the same. If they are not equal, it means that the data is inconsistent or tampered with on different chains; timestamp consistency (temporal rationality) the timestamp difference of the same data on the two chains must be within the threshold, such as 5 seconds. If it exceeds the time limit, it may indicate data synchronization delay or abnormality; digital signature validity (identity trustworthiness) the data must carry a valid digital signature to ensure that the source is trustworthy and has not been tampered with.
[0068] In a feasible implementation manner, the step data writing method may further include: Step S1: Monitor the first link and the second link in real time to obtain the respective health scores and load conditions corresponding to the first link and the second link.
[0069] Step S2: Adjust the data routing policies of the first link and the second link based on the health scores and the load conditions.
[0070] It should be understood that in an industrial environment, the reliability of the system is crucial. A failure in any link may affect the entire production process. Therefore, this embodiment designs a multi-dimensional health monitoring mechanism:
[0071] Where, represents the health score, represents the maximum response time, represents the error rate, represents the reliability. represents the weight of the response time index. The shorter the response time, the better the system performance. represents the weight of the error rate index. The lower the error rate, the higher the system reliability. This indicates the weight of the availability metric. Availability represents the proportion of time a system is available (e.g., 99.9%), typically a value between 0 and 1. The closer the value is to 1, the higher the availability. For two-chain data, the system error rate is the most critical metric because data integrity must be guaranteed. =0.2, =0.5, =0.3. This health score comprehensively considers three key indicators: response time, error rate, and availability. When the health score falls below a preset threshold, the system automatically executes a failover strategy to ensure service continuity. When the high-speed data chain fails, the system temporarily routes all data to the blockchain for processing. Although processing speed decreases, data loss is guaranteed. When the audit and traceability chain fails, important data is temporarily stored in a dedicated buffer of the high-speed data chain, awaiting batch synchronization after the fault is recovered.
[0072] To fully leverage the performance advantages of the dual-chain architecture, the system implements an intelligent load balancing mechanism. This is achieved by monitoring the load status of each chain in real time. The load status of the high-speed data chain is defined as follows: ; in, This indicates the current number of transactions per second. This indicates the maximum TPS (Transactions Per Second) of the high-speed data chain. Indicates the current storage usage. Indicates the maximum storage capacity. Represents the weighting coefficients, satisfying Typical value The load condition of the audit tracing chain is defined as follows: .
[0073] Furthermore, this embodiment can also dynamically adjust the routing threshold based on load conditions: ; in, This indicates the adjusted routing threshold. Indicates the basic routing threshold. Indicates the adjustment factor. Indicates the target load level.
[0074] This embodiment calculates the anchor root hash value of the Merkle tree structure and submits the anchor root hash value to the first link. When a verification request for data to be verified is received, the Merkle path corresponding to the data to be verified is obtained from the Merkle tree structure. The hash value to be verified corresponding to the Merkle path is calculated, and the data consistency verification of the data to be verified is performed based on the hash value to be verified and the anchor root hash value. The first link and the second link are monitored in real time to obtain the health score and load status of each link. The data routing strategy of the first link and the second link is adjusted based on the health score and the load status. In this embodiment, when the integrity of a certain data needs to be verified, it is not necessary to download the entire dataset. Only the data item and the corresponding Merkle path need to be provided. The verification process recalculates the hash path from the leaf node to the root node. If the calculation result is consistent with the root hash stored on the blockchain, it means that the data has not been tampered with, thereby improving the efficiency of data verification. At the same time, this embodiment also adjusts the data routing strategy of the first link and the second link based on the health score and the load status, thereby achieving a balanced load distribution between the first link and the second link.
[0075] Reference Figure 6 , Figure 6 This is a structural block diagram of the first embodiment of the data writing device of this application.
[0076] like Figure 6 As shown, the data writing device proposed in this application embodiment includes: Feature extraction module 601 is used to extract multi-dimensional features from IoT data and construct feature vectors based on the multi-dimensional features; The data segmentation module 602 is used to determine the importance score of the IoT data based on the feature vector, and to segment the IoT data into first data and second data based on the importance score, wherein the importance score of the first data is higher than the importance score of the second data. The data writing module 603 is used to write the first data into the first link and the second link, and to write the second data into the second link. The first link is built on a blockchain and the second link is built on a database.
[0077] This embodiment extracts multidimensional features from IoT data and constructs feature vectors based on these features. It then determines the importance score of the IoT data based on the feature vectors and divides the IoT data into first data and second data based on the importance score, with the first data having a higher importance score than the second data. The first data is written to a first link and a second link, and the second data is written to the second link. The first link is built on a blockchain, and the second link is built on a database. This method divides IoT data into first data (relatively high importance) and second data (relatively low importance) based on their importance scores. The first data is then written to the first link (based on blockchain) and the second link (based on database), and the second data is written to the second link (based on database), thus ensuring the security of important data in scenarios requiring the writing of massive amounts of data.
[0078] Based on the first embodiment of the data writing device described in this application, a second embodiment of the data writing device of this application is proposed.
[0079] In this embodiment, the data segmentation module 602 is further configured to determine the anomaly score, business criticality score, and trend score of the IoT data based on the feature vector; and to obtain the importance score of the IoT data by weighting and summing the anomaly score, the business criticality score, and the trend score using preset weights; wherein, the anomaly score represents the degree of abnormal deviation of the IoT data, the business criticality score represents the degree of impact of the IoT data on the business when abnormal deviation occurs, and the trend score represents the overall trend of the IoT data.
[0080] Further, the first data includes first urgent data and first temporary data. The data segmentation module 602 is also used to determine the corresponding IoT data as the first urgent data if the importance score is greater than or equal to a first threshold, where the first threshold is the importance score threshold corresponding to the determination that the IoT data needs to be urgently uploaded to the blockchain; if the importance score is greater than a second threshold and less than the first threshold, the corresponding IoT data is determined as the first temporary data, where the second threshold is the importance score threshold corresponding to the determination that the IoT data needs to be batch processed; if the importance score is less than or equal to the second threshold, the corresponding IoT data is determined as the second data.
[0081] Furthermore, the data writing module 603 is also used to completely write the first emergency data into the first link and the second link, and divide the first temporary data into selected data and discarded data according to the batch optimization decision; write the selected data into the first link, and write the discarded data into the second link.
[0082] Furthermore, the second link includes a Merkle tree structure based on the IoT data organization. The data writing module 603 is also used to calculate the anchor root hash value of the Merkle tree structure and submit the anchor root hash value to the first link. When a verification request for data to be verified is received, the Merkle path corresponding to the data to be verified is obtained from the Merkle tree structure. The hash value to be verified corresponding to the Merkle path is calculated, and the data consistency verification of the data to be verified is performed based on the hash value to be verified and the anchor root hash value.
[0083] Furthermore, the data writing module 603 is also used to monitor the first link and the second link in real time, obtain the health score and load status of the first link and the second link respectively, and adjust the data routing strategy of the first link and the second link based on the health score and the load status.
[0084] Other embodiments or specific implementations of the data writing device of this application can be found in the above-described method embodiments, and will not be repeated here.
[0085] This application provides a data writing device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the data writing method in the first embodiment described above.
[0086] The following reference Figure 7 The diagram illustrates a structural schematic of a data writing device suitable for implementing embodiments of this application. The data writing device in the embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 7The data writing device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0087] like Figure 7 As shown, the data writing device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in the read-only memory 1002 or a program loaded from the storage device 1003 into the random access memory 1004. The random access memory 1004 also stores various programs and data required for the operation of the data writing device. The processing unit 1001, the read-only memory 1002, and the random access memory 1004 are interconnected via a bus 1005. An input / output interface 1006 is also connected to the bus. Typically, the following systems can be connected to the input / output interface 1006: input devices 1007 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. Communication device 1009 allows the data writing device to communicate wirelessly or wiredly with other devices to exchange data. While the figures show data writing devices with various systems, it should be understood that implementation or possession of all the systems shown is not required. More or fewer systems may be implemented alternatively.
[0088] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from read-only memory 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0089] The data writing device provided in this application, employing the data writing method described in the above embodiments, can solve the technical problem of ensuring the security of important data in scenarios requiring the writing of massive amounts of data. Compared with the prior art, the beneficial effects of the data writing device provided in this application are the same as those of the data writing method provided in the above embodiments, and other technical features of this data writing device are the same as those disclosed in the previous embodiment method, and will not be repeated here.
[0090] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0091] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0092] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the data writing method in the above embodiments.
[0093] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0094] The aforementioned computer-readable storage medium may be included in the data writing device; or it may exist independently and not assembled into the data writing device.
[0095] The aforementioned computer-readable storage medium carries one or more programs that, when executed by a data writing device, enable the data writing device to write computer program code for performing the operations of this application in one or more programming languages or a combination thereof. These programming languages include object-oriented programming languages such as Java, Smalltalk, and C++; and also conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone 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 remote computers, the remote computer can be connected to the user's computer via any type of network, such as a local area network (LAN) or a wide area network (WAN), or connected to an external computer (e.g., via the Internet using an Internet service provider).
[0096] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0097] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0098] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described data writing method. This solves the technical problem of ensuring the security of important data in scenarios requiring the writing of massive amounts of data. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the data writing method provided in the above embodiments, and will not be repeated here.
[0099] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the data writing method described above.
[0100] The computer program product provided in this application can solve the technical problem of data writing. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as the beneficial effects of the data writing method provided in the above embodiments, and will not be repeated here.
[0101] The above description is only a part of the embodiments of this application and does not limit the scope of protection of this application. All equivalent structural transformations made under the technical concept of this application and using the content of this application specification and drawings, or direct / indirect applications in other related technical fields, are included in the scope of protection of this application.
Claims
1. A data writing method, characterized in that, The method includes the following steps: Extract multidimensional features from IoT data and construct feature vectors based on the multidimensional features; The importance score of the IoT data is determined based on the feature vector, and the IoT data is divided into first data and second data based on the importance score, wherein the importance score of the first data is higher than the importance score of the second data. The first data is written to the first link and the second link, and the second data is written to the second link. The first link is built on a blockchain, and the second link is built on a database.
2. The data writing method as described in claim 1, characterized in that, The step of determining the importance score of the IoT data based on the feature vector includes: Based on the feature vector, determine the anomaly score, business criticality score, and trend score of the IoT data; The importance score of the IoT data is obtained by weighting and summing the anomaly score, the business criticality score, and the trend score using preset weights. The anomaly score represents the degree of abnormal deviation of the IoT data, the business criticality score represents the impact of the IoT data on the business when abnormal deviation occurs, and the trend score represents the overall trend of the IoT data.
3. The data writing method as described in claim 1, characterized in that, The first data includes first emergency data and first temporary data. The step of dividing the IoT data into first data and second data according to the importance score includes: If the importance score is greater than or equal to the first threshold, the corresponding IoT data is determined to be the first urgent data. The first threshold is the importance score threshold corresponding to the determination that the IoT data needs to be urgently uploaded to the blockchain. If the importance score is greater than the second threshold and less than the first threshold, then the corresponding IoT data is determined to be the first temporary data. The second threshold is the importance score threshold corresponding to the determination that the IoT data needs to be processed in batches. If the importance score is less than or equal to the second threshold, then the corresponding IoT data is determined to be the second data.
4. The data writing method as described in claim 3, characterized in that, The step of writing the first data into the first link and the second link includes: The first emergency data is completely written into the first link and the second link, and the first temporary data is divided into selected data and discarded data according to the batch optimization decision. The selected data is written to the first link, and the discarded data is written to the second link.
5. The data writing method as described in claim 1, characterized in that, The second link includes a Merkle tree structure based on the IoT data organization. After the step of writing the first data into the first link and the second link, the method further includes: Calculate the anchor root hash value of the Merkle tree structure and submit the anchor root hash value to the first link; When a verification request for data to be verified is received, the Merkle path corresponding to the data to be verified is obtained from the Merkle tree structure. Calculate the hash value to be verified corresponding to the Merkel path, and perform data consistency verification on the data to be verified based on the hash value to be verified and the anchor root hash value.
6. The data writing method as described in claim 1, characterized in that, The method further includes: Real-time monitoring is performed on the first link and the second link to obtain the health score and load status of each link. The data routing strategies for the first link and the second link are adjusted based on the health score and the load status.
7. A data writing device, characterized in that, The data writing device includes: The feature extraction module is used to extract multidimensional features from IoT data and construct feature vectors based on the multidimensional features. The data segmentation module is used to determine the importance score of the IoT data based on the feature vector, and to segment the IoT data into first data and second data based on the importance score, wherein the importance score of the first data is higher than the importance score of the second data. The data writing module is used to write the first data into the first link and the second link, and to write the second data into the second link. The first link is built on a blockchain and the second link is built on a database.
8. A data writing device, characterized in that, The device includes: a memory, a processor, and a data writing program stored on the memory and executable on the processor, the data writing program being configured to implement the steps of the data writing method as described in any one of claims 1 to 6.
9. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a data writing program is stored on the storage medium. When the data writing program is executed by a processor, it implements the steps of the data writing method as described in any one of claims 1 to 6.
10. A computer program product, characterized in that, The computer program product includes a data writing program, which, when executed by a processor, implements the steps of the data writing method as described in any one of claims 1 to 6.