OSDN Git Service

Merge pull request #41 from Bytom/dev
[bytom/vapor.git] / protocol / validation / block.go
index e55e22c..17aff8a 100644 (file)
@@ -5,9 +5,7 @@ import (
 
        log "github.com/sirupsen/logrus"
 
-       "github.com/vapor/chain"
        "github.com/vapor/consensus"
-       engine "github.com/vapor/consensus/consensus"
        "github.com/vapor/errors"
        "github.com/vapor/protocol/bc"
        "github.com/vapor/protocol/bc/types"
@@ -56,7 +54,7 @@ func checkCoinbaseAmount(b *bc.Block, amount uint64) error {
 }
 
 // ValidateBlockHeader check the block's header
-func ValidateBlockHeader(b *bc.Block, block *types.Block, parent *state.BlockNode, c chain.Chain, engine engine.Engine) error {
+func ValidateBlockHeader(b *bc.Block, block *types.Block, parent *state.BlockNode) error {
        if b.Version < parent.Version {
                return errors.WithDetailf(errVersionRegression, "previous block verson %d, current block version %d", parent.Version, b.Version)
        }
@@ -69,31 +67,17 @@ func ValidateBlockHeader(b *bc.Block, block *types.Block, parent *state.BlockNod
        if err := checkBlockTime(b, parent); err != nil {
                return err
        }
-       if err := engine.VerifyHeader(c, &block.BlockHeader, false); err != nil {
-               return err
-       }
 
        return nil
 }
 
 // ValidateBlock validates a block and the transactions within.
-func ValidateBlock(b *bc.Block, parent *state.BlockNode, block *types.Block, c chain.Chain, engine engine.Engine, authoritys map[string]string, position uint64) error {
+func ValidateBlock(b *bc.Block, parent *state.BlockNode, block *types.Block) error {
        startTime := time.Now()
-       if err := ValidateBlockHeader(b, block, parent, c, engine); err != nil {
+       if err := ValidateBlockHeader(b, block, parent); err != nil {
                return err
        }
-       /*
-               time.Sleep(3 * time.Second)
-               // 验证出块人
-               controlProgram := hex.EncodeToString(block.Proof.ControlProgram)
-               xpub := &chainkd.XPub{}
-               xpub.UnmarshalText([]byte(authoritys[controlProgram]))
 
-               msg := block.BlockCommitment.TransactionsMerkleRoot.Bytes()
-               if !xpub.Verify(msg, block.Proof.Sign) {
-                       return errors.New("Verification signature failed")
-               }
-       */
        blockGasSum := uint64(0)
        coinbaseAmount := consensus.BlockSubsidy(b.BlockHeader.Height)
        b.TransactionStatus = bc.NewTransactionStatus()