X-Git-Url: http://git.osdn.net/view?p=bytom%2Fvapor.git;a=blobdiff_plain;f=test%2Fbench_blockchain_test.go;h=77cf9c174d7ee2d5e121fdc4fa197ff2df5bcf03;hp=c29746f71175343d24c22717911044e25b56d334;hb=1337be95f74a1d2a1a7316737efde413f29bcb2f;hpb=0e10ee14a3622222d6f0cff01d3046a6d44b9f50 diff --git a/test/bench_blockchain_test.go b/test/bench_blockchain_test.go index c29746f7..77cf9c17 100644 --- a/test/bench_blockchain_test.go +++ b/test/bench_blockchain_test.go @@ -7,21 +7,22 @@ import ( "testing" "time" - dbm "github.com/tendermint/tmlibs/db" - - "github.com/vapor/account" - "github.com/vapor/blockchain/pseudohsm" - "github.com/vapor/blockchain/signers" - "github.com/vapor/blockchain/txbuilder" - "github.com/vapor/consensus" - "github.com/vapor/crypto/ed25519/chainkd" - "github.com/vapor/database/leveldb" - "github.com/vapor/database/storage" - "github.com/vapor/mining" - "github.com/vapor/protocol" - "github.com/vapor/protocol/bc" - "github.com/vapor/protocol/bc/types" - "github.com/vapor/protocol/state" + "github.com/bytom/vapor/account" + "github.com/bytom/vapor/blockchain/pseudohsm" + "github.com/bytom/vapor/blockchain/signers" + "github.com/bytom/vapor/blockchain/txbuilder" + "github.com/bytom/vapor/config" + "github.com/bytom/vapor/consensus" + "github.com/bytom/vapor/crypto/ed25519/chainkd" + "github.com/bytom/vapor/database" + dbm "github.com/bytom/vapor/database/leveldb" + "github.com/bytom/vapor/database/storage" + "github.com/bytom/vapor/event" + "github.com/bytom/vapor/proposal" + "github.com/bytom/vapor/protocol" + "github.com/bytom/vapor/protocol/bc" + "github.com/bytom/vapor/protocol/bc/types" + "github.com/bytom/vapor/protocol/state" ) func BenchmarkChain_CoinBaseTx_NoAsset(b *testing.B) { @@ -126,7 +127,7 @@ func GenerateChainData(dirPath string, testDB dbm.DB, txNumber, otherAssetNum in // init UtxoViewpoint utxoView := state.NewUtxoViewpoint() - utxoEntry := storage.NewUtxoEntry(false, 1, false) + utxoEntry := storage.NewUtxoEntry(storage.NormalUTXOType, 1, false) for _, tx := range txs { for _, id := range tx.SpentOutputIDs { utxoView.Entries[id] = utxoEntry @@ -137,9 +138,11 @@ func GenerateChainData(dirPath string, testDB dbm.DB, txNumber, otherAssetNum in return nil, nil, nil, err } - store := leveldb.NewStore(testDB) - txPool := protocol.NewTxPool(store) - chain, err := protocol.NewChain(store, txPool) + config.CommonConfig = config.DefaultConfig() + store := database.NewStore(testDB) + dispatcher := event.NewDispatcher() + txPool := protocol.NewTxPool(store, dispatcher) + chain, err := protocol.NewChain(store, txPool, dispatcher) if err != nil { return nil, nil, nil, err } @@ -156,7 +159,7 @@ func InsertChain(chain *protocol.Chain, txPool *protocol.TxPool, txs []*types.Tx } } - block, err := mining.NewBlockTemplate(chain, txPool, nil) + block, err := proposal.NewBlockTemplate(chain, txPool, nil, uint64(time.Now().UnixNano()/1e6)) if err != nil { return err } @@ -181,11 +184,6 @@ func InsertChain(chain *protocol.Chain, txPool *protocol.TxPool, txs []*types.Tx } func processNewTxch(txPool *protocol.TxPool) { - newTxCh := txPool.GetMsgCh() - for tx := range newTxCh { - if tx == nil { - } - } } func MockSimpleUtxo(index uint64, assetID *bc.AssetID, amount uint64, ctrlProg *account.CtrlProgram) *account.UTXO { @@ -253,7 +251,7 @@ func AddTxInputFromUtxo(utxo *account.UTXO, singer *signers.Signer) (*types.TxIn } func AddTxOutput(assetID bc.AssetID, amount uint64, controlProgram []byte) *types.TxOutput { - out := types.NewTxOutput(assetID, amount, controlProgram) + out := types.NewIntraChainOutput(assetID, amount, controlProgram) return out } @@ -361,7 +359,7 @@ func CreateTxbyNum(txNumber, otherAssetNum int) ([]*types.Tx, error) { func SetUtxoView(db dbm.DB, view *state.UtxoViewpoint) error { batch := db.NewBatch() - if err := leveldb.SaveUtxoView(batch, view); err != nil { + if err := database.SaveUtxoView(batch, view); err != nil { return err } batch.Write() @@ -370,7 +368,8 @@ func SetUtxoView(db dbm.DB, view *state.UtxoViewpoint) error { //-------------------------Mock actual transaction---------------------------------- func MockTxsP2PKH(keyDirPath string, testDB dbm.DB, txNumber, otherAssetNum int) ([]*types.Tx, error) { - accountManager := account.NewManager(testDB, nil) + accountStore := database.NewAccountStore(testDB) + accountManager := account.NewManager(accountStore, nil) hsm, err := pseudohsm.New(keyDirPath) if err != nil { return nil, err @@ -412,7 +411,8 @@ func MockTxsP2PKH(keyDirPath string, testDB dbm.DB, txNumber, otherAssetNum int) } func MockTxsP2SH(keyDirPath string, testDB dbm.DB, txNumber, otherAssetNum int) ([]*types.Tx, error) { - accountManager := account.NewManager(testDB, nil) + accountStore := database.NewAccountStore(testDB) + accountManager := account.NewManager(accountStore, nil) hsm, err := pseudohsm.New(keyDirPath) if err != nil { return nil, err @@ -459,7 +459,8 @@ func MockTxsP2SH(keyDirPath string, testDB dbm.DB, txNumber, otherAssetNum int) } func MockTxsMultiSign(keyDirPath string, testDB dbm.DB, txNumber, otherAssetNum int) ([]*types.Tx, error) { - accountManager := account.NewManager(testDB, nil) + accountStore := database.NewAccountStore(testDB) + accountManager := account.NewManager(accountStore, nil) hsm, err := pseudohsm.New(keyDirPath) if err != nil { return nil, err