OSDN Git Service

fix sign block (#112)
[bytom/vapor.git] / protocol / bbft.go
index 107334a..d026e95 100644 (file)
@@ -223,6 +223,14 @@ func (b *bbft) SignBlock(block *types.Block) ([]byte, error) {
                return nil, nil
        }
 
+       blockNodes := b.consensusNodeManager.blockIndex.NodesByHeight(block.Height)
+       for _, blockNode := range blockNodes {
+               // Has already signed the same height block
+               if ok, err := blockNode.BlockWitness.Test(uint32(node.order)); err != nil && ok {
+                       return nil, nil
+               }
+       }
+
        signature := block.Witness[node.order]
        if len(signature) == 0 {
                signature = xprv.Sign(block.Hash().Bytes())