# An Internet of Things Access Control Scheme Based on Permissioned Blockchain and Edge Computing
## 5 KRaft Consensus Algorithm  
Consensus algorithm is the key technology in the blockchain [23]. Because of the admission mechanism of the license chain, all nodes in the blockchain network are honest  
Figure 4: Access control process.  
and credible nodes, and there is no Byzantine fault tolerance problem. Only unexpected scenarios such as network interruption, disk failure, and machine downtime should be considered [24]. The Kraft consensus algorithm is based on an improvement of the Raft algorithm, using Kademolia's efficient log replication logic to solve the parallel and leader overload problems, improving the efficiency and scalability of the blockchain. In this paper, the deployment of smart contract access control policy, access authorization, access authorization logging, and access logging are all recorded into the object blockchain and log blockchain through the KRaft consensus algorithm.  
The KRaft consensus algorithm is introduced to solve the problems of low throughput and scalability of the existing consensus algorithm and improve the scalability of the license chain. The following explains how to log access into the blockchain using the KRaft algorithm.  
The KRaft consensus algorithm [25] consists of two essential processes: Leader election and log replication. During the device initialization phase, all nodes act as candidate nodes and ship election requests to all different nodes. When a Candidate node is supported by greater than half of the different nodes, it will be chosen as the Leader node. If no candidate node meets the election criteria, the election will take location once more after a positive quantity of built-in clock. For Leader node failure or downtime due to exterior reasons, the state of affairs is equal as it is throughout the re-election transition phase. Because all different nodes end up receiving records from the Leader node, they enter the re-election segment early. The leadership election method is proven in Figure 5.  
The core consensus process of the KRaft algorithm is the log replication process, as shown in Figure 6. It can be briefly described as follows: (1) The client initiates an access logging request to the Leader node. (2) The Leader node adds an entry for the request and broadcasts it to the Follower node. (3) The Follower node stores the entries locally and informs the Leader node. (4) After receiving more than half of the replies, the Leader node confirms the request and returns it to the client. The confirmation message is sent to the Follower node in the next broadcast.  
Figure 5: Leader election process.  
The Leader node sends extra log entries repeatedly to make sure that the log entries stored in the Follower node are consistent with itself and attain a consensus. Log entries will also no longer be synchronized immediately after comments from the Followers node to the Leader node. We should wait for the next round of log entries furnished by means of the Leader node to incorporate confirmation that the Leader node has synchronized the previous round of entries, and then synchronize the entries.  
In the process of access logging, the Leader node packages the collected access logs into blocks. Once a consensus is reached, the block is added to the blockchain.