OSDN Git Service

Mov (#518)
[bytom/vapor.git] / protocol / validation / tx.go
index bb82479..44287e9 100644 (file)
@@ -3,8 +3,10 @@ package validation
 import (
        "fmt"
        "math"
+       "runtime"
        "sync"
 
+       "github.com/bytom/vapor/common"
        "github.com/bytom/vapor/config"
        "github.com/bytom/vapor/consensus"
        "github.com/bytom/vapor/errors"
@@ -13,10 +15,6 @@ import (
        "github.com/bytom/vapor/protocol/vm"
 )
 
-const (
-       validateWorkerNum = 32
-)
-
 // validate transaction error
 var (
        ErrTxVersion                 = errors.New("invalid transaction version")
@@ -278,8 +276,12 @@ func checkValid(vs *validationState, e bc.Entry) (err error) {
                }
 
                prog := &bc.Program{
-                       VmVersion: e.ControlProgram.VmVersion,
-                       Code:      config.FederationWScript(config.CommonConfig),
+                       VmVersion: e.AssetDefinition.IssuanceProgram.VmVersion,
+                       Code:      e.AssetDefinition.IssuanceProgram.Code,
+               }
+
+               if !common.IsOpenFederationIssueAsset(e.RawDefinitionByte) {
+                       prog.Code = config.FederationWScript(config.CommonConfig)
                }
 
                if _, err := vm.Verify(NewTxVMContext(vs, e, prog, e.WitnessArguments), consensus.ActiveNetParams.DefaultGasCredit); err != nil {
@@ -663,6 +665,7 @@ func validateTxWorker(workCh chan *validateTxWork, resultCh chan *ValidateTxResu
 // ValidateTxs validates txs in async mode
 func ValidateTxs(txs []*bc.Tx, block *bc.Block) []*ValidateTxResult {
        txSize := len(txs)
+       validateWorkerNum := runtime.NumCPU()
        //init the goroutine validate worker
        var wg sync.WaitGroup
        workCh := make(chan *validateTxWork, txSize)