Commit 9d6dc786 authored by vipwzw's avatar vipwzw

use executor.statedb statedb

parent 0f22c9c6
...@@ -11,6 +11,7 @@ APP := build/chain33 ...@@ -11,6 +11,7 @@ APP := build/chain33
CHAIN33=github.com/33cn/chain33 CHAIN33=github.com/33cn/chain33
CHAIN33_PATH=vendor/${CHAIN33} CHAIN33_PATH=vendor/${CHAIN33}
LDFLAGS := -ldflags "-w -s" LDFLAGS := -ldflags "-w -s"
PKG_LIST_VET := `go list ./... | grep -v "vendor"`
PKG_LIST := `go list ./... | grep -v "vendor" | grep -v "chain33/test" | grep -v "mocks" | grep -v "pbft"` PKG_LIST := `go list ./... | grep -v "vendor" | grep -v "chain33/test" | grep -v "mocks" | grep -v "pbft"`
PKG_LIST_Q := `go list ./... | grep -v "vendor" | grep -v "chain33/test" | grep -v "mocks" | grep -v "blockchain" | grep -v "pbft"` PKG_LIST_Q := `go list ./... | grep -v "vendor" | grep -v "chain33/test" | grep -v "mocks" | grep -v "blockchain" | grep -v "pbft"`
BUILD_FLAGS = -ldflags "-X github.com/33cn/chain33/common/version.GitCommit=`git rev-parse --short=8 HEAD`" BUILD_FLAGS = -ldflags "-X github.com/33cn/chain33/common/version.GitCommit=`git rev-parse --short=8 HEAD`"
...@@ -35,6 +36,8 @@ build_ci: depends ## Build the binary file for CI ...@@ -35,6 +36,8 @@ build_ci: depends ## Build the binary file for CI
para: para:
@go build -v -o build/$(NAME) -ldflags "-X $(SRC_CLI)/buildflags.ParaName=user.p.$(NAME). -X $(SRC_CLI)/buildflags.RPCAddr=http://localhost:8901" $(SRC_CLI) @go build -v -o build/$(NAME) -ldflags "-X $(SRC_CLI)/buildflags.ParaName=user.p.$(NAME). -X $(SRC_CLI)/buildflags.RPCAddr=http://localhost:8901" $(SRC_CLI)
vet:
@go vet ${PKG_LIST_VET}
autotest: ## build autotest binary autotest: ## build autotest binary
@cd build/autotest && bash ./build.sh && cd ../../ @cd build/autotest && bash ./build.sh && cd ../../
...@@ -260,4 +263,23 @@ push: ...@@ -260,4 +263,23 @@ push:
make sync make sync
git checkout ${b} git checkout ${b}
git merge master git merge master
git push origin ${b} git push origin ${b}
\ No newline at end of file
pull:
@remotelist=$$(git remote | grep ${name});if [ -z $$remotelist ]; then \
echo ${remotelist}; \
git remote add ${name} https://github.com/${name}/plugin.git ; \
fi;
git fetch ${name}
git checkout ${name}/${b}
git checkout -b ${name}-${b}
pullsync:
git fetch ${name}
git checkout ${name}-${b}
git merge ${name}/${b}
pullpush:
@if [ -n "$$m" ]; then \
git commit -a -m "${m}" ; \
fi;
make pullsync
git push ${name} ${name}-${b}:${b}
...@@ -12,6 +12,7 @@ import ( ...@@ -12,6 +12,7 @@ import (
"github.com/33cn/chain33/common/crypto" "github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/common/db" "github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/executor"
drivers "github.com/33cn/chain33/system/dapp" drivers "github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
rt "github.com/33cn/plugin/plugin/dapp/retrieve/types" rt "github.com/33cn/plugin/plugin/dapp/retrieve/types"
...@@ -33,6 +34,9 @@ func init() { ...@@ -33,6 +34,9 @@ func init() {
retrieve = constructRetrieveInstance() retrieve = constructRetrieveInstance()
} }
func NewTestDB() db.KV {
return executor.NewStateDB(nil, nil, nil, &executor.StateDBOption{Height: types.GetFork("ForkExecRollback")})
}
func TestExecBackup(t *testing.T) { func TestExecBackup(t *testing.T) {
var targetReceipt types.Receipt var targetReceipt types.Receipt
var targetErr error var targetErr error
...@@ -360,35 +364,3 @@ func (e *TestLDB) List(prefix, key []byte, count, direction int32) ([][]byte, er ...@@ -360,35 +364,3 @@ func (e *TestLDB) List(prefix, key []byte, count, direction int32) ([][]byte, er
func (e *TestLDB) PrefixCount(prefix []byte) int64 { func (e *TestLDB) PrefixCount(prefix []byte) int64 {
return 0 return 0
} }
type TestDB struct {
db.TransactionDB
cache map[string][]byte
}
func NewTestDB() *TestDB {
return &TestDB{cache: make(map[string][]byte)}
}
func (e *TestDB) Get(key []byte) (value []byte, err error) {
if value, ok := e.cache[string(key)]; ok {
//elog.Error("getkey", "key", string(key), "value", string(value))
return value, nil
}
return nil, types.ErrNotFound
}
func (e *TestDB) Set(key []byte, value []byte) error {
//elog.Error("setkey", "key", string(key), "value", string(value))
e.cache[string(key)] = value
return nil
}
func (e *TestDB) BatchGet(keys [][]byte) (values [][]byte, err error) {
return nil, types.ErrNotFound
}
//从数据库中查询数据列表,set 中的cache 更新不会影响这个list
func (e *TestDB) List(prefix, key []byte, count, direction int32) ([][]byte, error) {
return nil, types.ErrNotFound
}
...@@ -6,7 +6,6 @@ package db ...@@ -6,7 +6,6 @@ package db
import ( import (
"bytes" "bytes"
"fmt"
log "github.com/33cn/chain33/common/log/log15" log "github.com/33cn/chain33/common/log/log15"
) )
...@@ -173,22 +172,22 @@ func (db *ListHelper) IteratorCallback(start []byte, end []byte, count int32, di ...@@ -173,22 +172,22 @@ func (db *ListHelper) IteratorCallback(start []byte, end []byte, count int32, di
if end != nil { if end != nil {
cmp := bytes.Compare(key, end) cmp := bytes.Compare(key, end)
if !reserse && cmp > 0 { if !reserse && cmp > 0 {
fmt.Println("break1") listlog.Debug("break1")
break break
} }
if reserse && cmp < 0 { if reserse && cmp < 0 {
fmt.Println("break2") listlog.Debug("break2")
break break
} }
} }
if fn(cloneByte(key), cloneByte(value)) { if fn(cloneByte(key), cloneByte(value)) {
fmt.Println("break3") listlog.Debug("break3")
break break
} }
//count 到数目了 //count 到数目了
i++ i++
if i == count { if i == count {
fmt.Println("break4") listlog.Debug("break4")
break break
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment