| 242 | } |
| 243 | |
| 244 | func (self *Syncer) blockConsensusDone(blks BlockFromPeers) *Block { |
| 245 | // TODO: also check blockhash |
| 246 | proposers := make(map[uint32]int) |
| 247 | for _, blk := range blks { |
| 248 | proposers[blk.getProposer()] += 1 |
| 249 | } |
| 250 | for proposerId, cnt := range proposers { |
| 251 | if cnt > int(self.server.config.C) { |
| 252 | // find the block |
| 253 | for _, blk := range blks { |
| 254 | if blk.getProposer() == proposerId { |
| 255 | return blk |
| 256 | } |
| 257 | } |
| 258 | } |
| 259 | } |
| 260 | return nil |
| 261 | } |
| 262 | |
| 263 | func (self *Syncer) getCurrentTargetBlockNum() uint32 { |
| 264 | var targetBlkNum uint32 |