-func (b *bbft) DetachBlock(voteResultMap map[uint64]*state.VoteResult, block *types.Block) error {
- voteSeq := block.Height / roundVoteBlockNums
- voteResult := voteResultMap[voteSeq]
-
- if voteResult == nil {
- store := b.consensusNodeManager.store
- voteResult, err := store.GetVoteResult(voteSeq)
- if err != nil {
- return err
- }
- voteResultMap[voteSeq] = voteResult
- }
-
- if voteResult.LastBlockHeight != block.Height {
- return errors.New("bbft detach block error, the block height is not equals last block height of vote result")
- }
-
- for _, tx := range block.Transactions {
- for _, input := range tx.Inputs {
- unVoteInput, ok := input.TypedInput.(*types.UnvoteInput)
- if !ok {
- continue
- }
-
- pubkey := hex.EncodeToString(unVoteInput.Vote)
- voteResult.NumOfVote[pubkey], ok = checked.AddUint64(voteResult.NumOfVote[pubkey], unVoteInput.Amount)
- if !ok {
- return errVotingOperationOverFlow
- }
- }
- for _, output := range tx.Outputs {
- voteOutput, ok := output.TypedOutput.(*types.VoteTxOutput)
- if !ok {
- continue
- }
-
- pubkey := hex.EncodeToString(voteOutput.Vote)
- voteResult.NumOfVote[pubkey], ok = checked.SubUint64(voteResult.NumOfVote[pubkey], voteOutput.Amount)
- if !ok {
- return errVotingOperationOverFlow
- }
- }
- }
-
- voteResult.LastBlockHeight--
- voteResult.Finalized = false
- return nil
+// NextLeaderTime returns the start time of the specified public key as the next leader node
+func (c *Chain) IsBlocker(prevBlockHash *bc.Hash, pubkey string, timeStamp uint64) (bool, error) {
+ return c.consensusNodeManager.isBlocker(prevBlockHash, pubkey, timeStamp)