Disclosure of Invention
Aiming at the technical problem of insufficient storage capacity, the invention provides a block chain-based Internet of things data capacity expansion storage method, a block chain-based Internet of things data capacity expansion storage system and computing equipment for effectively expanding storage.
In order to achieve the purpose, the invention provides the following technical scheme:
in a first aspect, the invention provides a block chain-based internet of things data capacity expansion storage method, which includes the following steps:
an environment deployment step, namely deploying block chain running environments at the edge gateway and the server, and building a block chain network by taking the edge gateway and the server as block chain link points;
a request monitoring step, in which an equipment detection data storage intelligent contract in a block chain respectively monitors an equipment monitoring data storage request sent to the block chain by a user through an interface or an edge gateway of a server, and an equipment maintenance data storage intelligent contract in the block chain monitors an equipment maintenance data storage request sent to the block chain by the user through the interface or the edge gateway of the server;
and a data storage step, namely storing the data in the data storage request into the corresponding fragment according to the block chain fragment expansion storage method when the corresponding data storage request is monitored.
Preferably, the method further comprises a data query step, specifically comprising:
an inquiry request sending step, after corresponding data is stored in fragments through a block chain fragment expansion storage method, a user initiates an equipment monitoring data inquiry request or an equipment maintenance data inquiry request to a block chain through an interface or an edge gateway of a server;
and a data return step, in which the equipment monitoring data query intelligent contract or the equipment maintenance data query intelligent contract in the block chain respectively monitors the equipment monitoring data query request or the equipment maintenance data query request, queries corresponding data from the corresponding fragments according to the request parameters in the corresponding query requests and returns the corresponding data.
Preferably, the block chain fragmentation extended storage method comprises the following steps:
a random number generation step, wherein block chain link points automatically call a RandHound protocol in a node division intelligent contract to generate a random number at intervals of a set time;
a re-fragmentation step, wherein the block chain link points calculate the serial numbers of the fragments to which the block chain nodes are to be partitioned according to the random number and the fragment number, and call the fragment adding intelligent contract to add the corresponding fragments;
an identity identification storage step, wherein a block chain link point calls an identity generation intelligent contract to generate a unique public and private key pair, a verifiable random function is used to generate a random hash value and a zero knowledge certificate, the public and private key pair, the random hash value and the zero knowledge certificate are uploaded to an identity block chain network together, and the public and private key pair, the random hash value and the zero knowledge certificate are stored in an identity block chain after being identified together;
and a storage step, namely receiving the data which are monitored and sent by the equipment maintenance data storage intelligent contract through the fragments, and identifying and storing the data into a corresponding fragment block chain by using a Raft common identification mechanism.
Preferably, the identification storage step further comprises:
the verification random function is combined with a public and private key pair, and a Verify () function is used for detecting whether the random hash value is generated by a private key holder of a public key so as to judge whether the identity of the block chain node is legal.
Preferably, the block chain fragmentation extended storage method further comprises the following steps:
a global fragment table updating step, wherein the block chain nodes call the global fragment table to obtain an intelligent contract to obtain the global fragment table from a root block chain network, and accordingly, the fragments with the minimum number of added nodes are selected, the fragments are called to add the intelligent contract to the fragments, and the global fragment table is updated;
a block storage step, wherein the fragment receiving equipment monitors a data storage intelligent contract to monitor data which corresponds to the storage request and is sent, and after a Raft consensus mechanism is used for realizing consensus on the data, the data are packaged into blocks and stored into corresponding fragment block chains;
and a block state updating step, wherein the block is sent to the root block chain network by the fragment through the network to be verified again and a returned verification result is received, and the block state in the fragment block validity table is updated according to the verification result.
Preferably, the verification process in the block status updating step includes:
and the block chain link points in the root block chain network verify whether the size of the block head of the block is within the length limit range, whether the transaction is legal and whether the Merklerroot value in the root and the block head obtained by reconstructing the Merkle tree is consistent, if the verification is passed, the block is connected to the root block chain, and if the verification is not passed, the block is directly discarded.
In a second aspect, the present invention further provides a block chain based data capacity expansion storage system for the internet of things, where the block chain based data capacity expansion storage method for the internet of things according to the first aspect is applied, and includes:
the environment deployment module is used for deploying block chain running environments at the edge gateway and the server and building a block chain network by taking the edge gateway and the server as block chain link points;
the request monitoring module is used for monitoring that a user sends an equipment monitoring data storage request or an equipment maintenance data storage request to the block chain through an interface of the server or an edge gateway;
the data storage module is used for storing data in the equipment monitoring data storage request or the equipment maintenance data storage request into the corresponding fragment by using a block chain fragment capacity expansion storage method;
and the data query module is used for querying the device monitoring data or the device maintenance data from the corresponding fragment according to the device monitoring data query request or the device maintenance data query request and returning the device monitoring data or the device maintenance data.
Preferably, the data storage module includes a first data storage unit, and the first data storage unit includes:
the random number generation subunit is used for automatically calling a randHound protocol in a node division intelligent contract by block chain nodes at a set time interval to generate a random number;
the block chain link point calculates the serial number of the fragments to which the block chain node is divided according to the random number and the fragment number, and calls a fragment adding intelligent contract to add the corresponding fragments;
the identity recognition storage subunit calls an identity generation intelligent contract to generate a unique public and private key pair by the block link point, generates a random hash value and a zero knowledge certificate by using a verifiable random function, uploads the public and private key pair, the random hash value and the zero knowledge certificate to an identity block link network together, and stores the public and private key pair, the random hash value and the zero knowledge certificate in an identity block link after the public and private key pair, the random hash value and the zero knowledge certificate pass the consensus;
and the storage subunit monitors the data which corresponds to the storage request and is sent by the equipment maintenance data storage intelligent contract which is received by the fragments, and the data is identified and stored into the corresponding fragment block chain by utilizing a Raft identification mechanism.
Preferably, the data storage module further includes a second data storage unit, the second data storage unit including:
a global fragment table updating subunit, wherein the block chain link point calls the global fragment table to obtain an intelligent contract to obtain the global fragment table from a root block chain network, selects the fragment with the least number of added nodes according to the global fragment table, calls the fragment to add the intelligent contract to the fragment, and updates the global fragment table;
the block storage subunit monitors data storage intelligent contracts of the fragment receiving equipment, monitors data corresponding to the storage requests and sent, and packs the data into blocks and stores the blocks into corresponding fragment block chains after sharing the data by using a Raft consensus mechanism;
and the block state updating subunit is used for sending the block to the root block chain network through the network for verification again and receiving a returned verification result by the network fragment, and updating the block state in the block validity table of the fragment according to the verification result.
In a third aspect, the present invention also provides a computing device, including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of the first aspect.
Compared with the prior art, the embodiment of the application provides the block chain-based Internet of things data capacity expansion storage method, system and computing equipment, and can be applied to the technical field of building Internet of things or manufacturing Internet of things. Meanwhile, each block chain node only stores partial data, so that the data quantity to be stored by the block chain node is reduced, and the data query speed of the node is indirectly improved.
Detailed Description
Hereinafter, embodiments of the present invention will be further described with reference to the accompanying drawings.
The block chain is widely applied to many fields as a novel application mode, and safe and reliable storage and access control of data of the building Internet of things are realized by combining the block chain and the building Internet of things technology. However, as the number of intelligent devices and sensors in the building internet of things is increased, the number of data of the building internet of things which need to be stored in the block chain is increased, and the problem of storage capacity of the block chain is inevitable. The existing block chain capacity expansion storage mode for expanding a disk and using an external database faces a series of problems of influencing normal use of a user, increasing storage cost and the like.
Aiming at the prior art, the application provides an Internet of things data capacity expansion storage method, system and computing equipment based on a block chain, which can effectively solve a series of problems faced by the existing block chain capacity expansion storage under application scenes with big data, such as building Internet of things, manufacturing Internet of things and the like, and improve the storage capacity of the block chain.
The intelligent contracts related in the embodiment of the application comprise equipment monitoring data storage intelligent contracts, equipment maintenance data storage intelligent contracts, equipment monitoring data query intelligent contracts, equipment maintenance data query intelligent contracts, node division intelligent contracts, intelligent contracts added in a slicing mode, identity generation intelligent contracts, intelligent contracts obtained through a global slicing table and the like.
The tiled blockchain network includes a plurality of tiles, each tile including a plurality of tiled blockchains, the identity blockchain network including a plurality of identity blockchains, the root blockchain network including a plurality of root blockchains.
The embodiments of the present application will be described below by taking a building internet of things as an example.
The embodiment of the application provides a block chain-based data capacity expansion storage method for the internet of things, and a flow chart of the method is shown in fig. 1, and the method comprises the following steps:
an environment deployment step S1, deploying a block chain operation environment at an edge gateway and a server, and building a block chain network by taking the edge gateway and the server as block chain link points;
in practical application, block chain operation environments are deployed in all edge gateways and servers of an intelligent building management system in an intelligent building group, and an operable block chain network is built by taking the edge gateways and the system servers as block chain link points.
The intelligent building management system integrates subsystems such as a building automatic control system, a fire fighting system, a security protection management system and the like, integrates the data of the Internet of things of the subsystems, provides an intelligent comprehensive management platform for managers, and is convenient for comprehensively mastering the real-time state, alarm and fault conditions of equipment in a building; through data periodic analysis, the running state and the energy utilization condition of each subsystem equipment are known, and support is provided for equipment maintenance and energy-saving optimization.
It should be noted that the edge gateway and the server must meet the storage space and the computing power required by the deployment blockchain operating environment, otherwise, the blockchain cannot operate normally, and therefore the performance requirements of the edge gateway and the server are high.
It should be noted that, considering that a terminal used by a user of the intelligent building management system mainly includes a mobile phone terminal and a computer terminal, a configured blockchain operating environment cannot be installed at the mobile phone terminal, and it takes a long time to install the configured blockchain operating environment at the computer terminal, therefore, except for installing the configured blockchain operating environment in the edge gateway, only installing and deploying the blockchain operating environment in a server in which the intelligent building management system is deployed, writing a relevant blockchain operating interface using an SDK of the blockchain and exposing the operating interface to the user for use, indirectly completing an interactive operation with the blockchain, and simplifying a usage flow of the method.
It should be noted that, if a user needs to use the intelligent building management system frequently and the used terminal meets the performance requirement of installing and deploying the blockchain operating environment, the blockchain operating environment may be installed and deployed in the user terminal, and the user terminal is also added to the existing blockchain network as a blockchain node to directly interact with the blockchain.
Specifically, the users include project managers and operation and maintenance engineers: the project management party is project management personnel and is responsible for dispatching and confirming faults, alarms and other problems of all intelligent equipment and edge gateways in the project; the operation and maintenance engineer is responsible for the maintenance of the fault equipment, the daily maintenance and the routing inspection of the equipment and the like.
A request monitoring step S2, wherein the equipment detection data storage intelligent contract in the block chain respectively monitors an equipment monitoring data storage request sent to the block chain by a user through an interface or an edge gateway of a server, and the equipment maintenance data storage intelligent contract in the block chain monitors an equipment maintenance data storage request sent to the block chain by the user through the interface or the edge gateway of the server;
it should be noted that the device monitoring data storage intelligent contract and the device maintenance data storage intelligent contract are successfully deployed into the blockchain through the consensus of all blockchain nodes before the operation of the blockchain network, and if the code logic in the intelligent contract needs to be modified subsequently, the modified intelligent contract needs to be newly identified and deployed, wherein the common identification and deployment mainly include data storage request event monitoring and the related code for storing data into the segment by calling the SDK of the blockchain.
The equipment monitoring data comprises information such as the running state, alarm information and fault information of intelligent equipment, wherein the running state comprises information such as equipment codes, equipment names, equipment classifications, the online state and state occurrence time, the alarm information comprises information such as equipment numbers, equipment names, alarm types, alarm events, alarm levels and alarm time, and the fault information comprises information such as equipment numbers, equipment names, equipment classifications, fault sources, fault time, fault types and fault descriptions.
The intelligent equipment comprises intelligent equipment such as an intelligent lamp, an intelligent entrance guard, an intelligent air conditioner and an intelligent electric meter, corresponding programs are arranged in the intelligent equipment and are responsible for monitoring and acquiring the running state of the intelligent equipment and monitoring data of the intelligent equipment such as fault information, the programs are connected with the edge gateway through a network, the acquired equipment monitoring data are sent to the edge gateway through an Http protocol, and the acquired equipment monitoring data are uploaded to a block chain through the edge gateway.
Specifically, the equipment maintenance and protection data comprises information such as an equipment inspection plan, an equipment repair work order, and equipment repair execution, wherein the equipment inspection plan comprises information such as a project name, a plan number, a plan name, a start time, an end time, a plan period, an engineer, an equipment area, whether to verify or not, and a plan state, the equipment repair work order comprises information such as a project name, a work order number, a work order name, an equipment code, an equipment name, an equipment classification, a repair source, repair time, a fault type, and a fault description, and the equipment repair execution comprises information such as a project name, a work order number, a work order name, an equipment code, an equipment name, a repair state, repair time, a verification state, a fault type, and a fault description.
Specifically, in the intelligent contract for monitoring data storage of equipment and the intelligent contract for maintaining data storage of equipment, a data storage request monitoring part code is run at intervals through a timer to monitor the data storage request, and in order to process the data storage request in time, the shorter the interval of the timer is, the better the interval is, the timer is set to run once every 1 second.
And a data storage step S3, when the corresponding data storage request is monitored, storing the data in the data storage request into the corresponding fragment according to the block chain fragment expansion storage method.
Through the steps, the problem of insufficient storage capacity of the block chain can be effectively solved by adopting the block chain fragmentation capacity expansion storage method. The fragment is used as a block chain capacity expansion storage mode, a disk does not need to be replaced or an external database does not need to be used, capacity expansion storage can be achieved on the basis of the existing block chain, and the problem of the existing block chain capacity expansion storage is solved. The capacity expansion storage of the block chain is realized on the premise of not influencing the normal use of a system user and not improving the storage cost and complexity.
In some embodiments, the method further includes a data query step S4, which specifically includes:
an inquiry request sending step, after corresponding data is stored in fragments through a block chain fragment expansion storage method, a user initiates an equipment monitoring data inquiry request or an equipment maintenance data inquiry request to a block chain through an interface or an edge gateway of a server;
and a data return step, in which the equipment monitoring data query intelligent contract or the equipment maintenance data query intelligent contract in the block chain respectively monitors the equipment monitoring data query request or the equipment maintenance data query request, queries corresponding data from the corresponding fragments according to the request parameters in the corresponding query requests and returns the corresponding data.
Specifically, the request parameter includes information such as a device number, a device name, time, and presence status of the data to be requested.
It should be noted that, as shown in fig. 1, the block chain fragment expansion storage method used in step S3 stores data of the internet of things, and includes two methods, which are respectively denoted as a first block chain fragment expansion storage method and a second block chain fragment expansion storage method.
Fig. 3 is a schematic model diagram of a first blockchain segment capacity expansion storage method according to an embodiment of the present application, which mainly includes a blockchain node, a segment blockchain network, and an identity blockchain network. The fragment block chain network is composed of a plurality of fragments, each fragment is composed of block chain link points randomly distributed through a randHound protocol, each fragment maintains a fragment block chain, a plurality of fragments in the fragment block chain network can be set (for convenience of explanation, three fragments are set, and the limitation is not included in the embodiment of the application), only the data of the fragment where the fragment is located is stored in the fragment block chain, and the data of other fragments does not need to be synchronously stored, so that the data amount needing to be stored is reduced under the condition that the storage capacity of the block chain is certain, and the storage capacity of the block chain is improved. The identity block chain network consists of a plurality of specific block chain nodes, one identity block chain is maintained and used for storing identity information after all the block chain node fragmentation is finished, the identity information is used for verifying whether the node identity is legal or not when the node is fragmented again, and Sybil attack is avoided, wherein the Sybil attack refers to attack initiated by simulating the identity for many times.
Fig. 2 is a schematic flow chart of a first block chain fragment capacity expansion storage method according to an embodiment of the present application, where the method includes the following steps:
a random number generation step S311, wherein every interval of a set time, a random number is generated by automatically calling a randHound protocol in a node division intelligent contract by a block chain node;
specifically, the set time may be specifically one hour, one day, one week, and the like, and the shorter the time is, the easier the risk that the nodes in the segment collectively do harm is to be avoided, and the time may be adjusted according to the actual situation.
It should be noted that the re-fragmentation of the block link point may cause a data migration phenomenon of the fragmentation, that is, the block link point needs to use the network to re-download the newly added data of the fragmentation, and as the data amount in the fragmentation increases, a large amount of network bandwidth may be occupied, which affects the system operation efficiency.
Specifically, the node division intelligent contract is successfully deployed into the block chain through the consensus of all the block chain nodes before the operation of the block chain network, and all the block chain nodes can call the node division intelligent contract, wherein the node division intelligent contract mainly comprises a relevant code for generating a random number by using a RandHound protocol and is used for generating the random number for the current node.
Specifically, the RandHound protocol is an extensible, secure, multi-party computing protocol that provides unbiased, decentralized randomness in a byzantine environment. The RandHound protocol assumes that there is an externally responsible client that wants to obtain provable randomness from a large group of semi-trusted servers. To generate randomness, the RandHound protocol splits the server group into smaller groups and creates a publicly verifiable post-submission and post-exposure protocol that employs the pigeon cage principle to prove the final random number when including at least one honest participant contribution, thereby achieving unbiased, decentralized randomization.
A re-fragmentation step S312, calculating the serial number of the fragments to which the block chain nodes should be partitioned according to the random number and the fragmentation number by the block chain link points, and calling the fragment adding intelligent contract to add the corresponding fragments;
specifically, the remainder obtained by dividing the random number by the number of the segment is used as the serial number of the segment to be divided, for example, the random number generated by a certain block link point is 244, the total number of the segments is 3, and the remainder obtained by calculation is 1, so that the block link point should be divided into segment 1.
Specifically, the number of fragments is already configured in the configuration file of the segment chain node before the operation of the fragment block chain network, and can be directly obtained for use.
Specifically, the intelligent contract for adding the block chain is successfully deployed into the block chain through the consensus of all the block chain nodes before the operation of the block chain network, and all the block chain nodes can call the intelligent contract for adding the block chain nodes, wherein the intelligent contract mainly comprises script codes for adding the block chain nodes into the block chain and is used for realizing the automatic process of adding the block chain nodes into the block chain.
An identity identification storage step S313, calling an identity generation intelligent contract by block link points to generate a unique public and private key pair (pk, rk), generating a random hash value p and a zero knowledge proof k by using a verifiable random function, uploading the public and private key pair (pk, rk), the random hash value p and the zero knowledge proof k to an identity block chain network together, and storing the public and private key pair (pk, rk), the random hash value p and the zero knowledge proof k to an identity block chain after consensus is passed;
specifically, the identity generation intelligent contract is successfully deployed into the blockchain through the consensus of all blockchain nodes before the blockchain network operates, and all blockchain nodes can call the identity generation intelligent contract, wherein the identity generation intelligent contract mainly comprises a code for generating a unique public and private key pair for a block chain link point and is used for generating the unique public and private key pair for the block chain link point.
In particular, a zero knowledge proof refers to a prover being able to convince a verifier that some argument is correct without providing the verifier with any useful information.
It should be noted that before the next re-fragmentation, all the blockchain nodes need to obtain the identity certificates (pk, rk) of other blockchain nodes, the generated random hash value p and the zero knowledge certificate k from the identity blockchain, and then Verify whether the identities of other blockchain nodes are legal by using the Verify () function in the verifiable random function, if so, the next fragmentation can be performed, otherwise, an error is reported, and further processing is waited.
And a storage step S314, receiving the data sent by the device maintenance data storage intelligent contract monitoring corresponding storage request by the fragments, and identifying and storing the data into the corresponding fragment block chain by using a Raft common identification mechanism.
In some embodiments, the identity storing step further comprises:
the verification random function is combined with a public and private key pair, and a Verify () function is used for detecting whether the random hash value is generated by a private key holder of a public key so as to judge whether the identity of the block chain node is legal.
Specifically, the verifiable random function is combined with asymmetric encryption (namely, the public and private key pair generated above), so that both communication parties can verify the integrity and the source of the message without knowing the private key of the other communication party. Anyone can use the Verify () function in the verifiable random function to check whether the random hash value p is actually generated by the holder of the private key of the public key pk, so as to ensure that the identity of the blockchain node is legal and avoid the witch attack.
In some embodiments, fig. 5 is a schematic model diagram of a second blockchain fragment capacity expansion storage method according to an embodiment of the present application, and mainly includes a blockchain node, a fragment blockchain network, and a root blockchain network. The partitioned block chain network comprises a plurality of partitions (a plurality of partitions can be arranged in the partitioned block chain network, for convenience of description, three partitions are arranged, and the partition with the smallest number of nodes can be freely selected by a block chain node, each partition maintains a partitioned block chain, only data of the partition is stored in the partitioned block chain, and data of other partitions does not need to be synchronously stored, so that the data volume needing to be stored is reduced under the condition that the storage capacity of the block chain is certain, and the storage capacity of the block chain is improved. The root blockchain network is used for verifying and storing the blocks generated by the fragmentation again, and the purpose is to avoid the risk that blockchain nodes in the fragmentation collectively do harm.
Fig. 4 is a flowchart illustrating a second method for performing flash storage on blockchain fragments according to an embodiment of the present application, where as shown in fig. 4, the method includes the following steps:
a global partition table updating step S321, a block link point calls a global partition table to obtain an intelligent contract to obtain a global partition table from a root block chain network, accordingly selects a partition with the least added nodes, calls a partition to add the intelligent contract to the partition, and updates the global partition table;
specifically, the global fragment table includes information such as a fragment number, a fragment node list, a fragment node number, and the like, where the fragment node list is used to record node numbers of nodes in the fragment, the fragment node number refers to the total number of nodes currently added to the fragment, the global fragment table is initialized when the blockchain network is started and stored in the root blockchain, and all blockchain nodes can view the global fragment table in the root blockchain.
The global fragmentation table initialization means that after the blockchain network is started, nodes in the root blockchain initialize the content of the global fragmentation table according to the predefined configuration in the blockchain network starting configuration file, for example, if the total number of the predefined fragments in the configuration file is 3, 3 rows of data are initialized for the global fragmentation table, and the fragmentation number, the fragmentation node list and the fragmentation node number in each row of data correspond to the content in the configuration file.
The block chain network starting configuration file is a file necessary for starting the block chain network, and the configuration file content comprises the total number of fragments, the serial numbers of the nodes in each fragment and/or the number of the nodes in each fragment.
Specifically, updating the global fragmentation table means that after a block chain node is added into a fragmentation, the number of fragmentation nodes corresponding to the fragmentation in the global fragmentation table is added by 1 by calling the global fragmentation table to update an intelligent contract, and the node number of the node is added into a fragmentation node list.
The intelligent contract for updating the global slicing table refers to a code used by the block chain nodes for updating the global slicing table, the intelligent contract is successfully deployed into the root block chain through the consensus of all the nodes of the root block chain before the operation of the block chain network, and all the block chain nodes can call the intelligent contract.
A block storage step S322, in which the fragment receiving device monitors data storage intelligent contracts to monitor data corresponding to storage requests and send the data, and after a Raft consensus mechanism is used for achieving consensus on the data, the data are packaged into blocks and stored into corresponding fragment block chains;
specifically, the device monitoring intelligent contract for data storage is successfully deployed into the blockchain through consensus of all blockchain nodes before the blockchain network runs, and if the code logic in the intelligent contract needs to be modified subsequently, consensus and deployment need to be performed on the modified intelligent contract again, wherein the consensus and deployment mainly include monitoring of data storage request events and calling of an SDK of the blockchain to store data into related codes of the fragments.
And a block state updating step S323, wherein the block is sent to the root block chain network by the segment through the network to be verified again and a returned verification result is received, and the block state in the block validity table of the segment is updated according to the verification result.
In particular, the tiled chunk validity table is stored in all chunk chain nodes.
Specifically, the tile validity table includes a tile number, a tile storage time, and a tile validity, where the tile number and the tile storage time information may be obtained from a tile header, the tile validity table is stored in each tile chain, and all nodes in the tile chain may view the content of the tile validity table in the tile.
Specifically, the block number refers to a sequence number which is incremented by 1 each time from 0, and is used for identifying blocks in the partitioned block chain and recording the current block height; the block storage time refers to the time when the current block is connected to the tile block chain, such as "2021-05-27; the block validity is used to identify whether the block is legal (i.e. whether the block is verified by the root blockchain verification network), true is used to identify that the block is legal, and False is used to indicate that the block is illegal.
Specifically, updating the partition block validity table means that the partition block chain node stores the block number, the block storage time and the block validity (True/False) into the partition block validity table by calling a block state information newly added intelligent contract.
The block state information newly-added intelligent contract mainly comprises codes of the block state information of the fragment on the link points of the fragment blocks, and the block state information newly-added intelligent contract is successfully deployed into the corresponding fragment after passing through the consensus of all nodes in the fragment when each fragment is initialized.
Specifically, the block verification result refers to that the block verification passes or fails, and is represented by True and False respectively. The root blockchain network will only connect the block into the root blockchain after the block verification is passed, otherwise the block is directly discarded.
Preferably, the verifying step in the block status updating step S323 includes:
and the block chain link points in the root block chain network verify whether the size of the block in the block head is within the length limit range, whether the transaction is legal and whether the Merklerroot value in the root and the block head obtained by reconstructing the Merkle tree is consistent, if the verification is passed, the block is connected to the root block chain, and if the verification is not passed, the block is directly discarded.
Specifically, the root block chain network re-verification means that the generated blocks are sent to the root block chain network in a fragmentation mode, and the block chain link points in the root block chain network verify whether the size of the blocks in the block heads is within the length limit range, the validity of transactions, whether the MerkleroRoot values in the tree roots and the block heads obtained by reconstructing the Merkle tree are consistent and other information.
It should be noted that before querying data from the partition block chain, the intra-partition node may first invoke the block state information acquisition intelligent contract to acquire the partition block validity table from the partition block chain, verify the validity of each block in the partition block chain, and then only acquire data in the corresponding block whose block validity is True.
The intelligent contract for acquiring the block state information mainly comprises a code for inquiring the block state information of the fragment by the link points of the fragment blocks, and the intelligent contract for acquiring the block state information is successfully deployed into the corresponding fragment after passing through the common recognition of all nodes in the fragment when each fragment is initialized.
In a second aspect, the present invention further provides a block chain-based data capacity expansion storage system for the internet of things, where the block chain-based data capacity expansion storage method for the internet of things according to the first aspect is applied, and the method includes:
the environment deployment module 1 is used for deploying block chain running environments at the edge gateway and the server and building a block chain network by taking the edge gateway and the server as block chain link points;
in practical application, the environment deployment module 1 is used for deploying a blockchain operating environment in all edge gateways and servers of an intelligent building management system in an intelligent building group, and building an operable blockchain network by using the edge gateways and the system servers as blockchain link points.
Specifically, the environment deployment module 1 further includes:
and the environment installation unit 11 is used for installing the block chain operation environment in all the edge gateways in the intelligent building group and the servers of the intelligent building management system.
And the network building unit 12 is used for building an operable block chain network by using the edge gateway and the system server as block chain link points.
The request monitoring module 2 is used for monitoring that a user sends an equipment monitoring data storage request or an equipment maintenance data storage request to the block chain through an interface of the server or an edge gateway;
the data storage module 3 is used for storing the data in the equipment monitoring data storage request or the equipment maintenance data storage request into the corresponding fragment by using a block chain fragment capacity expansion storage method;
in practical application, the data storage module 3 is configured to store the data in the device monitoring data storage request into the corresponding segment by using a second blockchain segment expansion storage method; and storing the data in the device maintenance data storage request into the corresponding fragment by using a first block chain fragment expansion storage method.
And the data query module 4 is used for querying the device monitoring data or the device maintenance data from the corresponding fragment according to the device monitoring data query request or the device maintenance data query request and returning the device monitoring data or the device maintenance data.
In practical application, the data query module 4 is configured to query the requested device monitoring data from the corresponding segment of the second block chain segment expansion storage method and return the requested device monitoring data; and inquiring and returning the requested equipment maintenance data from the corresponding fragment of the first block chain fragment expansion storage method.
Preferably, the data storage module 3 includes a first data storage unit 31, and the first data storage unit 31 includes:
the random number generation subunit 311 is configured to, at intervals of a set time, automatically invoke a RandHound protocol in a node division intelligent contract by a block link point to generate a random number;
a re-fragmentation subunit 312, where the block link point calculates, according to the random number and the number of fragments, the serial number of the fragment to which the block link node should be partitioned, and invokes a fragment join intelligent contract to join the corresponding fragment;
the identity recognition storage subunit 313 calls an identity generation intelligent contract to generate a unique public and private key pair, generates a random hash value and a zero knowledge certificate by using a verifiable random function, uploads the public and private key pair, the random hash value and the zero knowledge certificate to an identity block chain network together, and stores the public and private key pair, the random hash value and the zero knowledge certificate in an identity block chain after consensus;
and the storage subunit 314 receives the data sent by the device maintenance data storage intelligent contract monitoring corresponding storage request, and identifies and stores the data into the corresponding fragment block chain by using a Raft identification mechanism.
Preferably, the data storage module 3 further comprises a second data storage unit 32, the second data storage unit 32 comprising:
a global fragment table updating subunit 321, where the block link point calls the global fragment table to obtain an intelligent contract to obtain the global fragment table from the root block chain network, and accordingly selects the fragment with the least number of added nodes, calls the fragment to add the intelligent contract to the fragment, and updates the global fragment table;
the block storage subunit 322 is used for monitoring the data storage intelligent contract by the fragment receiving equipment, monitoring the data corresponding to the storage request and transmitted, and after the data is agreed by using a Raft consensus mechanism, packaging the data into blocks and storing the blocks into corresponding fragment block chains;
the block state updating subunit 323 sends the block to the root block chain network through the network for verification again and receives a returned verification result, and updates the block state in the block validity table of the segment according to the verification result.
The following application embodiment is an example of fault maintenance of lighting equipment in a certain building, wherein intelligent equipment such as intelligent lighting, intelligent access control, intelligent air conditioners and intelligent fresh air are installed in the building, the equipment is connected with an edge gateway in the building through a network, the edge gateway collects equipment monitoring data through a built-in program of the equipment, meanwhile, the edge gateway is installed and deployed with a block chain operation environment, forms a block chain network with other edge gateways, user terminals (user computers) and an intelligent building management system server, and can upload data to the block chain.
The building internet of things data comprises two types of data, namely equipment monitoring data and equipment maintenance data, wherein each type of data specifically comprises a plurality of types of information, and the data is shown in table 1:
TABLE 1 data types, specific information and characteristics
The existing intelligent building management system is generally connected with and responsible for monitoring hundreds of intelligent devices in a building, device monitoring data is obtained every half minute or even shorter time, at most tens of thousands of pieces of data can be generated every hour, hundreds of thousands of pieces of data can be generated every day, GB-level storage space is occupied every day, and the data volume is very large; meanwhile, the running state information of the equipment in normal running is the same except for time, a large amount of repeated data with the same running state can be generated during the normal running of the equipment, and the occupation of the storage space of the block chain is aggravated; in addition, the monitoring data of the equipment does not contain user or equipment privacy data, so that higher storage safety is not needed.
The condition that equipment triggers the warning or breaks down in the building is less, and equipment ledger, spare parts and scrap information are also less, therefore the total data volume of equipment maintenance data is less. However, the information such as repair and routing inspection in the equipment maintenance data includes private data of some operation and maintenance engineers, such as operation and maintenance engineer numbers, positions, names, identification numbers, and the like, and the data needs higher storage security.
Aiming at different characteristics of equipment monitoring data and equipment maintenance data, the embodiment of the application uses a first block chain fragment expansion storage method and a second block chain fragment expansion storage method to meet the storage requirements of two types of data. The advantages and disadvantages of the first and second blockchain fragmentation extended capacity storage methods are shown in table 2:
TABLE 2 Excellent and disadvantageous in first and second blockchain fragmentation extended capacity storage methods
If the nodes in a certain fragment in the first block chain fragment expansion storage method meet the condition of carrying out malicious operation (more than half of the nodes are invaded) after being invaded by a hacker, the invaded nodes are redistributed in the next fragment, the condition of the malicious operation is not met any more, and the long-term safety of the fragment is ensured. In the second block chain fragment capacity expansion storage method, re-fragmentation is not performed, and a node in a certain fragment has a security risk of being invaded by a hacker after a long time, so that the long-term security of the fragment cannot be ensured.
If only the first block chain fragment capacity-expansion storage method is used for storing the device monitoring data and the device maintenance data, although higher storage security can be provided, the huge data volume of the device monitoring data can cause the data migration of the method during re-fragmentation to occupy huge network bandwidth, seriously affect the operating efficiency of the system, and even cause failure in storing or acquiring the data, so that the device monitoring data needs to be stored by using the second block chain fragment capacity-expansion storage method, thereby ensuring the higher storage security of the device maintenance data, and avoiding the large occupation of the network bandwidth.
If only the second blockchain fragment expansion storage method is used for storing the equipment monitoring data and the equipment maintenance data, although the network bandwidth can be saved and the system operation efficiency is not influenced, higher storage safety required by the equipment maintenance data cannot be provided, so that a small amount of network bandwidth is discarded, the first blockchain fragment expansion storage method is used for storing the equipment maintenance data, and higher storage safety is provided for the equipment maintenance data under the conditions that the network bandwidth is not occupied and the system normally operates.
In summary, the embodiment of the present application combines the characteristics of two types of data and the advantages and disadvantages of two block chain fragment expansion storage methods, and combines the two block chain fragment expansion storage methods to meet the storage requirements of the two types of data: and storing the maintenance data of the equipment by using a first block chain fragment expansion storage method, and storing the monitoring data of the equipment by using a second block chain fragment expansion storage method. The specific data storage fragmentation division is shown in table 3, the table is written into a related storage and query intelligent contract of the device monitoring and maintenance data in a hash table form, and the contract stores the data into the corresponding fragmentation according to the table or acquires the data from the corresponding fragmentation according to the table. The first block chain fragment expansion storage method and the second block chain fragment expansion storage method respectively have three fragments.
TABLE 3 data storage sharding partitioning
Fig. 7 is a schematic flowchart of lighting device fault maintenance provided in the embodiment of the present application, and fig. 8 is a schematic model diagram of lighting device fault maintenance provided in the embodiment of the present application, where an edge gateway and a user terminal have been installed and deployed with a blockchain operating environment, and as a blockchain node and other blockchain nodes, together form a blockchain network, and a first and second blockchain fragmentation and expansion storage method has completed fragmentation, and can receive data to perform a data storage operation. The embodiment of the application comprises the following steps:
s71: and the edge gateway acquires the monitoring information of the lighting equipment and then initiates an equipment monitoring data storage request to the block chain.
Specifically, the lighting device monitoring information includes information such as a device code, a device name, a device classification, a device area, an online status, and a status occurrence time, where the online status includes three statuses of online, offline, and failure.
In particular, the parameters of the device monitoring data storage request include raw lighting device monitoring information.
S72: after the device monitoring data storage intelligent contract in the block chain monitors the device monitoring data storage request, the data in the device monitoring data storage request calls a data storage SDK carried by the block chain to be stored in the block chain of the fragment A of the second block chain fragment expansion storage method.
Specifically, the lighting device monitoring information is sent to a block chain network in the segment a by a device monitoring data storage contract, a block is generated after consensus and connected to the segment block chain, meanwhile, the block is sent to a root block chain network for verification again, and the block is also connected to the root block chain after verification is passed.
S73: and the data detection intelligent contract acquires the monitoring information of the lighting equipment by using the data acquisition SDK from the fragment block chain of the fragment A at regular time and returns the monitoring information to detect whether the information is abnormal.
Specifically, each device has a special data detection intelligent contract, and the data detection intelligent contract in the embodiment of the present application specifically detects lighting device monitoring information.
Specifically, the data detection intelligent contract judges whether the lighting device has a fault according to the "online state" information in the lighting device monitoring information, that is: if the 'online state' is a fault, the lighting equipment is indicated to be in a fault at present and needs to be repaired.
In particular, since the data queries in the blockchain do not need to be subject to consensus, the data can be obtained directly from the tiled blockchain using the data query SDK.
S74: if the information is detected to be abnormal, the lighting equipment is indicated to have a fault, the intelligent contract for equipment maintenance and data storage is called after the intelligent contract for data detection generates equipment fault alarm information, and the equipment fault alarm information is used as a parameter to be sent to the intelligent contract for equipment maintenance and data storage.
Specifically, the equipment fault alarm information comprises information such as an item name, an equipment code, an equipment name, an equipment area, an installation position, an alarm type, an alarm event, an alarm level, alarm time, a processing state and the like, wherein the alarm type comprises an autonomous type and an artificial type, the alarm level comprises a common level, an alarm level and a severe level, and the processing state comprises a checked state and a processed state.
S75: the device maintenance data storage intelligent contract calls a data storage SDK of the block chain to store the received device fault alarm information into the fragment block chain of the fragment 2 of the first block chain fragment capacity expansion storage method.
S76: and the project management party initiates a device maintenance data query request to the block chain through the terminal.
Specifically, the parameters of the device maintenance data query request include information such as a device number and a specific data type, where the specific data type includes types such as "device repair information", "device inspection information", and "device alarm information", and here is "device alarm information".
Specifically, the terminal mainly refers to a computer, in which a blockchain operating environment has been installed and deployed, and is added to an operating blockchain network as a blockchain link point, so that data interaction can be directly performed with the blockchain.
S77: after the device maintenance data query intelligent contract in the block chain monitors the device maintenance data query request, the device fault alarm information is obtained from the segment block chain of the segment 2 of the first block chain segment expansion storage method by using the data obtaining SDK according to the parameters in the device maintenance data query request, and the device fault alarm information is returned to the project manager.
S78: and the project manager manually generates equipment fault report repair work order information at the computer terminal according to the equipment fault alarm information, and then initiates an equipment maintenance data storage request to the block chain.
Specifically, the parameters of the device maintenance data storage request include information such as a device number, a specific data type, original device fault repair work order information, and the like, where the specific data type includes types such as "device repair information", "device inspection information", and "device alarm information", and here is "device repair information".
Specifically, the equipment fault repair work order information includes information such as a project name, a work order number, a work order name, an equipment code, an equipment name, an equipment classification, an equipment area, an installation location, a repair source, repair time, a fault type, and a fault description.
S79: and monitoring the device maintenance data storage request by the device maintenance data storage intelligent contract in the block chain, calling a data storage SDK (secure data repository) carried by the block chain to store the original data in the device maintenance data storage request into the block chain of the partition 2 of the first block chain partition capacity expansion storage method.
S710: and the operation and maintenance engineer initiates a device maintenance data query request to the block chain through the terminal.
Specifically, the parameters of the device maintenance data query request include information such as a device number and a specific data type, where the specific data type includes types such as "device repair information", "device inspection information", and "device alarm information", and here is "device repair information".
S711: after monitoring the device maintenance data query request, the device maintenance data query intelligent contract in the block chain acquires the device fault report repair work order information from the block chain of the segment 2 of the first block chain segment expansion storage method according to the parameters in the device maintenance data query request, and returns the information to the operation and maintenance engineer, and the specific steps are the same as S77 and are not repeated.
S712: and the operation and maintenance engineer maintains the fault lighting equipment according to the repair work order information of the equipment fault.
S713: after the fault maintenance is finished, an operation and maintenance engineer manually generates equipment fault repair execution information at the computer terminal according to the actual condition of equipment fault maintenance, and then initiates an equipment maintenance data storage request to the block chain.
Specifically, the parameters of the device maintenance data storage request include information such as a device number, a specific data type, original device failure repair execution information, and the like, where the specific data type includes types such as "device repair information", "device inspection information", and "device alarm information", and is referred to as "device maintenance information" here.
S7014: and monitoring the device maintenance data storage request by the device maintenance data storage intelligent contract in the block chain, and storing the device fault repair execution information into the fragment block chain of the fragment 2 of the first block chain fragment expansion storage method according to the parameters in the device maintenance data storage request, wherein the specific steps are the same as S79 and are not repeated.
In addition, the method for capacity expansion and storage of the data of the internet of things based on the block chain in the embodiment of the present application described in conjunction with fig. 1 may be implemented by a computing device. Fig. 9 is a hardware structure diagram of a computing device according to an embodiment of the present application.
The computing device is deployed in a building internet of things environment and may include a processor 81 and memory 82 having stored thereon computer program instructions.
In particular, the processor 81 may include a Central Processing Unit (CPU), or an Application Specific Integrated Circuit (ASIC), or may be configured to implement one or more Integrated circuits of the embodiments of the present Application.
Memory 82 may include, among other things, mass storage for data or instructions. By way of example, and not limitation, the memory 82 may include a Hard Disk Drive (Hard Disk Drive, abbreviated HDD), a floppy Disk Drive, a Solid State Drive (SSD), flash memory, an optical Disk, a magneto-optical Disk, tape, or a Universal Serial Bus (USB) Drive or a combination of two or more of these. Memory 82 may include removable or non-removable (or fixed) media, where appropriate. The memory 82 may be internal or external to the data processing apparatus, where appropriate. In a particular embodiment, the memory 82 is a Non-Volatile (Non-Volatile) memory. In particular embodiments, memory 82 includes Read-Only Memory (ROM) and Random Access Memory (RAM). The ROM may be mask-programmed ROM, programmable ROM (PROM), erasable PROM (EPROM), electrically Erasable PROM (EEPROM), electrically rewritable ROM (EAROM), or FLASH Memory (FLASH), or a combination of two or more of these, where appropriate. The RAM may be a Static Random-Access Memory (SRAM) or a Dynamic Random-Access Memory (DRAM), where the DRAM may be a Fast Page Mode Dynamic Random-Access Memory (FPMDRAM), an Extended data output Dynamic Random-Access Memory (EDODRAM), a Synchronous Dynamic Random-Access Memory (SDRAM), and the like.
The memory 82 may be used to store or cache various data files for processing and/or communication use, as well as possible computer program instructions executed by the processor 81.
The processor 81 reads and executes the computer program instructions stored in the memory 82 to implement any one of the above embodiments of the method for expanding and storing data of the internet of things based on the block chain.
In some of these embodiments, the computing device may also include a communication interface 83 and a bus 80. As shown in fig. 9, the processor 81, the memory 82, and the communication interface 83 are connected via the bus 80 to complete communication therebetween.
The communication interface 83 is used for implementing communication between various modules, apparatuses, units and/or devices in the embodiments of the present application. The communication port 83 may also be implemented with other components such as: the data communication is carried out among external equipment, image/data acquisition equipment, a database, external storage, an image/data processing workstation and the like.
Bus 80 comprises hardware, software, or both coupling the components of the computing device to one another. Bus 80 includes, but is not limited to, at least one of the following: data Bus (Data Bus), address Bus (Address Bus), control Bus (Control Bus), expansion Bus (Expansion Bus), and Local Bus (Local Bus). By way of example and not limitation, bus 80 may include an Accelerated Graphics Port (AGP) or other Graphics Bus, an Enhanced Industry Standard Architecture (EISA) Bus, a Front-Side Bus (FSB), a Hyper Transport (HT) Interconnect, an ISA (ISA) Bus, an InfiniBand (InfiniBand) Interconnect, a Low Pin Count (LPC) Bus, a memory Bus, a microchannel Architecture (MCA) Bus, a PCI (Peripheral Component Interconnect) Bus, a PCI-Express (PCI-X) Bus, a Serial Advanced Technology Attachment (SATA) Bus, a vlslave Bus, a Video Bus, or a combination of two or more of these suitable electronic buses. Bus 80 may include one or more buses, where appropriate. Although specific buses are described and shown in the embodiments of the application, any suitable buses or interconnects are contemplated by the application.
The computing device may execute the block chain-based internet of things data capacity expansion storage method in the embodiment of the present application based on the acquired data storage request, so as to implement the block chain-based internet of things data capacity expansion storage method described in conjunction with fig. 1.
In addition, in combination with the block chain-based internet of things data capacity expansion storage method in the foregoing embodiments, embodiments of the present application may provide a computer-readable storage medium to implement the method. The computer readable storage medium having stored thereon computer program instructions; when executed by a processor, the computer program instructions implement any one of the above embodiments of the method for capacity expansion and storage of internet of things data based on a block chain.
The above description is only a preferred embodiment of the present invention, and not intended to limit the present invention in other forms, and any person skilled in the art may apply the above modifications or variations to the disclosed embodiments and equivalent embodiments, but also may make various changes, combinations, equivalents and modifications within the technical scope of the present invention without departing from the technical spirit of the present invention.