OSDN Git Service

add broadcast block signature (#139)
authormuscle_boy <shenao.78@163.com>
Thu, 6 Jun 2019 02:10:11 +0000 (10:10 +0800)
committerPaladz <yzhu101@uottawa.ca>
Thu, 6 Jun 2019 02:10:11 +0000 (10:10 +0800)
protocol/bbft.go

index 40b2730..4fdb607 100644 (file)
@@ -11,6 +11,7 @@ import (
        "github.com/vapor/protocol/bc"
        "github.com/vapor/protocol/bc/types"
        "github.com/vapor/protocol/state"
        "github.com/vapor/protocol/bc"
        "github.com/vapor/protocol/bc/types"
        "github.com/vapor/protocol/state"
+       "github.com/vapor/event"
 )
 
 const (
 )
 
 const (
@@ -65,7 +66,11 @@ func (c *Chain) ProcessBlockSignature(signature []byte, xPub [64]byte, blockHash
                return err
        }
 
                return err
        }
 
-       if consensusNode.XPub.Verify(blockHash.Bytes(), signature) {
+       if exist, err := blockNode.BlockWitness.Test(uint32(consensusNode.Order)); err != nil && exist {
+               return nil
+       }
+
+       if !consensusNode.XPub.Verify(blockHash.Bytes(), signature) {
                return errInvalidSignature
        }
 
                return errInvalidSignature
        }
 
@@ -90,7 +95,8 @@ func (c *Chain) ProcessBlockSignature(signature []byte, xPub [64]byte, blockHash
 
                c.bestIrreversibleNode = bestIrreversibleNode
        }
 
                c.bestIrreversibleNode = bestIrreversibleNode
        }
-       return nil
+
+       return c.eventDispatcher.Post(event.BlockSignatureEvent{BlockHash: *blockHash, Signature: signature, XPub: xPub})
 }
 
 // validateSign verify the signatures of block, and return the number of correct signature
 }
 
 // validateSign verify the signatures of block, and return the number of correct signature