- return 0, 0, err
- }
-
- return nextLeaderTime, nextLeaderTime + BlockNumEachNode*BlockTimeInterval, nil
-}
-
-func nextLeaderTimeHelper(startTime, now, nodeOrder uint64) (uint64, error) {
- nextLeaderTimestamp := getLastBlockTimeInTimeRange(startTime, now, nodeOrder)
- roundBlockTime := uint64(BlockNumEachNode * NumOfConsensusNode * BlockTimeInterval)
-
- if now > nextLeaderTimestamp {
- nextLeaderTimestamp += roundBlockTime
- }
-
- return nextLeaderTimestamp, nil
-}
-
-func getLastBlockTimeInTimeRange(startTimestamp, endTimestamp, order uint64) uint64 {
- // One round of product block time for all consensus nodes
- roundBlockTime := uint64(BlockNumEachNode * NumOfConsensusNode * BlockTimeInterval)
- // The start time of the last round of product block
- lastRoundStartTime := startTimestamp + (endTimestamp-startTimestamp)/roundBlockTime*roundBlockTime
- // The time of product block of the consensus in last round
- return lastRoundStartTime + order*(BlockNumEachNode*BlockTimeInterval)
-}
-
-func (c *consensusNodeManager) getPrevRoundVoteLastBlock(prevBlockHash *bc.Hash) (*state.BlockNode, error) {
- prevBlockNode := c.blockIndex.GetNode(prevBlockHash)
- if prevBlockNode == nil {
- return nil, errNotFoundBlockNode
- }
-
- blockHeight := prevBlockNode.Height + 1
-
- prevVoteRoundLastBlockHeight := blockHeight/RoundVoteBlockNums*RoundVoteBlockNums - 1
- // first round
- if blockHeight/RoundVoteBlockNums == 0 {
- prevVoteRoundLastBlockHeight = 0