github.com/cheng762/platon-go@v1.8.17-0.20190529111256-7deff2d7be26/consensus/cbft/rotating.go (about) 1 package cbft 2 3 import ( 4 "github.com/PlatONnetwork/PlatON-Go/common" 5 ) 6 7 type rotating struct { 8 ppos *ppos 9 rotaList []common.Address // This round of cyclic block node order list 10 startTime int64 // The current cycle start timestamp, in milliseconds 11 endTime int64 // The current cycle end timestamp, in milliseconds 12 timeInterval int64 // Block time per unit, in milliseconds 13 } 14 15 func newRotating(ppos *ppos, timeInterval int64) *rotating { 16 rotating := &rotating{ 17 ppos: ppos, 18 timeInterval: timeInterval, 19 } 20 return rotating 21 } 22 23 func sort() { 24 // New round of consensus sorting function 25 // xor(Last block last block hash + node public key address) 26 } 27 28 func (r *rotating) IsRotating(common.Address) bool { 29 // Determine whether the current node is out of order 30 // Sort by consensus and time window 31 return false 32 } 33 34 /*func (r *rotating) inturn(number uint64, signer common.Address) bool { 35 sort.Sort(signerOrderingRule(r.rotaList)) 36 offset := 0 37 for offset < len(r.rotaList) && r.rotaList[offset] != signer { 38 offset++ 39 } 40 return (number % uint64(len(r.rotaList))) == uint64(offset) 41 } 42 43 type signerOrderingRule []common.Address 44 func (s signerOrderingRule) Len() int { return len(s) } 45 func (s signerOrderingRule) Less(i, j int) bool { return bytes.Compare(s[i][:], s[j][:]) < 0 } 46 func (s signerOrderingRule) Swap(i, j int) { s[i], s[j] = s[j], s[i] }*/