Unverified Commit 9545e07c authored by vipwzw's avatar vipwzw Committed by GitHub

Merge branch 'master' into update_chain33

parents 15334ac8 87d3a21b
...@@ -15,6 +15,7 @@ function filterLinter() { ...@@ -15,6 +15,7 @@ function filterLinter() {
--enable=varcheck \ --enable=varcheck \
--enable=structcheck \ --enable=structcheck \
--enable=goimports \ --enable=goimports \
--enable=misspell \
--vendor ./...) --vendor ./...)
# --enable=staticcheck \ # --enable=staticcheck \
# --enable=gocyclo \ # --enable=gocyclo \
......
...@@ -148,5 +148,5 @@ func clearTestData() { ...@@ -148,5 +148,5 @@ func clearTestData() {
if err != nil { if err != nil {
fmt.Println("delete wallet have a err:", err.Error()) fmt.Println("delete wallet have a err:", err.Error())
} }
fmt.Println("test data clear sucessfully!") fmt.Println("test data clear successfully!")
} }
...@@ -175,5 +175,5 @@ func clearTestData() { ...@@ -175,5 +175,5 @@ func clearTestData() {
if err != nil { if err != nil {
fmt.Println("delete chain33_raft dir have a err:", err.Error()) fmt.Println("delete chain33_raft dir have a err:", err.Error())
} }
fmt.Println("test data clear sucessfully!") fmt.Println("test data clear successfully!")
} }
...@@ -181,7 +181,7 @@ func remoteScp(si *ScpInfo, reqnum chan struct{}) { ...@@ -181,7 +181,7 @@ func remoteScp(si *ScpInfo, reqnum chan struct{}) {
}() }()
ScpFileFromLocalToRemote(si) ScpFileFromLocalToRemote(si)
//session, err := sshconnect("ubuntu", "Fuzamei#123456", "raft15258.chinacloudapp.cn", 22) //session, err := sshconnect("ubuntu", "Fuzamei#123456", "raft15258.chinacloudapp.cn", 22)
fmt.Println("remoteScp file sucessfully!:") fmt.Println("remoteScp file successfully!:")
} }
......
...@@ -396,7 +396,7 @@ func (node *Node) stopAndRemovePeer(peer Peer, reason interface{}) { ...@@ -396,7 +396,7 @@ func (node *Node) stopAndRemovePeer(peer Peer, reason interface{}) {
peer.Stop() peer.Stop()
} }
// StopPeerForError called if error occured // StopPeerForError called if error occurred
func (node *Node) StopPeerForError(peer Peer, reason interface{}) { func (node *Node) StopPeerForError(peer Peer, reason interface{}) {
tendermintlog.Error("Stopping peer for error", "peer", peer, "err", reason) tendermintlog.Error("Stopping peer for error", "peer", peer, "err", reason)
addr, err := peer.RemoteAddr() addr, err := peer.RemoteAddr()
......
...@@ -161,7 +161,7 @@ func clearTestData() { ...@@ -161,7 +161,7 @@ func clearTestData() {
if err != nil { if err != nil {
fmt.Println("delete datadir have a err:", err.Error()) fmt.Println("delete datadir have a err:", err.Error())
} }
fmt.Println("test data clear sucessfully!") fmt.Println("test data clear successfully!")
} }
func NormPut() { func NormPut() {
......
...@@ -51,7 +51,7 @@ func TestTicket(t *testing.T) { ...@@ -51,7 +51,7 @@ func TestTicket(t *testing.T) {
//js, _ := json.MarshalIndent(detail, "", " ") //js, _ := json.MarshalIndent(detail, "", " ")
//fmt.Println(string(js)) //fmt.Println(string(js))
assert.Equal(t, int32(2), detail.Receipt.Ty) assert.Equal(t, int32(2), detail.Receipt.Ty)
reply, err = mock33.GetAPI().ExecWalletFunc("ticket", "WalletAutoMiner", &ty.MinerFlag{Flag: 1}) _, err = mock33.GetAPI().ExecWalletFunc("ticket", "WalletAutoMiner", &ty.MinerFlag{Flag: 1})
assert.Nil(t, err) assert.Nil(t, err)
err = mock33.WaitHeight(100) err = mock33.WaitHeight(100)
assert.Nil(t, err) assert.Nil(t, err)
......
...@@ -528,26 +528,26 @@ func (a *action) getWinner(round *gt.BlackwhiteRound) ([]*addrResult, *gt.ReplyL ...@@ -528,26 +528,26 @@ func (a *action) getWinner(round *gt.BlackwhiteRound) ([]*addrResult, *gt.ReplyL
addrRes := round.AddrResult addrRes := round.AddrResult
loop := int(round.Loop) loop := int(round.Loop)
for _, addres := range addrRes { for _, address := range addrRes {
if len(addres.ShowSecret) > 0 && len(addres.HashValues) == loop { if len(address.ShowSecret) > 0 && len(address.HashValues) == loop {
var isBlack []bool var isBlack []bool
// 加入分叉高度判断:分叉高度在ForkV25BlackWhite到ForkV25BlackWhiteV2之间的执行原来逻辑,大于ForkV25BlackWhiteV2执行新逻辑, // 加入分叉高度判断:分叉高度在ForkV25BlackWhite到ForkV25BlackWhiteV2之间的执行原来逻辑,大于ForkV25BlackWhiteV2执行新逻辑,
// 小于ForkV25BlackWhite则无法进入 // 小于ForkV25BlackWhite则无法进入
if !types.IsDappFork(a.height, gt.BlackwhiteX, "ForkBlackWhiteV2") { if !types.IsDappFork(a.height, gt.BlackwhiteX, "ForkBlackWhiteV2") {
for _, hash := range addres.HashValues { for _, hash := range address.HashValues {
if bytes.Equal(common.Sha256([]byte(addres.ShowSecret+black)), hash) { if bytes.Equal(common.Sha256([]byte(address.ShowSecret+black)), hash) {
isBlack = append(isBlack, true) isBlack = append(isBlack, true)
} else if bytes.Equal(common.Sha256([]byte(addres.ShowSecret+white)), hash) { } else if bytes.Equal(common.Sha256([]byte(address.ShowSecret+white)), hash) {
isBlack = append(isBlack, false) isBlack = append(isBlack, false)
} else { } else {
isBlack = append(isBlack, false) isBlack = append(isBlack, false)
} }
} }
} else { } else {
for i, hash := range addres.HashValues { for i, hash := range address.HashValues {
if bytes.Equal(common.Sha256([]byte(strconv.Itoa(i)+addres.ShowSecret+black)), hash) { if bytes.Equal(common.Sha256([]byte(strconv.Itoa(i)+address.ShowSecret+black)), hash) {
isBlack = append(isBlack, true) isBlack = append(isBlack, true)
} else if bytes.Equal(common.Sha256([]byte(strconv.Itoa(i)+addres.ShowSecret+white)), hash) { } else if bytes.Equal(common.Sha256([]byte(strconv.Itoa(i)+address.ShowSecret+white)), hash) {
isBlack = append(isBlack, false) isBlack = append(isBlack, false)
} else { } else {
isBlack = append(isBlack, false) isBlack = append(isBlack, false)
...@@ -555,8 +555,8 @@ func (a *action) getWinner(round *gt.BlackwhiteRound) ([]*addrResult, *gt.ReplyL ...@@ -555,8 +555,8 @@ func (a *action) getWinner(round *gt.BlackwhiteRound) ([]*addrResult, *gt.ReplyL
} }
} }
addresX := &resultCalc{ addresX := &resultCalc{
Addr: addres.Addr, Addr: address.Addr,
amount: addres.Amount, amount: address.Amount,
IsWin: true, IsWin: true,
IsBlack: isBlack, IsBlack: isBlack,
} }
......
...@@ -217,7 +217,7 @@ func Test_getWinnerAndLoser(t *testing.T) { ...@@ -217,7 +217,7 @@ func Test_getWinnerAndLoser(t *testing.T) {
Loop: 4, Loop: 4,
} }
addres := &gt.AddressResult{ address := &gt.AddressResult{
Addr: "1", Addr: "1",
HashValues: [][]byte{common.Sha256([]byte(strconv.Itoa(0) + showSecret + black)), HashValues: [][]byte{common.Sha256([]byte(strconv.Itoa(0) + showSecret + black)),
common.Sha256([]byte(strconv.Itoa(1) + showSecret + white)), common.Sha256([]byte(strconv.Itoa(1) + showSecret + white)),
...@@ -225,9 +225,9 @@ func Test_getWinnerAndLoser(t *testing.T) { ...@@ -225,9 +225,9 @@ func Test_getWinnerAndLoser(t *testing.T) {
common.Sha256([]byte(strconv.Itoa(3) + showSecret + white))}, common.Sha256([]byte(strconv.Itoa(3) + showSecret + white))},
ShowSecret: showSecret, ShowSecret: showSecret,
} }
addrRes = append(addrRes, addres) addrRes = append(addrRes, address)
addres = &gt.AddressResult{ address = &gt.AddressResult{
Addr: "2", Addr: "2",
HashValues: [][]byte{common.Sha256([]byte(strconv.Itoa(0) + showSecret + black)), HashValues: [][]byte{common.Sha256([]byte(strconv.Itoa(0) + showSecret + black)),
common.Sha256([]byte(strconv.Itoa(1) + showSecret + white)), common.Sha256([]byte(strconv.Itoa(1) + showSecret + white)),
...@@ -235,9 +235,9 @@ func Test_getWinnerAndLoser(t *testing.T) { ...@@ -235,9 +235,9 @@ func Test_getWinnerAndLoser(t *testing.T) {
common.Sha256([]byte(strconv.Itoa(3) + showSecret + white))}, common.Sha256([]byte(strconv.Itoa(3) + showSecret + white))},
ShowSecret: showSecret, ShowSecret: showSecret,
} }
addrRes = append(addrRes, addres) addrRes = append(addrRes, address)
addres = &gt.AddressResult{ address = &gt.AddressResult{
Addr: "3", Addr: "3",
HashValues: [][]byte{common.Sha256([]byte(strconv.Itoa(0) + showSecret + black)), HashValues: [][]byte{common.Sha256([]byte(strconv.Itoa(0) + showSecret + black)),
common.Sha256([]byte(strconv.Itoa(1) + showSecret + white)), common.Sha256([]byte(strconv.Itoa(1) + showSecret + white)),
...@@ -245,7 +245,7 @@ func Test_getWinnerAndLoser(t *testing.T) { ...@@ -245,7 +245,7 @@ func Test_getWinnerAndLoser(t *testing.T) {
common.Sha256([]byte(strconv.Itoa(3) + showSecret + black))}, common.Sha256([]byte(strconv.Itoa(3) + showSecret + black))},
ShowSecret: showSecret, ShowSecret: showSecret,
} }
addrRes = append(addrRes, addres) addrRes = append(addrRes, address)
round.AddrResult = addrRes round.AddrResult = addrRes
...@@ -257,7 +257,7 @@ func Test_getWinnerAndLoser(t *testing.T) { ...@@ -257,7 +257,7 @@ func Test_getWinnerAndLoser(t *testing.T) {
//t.Logf("winers1 is %v", winers) //t.Logf("winers1 is %v", winers)
//t.Logf("losers1 is %v", losers) //t.Logf("losers1 is %v", losers)
addres = &gt.AddressResult{ address = &gt.AddressResult{
Addr: "4", Addr: "4",
HashValues: [][]byte{common.Sha256([]byte(strconv.Itoa(0) + showSecret + black)), HashValues: [][]byte{common.Sha256([]byte(strconv.Itoa(0) + showSecret + black)),
common.Sha256([]byte(strconv.Itoa(1) + showSecret + white)), common.Sha256([]byte(strconv.Itoa(1) + showSecret + white)),
...@@ -265,9 +265,9 @@ func Test_getWinnerAndLoser(t *testing.T) { ...@@ -265,9 +265,9 @@ func Test_getWinnerAndLoser(t *testing.T) {
common.Sha256([]byte(strconv.Itoa(3) + showSecret + black))}, common.Sha256([]byte(strconv.Itoa(3) + showSecret + black))},
ShowSecret: showSecret, ShowSecret: showSecret,
} }
addrRes = append(addrRes, addres) addrRes = append(addrRes, address)
addres = &gt.AddressResult{ address = &gt.AddressResult{
Addr: "5", Addr: "5",
HashValues: [][]byte{common.Sha256([]byte(strconv.Itoa(0) + showSecret + black)), HashValues: [][]byte{common.Sha256([]byte(strconv.Itoa(0) + showSecret + black)),
common.Sha256([]byte(strconv.Itoa(1) + showSecret + white)), common.Sha256([]byte(strconv.Itoa(1) + showSecret + white)),
...@@ -275,7 +275,7 @@ func Test_getWinnerAndLoser(t *testing.T) { ...@@ -275,7 +275,7 @@ func Test_getWinnerAndLoser(t *testing.T) {
common.Sha256([]byte(strconv.Itoa(3) + showSecret + white))}, common.Sha256([]byte(strconv.Itoa(3) + showSecret + white))},
ShowSecret: showSecret, ShowSecret: showSecret,
} }
addrRes = append(addrRes, addres) addrRes = append(addrRes, address)
round.AddrResult = addrRes round.AddrResult = addrRes
...@@ -286,7 +286,7 @@ func Test_getWinnerAndLoser(t *testing.T) { ...@@ -286,7 +286,7 @@ func Test_getWinnerAndLoser(t *testing.T) {
//t.Logf("winers2 is %v", winers) //t.Logf("winers2 is %v", winers)
//t.Logf("losers2 is %v", losers) //t.Logf("losers2 is %v", losers)
addres = &gt.AddressResult{ address = &gt.AddressResult{
Addr: "6", Addr: "6",
HashValues: [][]byte{common.Sha256([]byte(strconv.Itoa(0) + showSecret + black)), HashValues: [][]byte{common.Sha256([]byte(strconv.Itoa(0) + showSecret + black)),
common.Sha256([]byte(strconv.Itoa(1) + showSecret + white)), common.Sha256([]byte(strconv.Itoa(1) + showSecret + white)),
...@@ -298,7 +298,7 @@ func Test_getWinnerAndLoser(t *testing.T) { ...@@ -298,7 +298,7 @@ func Test_getWinnerAndLoser(t *testing.T) {
common.Sha256([]byte(strconv.Itoa(7) + showSecret + white))}, common.Sha256([]byte(strconv.Itoa(7) + showSecret + white))},
ShowSecret: showSecret, ShowSecret: showSecret,
} }
addrRes = append(addrRes, addres) addrRes = append(addrRes, address)
round.AddrResult = addrRes round.AddrResult = addrRes
......
...@@ -285,3 +285,8 @@ func heightIndexToIndex(height int64, index int32) int64 { ...@@ -285,3 +285,8 @@ func heightIndexToIndex(height int64, index int32) int64 {
func (c *Blackwhite) GetPayloadValue() types.Message { func (c *Blackwhite) GetPayloadValue() types.Message {
return &gt.BlackwhiteAction{} return &gt.BlackwhiteAction{}
} }
// CheckReceiptExecOk return true to check if receipt ty is ok
func (c *Blackwhite) CheckReceiptExecOk() bool {
return true
}
...@@ -67,7 +67,7 @@ func (b BlackwhiteType) ActionName(tx *types.Transaction) string { ...@@ -67,7 +67,7 @@ func (b BlackwhiteType) ActionName(tx *types.Transaction) string {
var g BlackwhiteAction var g BlackwhiteAction
err := types.Decode(tx.Payload, &g) err := types.Decode(tx.Payload, &g)
if err != nil { if err != nil {
return "unkown-Blackwhite-action-err" return "unknown-Blackwhite-action-err"
} }
if g.Ty == BlackwhiteActionCreate && g.GetCreate() != nil { if g.Ty == BlackwhiteActionCreate && g.GetCreate() != nil {
return "BlackwhiteCreate" return "BlackwhiteCreate"
...@@ -78,7 +78,7 @@ func (b BlackwhiteType) ActionName(tx *types.Transaction) string { ...@@ -78,7 +78,7 @@ func (b BlackwhiteType) ActionName(tx *types.Transaction) string {
} else if g.Ty == BlackwhiteActionTimeoutDone && g.GetTimeoutDone() != nil { } else if g.Ty == BlackwhiteActionTimeoutDone && g.GetTimeoutDone() != nil {
return "BlackwhiteTimeoutDone" return "BlackwhiteTimeoutDone"
} }
return "unkown" return "unknown"
} }
// Amount ... // Amount ...
......
...@@ -139,3 +139,8 @@ func (c *Cert) loadHistoryByHeight() error { ...@@ -139,3 +139,8 @@ func (c *Cert) loadHistoryByHeight() error {
} }
return ct.ErrGetHistoryCertData return ct.ErrGetHistoryCertData
} }
// CheckReceiptExecOk return true to check if receipt ty is ok
func (c *Cert) CheckReceiptExecOk() bool {
return true
}
...@@ -22,9 +22,6 @@ func (c *Cert) ExecLocal_New(payload *ct.CertNew, tx *types.Transaction, receipt ...@@ -22,9 +22,6 @@ func (c *Cert) ExecLocal_New(payload *ct.CertNew, tx *types.Transaction, receipt
clog.Error("Authority is not available. Please check the authority config or authority initialize error logs.") clog.Error("Authority is not available. Please check the authority config or authority initialize error logs.")
return nil, ct.ErrInitializeAuthority return nil, ct.ErrInitializeAuthority
} }
if receiptData.GetTy() != types.ExecOk {
return &types.LocalDBSet{}, nil
}
var set types.LocalDBSet var set types.LocalDBSet
historityCertdata := &types.HistoryCertStore{} historityCertdata := &types.HistoryCertStore{}
...@@ -54,9 +51,6 @@ func (c *Cert) ExecLocal_Update(payload *ct.CertUpdate, tx *types.Transaction, r ...@@ -54,9 +51,6 @@ func (c *Cert) ExecLocal_Update(payload *ct.CertUpdate, tx *types.Transaction, r
clog.Error("Authority is not available. Please check the authority config or authority initialize error logs.") clog.Error("Authority is not available. Please check the authority config or authority initialize error logs.")
return nil, ct.ErrInitializeAuthority return nil, ct.ErrInitializeAuthority
} }
if receiptData.GetTy() != types.ExecOk {
return &types.LocalDBSet{}, nil
}
var set types.LocalDBSet var set types.LocalDBSet
// 写入上一纪录的next-height // 写入上一纪录的next-height
...@@ -87,9 +81,6 @@ func (c *Cert) ExecLocal_Normal(payload *ct.CertNormal, tx *types.Transaction, r ...@@ -87,9 +81,6 @@ func (c *Cert) ExecLocal_Normal(payload *ct.CertNormal, tx *types.Transaction, r
clog.Error("Authority is not available. Please check the authority config or authority initialize error logs.") clog.Error("Authority is not available. Please check the authority config or authority initialize error logs.")
return nil, ct.ErrInitializeAuthority return nil, ct.ErrInitializeAuthority
} }
if receiptData.GetTy() != types.ExecOk {
return &types.LocalDBSet{}, nil
}
var set types.LocalDBSet var set types.LocalDBSet
return &set, nil return &set, nil
......
...@@ -117,6 +117,11 @@ func (evm *EVMExecutor) IsFriend(myexec, writekey []byte, othertx *types.Transac ...@@ -117,6 +117,11 @@ func (evm *EVMExecutor) IsFriend(myexec, writekey []byte, othertx *types.Transac
return false return false
} }
// CheckReceiptExecOk return true to check if receipt ty is ok
func (c *EVMExecutor) CheckReceiptExecOk() bool {
return true
}
// 生成一个新的合约对象地址 // 生成一个新的合约对象地址
func (evm *EVMExecutor) getNewAddr(txHash []byte) common.Address { func (evm *EVMExecutor) getNewAddr(txHash []byte) common.Address {
return common.NewAddress(txHash) return common.NewAddress(txHash)
......
...@@ -106,7 +106,7 @@ func runDir(tt *testing.T, basePath string) { ...@@ -106,7 +106,7 @@ func runDir(tt *testing.T, basePath string) {
} }
func runCase(tt *testing.T, c VMCase, file string) { func runCase(tt *testing.T, c VMCase, file string) {
tt.Logf("runing test case:%s in file:%s", c.name, file) tt.Logf("running test case:%s in file:%s", c.name, file)
// 1 构建预置环境 pre // 1 构建预置环境 pre
inst := evm.NewEVMExecutor() inst := evm.NewEVMExecutor()
......
...@@ -12,9 +12,6 @@ import ( ...@@ -12,9 +12,6 @@ import (
// roll back local db data // roll back local db data
func (g *Game) execDelLocal(receiptData *types.ReceiptData) (*types.LocalDBSet, error) { func (g *Game) execDelLocal(receiptData *types.ReceiptData) (*types.LocalDBSet, error) {
dbSet := &types.LocalDBSet{} dbSet := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
return dbSet, nil
}
for _, log := range receiptData.Logs { for _, log := range receiptData.Logs {
switch log.GetTy() { switch log.GetTy() {
case gt.TyLogCreateGame, gt.TyLogMatchGame, gt.TyLogCloseGame, gt.TyLogCancleGame: case gt.TyLogCreateGame, gt.TyLogMatchGame, gt.TyLogCloseGame, gt.TyLogCancleGame:
......
...@@ -12,9 +12,6 @@ import ( ...@@ -12,9 +12,6 @@ import (
// save receiptData to local db // save receiptData to local db
func (g *Game) execLocal(receiptData *types.ReceiptData) (*types.LocalDBSet, error) { func (g *Game) execLocal(receiptData *types.ReceiptData) (*types.LocalDBSet, error) {
dbSet := &types.LocalDBSet{} dbSet := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
return dbSet, nil
}
for _, log := range receiptData.Logs { for _, log := range receiptData.Logs {
switch log.Ty { switch log.Ty {
case gt.TyLogCreateGame, gt.TyLogMatchGame, gt.TyLogCloseGame, gt.TyLogCancleGame: case gt.TyLogCreateGame, gt.TyLogMatchGame, gt.TyLogCloseGame, gt.TyLogCancleGame:
......
...@@ -174,3 +174,8 @@ func (g *Game) GetTypeMap() map[string]int32 { ...@@ -174,3 +174,8 @@ func (g *Game) GetTypeMap() map[string]int32 {
"Close": gt.GameActionClose, "Close": gt.GameActionClose,
} }
} }
// CheckReceiptExecOk return true to check if receipt ty is ok
func (g *Game) CheckReceiptExecOk() bool {
return true
}
...@@ -12,9 +12,6 @@ import ( ...@@ -12,9 +12,6 @@ import (
// ExecDelLocal_Hlock Action // ExecDelLocal_Hlock Action
func (h *Hashlock) ExecDelLocal_Hlock(hlock *pty.HashlockLock, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (h *Hashlock) ExecDelLocal_Hlock(hlock *pty.HashlockLock, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) {
if receipt.GetTy() != types.ExecOk {
return &types.LocalDBSet{}, nil
}
info := pty.Hashlockquery{Time: hlock.Time, Status: hashlockLocked, Amount: hlock.Amount, CreateTime: h.GetBlockTime(), CurrentTime: 0} info := pty.Hashlockquery{Time: hlock.Time, Status: hashlockLocked, Amount: hlock.Amount, CreateTime: h.GetBlockTime(), CurrentTime: 0}
kv, err := UpdateHashReciver(h.GetLocalDB(), hlock.Hash, info) kv, err := UpdateHashReciver(h.GetLocalDB(), hlock.Hash, info)
if err != nil { if err != nil {
...@@ -25,9 +22,6 @@ func (h *Hashlock) ExecDelLocal_Hlock(hlock *pty.HashlockLock, tx *types.Transac ...@@ -25,9 +22,6 @@ func (h *Hashlock) ExecDelLocal_Hlock(hlock *pty.HashlockLock, tx *types.Transac
// ExecDelLocal_Hsend Action // ExecDelLocal_Hsend Action
func (h *Hashlock) ExecDelLocal_Hsend(hsend *pty.HashlockSend, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (h *Hashlock) ExecDelLocal_Hsend(hsend *pty.HashlockSend, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) {
if receipt.GetTy() != types.ExecOk {
return &types.LocalDBSet{}, nil
}
info := pty.Hashlockquery{Time: 0, Status: hashlockSent, Amount: 0, CreateTime: 0, CurrentTime: 0} info := pty.Hashlockquery{Time: 0, Status: hashlockSent, Amount: 0, CreateTime: 0, CurrentTime: 0}
kv, err := UpdateHashReciver(h.GetLocalDB(), common.Sha256(hsend.Secret), info) kv, err := UpdateHashReciver(h.GetLocalDB(), common.Sha256(hsend.Secret), info)
if err != nil { if err != nil {
...@@ -38,9 +32,6 @@ func (h *Hashlock) ExecDelLocal_Hsend(hsend *pty.HashlockSend, tx *types.Transac ...@@ -38,9 +32,6 @@ func (h *Hashlock) ExecDelLocal_Hsend(hsend *pty.HashlockSend, tx *types.Transac
// ExecDelLocal_Hunlock Action // ExecDelLocal_Hunlock Action
func (h *Hashlock) ExecDelLocal_Hunlock(hunlock *pty.HashlockUnlock, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (h *Hashlock) ExecDelLocal_Hunlock(hunlock *pty.HashlockUnlock, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) {
if receipt.GetTy() != types.ExecOk {
return &types.LocalDBSet{}, nil
}
info := pty.Hashlockquery{Time: 0, Status: hashlockUnlocked, Amount: 0, CreateTime: 0, CurrentTime: 0} info := pty.Hashlockquery{Time: 0, Status: hashlockUnlocked, Amount: 0, CreateTime: 0, CurrentTime: 0}
kv, err := UpdateHashReciver(h.GetLocalDB(), common.Sha256(hunlock.Secret), info) kv, err := UpdateHashReciver(h.GetLocalDB(), common.Sha256(hunlock.Secret), info)
if err != nil { if err != nil {
......
...@@ -12,9 +12,6 @@ import ( ...@@ -12,9 +12,6 @@ import (
// ExecLocal_Hlock Action // ExecLocal_Hlock Action
func (h *Hashlock) ExecLocal_Hlock(hlock *pty.HashlockLock, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (h *Hashlock) ExecLocal_Hlock(hlock *pty.HashlockLock, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) {
if receipt.GetTy() != types.ExecOk {
return &types.LocalDBSet{}, nil
}
info := pty.Hashlockquery{Time: hlock.Time, Status: hashlockLocked, Amount: hlock.Amount, CreateTime: h.GetBlockTime(), CurrentTime: 0} info := pty.Hashlockquery{Time: hlock.Time, Status: hashlockLocked, Amount: hlock.Amount, CreateTime: h.GetBlockTime(), CurrentTime: 0}
clog.Error("ExecLocal", "info", info) clog.Error("ExecLocal", "info", info)
kv, err := UpdateHashReciver(h.GetLocalDB(), hlock.Hash, info) kv, err := UpdateHashReciver(h.GetLocalDB(), hlock.Hash, info)
...@@ -26,9 +23,6 @@ func (h *Hashlock) ExecLocal_Hlock(hlock *pty.HashlockLock, tx *types.Transactio ...@@ -26,9 +23,6 @@ func (h *Hashlock) ExecLocal_Hlock(hlock *pty.HashlockLock, tx *types.Transactio
// ExecLocal_Hsend Action // ExecLocal_Hsend Action
func (h *Hashlock) ExecLocal_Hsend(hsend *pty.HashlockSend, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (h *Hashlock) ExecLocal_Hsend(hsend *pty.HashlockSend, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) {
if receipt.GetTy() != types.ExecOk {
return &types.LocalDBSet{}, nil
}
info := pty.Hashlockquery{Time: 0, Status: hashlockSent, Amount: 0, CreateTime: 0, CurrentTime: 0} info := pty.Hashlockquery{Time: 0, Status: hashlockSent, Amount: 0, CreateTime: 0, CurrentTime: 0}
clog.Error("ExecLocal", "info", info) clog.Error("ExecLocal", "info", info)
kv, err := UpdateHashReciver(h.GetLocalDB(), common.Sha256(hsend.Secret), info) kv, err := UpdateHashReciver(h.GetLocalDB(), common.Sha256(hsend.Secret), info)
...@@ -40,9 +34,6 @@ func (h *Hashlock) ExecLocal_Hsend(hsend *pty.HashlockSend, tx *types.Transactio ...@@ -40,9 +34,6 @@ func (h *Hashlock) ExecLocal_Hsend(hsend *pty.HashlockSend, tx *types.Transactio
// ExecLocal_Hunlock Action // ExecLocal_Hunlock Action
func (h *Hashlock) ExecLocal_Hunlock(hunlock *pty.HashlockUnlock, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (h *Hashlock) ExecLocal_Hunlock(hunlock *pty.HashlockUnlock, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) {
if receipt.GetTy() != types.ExecOk {
return &types.LocalDBSet{}, nil
}
info := pty.Hashlockquery{Time: 0, Status: hashlockUnlocked, Amount: 0, CreateTime: 0, CurrentTime: 0} info := pty.Hashlockquery{Time: 0, Status: hashlockUnlocked, Amount: 0, CreateTime: 0, CurrentTime: 0}
clog.Error("ExecLocal", "info", info) clog.Error("ExecLocal", "info", info)
kv, err := UpdateHashReciver(h.GetLocalDB(), common.Sha256(hunlock.Secret), info) kv, err := UpdateHashReciver(h.GetLocalDB(), common.Sha256(hunlock.Secret), info)
......
...@@ -52,3 +52,8 @@ func (h *Hashlock) GetDriverName() string { ...@@ -52,3 +52,8 @@ func (h *Hashlock) GetDriverName() string {
func (h *Hashlock) CheckTx(tx *types.Transaction, index int) error { func (h *Hashlock) CheckTx(tx *types.Transaction, index int) error {
return nil return nil
} }
// CheckReceiptExecOk return true to check if receipt ty is ok
func (h *Hashlock) CheckReceiptExecOk() bool {
return true
}
...@@ -188,7 +188,7 @@ func estHashlock(t *testing.T) { ...@@ -188,7 +188,7 @@ func estHashlock(t *testing.T) {
func estHashunlock(t *testing.T) { func estHashunlock(t *testing.T) {
fmt.Println("TestHashunlock start") fmt.Println("TestHashunlock start")
defer fmt.Println("TestHashunlock end") defer fmt.Println("TestHashunlock end")
//not sucess as time not enough //not success as time not enough
time.Sleep(5 * time.Second) time.Sleep(5 * time.Second)
err := unlock(secret) err := unlock(secret)
if err != nil { if err != nil {
......
...@@ -33,8 +33,8 @@ message Hashlockquery { ...@@ -33,8 +33,8 @@ message Hashlockquery {
} }
message HashRecv { message HashRecv {
bytes HashlockId = 1; bytes HashlockId = 1;
Hashlockquery Infomation = 2; Hashlockquery Information = 2;
} }
message HashlockUnlock { message HashlockUnlock {
......
...@@ -291,7 +291,7 @@ func (m *Hashlockquery) GetCurrentTime() int64 { ...@@ -291,7 +291,7 @@ func (m *Hashlockquery) GetCurrentTime() int64 {
type HashRecv struct { type HashRecv struct {
HashlockId []byte `protobuf:"bytes,1,opt,name=HashlockId,proto3" json:"HashlockId,omitempty"` HashlockId []byte `protobuf:"bytes,1,opt,name=HashlockId,proto3" json:"HashlockId,omitempty"`
Infomation *Hashlockquery `protobuf:"bytes,2,opt,name=Infomation,proto3" json:"Infomation,omitempty"` Information *Hashlockquery `protobuf:"bytes,2,opt,name=Information,proto3" json:"Information,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
...@@ -329,9 +329,9 @@ func (m *HashRecv) GetHashlockId() []byte { ...@@ -329,9 +329,9 @@ func (m *HashRecv) GetHashlockId() []byte {
return nil return nil
} }
func (m *HashRecv) GetInfomation() *Hashlockquery { func (m *HashRecv) GetInformation() *Hashlockquery {
if m != nil { if m != nil {
return m.Infomation return m.Information
} }
return nil return nil
} }
...@@ -576,32 +576,32 @@ func init() { ...@@ -576,32 +576,32 @@ func init() {
func init() { proto.RegisterFile("hashlock.proto", fileDescriptor_acb83e90536b5ff8) } func init() { proto.RegisterFile("hashlock.proto", fileDescriptor_acb83e90536b5ff8) }
var fileDescriptor_acb83e90536b5ff8 = []byte{ var fileDescriptor_acb83e90536b5ff8 = []byte{
// 420 bytes of a gzipped FileDescriptorProto // 421 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0xcd, 0x6e, 0x9b, 0x40, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0xcd, 0x6a, 0xdb, 0x40,
0x10, 0xc7, 0xbd, 0xd8, 0xd8, 0xf5, 0x60, 0xfb, 0xb0, 0xfd, 0x10, 0x87, 0xaa, 0x42, 0xa8, 0xaa, 0x10, 0xc7, 0xbd, 0xb2, 0x65, 0xd7, 0x23, 0xdb, 0x87, 0xed, 0x07, 0x3a, 0x94, 0x22, 0x44, 0x29,
0x90, 0x2a, 0x59, 0xaa, 0xdb, 0x17, 0x70, 0x7b, 0xc1, 0x52, 0x4f, 0x9b, 0xe4, 0x1e, 0x02, 0x6b, 0x82, 0x82, 0xa1, 0x2e, 0xf4, 0xee, 0xf6, 0x22, 0x43, 0x4f, 0x9b, 0xe4, 0x01, 0x64, 0x69, 0x8d,
0xd9, 0x8a, 0xbd, 0xeb, 0x2c, 0x8b, 0x25, 0xf2, 0x18, 0x91, 0xf2, 0x2a, 0x79, 0x9c, 0x3c, 0x4b, 0x4d, 0xec, 0x5d, 0x67, 0xb5, 0x32, 0x28, 0x8f, 0x11, 0xc8, 0xab, 0xe4, 0x71, 0xf2, 0x2c, 0x61,
0xb4, 0x03, 0x64, 0x31, 0x49, 0x6e, 0xb9, 0x31, 0x7f, 0x7e, 0xcc, 0xc7, 0x7f, 0x06, 0x98, 0x6d, 0x47, 0x52, 0x56, 0x56, 0x92, 0x5b, 0x6e, 0x9a, 0xbf, 0x7e, 0x9a, 0x8f, 0xff, 0x8c, 0x60, 0xb6,
0x92, 0x7c, 0xb3, 0x93, 0xe9, 0xf5, 0xfc, 0xa0, 0xa4, 0x96, 0xd4, 0xd5, 0xe5, 0x81, 0xe7, 0xe1, 0x4d, 0xf2, 0xed, 0x5e, 0xa6, 0xd7, 0xf3, 0xa3, 0x92, 0x5a, 0x52, 0x57, 0x97, 0x47, 0x9e, 0x87,
0x23, 0x81, 0x0f, 0x71, 0xfd, 0x86, 0x7e, 0x03, 0x68, 0xa8, 0x55, 0xe6, 0x93, 0x80, 0x44, 0x13, 0x8f, 0x04, 0x3e, 0xc4, 0xf5, 0x1b, 0xfa, 0x0d, 0xa0, 0xa1, 0x56, 0x99, 0x4f, 0x02, 0x12, 0x4d,
0xd6, 0x52, 0xe8, 0x17, 0x18, 0xe6, 0x3a, 0xd1, 0x45, 0xee, 0x3b, 0x01, 0x89, 0x5c, 0x56, 0x47, 0x58, 0x4b, 0xa1, 0x5f, 0x60, 0x98, 0xeb, 0x44, 0x17, 0xb9, 0xef, 0x04, 0x24, 0x72, 0x59, 0x1d,
0xe6, 0xbb, 0x7f, 0x8a, 0x27, 0x9a, 0x9f, 0x6f, 0xf7, 0xdc, 0xef, 0x07, 0x24, 0xea, 0xb3, 0x96, 0x99, 0xef, 0xfe, 0x29, 0x9e, 0x68, 0x7e, 0xb9, 0x3b, 0x70, 0xbf, 0x1f, 0x90, 0xa8, 0xcf, 0x5a,
0x42, 0xbf, 0xc2, 0x58, 0xcb, 0x65, 0x96, 0x29, 0x9e, 0xe7, 0xfe, 0x20, 0x20, 0xd1, 0x98, 0x59, 0x0a, 0xfd, 0x0a, 0x63, 0x2d, 0x97, 0x59, 0xa6, 0x78, 0x9e, 0xfb, 0x83, 0x80, 0x44, 0x63, 0x66,
0x81, 0x7e, 0x87, 0xa9, 0xe2, 0xba, 0x50, 0xa2, 0x21, 0x5c, 0x24, 0x4e, 0x45, 0x53, 0x3b, 0xd9, 0x05, 0xfa, 0x1d, 0xa6, 0x8a, 0xeb, 0x42, 0x89, 0x86, 0x70, 0x91, 0x38, 0x17, 0x4d, 0xed, 0xe4,
0xcb, 0x42, 0x68, 0x7f, 0x88, 0xf9, 0xeb, 0xc8, 0xd4, 0x5e, 0x2b, 0x79, 0xcb, 0x85, 0x36, 0xb5, 0x20, 0x0b, 0xa1, 0xfd, 0x21, 0xe6, 0xaf, 0x23, 0x53, 0x7b, 0xa3, 0xe4, 0x2d, 0x17, 0xda, 0xd4,
0x47, 0x55, 0x6d, 0xab, 0x84, 0x77, 0x04, 0x26, 0xcd, 0x80, 0xff, 0xcd, 0x90, 0x36, 0x11, 0x39, 0x1e, 0x55, 0xb5, 0xad, 0x12, 0xde, 0x11, 0x98, 0x34, 0x03, 0xfe, 0x37, 0x43, 0xda, 0x44, 0xe4,
0x49, 0x44, 0x61, 0x80, 0x29, 0x1c, 0x54, 0xf1, 0xd9, 0x68, 0x66, 0x7c, 0x1c, 0x69, 0xc2, 0xf0, 0x2c, 0x11, 0x85, 0x01, 0xa6, 0x70, 0x50, 0xc5, 0x67, 0xa3, 0x99, 0xf1, 0x71, 0xa4, 0x09, 0xc3,
0xf9, 0x3d, 0x86, 0x09, 0x7f, 0xd8, 0x9e, 0xce, 0xb8, 0xa8, 0x8c, 0xe5, 0xa9, 0xe2, 0xba, 0x36, 0xe7, 0xf7, 0x18, 0x26, 0xfc, 0x61, 0x7b, 0xba, 0xe0, 0xa2, 0x32, 0x96, 0xa7, 0x8a, 0xeb, 0xda,
0xbd, 0x8e, 0xc2, 0x7b, 0x02, 0xd3, 0x06, 0xbc, 0x29, 0xb8, 0x2a, 0x9f, 0xbb, 0x24, 0xad, 0x2e, 0xf4, 0x3a, 0x0a, 0xef, 0x09, 0x4c, 0x1b, 0xf0, 0xa6, 0xe0, 0xaa, 0x7c, 0xee, 0x92, 0xb4, 0xba,
0xdf, 0x5a, 0x8b, 0x9d, 0xb4, 0xdf, 0xb5, 0x2c, 0xb5, 0xeb, 0x1a, 0x54, 0x96, 0x59, 0x85, 0x06, 0x7c, 0x6b, 0x2d, 0x76, 0xd2, 0x7e, 0xd7, 0xb2, 0xd4, 0xae, 0x6b, 0x50, 0x59, 0x66, 0x15, 0x1a,
0xe0, 0xa5, 0x85, 0x52, 0x5c, 0x68, 0x04, 0x5c, 0x04, 0xda, 0x52, 0x78, 0x59, 0x1d, 0x0d, 0xe3, 0x80, 0x97, 0x16, 0x4a, 0x71, 0xa1, 0x11, 0x70, 0x11, 0x68, 0x4b, 0xe1, 0xba, 0x3a, 0x1a, 0xc6,
0xe9, 0xd1, 0x64, 0x8b, 0x5f, 0x1c, 0x8d, 0x55, 0xe8, 0x1f, 0x80, 0x95, 0x58, 0xcb, 0x7d, 0xa2, 0xd3, 0x93, 0xc9, 0x16, 0xbf, 0x38, 0x1a, 0xab, 0xd0, 0x3f, 0xe0, 0xad, 0xc4, 0x46, 0xaa, 0x43,
0xb7, 0x52, 0x60, 0x87, 0xde, 0xe2, 0xd3, 0x1c, 0xaf, 0x6f, 0x7e, 0x32, 0x1b, 0x6b, 0x71, 0x61, 0xa2, 0x77, 0x52, 0x60, 0x8b, 0xde, 0xe2, 0xd3, 0x1c, 0xcf, 0x6f, 0x7e, 0x36, 0x1c, 0x6b, 0x83,
0x04, 0xb3, 0xe6, 0xe5, 0x85, 0xd8, 0xd5, 0x7b, 0x7b, 0xd5, 0xa3, 0x07, 0x62, 0xd1, 0x65, 0x6a, 0x61, 0x04, 0xb3, 0xe6, 0xed, 0x95, 0xd8, 0xd7, 0x9b, 0x7b, 0xd5, 0xa5, 0x07, 0x62, 0xd1, 0x65,
0x3e, 0xa6, 0x3f, 0xc1, 0xc5, 0x10, 0x49, 0x6f, 0xf1, 0xb1, 0x53, 0xcd, 0x9c, 0x41, 0xdc, 0x63, 0x6a, 0x3e, 0xa6, 0x3f, 0xc1, 0xc5, 0x10, 0x49, 0x6f, 0xf1, 0xb1, 0x53, 0xce, 0x1c, 0x42, 0xdc,
0x15, 0x83, 0x70, 0xce, 0x45, 0x56, 0xb7, 0xd6, 0x85, 0xcd, 0x7e, 0x10, 0x36, 0x0c, 0xfd, 0x05, 0x63, 0x15, 0x83, 0x70, 0xce, 0x45, 0x56, 0xf7, 0xd6, 0x85, 0xcd, 0x86, 0x10, 0x36, 0x0c, 0xfd,
0xa3, 0x4d, 0x81, 0xfd, 0xa0, 0xa7, 0xde, 0xe2, 0x73, 0x07, 0xaf, 0x9a, 0x8d, 0x7b, 0xac, 0xe1, 0x05, 0xa3, 0x6d, 0x81, 0xfd, 0xa0, 0xab, 0xde, 0xe2, 0x73, 0x07, 0xaf, 0x9a, 0x8d, 0x7b, 0xac,
0xe8, 0x0c, 0x1c, 0x5d, 0xa2, 0xcb, 0x2e, 0x73, 0x74, 0xf9, 0x77, 0x04, 0xee, 0x31, 0xd9, 0x15, 0xe1, 0xe8, 0x0c, 0x1c, 0x5d, 0xa2, 0xcf, 0x2e, 0x73, 0x74, 0xf9, 0x77, 0x04, 0xee, 0x29, 0xd9,
0xfc, 0x6a, 0x88, 0x3f, 0xe2, 0xef, 0xa7, 0x00, 0x00, 0x00, 0xff, 0xff, 0x56, 0x5e, 0xa0, 0xf4, 0x17, 0x7c, 0x3d, 0xc4, 0x5f, 0xf1, 0xf7, 0x53, 0x00, 0x00, 0x00, 0xff, 0xff, 0x38, 0xf6, 0x91,
0x9a, 0x03, 0x00, 0x00, 0xc1, 0x9c, 0x03, 0x00, 0x00,
} }
...@@ -12,9 +12,6 @@ import ( ...@@ -12,9 +12,6 @@ import (
func (l *Lottery) execDelLocal(tx *types.Transaction, receiptData *types.ReceiptData) (*types.LocalDBSet, error) { func (l *Lottery) execDelLocal(tx *types.Transaction, receiptData *types.ReceiptData) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{} set := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
return set, nil
}
for _, item := range receiptData.Logs { for _, item := range receiptData.Logs {
switch item.Ty { switch item.Ty {
case pty.TyLogLotteryCreate, pty.TyLogLotteryBuy, pty.TyLogLotteryDraw, pty.TyLogLotteryClose: case pty.TyLogLotteryCreate, pty.TyLogLotteryBuy, pty.TyLogLotteryDraw, pty.TyLogLotteryClose:
......
...@@ -12,9 +12,6 @@ import ( ...@@ -12,9 +12,6 @@ import (
func (l *Lottery) execLocal(tx *types.Transaction, receipt *types.ReceiptData) (*types.LocalDBSet, error) { func (l *Lottery) execLocal(tx *types.Transaction, receipt *types.ReceiptData) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{} set := &types.LocalDBSet{}
if receipt.GetTy() != types.ExecOk {
return set, nil
}
for _, item := range receipt.Logs { for _, item := range receipt.Logs {
switch item.Ty { switch item.Ty {
case pty.TyLogLotteryCreate, pty.TyLogLotteryBuy, pty.TyLogLotteryDraw, pty.TyLogLotteryClose: case pty.TyLogLotteryCreate, pty.TyLogLotteryBuy, pty.TyLogLotteryDraw, pty.TyLogLotteryClose:
......
...@@ -229,3 +229,8 @@ func dellottery(lotteryID string, status int32) *types.KeyValue { ...@@ -229,3 +229,8 @@ func dellottery(lotteryID string, status int32) *types.KeyValue {
func (lott *Lottery) GetPayloadValue() types.Message { func (lott *Lottery) GetPayloadValue() types.Message {
return &pty.LotteryAction{} return &pty.LotteryAction{}
} }
// CheckReceiptExecOk return true to check if receipt ty is ok
func (lott *Lottery) CheckReceiptExecOk() bool {
return true
}
...@@ -548,11 +548,11 @@ func (action *Action) GetCalculableHash(beg, end int64, randMolNum int64) ([]byt ...@@ -548,11 +548,11 @@ func (action *Action) GetCalculableHash(beg, end int64, randMolNum int64) ([]byt
return modify, nil return modify, nil
} }
//random used for verfication in solo //random used for verification in solo
func (action *Action) findLuckyNum(isSolo bool, lott *LotteryDB) int64 { func (action *Action) findLuckyNum(isSolo bool, lott *LotteryDB) int64 {
var num int64 var num int64
if isSolo { if isSolo {
//used for internal verfication //used for internal verification
num = 12345 num = 12345
} else { } else {
randMolNum := (lott.TotalPurchasedTxNum+action.height-lott.LastTransToPurState)%3 + 2 //3~5 randMolNum := (lott.TotalPurchasedTxNum+action.height-lott.LastTransToPurState)%3 + 2 //3~5
......
...@@ -58,3 +58,8 @@ func Key(str []byte) (key []byte) { ...@@ -58,3 +58,8 @@ func Key(str []byte) (key []byte) {
key = append(key, str...) key = append(key, str...)
return key return key
} }
// CheckReceiptExecOk return true to check if receipt ty is ok
func (n *Norm) CheckReceiptExecOk() bool {
return true
}
...@@ -354,3 +354,8 @@ func (c *Paracross) allowIsParaAssetTx(execer []byte) bool { ...@@ -354,3 +354,8 @@ func (c *Paracross) allowIsParaAssetTx(execer []byte) bool {
} }
return false return false
} }
// CheckReceiptExecOk return true to check if receipt ty is ok
func (c *Paracross) CheckReceiptExecOk() bool {
return true
}
...@@ -25,9 +25,6 @@ func (g *PokerBull) rollbackIndex(log *pkt.ReceiptPBGame) (kvs []*types.KeyValue ...@@ -25,9 +25,6 @@ func (g *PokerBull) rollbackIndex(log *pkt.ReceiptPBGame) (kvs []*types.KeyValue
func (g *PokerBull) execDelLocal(receiptData *types.ReceiptData) (*types.LocalDBSet, error) { func (g *PokerBull) execDelLocal(receiptData *types.ReceiptData) (*types.LocalDBSet, error) {
dbSet := &types.LocalDBSet{} dbSet := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
return dbSet, nil
}
for _, log := range receiptData.Logs { for _, log := range receiptData.Logs {
switch log.GetTy() { switch log.GetTy() {
case pkt.TyLogPBGameStart, pkt.TyLogPBGameContinue, pkt.TyLogPBGameQuit: case pkt.TyLogPBGameStart, pkt.TyLogPBGameContinue, pkt.TyLogPBGameQuit:
......
...@@ -55,9 +55,6 @@ func (c *PokerBull) updateIndex(log *pkt.ReceiptPBGame) (kvs []*types.KeyValue) ...@@ -55,9 +55,6 @@ func (c *PokerBull) updateIndex(log *pkt.ReceiptPBGame) (kvs []*types.KeyValue)
func (c *PokerBull) execLocal(receipt *types.ReceiptData) (*types.LocalDBSet, error) { func (c *PokerBull) execLocal(receipt *types.ReceiptData) (*types.LocalDBSet, error) {
dbSet := &types.LocalDBSet{} dbSet := &types.LocalDBSet{}
if receipt.GetTy() != types.ExecOk {
return dbSet, nil
}
for i := 0; i < len(receipt.Logs); i++ { for i := 0; i < len(receipt.Logs); i++ {
item := receipt.Logs[i] item := receipt.Logs[i]
if item.Ty == pkt.TyLogPBGameStart || item.Ty == pkt.TyLogPBGameContinue || item.Ty == pkt.TyLogPBGameQuit { if item.Ty == pkt.TyLogPBGameStart || item.Ty == pkt.TyLogPBGameContinue || item.Ty == pkt.TyLogPBGameQuit {
......
...@@ -139,3 +139,8 @@ func delPBGameStatusAndPlayer(status int32, player int32, value, index int64) *t ...@@ -139,3 +139,8 @@ func delPBGameStatusAndPlayer(status int32, player int32, value, index int64) *t
kv.Value = nil kv.Value = nil
return kv return kv
} }
// CheckReceiptExecOk return true to check if receipt ty is ok
func (g *PokerBull) CheckReceiptExecOk() bool {
return true
}
...@@ -520,9 +520,9 @@ func (action *Action) checkPlayerExistInGame() bool { ...@@ -520,9 +520,9 @@ func (action *Action) checkPlayerExistInGame() bool {
} }
var value pkt.PBGameRecord var value pkt.PBGameRecord
lenght := len(values) length := len(values)
if lenght != 0 { if length != 0 {
valueBytes := values[lenght-1] valueBytes := values[length-1]
err := types.Decode(valueBytes, &value) err := types.Decode(valueBytes, &value)
if err == nil && value.Status == pkt.PBGameActionQuit { if err == nil && value.Status == pkt.PBGameActionQuit {
return false return false
......
...@@ -499,7 +499,7 @@ func showPrivacyAccountInfoFlag(cmd *cobra.Command) { ...@@ -499,7 +499,7 @@ func showPrivacyAccountInfoFlag(cmd *cobra.Command) {
cmd.MarkFlagRequired("addr") cmd.MarkFlagRequired("addr")
cmd.Flags().StringP("token", "t", types.BTY, "coins token, BTY supported.") cmd.Flags().StringP("token", "t", types.BTY, "coins token, BTY supported.")
cmd.Flags().Int32P("displaymode", "d", 0, "display mode.(0: display collect. 1:display avaliable detail. 2:display frozen detail. 3:display all") cmd.Flags().Int32P("displaymode", "d", 0, "display mode.(0: display collect. 1:display available detail. 2:display frozen detail. 3:display all")
} }
func showPrivacyAccountInfo(cmd *cobra.Command, args []string) { func showPrivacyAccountInfo(cmd *cobra.Command, args []string) {
......
...@@ -108,17 +108,22 @@ func TestGenerateRingSignature1(t *testing.T) { ...@@ -108,17 +108,22 @@ func TestGenerateRingSignature1(t *testing.T) {
var signs [maxCount]*Sign var signs [maxCount]*Sign
index := 0 index := 0
prefixHash, err := common.FromHex("fd1f64844a7d6a9f74fc2141bceba9d9d69b1fd6104f93bfa42a6d708a6ab22c") prefixHash, err := common.FromHex("fd1f64844a7d6a9f74fc2141bceba9d9d69b1fd6104f93bfa42a6d708a6ab22c")
assert.Nil(t, err)
tmp, err := common.FromHex("e7d85d6e81512c5650adce0499d6c17a83e2e29a05c1166cd2171b6b9288b3c4") tmp, err := common.FromHex("e7d85d6e81512c5650adce0499d6c17a83e2e29a05c1166cd2171b6b9288b3c4")
assert.Nil(t, err)
copy(image[:], tmp) copy(image[:], tmp)
tmp, err = common.FromHex("15e3cc7cdb904d62f7c20d7fa51923fa2839f9e0a92ff0eddf8c12bd09089c15") tmp, err = common.FromHex("15e3cc7cdb904d62f7c20d7fa51923fa2839f9e0a92ff0eddf8c12bd09089c15")
assert.Nil(t, err)
for i := 0; i < maxCount; i++ { for i := 0; i < maxCount; i++ {
pub := PubKeyPrivacy{} pub := PubKeyPrivacy{}
copy(pub[:], tmp[32*i:32*(i+1)]) copy(pub[:], tmp[32*i:32*(i+1)])
pubs[i] = &pub pubs[i] = &pub
} }
tmp, err = common.FromHex("fd8de2e12410e3da20350e6f4083b73cc3396b4812c09af633d7c223bfb2560b") tmp, err = common.FromHex("fd8de2e12410e3da20350e6f4083b73cc3396b4812c09af633d7c223bfb2560b")
assert.Nil(t, err)
copy(sec[:], tmp) copy(sec[:], tmp)
tmp, err = common.FromHex("b5c0a53bce99106e74284ee1d2c64a68a14e8b4c1735e8ab9ca7215a414f97084749935d87d516b5659a01e84b08279c42e649b2e500e2ede443fe68885b0206") tmp, err = common.FromHex("b5c0a53bce99106e74284ee1d2c64a68a14e8b4c1735e8ab9ca7215a414f97084749935d87d516b5659a01e84b08279c42e649b2e500e2ede443fe68885b0206")
assert.Nil(t, err)
for i := 0; i < maxCount; i++ { for i := 0; i < maxCount; i++ {
signs[i] = &Sign{} signs[i] = &Sign{}
} }
...@@ -139,14 +144,17 @@ func TestCheckRingSignature1(t *testing.T) { ...@@ -139,14 +144,17 @@ func TestCheckRingSignature1(t *testing.T) {
t.Error("initialize public key from hex failed.") t.Error("initialize public key from hex failed.")
} }
tmp, err := common.FromHex("e7d85d6e81512c5650adce0499d6c17a83e2e29a05c1166cd2171b6b9288b3c4") tmp, err := common.FromHex("e7d85d6e81512c5650adce0499d6c17a83e2e29a05c1166cd2171b6b9288b3c4")
assert.Nil(t, err)
copy(image[:], tmp) copy(image[:], tmp)
tmp, err = common.FromHex("15e3cc7cdb904d62f7c20d7fa51923fa2839f9e0a92ff0eddf8c12bd09089c15") tmp, err = common.FromHex("15e3cc7cdb904d62f7c20d7fa51923fa2839f9e0a92ff0eddf8c12bd09089c15")
assert.Nil(t, err)
for i := 0; i < maxCount; i++ { for i := 0; i < maxCount; i++ {
pub := PubKeyPrivacy{} pub := PubKeyPrivacy{}
copy(pub[:], tmp[32*i:32*(i+1)]) copy(pub[:], tmp[32*i:32*(i+1)])
pubs[i] = &pub pubs[i] = &pub
} }
tmp, err = common.FromHex("a142d0180a6047cf883125a83617c7dd56e9d8153ec04a96b3c5d9a5e03cd70cfd6827b200d6c2f4b41fb5b0162117a5447e327c29482c358a0a3c82db88fb0f") tmp, err = common.FromHex("a142d0180a6047cf883125a83617c7dd56e9d8153ec04a96b3c5d9a5e03cd70cfd6827b200d6c2f4b41fb5b0162117a5447e327c29482c358a0a3c82db88fb0f")
assert.Nil(t, err)
for i := 0; i < maxCount; i++ { for i := 0; i < maxCount; i++ {
sign := Sign{} sign := Sign{}
copy(sign[:], tmp[64*i:64*(i+1)]) copy(sign[:], tmp[64*i:64*(i+1)])
...@@ -172,11 +180,13 @@ func TestCheckRingSignatureAPI1(t *testing.T) { ...@@ -172,11 +180,13 @@ func TestCheckRingSignatureAPI1(t *testing.T) {
} }
tmp, err := common.FromHex("15e3cc7cdb904d62f7c20d7fa51923fa2839f9e0a92ff0eddf8c12bd09089c15") tmp, err := common.FromHex("15e3cc7cdb904d62f7c20d7fa51923fa2839f9e0a92ff0eddf8c12bd09089c15")
assert.Nil(t, err)
for i := 0; i < maxCount; i++ { for i := 0; i < maxCount; i++ {
publickeys[i] = append(publickeys[i], tmp...) publickeys[i] = append(publickeys[i], tmp...)
} }
tmp, err = common.FromHex("a142d0180a6047cf883125a83617c7dd56e9d8153ec04a96b3c5d9a5e03cd70cfd6827b200d6c2f4b41fb5b0162117a5447e327c29482c358a0a3c82db88fb0f") tmp, err = common.FromHex("a142d0180a6047cf883125a83617c7dd56e9d8153ec04a96b3c5d9a5e03cd70cfd6827b200d6c2f4b41fb5b0162117a5447e327c29482c358a0a3c82db88fb0f")
assert.Nil(t, err)
data := make([][]byte, maxCount) data := make([][]byte, maxCount)
for i := 0; i < maxCount; i++ { for i := 0; i < maxCount; i++ {
data[i] = make([]byte, 0) data[i] = make([]byte, 0)
...@@ -200,14 +210,17 @@ func TestCheckRingSignature3(t *testing.T) { ...@@ -200,14 +210,17 @@ func TestCheckRingSignature3(t *testing.T) {
t.Error("initialize public key from hex failed.") t.Error("initialize public key from hex failed.")
} }
tmp, err := common.FromHex("04e593e5e4028ce1c1194eb473efc21359b114737e5a64f14420b3cf5b22204b") tmp, err := common.FromHex("04e593e5e4028ce1c1194eb473efc21359b114737e5a64f14420b3cf5b22204b")
assert.Nil(t, err)
copy(image[:], tmp) copy(image[:], tmp)
tmp, err = common.FromHex("6bfc9654082a7da3055121aa69ddb46852577be71d6c9a204aae3492f0db7e41194f27c9fe4d81cc8421bf8256374edf660806d78b4ed7914a3b74359c8ac0bd65ff1bca674607f7948ea0ae8e83b6d9c5092942b52d2847b6cf44c9c609264d") tmp, err = common.FromHex("6bfc9654082a7da3055121aa69ddb46852577be71d6c9a204aae3492f0db7e41194f27c9fe4d81cc8421bf8256374edf660806d78b4ed7914a3b74359c8ac0bd65ff1bca674607f7948ea0ae8e83b6d9c5092942b52d2847b6cf44c9c609264d")
assert.Nil(t, err)
for i := 0; i < maxCount; i++ { for i := 0; i < maxCount; i++ {
pub := PubKeyPrivacy{} pub := PubKeyPrivacy{}
copy(pub[:], tmp[32*i:32*(i+1)]) copy(pub[:], tmp[32*i:32*(i+1)])
pubs[i] = &pub pubs[i] = &pub
} }
tmp, err = common.FromHex("30041e9694c3184980c3bb87f817eab3f973cd969810ec9df4d2feeee907970693eba4bc5436dc7cf49ce476e091bf74d20003f0f73f6d0412909ed8c1a10701c9c4ec11623dd3c50980ead83865a03dfa27614e5e9fb875d75667c11ced390d438f5dd04a137c73a0ec9ca36dfab62c948ce596722067de0315b570db1f720bab7fb7ea1b124f55c9633548f06d1bb403d7e2e15a1fed70ab2865e324ef340327f6d0ad0a7129b272ce12a5a63836a4e96e95897ee44cc22a7048023f438006") tmp, err = common.FromHex("30041e9694c3184980c3bb87f817eab3f973cd969810ec9df4d2feeee907970693eba4bc5436dc7cf49ce476e091bf74d20003f0f73f6d0412909ed8c1a10701c9c4ec11623dd3c50980ead83865a03dfa27614e5e9fb875d75667c11ced390d438f5dd04a137c73a0ec9ca36dfab62c948ce596722067de0315b570db1f720bab7fb7ea1b124f55c9633548f06d1bb403d7e2e15a1fed70ab2865e324ef340327f6d0ad0a7129b272ce12a5a63836a4e96e95897ee44cc22a7048023f438006")
assert.Nil(t, err)
for i := 0; i < maxCount; i++ { for i := 0; i < maxCount; i++ {
sign := Sign{} sign := Sign{}
copy(sign[:], tmp[64*i:64*(i+1)]) copy(sign[:], tmp[64*i:64*(i+1)])
...@@ -250,15 +263,18 @@ func TestCheckRingSignature17(t *testing.T) { ...@@ -250,15 +263,18 @@ func TestCheckRingSignature17(t *testing.T) {
t.Error("initialize public key from hex failed.") t.Error("initialize public key from hex failed.")
} }
tmp, err := common.FromHex("199c5e78a71b320b704e01850a67c371fed3aca11a04077a36e10c808fdc5f57") tmp, err := common.FromHex("199c5e78a71b320b704e01850a67c371fed3aca11a04077a36e10c808fdc5f57")
assert.Nil(t, err)
copy(image[:], tmp) copy(image[:], tmp)
for i := 0; i < maxCount; i++ { for i := 0; i < maxCount; i++ {
pub := PubKeyPrivacy{} pub := PubKeyPrivacy{}
tmp, err = common.FromHex(pubstrs[i]) tmp, err = common.FromHex(pubstrs[i])
assert.Nil(t, err)
copy(pub[:], tmp) copy(pub[:], tmp)
pubs[i] = &pub pubs[i] = &pub
} }
tmp, err = common.FromHex("f5b1a5079f6122d2370da403efc2e5504b07d67ade7ca57ad3720c7e00a676096ad418262cd9f8c9afee8e58be894cb2bf6387a5018f67d629bf8845bdc9b307aee86f85f8612f74ed870abc81d54cb38f2f9108c20dbf81eb7c1160935bc801cdca5d3f09f1d4bac810cb03ec32753f65a2071a97ba787c2d550ea5ff4d890ac398a1576d108ee67138e7596af54199247c6413e06124af8db76c0ad67c160f351e53029cac4a073c8b188eb8b5151ebf1f34a6693ddbf467ac8c20eec51204c3ca29fd5814f0848b966d2bca9543fc953a0d04bb4782950123d87bd378f60d3cdc5e44160ed4265b7cd84a8200244fa24bac86c50c35b885a15f1bc1de9909fabab87d504fc0cb0b263564e606505477ded1f89543bd4d6ed87ce61918f705359c525c0e0a4cc1d77043c71dfdf9c6834e2623197af1629e34962d940eb4080d06dddaa6e12953232595906289e4712f6aa8c1189f336b823a6a38ac95390b63c508a3409256f0c4df687d4b49990d9878fc5c97af32aa99bc9ffa1215860f69fc141c763fe1f4ed3ccc72e6817e926164752686d55238e74032c47c8c580f7042a62bd74858768815a05b58887f9828bf0f184eceba1416ac294abe453105a0de353316374b1c0560acc0f98181e3229084721a0d2a6ed891d57b805984044372cbb566c91696f5d63e7e5d8cc906c5fb029e71e87a339fcbaee9502f3d01dfd203dbd04797c33370dd0626baabfb9577ca1c294d1d8c6b82ac9624496f04893ad6b2222799cfd1d4ec525b011ecf72b01f6f3b8a6a165f0169fa7cc0960025787d4253e1064e71190d36965605adb850e72e17685e35772cdd3fdfb3d505e96e5eb0ecf8c11bcef62c79e0d49e3ebc76e56d18753403a880b7d7ed399c0e143df235ac8b0748d99e1b0cdcc511abc079c1bdbfead04265d9ad44e5dd7c0e97e4afbacba478539071db02315cc9326c8edb3d8530c7fc78af9ca12b241c04f87bffab95d85f8486ff01aec75e7e38a75ff023e4b2b0f59999c4ac067b500863a63de803da2c89de74878879a39aec6cf800b117ef89ea068a71db5ef70200163d1b4beaeea8c642430e15a64baefd350cb16ca5dae6563c13162904908301485d2c4e5bac6d55dd947a169a38df2848d5e227482760f6d818c45f66a6380507d691ef87e3550626254da3ec65411e8e5aa2ab4846222e208c9ba18cd5ee09617398af31b9eac38b59180bfaec538e5542d698da20016720ced6edb7ba270059c1e1e7107d71524e4a9cf562b5da263b52368f477c5205c768ac36975a250310c37d1f40f5a6eac857ed6082c12f5cf20a0403afcde3f1ea2e4743cb1ba10fd5d92038b1fc65d09467aeac9fe7cd24f78b9376d47d2ef1d3677ede62b2640544dd1b301292b8d082a97bd910ca24fbb5eea878f2cfa4e983bb25a8a66a25065988477eec0c1815a3fa2ff421621707954e9eacdf823eea02c2e3742797c6097e570479b36ca4580c5be9bab187de6a1fa6609768b3fa6448b5bc56d6de820d") tmp, err = common.FromHex("f5b1a5079f6122d2370da403efc2e5504b07d67ade7ca57ad3720c7e00a676096ad418262cd9f8c9afee8e58be894cb2bf6387a5018f67d629bf8845bdc9b307aee86f85f8612f74ed870abc81d54cb38f2f9108c20dbf81eb7c1160935bc801cdca5d3f09f1d4bac810cb03ec32753f65a2071a97ba787c2d550ea5ff4d890ac398a1576d108ee67138e7596af54199247c6413e06124af8db76c0ad67c160f351e53029cac4a073c8b188eb8b5151ebf1f34a6693ddbf467ac8c20eec51204c3ca29fd5814f0848b966d2bca9543fc953a0d04bb4782950123d87bd378f60d3cdc5e44160ed4265b7cd84a8200244fa24bac86c50c35b885a15f1bc1de9909fabab87d504fc0cb0b263564e606505477ded1f89543bd4d6ed87ce61918f705359c525c0e0a4cc1d77043c71dfdf9c6834e2623197af1629e34962d940eb4080d06dddaa6e12953232595906289e4712f6aa8c1189f336b823a6a38ac95390b63c508a3409256f0c4df687d4b49990d9878fc5c97af32aa99bc9ffa1215860f69fc141c763fe1f4ed3ccc72e6817e926164752686d55238e74032c47c8c580f7042a62bd74858768815a05b58887f9828bf0f184eceba1416ac294abe453105a0de353316374b1c0560acc0f98181e3229084721a0d2a6ed891d57b805984044372cbb566c91696f5d63e7e5d8cc906c5fb029e71e87a339fcbaee9502f3d01dfd203dbd04797c33370dd0626baabfb9577ca1c294d1d8c6b82ac9624496f04893ad6b2222799cfd1d4ec525b011ecf72b01f6f3b8a6a165f0169fa7cc0960025787d4253e1064e71190d36965605adb850e72e17685e35772cdd3fdfb3d505e96e5eb0ecf8c11bcef62c79e0d49e3ebc76e56d18753403a880b7d7ed399c0e143df235ac8b0748d99e1b0cdcc511abc079c1bdbfead04265d9ad44e5dd7c0e97e4afbacba478539071db02315cc9326c8edb3d8530c7fc78af9ca12b241c04f87bffab95d85f8486ff01aec75e7e38a75ff023e4b2b0f59999c4ac067b500863a63de803da2c89de74878879a39aec6cf800b117ef89ea068a71db5ef70200163d1b4beaeea8c642430e15a64baefd350cb16ca5dae6563c13162904908301485d2c4e5bac6d55dd947a169a38df2848d5e227482760f6d818c45f66a6380507d691ef87e3550626254da3ec65411e8e5aa2ab4846222e208c9ba18cd5ee09617398af31b9eac38b59180bfaec538e5542d698da20016720ced6edb7ba270059c1e1e7107d71524e4a9cf562b5da263b52368f477c5205c768ac36975a250310c37d1f40f5a6eac857ed6082c12f5cf20a0403afcde3f1ea2e4743cb1ba10fd5d92038b1fc65d09467aeac9fe7cd24f78b9376d47d2ef1d3677ede62b2640544dd1b301292b8d082a97bd910ca24fbb5eea878f2cfa4e983bb25a8a66a25065988477eec0c1815a3fa2ff421621707954e9eacdf823eea02c2e3742797c6097e570479b36ca4580c5be9bab187de6a1fa6609768b3fa6448b5bc56d6de820d")
assert.Nil(t, err)
for i := 0; i < maxCount; i++ { for i := 0; i < maxCount; i++ {
sign := Sign{} sign := Sign{}
copy(sign[:], tmp[64*i:64*(i+1)]) copy(sign[:], tmp[64*i:64*(i+1)])
......
...@@ -13,10 +13,6 @@ import ( ...@@ -13,10 +13,6 @@ import (
func (p *privacy) execDelLocal(tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (p *privacy) execDelLocal(tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
txhashstr := common.Bytes2Hex(tx.Hash()) txhashstr := common.Bytes2Hex(tx.Hash())
dbSet := &types.LocalDBSet{} dbSet := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
privacylog.Error("execDelLocal", "txhash", txhashstr, "receipt.GetTy() = ", receiptData.GetTy())
return dbSet, nil
}
localDB := p.GetLocalDB() localDB := p.GetLocalDB()
for i, item := range receiptData.Logs { for i, item := range receiptData.Logs {
if item.Ty != ty.TyLogPrivacyOutput { if item.Ty != ty.TyLogPrivacyOutput {
......
...@@ -272,7 +272,7 @@ func (p *privacy) CheckTx(tx *types.Transaction, index int) error { ...@@ -272,7 +272,7 @@ func (p *privacy) CheckTx(tx *types.Transaction, index int) error {
totalOutput += output.Amount totalOutput += output.Amount
} }
feeAmount := int64(0) var feeAmount int64
if action.Ty == pty.ActionPrivacy2Privacy { if action.Ty == pty.ActionPrivacy2Privacy {
feeAmount = totalInput - totalOutput feeAmount = totalInput - totalOutput
} else { } else {
...@@ -331,3 +331,8 @@ func (p *privacy) checkPubKeyValid(keys [][]byte, pubkeys [][]byte) (bool, int32 ...@@ -331,3 +331,8 @@ func (p *privacy) checkPubKeyValid(keys [][]byte, pubkeys [][]byte) (bool, int32
return true, invalidIndex return true, invalidIndex
} }
// CheckReceiptExecOk return true to check if receipt ty is ok
func (p *privacy) CheckReceiptExecOk() bool {
return true
}
...@@ -38,7 +38,7 @@ func (policy *privacyPolicy) rescanAllTxAddToUpdateUTXOs() { ...@@ -38,7 +38,7 @@ func (policy *privacyPolicy) rescanAllTxAddToUpdateUTXOs() {
go policy.rescanReqTxDetailByAddr(acc.Addr, policy.rescanwg) go policy.rescanReqTxDetailByAddr(acc.Addr, policy.rescanwg)
} }
policy.rescanwg.Wait() policy.rescanwg.Wait()
bizlog.Debug("rescanAllTxToUpdateUTXOs sucess!") bizlog.Debug("rescanAllTxToUpdateUTXOs success!")
} }
//从blockchain模块同步addr参与的所有交易详细信息 //从blockchain模块同步addr参与的所有交易详细信息
...@@ -312,8 +312,8 @@ func (policy *privacyPolicy) showPrivacyKeyPair(reqAddr *types.ReqString) (*priv ...@@ -312,8 +312,8 @@ func (policy *privacyPolicy) showPrivacyKeyPair(reqAddr *types.ReqString) (*priv
return nil, err return nil, err
} }
pair := privacyInfo.ViewPubkey[:] //pair := privacyInfo.ViewPubkey[:]
pair = append(pair, privacyInfo.SpendPubkey[:]...) //pair = append(pair, privacyInfo.SpendPubkey[:]...)
replyPrivacyPkPair := &privacytypes.ReplyPrivacyPkPair{ replyPrivacyPkPair := &privacytypes.ReplyPrivacyPkPair{
ShowSuccessful: true, ShowSuccessful: true,
...@@ -333,6 +333,10 @@ func (policy *privacyPolicy) getPrivacyAccountInfo(req *privacytypes.ReqPPrivacy ...@@ -333,6 +333,10 @@ func (policy *privacyPolicy) getPrivacyAccountInfo(req *privacytypes.ReqPPrivacy
// 搜索可用余额 // 搜索可用余额
privacyDBStore, err := policy.store.listAvailableUTXOs(token, addr) privacyDBStore, err := policy.store.listAvailableUTXOs(token, addr)
if err != nil {
bizlog.Error("getPrivacyAccountInfo", "listAvailableUTXOs")
return nil, err
}
utxos := make([]*privacytypes.UTXO, 0) utxos := make([]*privacytypes.UTXO, 0)
for _, ele := range privacyDBStore { for _, ele := range privacyDBStore {
utxoBasic := &privacytypes.UTXOBasic{ utxoBasic := &privacytypes.UTXOBasic{
...@@ -820,7 +824,7 @@ func (policy *privacyPolicy) rescanReqUtxosByAddr(addrs []string) { ...@@ -820,7 +824,7 @@ func (policy *privacyPolicy) rescanReqUtxosByAddr(addrs []string) {
defer policy.getWalletOperate().GetWaitGroup().Done() defer policy.getWalletOperate().GetWaitGroup().Done()
bizlog.Debug("RescanAllUTXO begin!") bizlog.Debug("RescanAllUTXO begin!")
policy.reqUtxosByAddr(addrs) policy.reqUtxosByAddr(addrs)
bizlog.Debug("RescanAllUTXO sucess!") bizlog.Debug("RescanAllUTXO success!")
} }
func (policy *privacyPolicy) reqUtxosByAddr(addrs []string) { func (policy *privacyPolicy) reqUtxosByAddr(addrs []string) {
......
...@@ -118,7 +118,7 @@ func (mock *testDataMock) importPrivateKey(PrivKey *types.ReqWalletImportPrivkey ...@@ -118,7 +118,7 @@ func (mock *testDataMock) importPrivateKey(PrivKey *types.ReqWalletImportPrivkey
defer wallet.GetMutex().Unlock() defer wallet.GetMutex().Unlock()
ok, err := wallet.CheckWalletStatus() ok, err := wallet.CheckWalletStatus()
if !ok { if !ok || err != nil {
return return
} }
...@@ -128,7 +128,7 @@ func (mock *testDataMock) importPrivateKey(PrivKey *types.ReqWalletImportPrivkey ...@@ -128,7 +128,7 @@ func (mock *testDataMock) importPrivateKey(PrivKey *types.ReqWalletImportPrivkey
//校验label是否已经被使用 //校验label是否已经被使用
Account, err := wallet.GetAccountByLabel(PrivKey.GetLabel()) Account, err := wallet.GetAccountByLabel(PrivKey.GetLabel())
if Account != nil { if Account != nil || err != nil {
return return
} }
...@@ -161,7 +161,7 @@ func (mock *testDataMock) importPrivateKey(PrivKey *types.ReqWalletImportPrivkey ...@@ -161,7 +161,7 @@ func (mock *testDataMock) importPrivateKey(PrivKey *types.ReqWalletImportPrivkey
Encrypteredstr := common.ToHex(Encryptered) Encrypteredstr := common.ToHex(Encryptered)
//校验PrivKey对应的addr是否已经存在钱包中 //校验PrivKey对应的addr是否已经存在钱包中
Account, err = wallet.GetAccountByAddr(addr) Account, err = wallet.GetAccountByAddr(addr)
if Account != nil { if Account != nil || err != nil {
if Account.Privkey == Encrypteredstr { if Account.Privkey == Encrypteredstr {
return return
} else { } else {
...@@ -277,7 +277,7 @@ func Test_EnablePrivacy(t *testing.T) { ...@@ -277,7 +277,7 @@ func Test_EnablePrivacy(t *testing.T) {
req: &ty.ReqEnablePrivacy{Addrs: []string{testAddrs[0]}}, req: &ty.ReqEnablePrivacy{Addrs: []string{testAddrs[0]}},
needReply: &ty.RepEnablePrivacy{ needReply: &ty.RepEnablePrivacy{
Results: []*ty.PriAddrResult{ Results: []*ty.PriAddrResult{
{IsOK: true, Addr: testAddrs[0]}}, {Addr: testAddrs[0], Msg: "ErrAddrNotExist"}},
}, },
}, },
} }
...@@ -305,14 +305,15 @@ func Test_ShowPrivacyKey(t *testing.T) { ...@@ -305,14 +305,15 @@ func Test_ShowPrivacyKey(t *testing.T) {
}{ }{
{ {
req: &types.ReqString{Data: testAddrs[1]}, req: &types.ReqString{Data: testAddrs[1]},
needError: ty.ErrPrivacyNotEnabled, needError: types.ErrAddrNotExist,
}, },
{ {
req: &types.ReqString{Data: testAddrs[0]}, req: &types.ReqString{Data: testAddrs[0]},
needReply: &ty.ReplyPrivacyPkPair{ /*needReply: &ty.ReplyPrivacyPkPair{
ShowSuccessful: true, ShowSuccessful: true,
Pubkeypair: "92fe6cfec2e19cd15f203f83b5d440ddb63d0cb71559f96dc81208d819fea85886b08f6e874fca15108d244b40f9086d8c03260d4b954a40dfb3cbe41ebc7389", Pubkeypair: "92fe6cfec2e19cd15f203f83b5d440ddb63d0cb71559f96dc81208d819fea85886b08f6e874fca15108d244b40f9086d8c03260d4b954a40dfb3cbe41ebc7389",
}, },*/
needError: types.ErrAddrNotExist,
}, },
} }
...@@ -349,6 +350,7 @@ func Test_CreateUTXOs(t *testing.T) { ...@@ -349,6 +350,7 @@ func Test_CreateUTXOs(t *testing.T) {
Sender: testAddrs[0], Sender: testAddrs[0],
Pubkeypair: testPubkeyPairs[0], Pubkeypair: testPubkeyPairs[0],
}, },
needError: types.ErrAddrNotExist,
}, },
} }
...@@ -379,6 +381,7 @@ func Test_SendPublic2PrivacyTransaction(t *testing.T) { ...@@ -379,6 +381,7 @@ func Test_SendPublic2PrivacyTransaction(t *testing.T) {
Pubkeypair: testPubkeyPairs[0], Pubkeypair: testPubkeyPairs[0],
}, },
needReply: &types.Reply{IsOk: true}, needReply: &types.Reply{IsOk: true},
needError: types.ErrAddrNotExist,
}, },
} }
...@@ -418,6 +421,7 @@ func Test_SendPrivacy2PrivacyTransaction(t *testing.T) { ...@@ -418,6 +421,7 @@ func Test_SendPrivacy2PrivacyTransaction(t *testing.T) {
Pubkeypair: testPubkeyPairs[1], Pubkeypair: testPubkeyPairs[1],
}, },
needReply: &types.Reply{IsOk: true}, needReply: &types.Reply{IsOk: true},
needError: types.ErrAddrNotExist,
}, },
} }
...@@ -457,6 +461,7 @@ func Test_SendPrivacy2PublicTransaction(t *testing.T) { ...@@ -457,6 +461,7 @@ func Test_SendPrivacy2PublicTransaction(t *testing.T) {
Receiver: testAddrs[0], Receiver: testAddrs[0],
}, },
needReply: &types.Reply{IsOk: true}, needReply: &types.Reply{IsOk: true},
needError: types.ErrAddrNotExist,
}, },
} }
...@@ -496,6 +501,7 @@ func Test_CreateTransaction(t *testing.T) { ...@@ -496,6 +501,7 @@ func Test_CreateTransaction(t *testing.T) {
From: testAddrs[0], From: testAddrs[0],
Pubkeypair: testPubkeyPairs[0], Pubkeypair: testPubkeyPairs[0],
}, },
//needError:types.ErrAddrNotExist,
}, },
{ // 私对私测试 { // 私对私测试
req: &types.ReqCreateTransaction{ req: &types.ReqCreateTransaction{
...@@ -505,6 +511,7 @@ func Test_CreateTransaction(t *testing.T) { ...@@ -505,6 +511,7 @@ func Test_CreateTransaction(t *testing.T) {
From: testAddrs[0], From: testAddrs[0],
Pubkeypair: testPubkeyPairs[1], Pubkeypair: testPubkeyPairs[1],
}, },
needError: types.ErrAddrNotExist,
}, },
{ // 私对公测试 { // 私对公测试
req: &types.ReqCreateTransaction{ req: &types.ReqCreateTransaction{
...@@ -514,6 +521,7 @@ func Test_CreateTransaction(t *testing.T) { ...@@ -514,6 +521,7 @@ func Test_CreateTransaction(t *testing.T) {
From: testAddrs[0], From: testAddrs[0],
Pubkeypair: testPubkeyPairs[0], Pubkeypair: testPubkeyPairs[0],
}, },
needError: types.ErrAddrNotExist,
}, },
} }
for index, testCase := range testCases { for index, testCase := range testCases {
...@@ -621,7 +629,7 @@ func Test_RescanUTXOs(t *testing.T) { ...@@ -621,7 +629,7 @@ func Test_RescanUTXOs(t *testing.T) {
Addrs: testAddrs, Addrs: testAddrs,
Flag: 0, Flag: 0,
}, },
needError: ty.ErrPrivacyNotEnabled, needError: types.ErrAccountNotExist,
}, },
{ {
enable: true, enable: true,
...@@ -629,6 +637,7 @@ func Test_RescanUTXOs(t *testing.T) { ...@@ -629,6 +637,7 @@ func Test_RescanUTXOs(t *testing.T) {
Addrs: testAddrs, Addrs: testAddrs,
Flag: 0, Flag: 0,
}, },
needError: types.ErrAccountNotExist,
}, },
} }
for index, testCase := range testCases { for index, testCase := range testCases {
......
...@@ -255,8 +255,10 @@ func testStore_listAvailableUTXOs(t *testing.T) { ...@@ -255,8 +255,10 @@ func testStore_listAvailableUTXOs(t *testing.T) {
err = store.Set(key, []byte("AccKey")) err = store.Set(key, []byte("AccKey"))
assert.NoError(t, err) assert.NoError(t, err)
utxos, err = store.listAvailableUTXOs(token, addr) utxos, err = store.listAvailableUTXOs(token, addr)
assert.Nil(t, utxos)
assert.NotNil(t, err) assert.NotNil(t, err)
err = store.Set([]byte("AccKey"), bt) err = store.Set([]byte("AccKey"), bt)
assert.NoError(t, err)
utxos, err = store.listAvailableUTXOs(token, addr) utxos, err = store.listAvailableUTXOs(token, addr)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, 1, len(utxos)) assert.Equal(t, 1, len(utxos))
...@@ -290,6 +292,7 @@ func testStore_getAccountByAddr(t *testing.T) { ...@@ -290,6 +292,7 @@ func testStore_getAccountByAddr(t *testing.T) {
bt, err := proto.Marshal(account) bt, err := proto.Marshal(account)
assert.NoError(t, err) assert.NoError(t, err)
err = store.Set(calcAddrKey(addr), bt) err = store.Set(calcAddrKey(addr), bt)
assert.NoError(t, err)
was, err = store.getAccountByAddr(addr) was, err = store.getAccountByAddr(addr)
assert.Equal(t, true, proto.Equal(was, account)) assert.Equal(t, true, proto.Equal(was, account))
assert.NoError(t, err) assert.NoError(t, err)
...@@ -345,6 +348,7 @@ func testStore_getVersion(t *testing.T) { ...@@ -345,6 +348,7 @@ func testStore_getVersion(t *testing.T) {
bt, err = json.Marshal(PRIVACYDBVERSION) bt, err = json.Marshal(PRIVACYDBVERSION)
assert.NoError(t, err) assert.NoError(t, err)
err = store.Set(calcPrivacyDBVersion(), bt) err = store.Set(calcPrivacyDBVersion(), bt)
assert.NoError(t, err)
version = store.getVersion() version = store.getVersion()
assert.Equal(t, PRIVACYDBVERSION, version) assert.Equal(t, PRIVACYDBVERSION, version)
} }
...@@ -243,3 +243,8 @@ func deleteCreateOrderKeyValue(kv []*types.KeyValue, order *ty.RelayOrder, statu ...@@ -243,3 +243,8 @@ func deleteCreateOrderKeyValue(kv []*types.KeyValue, order *ty.RelayOrder, statu
return kv return kv
} }
// CheckReceiptExecOk return true to check if receipt ty is ok
func (r *relay) CheckReceiptExecOk() bool {
return true
}
...@@ -51,9 +51,6 @@ func DelRetrieveInfo(info *rt.RetrieveQuery, Status int64, db dbm.KVDB) (*types. ...@@ -51,9 +51,6 @@ func DelRetrieveInfo(info *rt.RetrieveQuery, Status int64, db dbm.KVDB) (*types.
// ExecDelLocal_Backup Action // ExecDelLocal_Backup Action
func (c *Retrieve) ExecDelLocal_Backup(backup *rt.BackupRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (c *Retrieve) ExecDelLocal_Backup(backup *rt.BackupRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{} set := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
return set, nil
}
rlog.Debug("Retrieve ExecDelLocal_Backup") rlog.Debug("Retrieve ExecDelLocal_Backup")
info := rt.RetrieveQuery{BackupAddress: backup.BackupAddress, DefaultAddress: backup.DefaultAddress, DelayPeriod: backup.DelayPeriod, PrepareTime: zeroPrepareTime, RemainTime: zeroRemainTime, Status: retrieveBackup} info := rt.RetrieveQuery{BackupAddress: backup.BackupAddress, DefaultAddress: backup.DefaultAddress, DelayPeriod: backup.DelayPeriod, PrepareTime: zeroPrepareTime, RemainTime: zeroRemainTime, Status: retrieveBackup}
...@@ -72,9 +69,6 @@ func (c *Retrieve) ExecDelLocal_Backup(backup *rt.BackupRetrieve, tx *types.Tran ...@@ -72,9 +69,6 @@ func (c *Retrieve) ExecDelLocal_Backup(backup *rt.BackupRetrieve, tx *types.Tran
// ExecDelLocal_Prepare Action // ExecDelLocal_Prepare Action
func (c *Retrieve) ExecDelLocal_Prepare(pre *rt.PrepareRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (c *Retrieve) ExecDelLocal_Prepare(pre *rt.PrepareRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{} set := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
return set, nil
}
rlog.Debug("Retrieve ExecDelLocal_Prepare") rlog.Debug("Retrieve ExecDelLocal_Prepare")
info := rt.RetrieveQuery{BackupAddress: pre.BackupAddress, DefaultAddress: pre.DefaultAddress, DelayPeriod: zeroDelay, PrepareTime: c.GetBlockTime(), RemainTime: zeroRemainTime, Status: retrievePrepare} info := rt.RetrieveQuery{BackupAddress: pre.BackupAddress, DefaultAddress: pre.DefaultAddress, DelayPeriod: zeroDelay, PrepareTime: c.GetBlockTime(), RemainTime: zeroRemainTime, Status: retrievePrepare}
...@@ -93,9 +87,6 @@ func (c *Retrieve) ExecDelLocal_Prepare(pre *rt.PrepareRetrieve, tx *types.Trans ...@@ -93,9 +87,6 @@ func (c *Retrieve) ExecDelLocal_Prepare(pre *rt.PrepareRetrieve, tx *types.Trans
// ExecDelLocal_Perform Action // ExecDelLocal_Perform Action
func (c *Retrieve) ExecDelLocal_Perform(perf *rt.PerformRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (c *Retrieve) ExecDelLocal_Perform(perf *rt.PerformRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{} set := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
return set, nil
}
rlog.Debug("Retrieve ExecDelLocal_Perform") rlog.Debug("Retrieve ExecDelLocal_Perform")
info := rt.RetrieveQuery{BackupAddress: perf.BackupAddress, DefaultAddress: perf.DefaultAddress, DelayPeriod: zeroDelay, PrepareTime: zeroPrepareTime, RemainTime: zeroRemainTime, Status: retrievePerform} info := rt.RetrieveQuery{BackupAddress: perf.BackupAddress, DefaultAddress: perf.DefaultAddress, DelayPeriod: zeroDelay, PrepareTime: zeroPrepareTime, RemainTime: zeroRemainTime, Status: retrievePerform}
...@@ -114,9 +105,6 @@ func (c *Retrieve) ExecDelLocal_Perform(perf *rt.PerformRetrieve, tx *types.Tran ...@@ -114,9 +105,6 @@ func (c *Retrieve) ExecDelLocal_Perform(perf *rt.PerformRetrieve, tx *types.Tran
// ExecDelLocal_Cancel Action // ExecDelLocal_Cancel Action
func (c *Retrieve) ExecDelLocal_Cancel(cancel *rt.CancelRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (c *Retrieve) ExecDelLocal_Cancel(cancel *rt.CancelRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{} set := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
return set, nil
}
rlog.Debug("Retrieve ExecDelLocal_Cancel") rlog.Debug("Retrieve ExecDelLocal_Cancel")
info := rt.RetrieveQuery{BackupAddress: cancel.BackupAddress, DefaultAddress: cancel.DefaultAddress, DelayPeriod: zeroDelay, PrepareTime: zeroPrepareTime, RemainTime: zeroRemainTime, Status: retrieveCancel} info := rt.RetrieveQuery{BackupAddress: cancel.BackupAddress, DefaultAddress: cancel.DefaultAddress, DelayPeriod: zeroDelay, PrepareTime: zeroPrepareTime, RemainTime: zeroRemainTime, Status: retrieveCancel}
......
...@@ -54,9 +54,6 @@ func SaveRetrieveInfo(info *rt.RetrieveQuery, Status int64, db dbm.KVDB) (*types ...@@ -54,9 +54,6 @@ func SaveRetrieveInfo(info *rt.RetrieveQuery, Status int64, db dbm.KVDB) (*types
// ExecLocal_Backup Action // ExecLocal_Backup Action
func (c *Retrieve) ExecLocal_Backup(backup *rt.BackupRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (c *Retrieve) ExecLocal_Backup(backup *rt.BackupRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{} set := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
return set, nil
}
rlog.Debug("Retrieve ExecLocal_Backup") rlog.Debug("Retrieve ExecLocal_Backup")
info := rt.RetrieveQuery{BackupAddress: backup.BackupAddress, DefaultAddress: backup.DefaultAddress, DelayPeriod: backup.DelayPeriod, PrepareTime: zeroPrepareTime, RemainTime: zeroRemainTime, Status: retrieveBackup} info := rt.RetrieveQuery{BackupAddress: backup.BackupAddress, DefaultAddress: backup.DefaultAddress, DelayPeriod: backup.DelayPeriod, PrepareTime: zeroPrepareTime, RemainTime: zeroRemainTime, Status: retrieveBackup}
kv, err := SaveRetrieveInfo(&info, retrieveBackup, c.GetLocalDB()) kv, err := SaveRetrieveInfo(&info, retrieveBackup, c.GetLocalDB())
...@@ -74,9 +71,6 @@ func (c *Retrieve) ExecLocal_Backup(backup *rt.BackupRetrieve, tx *types.Transac ...@@ -74,9 +71,6 @@ func (c *Retrieve) ExecLocal_Backup(backup *rt.BackupRetrieve, tx *types.Transac
// ExecLocal_Prepare Action // ExecLocal_Prepare Action
func (c *Retrieve) ExecLocal_Prepare(pre *rt.PrepareRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (c *Retrieve) ExecLocal_Prepare(pre *rt.PrepareRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{} set := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
return set, nil
}
rlog.Debug("Retrieve ExecLocal_Prepare") rlog.Debug("Retrieve ExecLocal_Prepare")
info := rt.RetrieveQuery{BackupAddress: pre.BackupAddress, DefaultAddress: pre.DefaultAddress, DelayPeriod: zeroDelay, PrepareTime: zeroPrepareTime, RemainTime: zeroRemainTime, Status: retrievePrepare} info := rt.RetrieveQuery{BackupAddress: pre.BackupAddress, DefaultAddress: pre.DefaultAddress, DelayPeriod: zeroDelay, PrepareTime: zeroPrepareTime, RemainTime: zeroRemainTime, Status: retrievePrepare}
...@@ -95,9 +89,6 @@ func (c *Retrieve) ExecLocal_Prepare(pre *rt.PrepareRetrieve, tx *types.Transact ...@@ -95,9 +89,6 @@ func (c *Retrieve) ExecLocal_Prepare(pre *rt.PrepareRetrieve, tx *types.Transact
// ExecLocal_Perform Action // ExecLocal_Perform Action
func (c *Retrieve) ExecLocal_Perform(perf *rt.PerformRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (c *Retrieve) ExecLocal_Perform(perf *rt.PerformRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{} set := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
return set, nil
}
rlog.Debug("Retrieve ExecLocal_Perf") rlog.Debug("Retrieve ExecLocal_Perf")
info := rt.RetrieveQuery{BackupAddress: perf.BackupAddress, DefaultAddress: perf.DefaultAddress, DelayPeriod: zeroDelay, PrepareTime: zeroPrepareTime, RemainTime: zeroRemainTime, Status: retrievePerform} info := rt.RetrieveQuery{BackupAddress: perf.BackupAddress, DefaultAddress: perf.DefaultAddress, DelayPeriod: zeroDelay, PrepareTime: zeroPrepareTime, RemainTime: zeroRemainTime, Status: retrievePerform}
...@@ -116,9 +107,6 @@ func (c *Retrieve) ExecLocal_Perform(perf *rt.PerformRetrieve, tx *types.Transac ...@@ -116,9 +107,6 @@ func (c *Retrieve) ExecLocal_Perform(perf *rt.PerformRetrieve, tx *types.Transac
// ExecLocal_Cancel Action // ExecLocal_Cancel Action
func (c *Retrieve) ExecLocal_Cancel(cancel *rt.CancelRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (c *Retrieve) ExecLocal_Cancel(cancel *rt.CancelRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{} set := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
return set, nil
}
rlog.Debug("Retrieve ExecLocal_Cancel") rlog.Debug("Retrieve ExecLocal_Cancel")
info := rt.RetrieveQuery{BackupAddress: cancel.BackupAddress, DefaultAddress: cancel.DefaultAddress, DelayPeriod: zeroDelay, PrepareTime: zeroPrepareTime, RemainTime: zeroRemainTime, Status: retrieveCancel} info := rt.RetrieveQuery{BackupAddress: cancel.BackupAddress, DefaultAddress: cancel.DefaultAddress, DelayPeriod: zeroDelay, PrepareTime: zeroPrepareTime, RemainTime: zeroRemainTime, Status: retrieveCancel}
......
...@@ -82,3 +82,8 @@ func getRetrieveInfo(db dbm.KVDB, backupAddr string, defaultAddr string) (*rt.Re ...@@ -82,3 +82,8 @@ func getRetrieveInfo(db dbm.KVDB, backupAddr string, defaultAddr string) (*rt.Re
} }
return &info, nil return &info, nil
} }
// CheckReceiptExecOk return true to check if receipt ty is ok
func (r *Retrieve) CheckReceiptExecOk() bool {
return true
}
...@@ -344,7 +344,7 @@ func estRetrievePerform(t *testing.T) { ...@@ -344,7 +344,7 @@ func estRetrievePerform(t *testing.T) {
func estRetrieveCancel(t *testing.T) { func estRetrieveCancel(t *testing.T) {
fmt.Println("\nTestRetrieveCancel start") fmt.Println("\nTestRetrieveCancel start")
fmt.Println("*This case is used for checking cancel operation\n*Cancel action is done with privkey of account A/B, although the cancel action for A could succeed, but the balance have been transfered by last action with backup a\n*currBalanceA = currBalanceA - 2*fee currBalanceB = currBalanceB + 1e8 - 2*fee") fmt.Println("*This case is used for checking cancel operation\n*Cancel action is done with privkey of account A/B, although the cancel action for A could succeed, but the balance have been transferred by last action with backup a\n*currBalanceA = currBalanceA - 2*fee currBalanceB = currBalanceB + 1e8 - 2*fee")
defer fmt.Println("TestRetrieveCancel end") defer fmt.Println("TestRetrieveCancel end")
var hashes [][]byte var hashes [][]byte
......
...@@ -11,9 +11,6 @@ import ( ...@@ -11,9 +11,6 @@ import (
func (t *Ticket) execDelLocal(receiptData *types.ReceiptData) (*types.LocalDBSet, error) { func (t *Ticket) execDelLocal(receiptData *types.ReceiptData) (*types.LocalDBSet, error) {
dbSet := &types.LocalDBSet{} dbSet := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
return dbSet, nil
}
for _, item := range receiptData.Logs { for _, item := range receiptData.Logs {
//这三个是ticket 的log //这三个是ticket 的log
if item.Ty == ty.TyLogNewTicket || item.Ty == ty.TyLogMinerTicket || item.Ty == ty.TyLogCloseTicket { if item.Ty == ty.TyLogNewTicket || item.Ty == ty.TyLogMinerTicket || item.Ty == ty.TyLogCloseTicket {
......
...@@ -11,9 +11,6 @@ import ( ...@@ -11,9 +11,6 @@ import (
func (t *Ticket) execLocal(receiptData *types.ReceiptData) (*types.LocalDBSet, error) { func (t *Ticket) execLocal(receiptData *types.ReceiptData) (*types.LocalDBSet, error) {
dbSet := &types.LocalDBSet{} dbSet := &types.LocalDBSet{}
if receiptData.GetTy() != types.ExecOk {
return dbSet, nil
}
for _, item := range receiptData.Logs { for _, item := range receiptData.Logs {
//这三个是ticket 的log //这三个是ticket 的log
if item.Ty == ty.TyLogNewTicket || item.Ty == ty.TyLogMinerTicket || item.Ty == ty.TyLogCloseTicket { if item.Ty == ty.TyLogNewTicket || item.Ty == ty.TyLogMinerTicket || item.Ty == ty.TyLogCloseTicket {
......
...@@ -186,3 +186,8 @@ func (t *Ticket) CheckTx(tx *types.Transaction, index int) error { ...@@ -186,3 +186,8 @@ func (t *Ticket) CheckTx(tx *types.Transaction, index int) error {
} }
return nil return nil
} }
// CheckReceiptExecOk return true to check if receipt ty is ok
func (t *Ticket) CheckReceiptExecOk() bool {
return true
}
...@@ -59,7 +59,7 @@ func init() { ...@@ -59,7 +59,7 @@ func init() {
types.AllowUserExec = append(types.AllowUserExec, []byte(TicketX)) types.AllowUserExec = append(types.AllowUserExec, []byte(TicketX))
types.RegistorExecutor(TicketX, NewType()) types.RegistorExecutor(TicketX, NewType())
types.RegisterDappFork(TicketX, "Enable", 0) types.RegisterDappFork(TicketX, "Enable", 0)
types.RegisterDappFork(TicketX, "ForkTicketId", 1200000) types.RegisterDappFork(TicketX, "ForkTicketId", 1062000)
} }
// TicketType ticket exec type // TicketType ticket exec type
......
...@@ -338,3 +338,8 @@ func (t *token) getTxByToken(req *tokenty.ReqTokenTx) (types.Message, error) { ...@@ -338,3 +338,8 @@ func (t *token) getTxByToken(req *tokenty.ReqTokenTx) (types.Message, error) {
} }
return &replyTxInfos, nil return &replyTxInfos, nil
} }
// CheckReceiptExecOk return true to check if receipt ty is ok
func (t *token) CheckReceiptExecOk() bool {
return true
}
...@@ -202,3 +202,8 @@ func saveBuyMarketOrderKeyValue(kv []*types.KeyValue, receipt *pty.ReceiptBuyBas ...@@ -202,3 +202,8 @@ func saveBuyMarketOrderKeyValue(kv []*types.KeyValue, receipt *pty.ReceiptBuyBas
func deleteBuyMarketOrderKeyValue(kv []*types.KeyValue, receipt *pty.ReceiptBuyBase, status int32, height int64) []*types.KeyValue { func deleteBuyMarketOrderKeyValue(kv []*types.KeyValue, receipt *pty.ReceiptBuyBase, status int32, height int64) []*types.KeyValue {
return genBuyMarketOrderKeyValue(kv, receipt, status, height, nil) return genBuyMarketOrderKeyValue(kv, receipt, status, height, nil)
} }
// CheckReceiptExecOk return true to check if receipt ty is ok
func (t *trade) CheckReceiptExecOk() bool {
return true
}
...@@ -12,9 +12,6 @@ import ( ...@@ -12,9 +12,6 @@ import (
// ExecDelLocal_Node method // ExecDelLocal_Node method
func (val *ValNode) ExecDelLocal_Node(node *pty.ValNode, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (val *ValNode) ExecDelLocal_Node(node *pty.ValNode, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{} set := &types.LocalDBSet{}
if receipt.GetTy() != types.ExecOk {
return set, nil
}
key := CalcValNodeUpdateHeightIndexKey(val.GetHeight(), index) key := CalcValNodeUpdateHeightIndexKey(val.GetHeight(), index)
set.KV = append(set.KV, &types.KeyValue{Key: key, Value: nil}) set.KV = append(set.KV, &types.KeyValue{Key: key, Value: nil})
return set, nil return set, nil
...@@ -23,9 +20,6 @@ func (val *ValNode) ExecDelLocal_Node(node *pty.ValNode, tx *types.Transaction, ...@@ -23,9 +20,6 @@ func (val *ValNode) ExecDelLocal_Node(node *pty.ValNode, tx *types.Transaction,
// ExecDelLocal_BlockInfo method // ExecDelLocal_BlockInfo method
func (val *ValNode) ExecDelLocal_BlockInfo(blockInfo *pty.TendermintBlockInfo, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (val *ValNode) ExecDelLocal_BlockInfo(blockInfo *pty.TendermintBlockInfo, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{} set := &types.LocalDBSet{}
if receipt.GetTy() != types.ExecOk {
return set, nil
}
key := CalcValNodeBlockInfoHeightKey(val.GetHeight()) key := CalcValNodeBlockInfoHeightKey(val.GetHeight())
set.KV = append(set.KV, &types.KeyValue{Key: key, Value: nil}) set.KV = append(set.KV, &types.KeyValue{Key: key, Value: nil})
return set, nil return set, nil
......
...@@ -14,9 +14,6 @@ import ( ...@@ -14,9 +14,6 @@ import (
// ExecLocal_Node method // ExecLocal_Node method
func (val *ValNode) ExecLocal_Node(node *pty.ValNode, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (val *ValNode) ExecLocal_Node(node *pty.ValNode, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{} set := &types.LocalDBSet{}
if receipt.GetTy() != types.ExecOk {
return set, nil
}
if len(node.GetPubKey()) == 0 { if len(node.GetPubKey()) == 0 {
return nil, errors.New("validator pubkey is empty") return nil, errors.New("validator pubkey is empty")
} }
...@@ -32,9 +29,6 @@ func (val *ValNode) ExecLocal_Node(node *pty.ValNode, tx *types.Transaction, rec ...@@ -32,9 +29,6 @@ func (val *ValNode) ExecLocal_Node(node *pty.ValNode, tx *types.Transaction, rec
// ExecLocal_BlockInfo method // ExecLocal_BlockInfo method
func (val *ValNode) ExecLocal_BlockInfo(blockInfo *pty.TendermintBlockInfo, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (val *ValNode) ExecLocal_BlockInfo(blockInfo *pty.TendermintBlockInfo, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{} set := &types.LocalDBSet{}
if receipt.GetTy() != types.ExecOk {
return set, nil
}
key := CalcValNodeBlockInfoHeightKey(val.GetHeight()) key := CalcValNodeBlockInfoHeightKey(val.GetHeight())
set.KV = append(set.KV, &types.KeyValue{Key: key, Value: types.Encode(blockInfo)}) set.KV = append(set.KV, &types.KeyValue{Key: key, Value: types.Encode(blockInfo)})
return set, nil return set, nil
......
...@@ -68,3 +68,8 @@ func CalcValNodeUpdateHeightKey(height int64) []byte { ...@@ -68,3 +68,8 @@ func CalcValNodeUpdateHeightKey(height int64) []byte {
func CalcValNodeBlockInfoHeightKey(height int64) []byte { func CalcValNodeBlockInfoHeightKey(height int64) []byte {
return []byte(fmt.Sprintf("LODB-valnode-BlockInfo:%18d:", height)) return []byte(fmt.Sprintf("LODB-valnode-BlockInfo:%18d:", height))
} }
// CheckReceiptExecOk return true to check if receipt ty is ok
func (val *ValNode) CheckReceiptExecOk() bool {
return true
}
...@@ -26,5 +26,4 @@ func version(cmd *cobra.Command, args []string) { ...@@ -26,5 +26,4 @@ func version(cmd *cobra.Command, args []string) {
var res types.NodeVersion var res types.NodeVersion
ctx := jsonclient.NewRPCCtx(rpcLaddr, "Chain33.Version", nil, &res) ctx := jsonclient.NewRPCCtx(rpcLaddr, "Chain33.Version", nil, &res)
ctx.Run() ctx.Run()
} }
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