Research Article

Research on Grain Food Blockchain Traceability Information Management Model Based on Master-Slave Multichain

Algorithm 3

CI-PBFT consensus algorithm.
Input: common node cluster Q
Output: consensus node cluster CN, preset node cluster PN
(1)  for round i
(2)if s″ = “Ordinary Node”
(3)  if j apply to become Consensus Node then
(4)   if CCN < 70% N then
(5)   if application is approved then
(6)    CCN = CCN + 1
(7)   end if
(8)   else
(9)    CPN = CPN + 1
(10)   end if
(11)  else
(12)   switch(b)
(13)   {
(14)    case1://Successful initial block as master node
(15)     Score″ += 1
(16)     break
(17)    case2://Successful initial block as slave node
(18)     Score″ += 1
(19)     break
(20)    case3://Successfully challenge the master node as a slave node
(21)     Score″ += 1
(22)     break
(23)    case4://Being challenged by the master node as a slave node
(24)     Score″ −= 2
(25)     break
(26)    case5://Failed to unpack as master/slave node
(27)     Score″ −= 2
(28)     break
(29)   }
(30)  end if
(31)  The first n nodes of CPN become CCN
(32)  The next n nodes of CCN become CPN
(33)  return CCN, CPN