# IoT Blockchain Data Vercity with Data Loss Tolerance
## 2 Materials and Methods
### Overview of IoT with Edge Computing and Blockchain
#### 2.2.1 Peer-to-Peer (P2P) Network and Secured Distributed Storage in IoT Blockchain  
The data veracity is featured in IoT blockchain through its P2P network and secured distributed storage capability. Two-level network access control was adopted in the proposed IoT blockchain to ensure a high level of security. These are the WIFI D2D private secure key and the IoT blockchain network membership. In WIFI D2D connectivity, prior joining to the network, a new node must obtain the WIFI D2D private secure key. The node will be rejected if it fails in presenting the correct key. After the new node successfully joined into the WIFI D2D network, it can only then proceed to the next level of connection to the IoT blockchain P2P network. For a new node to get connected to an existing IoT blockchain, it must first obtain the IoT blockchain's daemon name and its proprietary information. The daemon name and its proprietary information are private, confidential, and restricted to private communication only. A new node joining an IoT blockchain process flow is depicted in Figure 3.  
The algorithm for a new node joining the IoT blockchain is evaluated with intelligent small computing resources, in this case the Raspberry Pi. The algorithm is shown in Appendix A Algorithm A1: New node joining IoT blockchain P2P network. The algorithm begins with booting up the first blockchain node, creating a new IoT blockchain daemon name and configuring the parameters according to the IoT blockchain requirements. The IoT blockchain daemon is established once the parameter settings are completed. The daemon name, IP address and port number will only be shared internally to members. The first administrator node is granted all permissions, including admin  
Figure 3: New node joining IoT blockchain: (**a**) Process flow; (**b**) Flow diagram. istration and distributed storage. It also automatically receives all privileges, including administrator rights to manage the privileges of other nodes. When the number of connected nodes increases, redundancy can be created where more nodes can be promoted as administrator. The new node initiates a joining request with the IoT blockchain daemon and its proprietary connection information. The connection request is handled by the IoT blockchain administrators, which grant the connection request only upon confirmation of validity. Once the new node is successfully connected to the IoT blockchain, it begins downloading the IoT blockchain parameters, verifying and discovering with other peers. The transaction data publishing and replication are then evaluated. Most IoT data capturing is processed in a stream format. The data publishing, storage and replication also adopted a stream format. Moving further up to the data exchange between nodes and application, it continues to leverage on similar stream-based messaging protocols: message queuing telemetry transport protocol (MQTT) and advanced message queuing protocol (AMQP). Stream-based transacted data is used for analysis in the application layer. The IoT blockchain provides data stream protocol for the data publishing, storage, and replication process. Data stream protocols allow the IoT blockchain to create a transaction with a key, values, time series, or identity in encrypted distributed ledger technology. Each data stream on the IoT blockchain consists of a list of items. The items contain information about the node, data stored and index. To store data using stream, one needs two inputs: the data and a key as an identifier for the data. In addition, it also provides time stamping. Transaction data published is replicated and stored to all the nodes. Each data stream on an IoT blockchain consists of a list of items. Each of the items in the data stream contains the information as shown in Table 5.  
There is no limit on the size of data streams, apart from the disk space available. Data streams are efficiently indexed using on-storage indexes which accommodate millions of items.