-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) getConsensusNodesByVoteResult(blockHeight uint64) (map[string]*consensusNode, error) {
- defer c.RUnlock()
- c.RLock()
- if blockHeight >= c.effectiveStartHeight+roundVoteBlockNums {
- return nil, errors.New("the given block height is greater than current vote start height")
- }
-
- if blockHeight >= c.effectiveStartHeight {
- return c.consensusNodeMap, nil
+func (c *Chain) reorganizeVoteResult(voteResult *state.VoteResult, blockHeader *types.BlockHeader) error {
+ mainChainBlockHeader, err := c.store.GetBlockHeader(&voteResult.BlockHash)
+ if err != nil {
+ return err