-func (c *Chain) ProcessDPoSConnectBlock(block *types.Block) {
- mapTxFee := c.CalculateBalance(block, true)
- fmt.Println(mapTxFee)
-}
-
-func DoVoting(block *types.Block, mapTxFee map[bc.Hash]uint64) error {
- for _, tx := range block.Transactions {
- to := tx.Outputs[0]
- var delegate engine.TypedData
-
- if err := json.Unmarshal(tx.TxData.ReferenceData, delegate); err != nil && to.Amount > 0 {
- continue
- }
- var (
- address common.Address
- err error
- )
- address, err = common.NewAddressWitnessPubKeyHash(to.ControlProgram[2:], &consensus.ActiveNetParams)
- if err != nil {
- address, err = common.NewAddressWitnessScriptHash(to.ControlProgram[2:], &consensus.ActiveNetParams)
- if err != nil {
- return errors.New("ControlProgram cannot be converted to address")
- }
- }
- hash := block.Hash()
- height := block.Height
- switch data := delegate.(type) {
- case *engine.DelegateInfoList:
- continue
- case *engine.RegisterForgerData:
- if mapTxFee[tx.Tx.ID] >= consensus.RegisrerForgerFee {
- engine.DposVote.ProcessRegister(address.EncodeAddress(), data.Name, hash, height)
- }
- case *engine.VoteForgerData:
- if mapTxFee[tx.Tx.ID] >= consensus.VoteForgerFee {
- engine.DposVote.ProcessVote(address.EncodeAddress(), data.Forgers, hash, height)
- }
- case *engine.CancelVoteForgerData:
- if mapTxFee[tx.Tx.ID] >= consensus.CancelVoteForgerFee {
- engine.DposVote.ProcessCancelVote(address.EncodeAddress(), data.Forgers, hash, height)
- }
- }
+func (c *Chain) ProcessBlockSignature(signature []byte, xPub [64]byte, blockHeight uint64, blockHash *bc.Hash) error {
+ isIrreversible, err := c.bbft.ProcessBlockSignature(signature, xPub, blockHeight, blockHash)
+ if err != nil {
+ return err