diff --git a/golinter.sh b/golinter.sh index 67901258dc3401ed3ce5e4dd9c8bce4855913020..57bf3412a40e08d63f8e9ce1b5e9645ffc36bffb 100755 --- a/golinter.sh +++ b/golinter.sh @@ -15,6 +15,7 @@ function filterLinter() { --enable=varcheck \ --enable=structcheck \ --enable=goimports \ + --enable=misspell \ --vendor ./...) # --enable=staticcheck \ # --enable=gocyclo \ diff --git a/plugin/consensus/pbft/pbft_test.go b/plugin/consensus/pbft/pbft_test.go index a98a3e15b27d35c23d9ec807135a3d3a52b6e634..01273243ff2fb5de62d0782a03979892954bd179 100644 --- a/plugin/consensus/pbft/pbft_test.go +++ b/plugin/consensus/pbft/pbft_test.go @@ -148,5 +148,5 @@ func clearTestData() { if err != nil { fmt.Println("delete wallet have a err:", err.Error()) } - fmt.Println("test data clear sucessfully!") + fmt.Println("test data clear successfully!") } diff --git a/plugin/consensus/raft/raft_test.go b/plugin/consensus/raft/raft_test.go index 7f153f5ba584164c639115ce1e84c6bceefaeb78..8172e9100eb16671d970126388b4c598609fc244 100644 --- a/plugin/consensus/raft/raft_test.go +++ b/plugin/consensus/raft/raft_test.go @@ -175,5 +175,5 @@ func clearTestData() { if err != nil { fmt.Println("delete chain33_raft dir have a err:", err.Error()) } - fmt.Println("test data clear sucessfully!") + fmt.Println("test data clear successfully!") } diff --git a/plugin/consensus/raft/tools/scripts/go-scp/scp.go b/plugin/consensus/raft/tools/scripts/go-scp/scp.go index 9773abbe98b8a8d83f676d0eb7f1829142cf2f42..a07c368c73a29cade8d71d8cb4e7beded29366f2 100644 --- a/plugin/consensus/raft/tools/scripts/go-scp/scp.go +++ b/plugin/consensus/raft/tools/scripts/go-scp/scp.go @@ -181,7 +181,7 @@ func remoteScp(si *ScpInfo, reqnum chan struct{}) { }() ScpFileFromLocalToRemote(si) //session, err := sshconnect("ubuntu", "Fuzamei#123456", "raft15258.chinacloudapp.cn", 22) - fmt.Println("remoteScp file sucessfully!:") + fmt.Println("remoteScp file successfully!:") } diff --git a/plugin/consensus/tendermint/node.go b/plugin/consensus/tendermint/node.go index cb000e5ab5abc39d02632f260d2f2a25b9a24e73..59b8764cceb019fadd39e58a27f862e167f9c0f1 100644 --- a/plugin/consensus/tendermint/node.go +++ b/plugin/consensus/tendermint/node.go @@ -396,7 +396,7 @@ func (node *Node) stopAndRemovePeer(peer Peer, reason interface{}) { peer.Stop() } -// StopPeerForError called if error occured +// StopPeerForError called if error occurred func (node *Node) StopPeerForError(peer Peer, reason interface{}) { tendermintlog.Error("Stopping peer for error", "peer", peer, "err", reason) addr, err := peer.RemoteAddr() diff --git a/plugin/consensus/tendermint/tendermint_test.go b/plugin/consensus/tendermint/tendermint_test.go index 359d4f2ef8d84b791728930382e1ff04ac5b73dd..431450eb8b1725a7f0ed54a3d510d4f43f802168 100644 --- a/plugin/consensus/tendermint/tendermint_test.go +++ b/plugin/consensus/tendermint/tendermint_test.go @@ -161,7 +161,7 @@ func clearTestData() { if err != nil { fmt.Println("delete datadir have a err:", err.Error()) } - fmt.Println("test data clear sucessfully!") + fmt.Println("test data clear successfully!") } func NormPut() { diff --git a/plugin/consensus/ticket/ticket_test.go b/plugin/consensus/ticket/ticket_test.go index 06918652fb8af938b1ca1a122948aa3ae3fc9068..0fa61310b3a2fc3cac0c82cab06fc0a6cc158ecc 100644 --- a/plugin/consensus/ticket/ticket_test.go +++ b/plugin/consensus/ticket/ticket_test.go @@ -51,7 +51,7 @@ func TestTicket(t *testing.T) { //js, _ := json.MarshalIndent(detail, "", " ") //fmt.Println(string(js)) 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) err = mock33.WaitHeight(100) assert.Nil(t, err) diff --git a/plugin/dapp/blackwhite/executor/action.go b/plugin/dapp/blackwhite/executor/action.go index 2eaad4e25c160663579bdb2c12873a198c70e469..3f01a4cc36ae765443620483f27dd0e02c907516 100644 --- a/plugin/dapp/blackwhite/executor/action.go +++ b/plugin/dapp/blackwhite/executor/action.go @@ -528,26 +528,26 @@ func (a *action) getWinner(round *gt.BlackwhiteRound) ([]*addrResult, *gt.ReplyL addrRes := round.AddrResult loop := int(round.Loop) - for _, addres := range addrRes { - if len(addres.ShowSecret) > 0 && len(addres.HashValues) == loop { + for _, address := range addrRes { + if len(address.ShowSecret) > 0 && len(address.HashValues) == loop { var isBlack []bool // 加入分叉高度判断:分叉高度在ForkV25BlackWhite到ForkV25BlackWhiteV2之间的执行原来逻辑,大于ForkV25BlackWhiteV2执行新逻辑, // 小于ForkV25BlackWhite则无法进入 if !types.IsDappFork(a.height, gt.BlackwhiteX, "ForkBlackWhiteV2") { - for _, hash := range addres.HashValues { - if bytes.Equal(common.Sha256([]byte(addres.ShowSecret+black)), hash) { + for _, hash := range address.HashValues { + if bytes.Equal(common.Sha256([]byte(address.ShowSecret+black)), hash) { 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) } else { isBlack = append(isBlack, false) } } } else { - for i, hash := range addres.HashValues { - if bytes.Equal(common.Sha256([]byte(strconv.Itoa(i)+addres.ShowSecret+black)), hash) { + for i, hash := range address.HashValues { + if bytes.Equal(common.Sha256([]byte(strconv.Itoa(i)+address.ShowSecret+black)), hash) { 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) } else { isBlack = append(isBlack, false) @@ -555,8 +555,8 @@ func (a *action) getWinner(round *gt.BlackwhiteRound) ([]*addrResult, *gt.ReplyL } } addresX := &resultCalc{ - Addr: addres.Addr, - amount: addres.Amount, + Addr: address.Addr, + amount: address.Amount, IsWin: true, IsBlack: isBlack, } diff --git a/plugin/dapp/blackwhite/executor/action_test.go b/plugin/dapp/blackwhite/executor/action_test.go index 880e39da0027fcb9574507aa448ef7ed917f8d71..14ed410a2862d28db0b31b71fa8c2e9730d3da39 100644 --- a/plugin/dapp/blackwhite/executor/action_test.go +++ b/plugin/dapp/blackwhite/executor/action_test.go @@ -217,7 +217,7 @@ func Test_getWinnerAndLoser(t *testing.T) { Loop: 4, } - addres := >.AddressResult{ + address := >.AddressResult{ Addr: "1", HashValues: [][]byte{common.Sha256([]byte(strconv.Itoa(0) + showSecret + black)), common.Sha256([]byte(strconv.Itoa(1) + showSecret + white)), @@ -225,9 +225,9 @@ func Test_getWinnerAndLoser(t *testing.T) { common.Sha256([]byte(strconv.Itoa(3) + showSecret + white))}, ShowSecret: showSecret, } - addrRes = append(addrRes, addres) + addrRes = append(addrRes, address) - addres = >.AddressResult{ + address = >.AddressResult{ Addr: "2", HashValues: [][]byte{common.Sha256([]byte(strconv.Itoa(0) + showSecret + black)), common.Sha256([]byte(strconv.Itoa(1) + showSecret + white)), @@ -235,9 +235,9 @@ func Test_getWinnerAndLoser(t *testing.T) { common.Sha256([]byte(strconv.Itoa(3) + showSecret + white))}, ShowSecret: showSecret, } - addrRes = append(addrRes, addres) + addrRes = append(addrRes, address) - addres = >.AddressResult{ + address = >.AddressResult{ Addr: "3", HashValues: [][]byte{common.Sha256([]byte(strconv.Itoa(0) + showSecret + black)), common.Sha256([]byte(strconv.Itoa(1) + showSecret + white)), @@ -245,7 +245,7 @@ func Test_getWinnerAndLoser(t *testing.T) { common.Sha256([]byte(strconv.Itoa(3) + showSecret + black))}, ShowSecret: showSecret, } - addrRes = append(addrRes, addres) + addrRes = append(addrRes, address) round.AddrResult = addrRes @@ -257,7 +257,7 @@ func Test_getWinnerAndLoser(t *testing.T) { //t.Logf("winers1 is %v", winers) //t.Logf("losers1 is %v", losers) - addres = >.AddressResult{ + address = >.AddressResult{ Addr: "4", HashValues: [][]byte{common.Sha256([]byte(strconv.Itoa(0) + showSecret + black)), common.Sha256([]byte(strconv.Itoa(1) + showSecret + white)), @@ -265,9 +265,9 @@ func Test_getWinnerAndLoser(t *testing.T) { common.Sha256([]byte(strconv.Itoa(3) + showSecret + black))}, ShowSecret: showSecret, } - addrRes = append(addrRes, addres) + addrRes = append(addrRes, address) - addres = >.AddressResult{ + address = >.AddressResult{ Addr: "5", HashValues: [][]byte{common.Sha256([]byte(strconv.Itoa(0) + showSecret + black)), common.Sha256([]byte(strconv.Itoa(1) + showSecret + white)), @@ -275,7 +275,7 @@ func Test_getWinnerAndLoser(t *testing.T) { common.Sha256([]byte(strconv.Itoa(3) + showSecret + white))}, ShowSecret: showSecret, } - addrRes = append(addrRes, addres) + addrRes = append(addrRes, address) round.AddrResult = addrRes @@ -286,7 +286,7 @@ func Test_getWinnerAndLoser(t *testing.T) { //t.Logf("winers2 is %v", winers) //t.Logf("losers2 is %v", losers) - addres = >.AddressResult{ + address = >.AddressResult{ Addr: "6", HashValues: [][]byte{common.Sha256([]byte(strconv.Itoa(0) + showSecret + black)), common.Sha256([]byte(strconv.Itoa(1) + showSecret + white)), @@ -298,7 +298,7 @@ func Test_getWinnerAndLoser(t *testing.T) { common.Sha256([]byte(strconv.Itoa(7) + showSecret + white))}, ShowSecret: showSecret, } - addrRes = append(addrRes, addres) + addrRes = append(addrRes, address) round.AddrResult = addrRes diff --git a/plugin/dapp/blackwhite/executor/blackwhite.go b/plugin/dapp/blackwhite/executor/blackwhite.go index e25aba6e94b2eae61a1689ca84db0ab8bb4718a0..d9bd354d0362eb36ae29c8e49df88c2f1c6c2e31 100644 --- a/plugin/dapp/blackwhite/executor/blackwhite.go +++ b/plugin/dapp/blackwhite/executor/blackwhite.go @@ -285,3 +285,8 @@ func heightIndexToIndex(height int64, index int32) int64 { func (c *Blackwhite) GetPayloadValue() types.Message { return >.BlackwhiteAction{} } + +// CheckReceiptExecOk return true to check if receipt ty is ok +func (c *Blackwhite) CheckReceiptExecOk() bool { + return true +} diff --git a/plugin/dapp/blackwhite/types/types.go b/plugin/dapp/blackwhite/types/types.go index 71e1a698c2da4375970e303285b7bef23e8b5a4e..633410a03874d09d6ac03769dd2311215cb173f4 100644 --- a/plugin/dapp/blackwhite/types/types.go +++ b/plugin/dapp/blackwhite/types/types.go @@ -67,7 +67,7 @@ func (b BlackwhiteType) ActionName(tx *types.Transaction) string { var g BlackwhiteAction err := types.Decode(tx.Payload, &g) if err != nil { - return "unkown-Blackwhite-action-err" + return "unknown-Blackwhite-action-err" } if g.Ty == BlackwhiteActionCreate && g.GetCreate() != nil { return "BlackwhiteCreate" @@ -78,7 +78,7 @@ func (b BlackwhiteType) ActionName(tx *types.Transaction) string { } else if g.Ty == BlackwhiteActionTimeoutDone && g.GetTimeoutDone() != nil { return "BlackwhiteTimeoutDone" } - return "unkown" + return "unknown" } // Amount ... diff --git a/plugin/dapp/cert/executor/cert.go b/plugin/dapp/cert/executor/cert.go index 9edaeab659866a0a935d21224a092b2fa9ae935f..cc04ce96e161fe9b24aa837dbddbe8de1c348007 100644 --- a/plugin/dapp/cert/executor/cert.go +++ b/plugin/dapp/cert/executor/cert.go @@ -139,3 +139,8 @@ func (c *Cert) loadHistoryByHeight() error { } return ct.ErrGetHistoryCertData } + +// CheckReceiptExecOk return true to check if receipt ty is ok +func (c *Cert) CheckReceiptExecOk() bool { + return true +} diff --git a/plugin/dapp/cert/executor/exec_local.go b/plugin/dapp/cert/executor/exec_local.go index 132b76d4e37520242af3a367b5176e700b19b766..28ff8fff3601727f98158f149532b4be7e94d1c9 100755 --- a/plugin/dapp/cert/executor/exec_local.go +++ b/plugin/dapp/cert/executor/exec_local.go @@ -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.") return nil, ct.ErrInitializeAuthority } - if receiptData.GetTy() != types.ExecOk { - return &types.LocalDBSet{}, nil - } var set types.LocalDBSet historityCertdata := &types.HistoryCertStore{} @@ -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.") return nil, ct.ErrInitializeAuthority } - if receiptData.GetTy() != types.ExecOk { - return &types.LocalDBSet{}, nil - } var set types.LocalDBSet // 写入上一纪录的next-height @@ -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.") return nil, ct.ErrInitializeAuthority } - if receiptData.GetTy() != types.ExecOk { - return &types.LocalDBSet{}, nil - } var set types.LocalDBSet return &set, nil diff --git a/plugin/dapp/evm/executor/evm.go b/plugin/dapp/evm/executor/evm.go index 629ab8fb7e6c4c1a0e59883270344241e193ae0a..53990c2f4f2f442f135f4b9bcae24e05472c70db 100644 --- a/plugin/dapp/evm/executor/evm.go +++ b/plugin/dapp/evm/executor/evm.go @@ -117,6 +117,11 @@ func (evm *EVMExecutor) IsFriend(myexec, writekey []byte, othertx *types.Transac 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 { return common.NewAddress(txHash) diff --git a/plugin/dapp/evm/executor/tests/evm_test.go b/plugin/dapp/evm/executor/tests/evm_test.go index cbe5cb83a53bbe0abd852b8c3fa3746e962f4c3d..c10f232bda7aa57781bf3b0b013c51cd9f3f57d3 100644 --- a/plugin/dapp/evm/executor/tests/evm_test.go +++ b/plugin/dapp/evm/executor/tests/evm_test.go @@ -106,7 +106,7 @@ func runDir(tt *testing.T, basePath 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 inst := evm.NewEVMExecutor() diff --git a/plugin/dapp/game/executor/exec_del_local.go b/plugin/dapp/game/executor/exec_del_local.go index baf6a28089d2bea3d2689731094f1e29db045d97..53c16c51f56617c0b88a25682ebcad5a7c6a31f3 100644 --- a/plugin/dapp/game/executor/exec_del_local.go +++ b/plugin/dapp/game/executor/exec_del_local.go @@ -12,9 +12,6 @@ import ( // roll back local db data func (g *Game) execDelLocal(receiptData *types.ReceiptData) (*types.LocalDBSet, error) { dbSet := &types.LocalDBSet{} - if receiptData.GetTy() != types.ExecOk { - return dbSet, nil - } for _, log := range receiptData.Logs { switch log.GetTy() { case gt.TyLogCreateGame, gt.TyLogMatchGame, gt.TyLogCloseGame, gt.TyLogCancleGame: diff --git a/plugin/dapp/game/executor/exec_local.go b/plugin/dapp/game/executor/exec_local.go index 858047210bc2b022eaa562506b6f712508e84900..8e89c56deb82592d7f2bcaf3b7a6053ea05b4aed 100644 --- a/plugin/dapp/game/executor/exec_local.go +++ b/plugin/dapp/game/executor/exec_local.go @@ -12,9 +12,6 @@ import ( // save receiptData to local db func (g *Game) execLocal(receiptData *types.ReceiptData) (*types.LocalDBSet, error) { dbSet := &types.LocalDBSet{} - if receiptData.GetTy() != types.ExecOk { - return dbSet, nil - } for _, log := range receiptData.Logs { switch log.Ty { case gt.TyLogCreateGame, gt.TyLogMatchGame, gt.TyLogCloseGame, gt.TyLogCancleGame: diff --git a/plugin/dapp/game/executor/game.go b/plugin/dapp/game/executor/game.go index 25ee7b81608a92b1d428577cee8e50b924dfc44a..f92b631098e49361c19ac12c84075f647fe3ebe4 100644 --- a/plugin/dapp/game/executor/game.go +++ b/plugin/dapp/game/executor/game.go @@ -174,3 +174,8 @@ func (g *Game) GetTypeMap() map[string]int32 { "Close": gt.GameActionClose, } } + +// CheckReceiptExecOk return true to check if receipt ty is ok +func (g *Game) CheckReceiptExecOk() bool { + return true +} diff --git a/plugin/dapp/hashlock/executor/exec_del_local.go b/plugin/dapp/hashlock/executor/exec_del_local.go index 7867117057f789450d75e574627b7c16e06b2b42..cb9895526d64cf94fe3a550e813acb095bc9d06d 100755 --- a/plugin/dapp/hashlock/executor/exec_del_local.go +++ b/plugin/dapp/hashlock/executor/exec_del_local.go @@ -12,9 +12,6 @@ import ( // ExecDelLocal_Hlock Action 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} kv, err := UpdateHashReciver(h.GetLocalDB(), hlock.Hash, info) if err != nil { @@ -25,9 +22,6 @@ func (h *Hashlock) ExecDelLocal_Hlock(hlock *pty.HashlockLock, tx *types.Transac // ExecDelLocal_Hsend Action 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} kv, err := UpdateHashReciver(h.GetLocalDB(), common.Sha256(hsend.Secret), info) if err != nil { @@ -38,9 +32,6 @@ func (h *Hashlock) ExecDelLocal_Hsend(hsend *pty.HashlockSend, tx *types.Transac // ExecDelLocal_Hunlock Action 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} kv, err := UpdateHashReciver(h.GetLocalDB(), common.Sha256(hunlock.Secret), info) if err != nil { diff --git a/plugin/dapp/hashlock/executor/exec_local.go b/plugin/dapp/hashlock/executor/exec_local.go index e71643cf4d3d10911c1fcb84ffc6f98bf4c1139a..bbef8470636261dcd0712102381bd50417ae0a3a 100755 --- a/plugin/dapp/hashlock/executor/exec_local.go +++ b/plugin/dapp/hashlock/executor/exec_local.go @@ -12,9 +12,6 @@ import ( // ExecLocal_Hlock Action 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} clog.Error("ExecLocal", "info", info) kv, err := UpdateHashReciver(h.GetLocalDB(), hlock.Hash, info) @@ -26,9 +23,6 @@ func (h *Hashlock) ExecLocal_Hlock(hlock *pty.HashlockLock, tx *types.Transactio // ExecLocal_Hsend Action 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} clog.Error("ExecLocal", "info", 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 // ExecLocal_Hunlock Action 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} clog.Error("ExecLocal", "info", info) kv, err := UpdateHashReciver(h.GetLocalDB(), common.Sha256(hunlock.Secret), info) diff --git a/plugin/dapp/hashlock/executor/hashlock.go b/plugin/dapp/hashlock/executor/hashlock.go index 10e22e221a4d0a32b2724e5e41ec01062bc063f0..fc59d077805268968fa40bb29a0f1fd1d966c18c 100755 --- a/plugin/dapp/hashlock/executor/hashlock.go +++ b/plugin/dapp/hashlock/executor/hashlock.go @@ -52,3 +52,8 @@ func (h *Hashlock) GetDriverName() string { func (h *Hashlock) CheckTx(tx *types.Transaction, index int) error { return nil } + +// CheckReceiptExecOk return true to check if receipt ty is ok +func (h *Hashlock) CheckReceiptExecOk() bool { + return true +} diff --git a/plugin/dapp/hashlock/executor/hashlock_test.go b/plugin/dapp/hashlock/executor/hashlock_test.go index 26a84e47f9c6edb9d7bddddaf3fd64d2776be68a..4014ec581241b4fccb1d5e67f3b6b82bdf097e14 100755 --- a/plugin/dapp/hashlock/executor/hashlock_test.go +++ b/plugin/dapp/hashlock/executor/hashlock_test.go @@ -188,7 +188,7 @@ func estHashlock(t *testing.T) { func estHashunlock(t *testing.T) { fmt.Println("TestHashunlock start") defer fmt.Println("TestHashunlock end") - //not sucess as time not enough + //not success as time not enough time.Sleep(5 * time.Second) err := unlock(secret) if err != nil { diff --git a/plugin/dapp/hashlock/proto/hashlock.proto b/plugin/dapp/hashlock/proto/hashlock.proto index bd8f45e6f1ec4ff0806529cc26c85a1be70352c2..a59540f6ad1b5272f55e34535fd3b5a20ad3207f 100644 --- a/plugin/dapp/hashlock/proto/hashlock.proto +++ b/plugin/dapp/hashlock/proto/hashlock.proto @@ -33,8 +33,8 @@ message Hashlockquery { } message HashRecv { - bytes HashlockId = 1; - Hashlockquery Infomation = 2; + bytes HashlockId = 1; + Hashlockquery Information = 2; } message HashlockUnlock { diff --git a/plugin/dapp/hashlock/types/hashlock.pb.go b/plugin/dapp/hashlock/types/hashlock.pb.go index 966816a7db48df46e2c078aed330c78d5ed3fe16..b66c254e4f99e31b4b7fe94450f5d0fecbb0c7f0 100644 --- a/plugin/dapp/hashlock/types/hashlock.pb.go +++ b/plugin/dapp/hashlock/types/hashlock.pb.go @@ -291,7 +291,7 @@ func (m *Hashlockquery) GetCurrentTime() int64 { type HashRecv struct { 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_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -329,9 +329,9 @@ func (m *HashRecv) GetHashlockId() []byte { return nil } -func (m *HashRecv) GetInfomation() *Hashlockquery { +func (m *HashRecv) GetInformation() *Hashlockquery { if m != nil { - return m.Infomation + return m.Information } return nil } @@ -576,32 +576,32 @@ func init() { func init() { proto.RegisterFile("hashlock.proto", fileDescriptor_acb83e90536b5ff8) } var fileDescriptor_acb83e90536b5ff8 = []byte{ - // 420 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0xcd, 0x6e, 0x9b, 0x40, - 0x10, 0xc7, 0xbd, 0xd8, 0xd8, 0xf5, 0x60, 0xfb, 0xb0, 0xfd, 0x10, 0x87, 0xaa, 0x42, 0xa8, 0xaa, - 0x90, 0x2a, 0x59, 0xaa, 0xdb, 0x17, 0x70, 0x7b, 0xc1, 0x52, 0x4f, 0x9b, 0xe4, 0x1e, 0x02, 0x6b, - 0xd9, 0x8a, 0xbd, 0xeb, 0x2c, 0x8b, 0x25, 0xf2, 0x18, 0x91, 0xf2, 0x2a, 0x79, 0x9c, 0x3c, 0x4b, - 0xb4, 0x03, 0x64, 0x31, 0x49, 0x6e, 0xb9, 0x31, 0x7f, 0x7e, 0xcc, 0xc7, 0x7f, 0x06, 0x98, 0x6d, - 0x92, 0x7c, 0xb3, 0x93, 0xe9, 0xf5, 0xfc, 0xa0, 0xa4, 0x96, 0xd4, 0xd5, 0xe5, 0x81, 0xe7, 0xe1, - 0x23, 0x81, 0x0f, 0x71, 0xfd, 0x86, 0x7e, 0x03, 0x68, 0xa8, 0x55, 0xe6, 0x93, 0x80, 0x44, 0x13, - 0xd6, 0x52, 0xe8, 0x17, 0x18, 0xe6, 0x3a, 0xd1, 0x45, 0xee, 0x3b, 0x01, 0x89, 0x5c, 0x56, 0x47, - 0xe6, 0xbb, 0x7f, 0x8a, 0x27, 0x9a, 0x9f, 0x6f, 0xf7, 0xdc, 0xef, 0x07, 0x24, 0xea, 0xb3, 0x96, - 0x42, 0xbf, 0xc2, 0x58, 0xcb, 0x65, 0x96, 0x29, 0x9e, 0xe7, 0xfe, 0x20, 0x20, 0xd1, 0x98, 0x59, - 0x81, 0x7e, 0x87, 0xa9, 0xe2, 0xba, 0x50, 0xa2, 0x21, 0x5c, 0x24, 0x4e, 0x45, 0x53, 0x3b, 0xd9, - 0xcb, 0x42, 0x68, 0x7f, 0x88, 0xf9, 0xeb, 0xc8, 0xd4, 0x5e, 0x2b, 0x79, 0xcb, 0x85, 0x36, 0xb5, - 0x47, 0x55, 0x6d, 0xab, 0x84, 0x77, 0x04, 0x26, 0xcd, 0x80, 0xff, 0xcd, 0x90, 0x36, 0x11, 0x39, - 0x49, 0x44, 0x61, 0x80, 0x29, 0x1c, 0x54, 0xf1, 0xd9, 0x68, 0x66, 0x7c, 0x1c, 0x69, 0xc2, 0xf0, - 0xf9, 0x3d, 0x86, 0x09, 0x7f, 0xd8, 0x9e, 0xce, 0xb8, 0xa8, 0x8c, 0xe5, 0xa9, 0xe2, 0xba, 0x36, - 0xbd, 0x8e, 0xc2, 0x7b, 0x02, 0xd3, 0x06, 0xbc, 0x29, 0xb8, 0x2a, 0x9f, 0xbb, 0x24, 0xad, 0x2e, - 0xdf, 0x5a, 0x8b, 0x9d, 0xb4, 0xdf, 0xb5, 0x2c, 0xb5, 0xeb, 0x1a, 0x54, 0x96, 0x59, 0x85, 0x06, - 0xe0, 0xa5, 0x85, 0x52, 0x5c, 0x68, 0x04, 0x5c, 0x04, 0xda, 0x52, 0x78, 0x59, 0x1d, 0x0d, 0xe3, - 0xe9, 0xd1, 0x64, 0x8b, 0x5f, 0x1c, 0x8d, 0x55, 0xe8, 0x1f, 0x80, 0x95, 0x58, 0xcb, 0x7d, 0xa2, - 0xb7, 0x52, 0x60, 0x87, 0xde, 0xe2, 0xd3, 0x1c, 0xaf, 0x6f, 0x7e, 0x32, 0x1b, 0x6b, 0x71, 0x61, - 0x04, 0xb3, 0xe6, 0xe5, 0x85, 0xd8, 0xd5, 0x7b, 0x7b, 0xd5, 0xa3, 0x07, 0x62, 0xd1, 0x65, 0x6a, - 0x3e, 0xa6, 0x3f, 0xc1, 0xc5, 0x10, 0x49, 0x6f, 0xf1, 0xb1, 0x53, 0xcd, 0x9c, 0x41, 0xdc, 0x63, - 0x15, 0x83, 0x70, 0xce, 0x45, 0x56, 0xb7, 0xd6, 0x85, 0xcd, 0x7e, 0x10, 0x36, 0x0c, 0xfd, 0x05, - 0xa3, 0x4d, 0x81, 0xfd, 0xa0, 0xa7, 0xde, 0xe2, 0x73, 0x07, 0xaf, 0x9a, 0x8d, 0x7b, 0xac, 0xe1, - 0xe8, 0x0c, 0x1c, 0x5d, 0xa2, 0xcb, 0x2e, 0x73, 0x74, 0xf9, 0x77, 0x04, 0xee, 0x31, 0xd9, 0x15, - 0xfc, 0x6a, 0x88, 0x3f, 0xe2, 0xef, 0xa7, 0x00, 0x00, 0x00, 0xff, 0xff, 0x56, 0x5e, 0xa0, 0xf4, - 0x9a, 0x03, 0x00, 0x00, + // 421 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0xcd, 0x6a, 0xdb, 0x40, + 0x10, 0xc7, 0xbd, 0xb2, 0x65, 0xd7, 0x23, 0xdb, 0x87, 0xed, 0x07, 0x3a, 0x94, 0x22, 0x44, 0x29, + 0x82, 0x82, 0xa1, 0x2e, 0xf4, 0xee, 0xf6, 0x22, 0x43, 0x4f, 0x9b, 0xe4, 0x01, 0x64, 0x69, 0x8d, + 0x4d, 0xec, 0x5d, 0x67, 0xb5, 0x32, 0x28, 0x8f, 0x11, 0xc8, 0xab, 0xe4, 0x71, 0xf2, 0x2c, 0x61, + 0x47, 0x52, 0x56, 0x56, 0x92, 0x5b, 0x6e, 0x9a, 0xbf, 0x7e, 0x9a, 0x8f, 0xff, 0x8c, 0x60, 0xb6, + 0x4d, 0xf2, 0xed, 0x5e, 0xa6, 0xd7, 0xf3, 0xa3, 0x92, 0x5a, 0x52, 0x57, 0x97, 0x47, 0x9e, 0x87, + 0x8f, 0x04, 0x3e, 0xc4, 0xf5, 0x1b, 0xfa, 0x0d, 0xa0, 0xa1, 0x56, 0x99, 0x4f, 0x02, 0x12, 0x4d, + 0x58, 0x4b, 0xa1, 0x5f, 0x60, 0x98, 0xeb, 0x44, 0x17, 0xb9, 0xef, 0x04, 0x24, 0x72, 0x59, 0x1d, + 0x99, 0xef, 0xfe, 0x29, 0x9e, 0x68, 0x7e, 0xb9, 0x3b, 0x70, 0xbf, 0x1f, 0x90, 0xa8, 0xcf, 0x5a, + 0x0a, 0xfd, 0x0a, 0x63, 0x2d, 0x97, 0x59, 0xa6, 0x78, 0x9e, 0xfb, 0x83, 0x80, 0x44, 0x63, 0x66, + 0x05, 0xfa, 0x1d, 0xa6, 0x8a, 0xeb, 0x42, 0x89, 0x86, 0x70, 0x91, 0x38, 0x17, 0x4d, 0xed, 0xe4, + 0x20, 0x0b, 0xa1, 0xfd, 0x21, 0xe6, 0xaf, 0x23, 0x53, 0x7b, 0xa3, 0xe4, 0x2d, 0x17, 0xda, 0xd4, + 0x1e, 0x55, 0xb5, 0xad, 0x12, 0xde, 0x11, 0x98, 0x34, 0x03, 0xfe, 0x37, 0x43, 0xda, 0x44, 0xe4, + 0x2c, 0x11, 0x85, 0x01, 0xa6, 0x70, 0x50, 0xc5, 0x67, 0xa3, 0x99, 0xf1, 0x71, 0xa4, 0x09, 0xc3, + 0xe7, 0xf7, 0x18, 0x26, 0xfc, 0x61, 0x7b, 0xba, 0xe0, 0xa2, 0x32, 0x96, 0xa7, 0x8a, 0xeb, 0xda, + 0xf4, 0x3a, 0x0a, 0xef, 0x09, 0x4c, 0x1b, 0xf0, 0xa6, 0xe0, 0xaa, 0x7c, 0xee, 0x92, 0xb4, 0xba, + 0x7c, 0x6b, 0x2d, 0x76, 0xd2, 0x7e, 0xd7, 0xb2, 0xd4, 0xae, 0x6b, 0x50, 0x59, 0x66, 0x15, 0x1a, + 0x80, 0x97, 0x16, 0x4a, 0x71, 0xa1, 0x11, 0x70, 0x11, 0x68, 0x4b, 0xe1, 0xba, 0x3a, 0x1a, 0xc6, + 0xd3, 0x93, 0xc9, 0x16, 0xbf, 0x38, 0x1a, 0xab, 0xd0, 0x3f, 0xe0, 0xad, 0xc4, 0x46, 0xaa, 0x43, + 0xa2, 0x77, 0x52, 0x60, 0x8b, 0xde, 0xe2, 0xd3, 0x1c, 0xcf, 0x6f, 0x7e, 0x36, 0x1c, 0x6b, 0x83, + 0x61, 0x04, 0xb3, 0xe6, 0xed, 0x95, 0xd8, 0xd7, 0x9b, 0x7b, 0xd5, 0xa5, 0x07, 0x62, 0xd1, 0x65, + 0x6a, 0x3e, 0xa6, 0x3f, 0xc1, 0xc5, 0x10, 0x49, 0x6f, 0xf1, 0xb1, 0x53, 0xce, 0x1c, 0x42, 0xdc, + 0x63, 0x15, 0x83, 0x70, 0xce, 0x45, 0x56, 0xf7, 0xd6, 0x85, 0xcd, 0x86, 0x10, 0x36, 0x0c, 0xfd, + 0x05, 0xa3, 0x6d, 0x81, 0xfd, 0xa0, 0xab, 0xde, 0xe2, 0x73, 0x07, 0xaf, 0x9a, 0x8d, 0x7b, 0xac, + 0xe1, 0xe8, 0x0c, 0x1c, 0x5d, 0xa2, 0xcf, 0x2e, 0x73, 0x74, 0xf9, 0x77, 0x04, 0xee, 0x29, 0xd9, + 0x17, 0x7c, 0x3d, 0xc4, 0x5f, 0xf1, 0xf7, 0x53, 0x00, 0x00, 0x00, 0xff, 0xff, 0x38, 0xf6, 0x91, + 0xc1, 0x9c, 0x03, 0x00, 0x00, } diff --git a/plugin/dapp/lottery/executor/exec_del_local.go b/plugin/dapp/lottery/executor/exec_del_local.go index a09bd2bd0d65c151e8b95379493bd2df35586e97..e953febaac45fa8df6fd431b79fc940046637e0f 100755 --- a/plugin/dapp/lottery/executor/exec_del_local.go +++ b/plugin/dapp/lottery/executor/exec_del_local.go @@ -12,9 +12,6 @@ import ( func (l *Lottery) execDelLocal(tx *types.Transaction, receiptData *types.ReceiptData) (*types.LocalDBSet, error) { set := &types.LocalDBSet{} - if receiptData.GetTy() != types.ExecOk { - return set, nil - } for _, item := range receiptData.Logs { switch item.Ty { case pty.TyLogLotteryCreate, pty.TyLogLotteryBuy, pty.TyLogLotteryDraw, pty.TyLogLotteryClose: diff --git a/plugin/dapp/lottery/executor/exec_local.go b/plugin/dapp/lottery/executor/exec_local.go index 9835e532923c131f9d3c79b3b9f336a40f6a0862..7e684f92626cfe967097b41b7a3aa23134929146 100755 --- a/plugin/dapp/lottery/executor/exec_local.go +++ b/plugin/dapp/lottery/executor/exec_local.go @@ -12,9 +12,6 @@ import ( func (l *Lottery) execLocal(tx *types.Transaction, receipt *types.ReceiptData) (*types.LocalDBSet, error) { set := &types.LocalDBSet{} - if receipt.GetTy() != types.ExecOk { - return set, nil - } for _, item := range receipt.Logs { switch item.Ty { case pty.TyLogLotteryCreate, pty.TyLogLotteryBuy, pty.TyLogLotteryDraw, pty.TyLogLotteryClose: diff --git a/plugin/dapp/lottery/executor/lottery.go b/plugin/dapp/lottery/executor/lottery.go index a9968d1bf07cc5cc5befec6e852611b718f8b972..9db0c3ea419c9c371a379e5d5682f964ba27d483 100755 --- a/plugin/dapp/lottery/executor/lottery.go +++ b/plugin/dapp/lottery/executor/lottery.go @@ -229,3 +229,8 @@ func dellottery(lotteryID string, status int32) *types.KeyValue { func (lott *Lottery) GetPayloadValue() types.Message { return &pty.LotteryAction{} } + +// CheckReceiptExecOk return true to check if receipt ty is ok +func (lott *Lottery) CheckReceiptExecOk() bool { + return true +} diff --git a/plugin/dapp/lottery/executor/lotterydb.go b/plugin/dapp/lottery/executor/lotterydb.go index 3d64521810f7ddaf55d04101840bdcb0564ad998..4dfce5fd0bcfa938ad66d49952200ffba09abb9c 100755 --- a/plugin/dapp/lottery/executor/lotterydb.go +++ b/plugin/dapp/lottery/executor/lotterydb.go @@ -548,11 +548,11 @@ func (action *Action) GetCalculableHash(beg, end int64, randMolNum int64) ([]byt return modify, nil } -//random used for verfication in solo +//random used for verification in solo func (action *Action) findLuckyNum(isSolo bool, lott *LotteryDB) int64 { var num int64 if isSolo { - //used for internal verfication + //used for internal verification num = 12345 } else { randMolNum := (lott.TotalPurchasedTxNum+action.height-lott.LastTransToPurState)%3 + 2 //3~5 diff --git a/plugin/dapp/norm/executor/norm.go b/plugin/dapp/norm/executor/norm.go index a5a92aebe02d8aa6c816f87a8dfb596c635431c2..ee286b3f9baa708cf1368a9b079da4c1bc5560d2 100644 --- a/plugin/dapp/norm/executor/norm.go +++ b/plugin/dapp/norm/executor/norm.go @@ -58,3 +58,8 @@ func Key(str []byte) (key []byte) { key = append(key, str...) return key } + +// CheckReceiptExecOk return true to check if receipt ty is ok +func (n *Norm) CheckReceiptExecOk() bool { + return true +} diff --git a/plugin/dapp/paracross/executor/paracross.go b/plugin/dapp/paracross/executor/paracross.go index 483b12d1b409a11c4908478902cf5f2c191cfb91..ac93d612ce3e9894bc410990de737e6d5a24bdd4 100644 --- a/plugin/dapp/paracross/executor/paracross.go +++ b/plugin/dapp/paracross/executor/paracross.go @@ -354,3 +354,8 @@ func (c *Paracross) allowIsParaAssetTx(execer []byte) bool { } return false } + +// CheckReceiptExecOk return true to check if receipt ty is ok +func (c *Paracross) CheckReceiptExecOk() bool { + return true +} diff --git a/plugin/dapp/pokerbull/executor/exec_del_local.go b/plugin/dapp/pokerbull/executor/exec_del_local.go index 55f0d8b1e26e57bc6b50b002c2ec55aebd89099f..73fdd827e7e4c3b4bc6e72a89ffafa31b038faae 100644 --- a/plugin/dapp/pokerbull/executor/exec_del_local.go +++ b/plugin/dapp/pokerbull/executor/exec_del_local.go @@ -25,9 +25,6 @@ func (g *PokerBull) rollbackIndex(log *pkt.ReceiptPBGame) (kvs []*types.KeyValue func (g *PokerBull) execDelLocal(receiptData *types.ReceiptData) (*types.LocalDBSet, error) { dbSet := &types.LocalDBSet{} - if receiptData.GetTy() != types.ExecOk { - return dbSet, nil - } for _, log := range receiptData.Logs { switch log.GetTy() { case pkt.TyLogPBGameStart, pkt.TyLogPBGameContinue, pkt.TyLogPBGameQuit: diff --git a/plugin/dapp/pokerbull/executor/exec_local.go b/plugin/dapp/pokerbull/executor/exec_local.go index 07ac775c886a59192efc97e0b9a20ffcdce61df6..24aa6c471e597db6d85dafe84d3b625037f4213d 100644 --- a/plugin/dapp/pokerbull/executor/exec_local.go +++ b/plugin/dapp/pokerbull/executor/exec_local.go @@ -55,9 +55,6 @@ func (c *PokerBull) updateIndex(log *pkt.ReceiptPBGame) (kvs []*types.KeyValue) func (c *PokerBull) execLocal(receipt *types.ReceiptData) (*types.LocalDBSet, error) { dbSet := &types.LocalDBSet{} - if receipt.GetTy() != types.ExecOk { - return dbSet, nil - } for i := 0; i < len(receipt.Logs); i++ { item := receipt.Logs[i] if item.Ty == pkt.TyLogPBGameStart || item.Ty == pkt.TyLogPBGameContinue || item.Ty == pkt.TyLogPBGameQuit { diff --git a/plugin/dapp/pokerbull/executor/pokerbull.go b/plugin/dapp/pokerbull/executor/pokerbull.go index 3617c3e6e5150289fcf59a682c0005a9aaafb3e6..b099b6932d9a76fbe504064333845df7c1811a4f 100644 --- a/plugin/dapp/pokerbull/executor/pokerbull.go +++ b/plugin/dapp/pokerbull/executor/pokerbull.go @@ -139,3 +139,8 @@ func delPBGameStatusAndPlayer(status int32, player int32, value, index int64) *t kv.Value = nil return kv } + +// CheckReceiptExecOk return true to check if receipt ty is ok +func (g *PokerBull) CheckReceiptExecOk() bool { + return true +} diff --git a/plugin/dapp/pokerbull/executor/pokerbulldb.go b/plugin/dapp/pokerbull/executor/pokerbulldb.go index dbd2240a6e0a673331ad7da8711a4f76fb3ce76c..5aeaadcb9d7ea6592d67468198d4c92a04bf02f0 100644 --- a/plugin/dapp/pokerbull/executor/pokerbulldb.go +++ b/plugin/dapp/pokerbull/executor/pokerbulldb.go @@ -520,9 +520,9 @@ func (action *Action) checkPlayerExistInGame() bool { } var value pkt.PBGameRecord - lenght := len(values) - if lenght != 0 { - valueBytes := values[lenght-1] + length := len(values) + if length != 0 { + valueBytes := values[length-1] err := types.Decode(valueBytes, &value) if err == nil && value.Status == pkt.PBGameActionQuit { return false diff --git a/plugin/dapp/privacy/commands/privacy.go b/plugin/dapp/privacy/commands/privacy.go index 723fffa6c84e74d7406893de85b0ffc70d60c081..974d40add20e066661317185e9f1133c13c66c84 100644 --- a/plugin/dapp/privacy/commands/privacy.go +++ b/plugin/dapp/privacy/commands/privacy.go @@ -499,7 +499,7 @@ func showPrivacyAccountInfoFlag(cmd *cobra.Command) { cmd.MarkFlagRequired("addr") 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) { diff --git a/plugin/dapp/privacy/crypto/ring_signature_test.go b/plugin/dapp/privacy/crypto/ring_signature_test.go index a0c6440c3adb07e689e3789f28ed7e2b5eb84837..3b8b1ed68b4cb581ed4c80afd0e0e351a52cd67f 100644 --- a/plugin/dapp/privacy/crypto/ring_signature_test.go +++ b/plugin/dapp/privacy/crypto/ring_signature_test.go @@ -108,17 +108,22 @@ func TestGenerateRingSignature1(t *testing.T) { var signs [maxCount]*Sign index := 0 prefixHash, err := common.FromHex("fd1f64844a7d6a9f74fc2141bceba9d9d69b1fd6104f93bfa42a6d708a6ab22c") + assert.Nil(t, err) tmp, err := common.FromHex("e7d85d6e81512c5650adce0499d6c17a83e2e29a05c1166cd2171b6b9288b3c4") + assert.Nil(t, err) copy(image[:], tmp) tmp, err = common.FromHex("15e3cc7cdb904d62f7c20d7fa51923fa2839f9e0a92ff0eddf8c12bd09089c15") + assert.Nil(t, err) for i := 0; i < maxCount; i++ { pub := PubKeyPrivacy{} copy(pub[:], tmp[32*i:32*(i+1)]) pubs[i] = &pub } tmp, err = common.FromHex("fd8de2e12410e3da20350e6f4083b73cc3396b4812c09af633d7c223bfb2560b") + assert.Nil(t, err) copy(sec[:], tmp) tmp, err = common.FromHex("b5c0a53bce99106e74284ee1d2c64a68a14e8b4c1735e8ab9ca7215a414f97084749935d87d516b5659a01e84b08279c42e649b2e500e2ede443fe68885b0206") + assert.Nil(t, err) for i := 0; i < maxCount; i++ { signs[i] = &Sign{} } @@ -139,14 +144,17 @@ func TestCheckRingSignature1(t *testing.T) { t.Error("initialize public key from hex failed.") } tmp, err := common.FromHex("e7d85d6e81512c5650adce0499d6c17a83e2e29a05c1166cd2171b6b9288b3c4") + assert.Nil(t, err) copy(image[:], tmp) tmp, err = common.FromHex("15e3cc7cdb904d62f7c20d7fa51923fa2839f9e0a92ff0eddf8c12bd09089c15") + assert.Nil(t, err) for i := 0; i < maxCount; i++ { pub := PubKeyPrivacy{} copy(pub[:], tmp[32*i:32*(i+1)]) pubs[i] = &pub } tmp, err = common.FromHex("a142d0180a6047cf883125a83617c7dd56e9d8153ec04a96b3c5d9a5e03cd70cfd6827b200d6c2f4b41fb5b0162117a5447e327c29482c358a0a3c82db88fb0f") + assert.Nil(t, err) for i := 0; i < maxCount; i++ { sign := Sign{} copy(sign[:], tmp[64*i:64*(i+1)]) @@ -172,11 +180,13 @@ func TestCheckRingSignatureAPI1(t *testing.T) { } tmp, err := common.FromHex("15e3cc7cdb904d62f7c20d7fa51923fa2839f9e0a92ff0eddf8c12bd09089c15") + assert.Nil(t, err) for i := 0; i < maxCount; i++ { publickeys[i] = append(publickeys[i], tmp...) } tmp, err = common.FromHex("a142d0180a6047cf883125a83617c7dd56e9d8153ec04a96b3c5d9a5e03cd70cfd6827b200d6c2f4b41fb5b0162117a5447e327c29482c358a0a3c82db88fb0f") + assert.Nil(t, err) data := make([][]byte, maxCount) for i := 0; i < maxCount; i++ { data[i] = make([]byte, 0) @@ -200,14 +210,17 @@ func TestCheckRingSignature3(t *testing.T) { t.Error("initialize public key from hex failed.") } tmp, err := common.FromHex("04e593e5e4028ce1c1194eb473efc21359b114737e5a64f14420b3cf5b22204b") + assert.Nil(t, err) copy(image[:], tmp) tmp, err = common.FromHex("6bfc9654082a7da3055121aa69ddb46852577be71d6c9a204aae3492f0db7e41194f27c9fe4d81cc8421bf8256374edf660806d78b4ed7914a3b74359c8ac0bd65ff1bca674607f7948ea0ae8e83b6d9c5092942b52d2847b6cf44c9c609264d") + assert.Nil(t, err) for i := 0; i < maxCount; i++ { pub := PubKeyPrivacy{} copy(pub[:], tmp[32*i:32*(i+1)]) pubs[i] = &pub } tmp, err = common.FromHex("30041e9694c3184980c3bb87f817eab3f973cd969810ec9df4d2feeee907970693eba4bc5436dc7cf49ce476e091bf74d20003f0f73f6d0412909ed8c1a10701c9c4ec11623dd3c50980ead83865a03dfa27614e5e9fb875d75667c11ced390d438f5dd04a137c73a0ec9ca36dfab62c948ce596722067de0315b570db1f720bab7fb7ea1b124f55c9633548f06d1bb403d7e2e15a1fed70ab2865e324ef340327f6d0ad0a7129b272ce12a5a63836a4e96e95897ee44cc22a7048023f438006") + assert.Nil(t, err) for i := 0; i < maxCount; i++ { sign := Sign{} copy(sign[:], tmp[64*i:64*(i+1)]) @@ -250,15 +263,18 @@ func TestCheckRingSignature17(t *testing.T) { t.Error("initialize public key from hex failed.") } tmp, err := common.FromHex("199c5e78a71b320b704e01850a67c371fed3aca11a04077a36e10c808fdc5f57") + assert.Nil(t, err) copy(image[:], tmp) for i := 0; i < maxCount; i++ { pub := PubKeyPrivacy{} tmp, err = common.FromHex(pubstrs[i]) + assert.Nil(t, err) copy(pub[:], tmp) pubs[i] = &pub } tmp, err = common.FromHex("f5b1a5079f6122d2370da403efc2e5504b07d67ade7ca57ad3720c7e00a676096ad418262cd9f8c9afee8e58be894cb2bf6387a5018f67d629bf8845bdc9b307aee86f85f8612f74ed870abc81d54cb38f2f9108c20dbf81eb7c1160935bc801cdca5d3f09f1d4bac810cb03ec32753f65a2071a97ba787c2d550ea5ff4d890ac398a1576d108ee67138e7596af54199247c6413e06124af8db76c0ad67c160f351e53029cac4a073c8b188eb8b5151ebf1f34a6693ddbf467ac8c20eec51204c3ca29fd5814f0848b966d2bca9543fc953a0d04bb4782950123d87bd378f60d3cdc5e44160ed4265b7cd84a8200244fa24bac86c50c35b885a15f1bc1de9909fabab87d504fc0cb0b263564e606505477ded1f89543bd4d6ed87ce61918f705359c525c0e0a4cc1d77043c71dfdf9c6834e2623197af1629e34962d940eb4080d06dddaa6e12953232595906289e4712f6aa8c1189f336b823a6a38ac95390b63c508a3409256f0c4df687d4b49990d9878fc5c97af32aa99bc9ffa1215860f69fc141c763fe1f4ed3ccc72e6817e926164752686d55238e74032c47c8c580f7042a62bd74858768815a05b58887f9828bf0f184eceba1416ac294abe453105a0de353316374b1c0560acc0f98181e3229084721a0d2a6ed891d57b805984044372cbb566c91696f5d63e7e5d8cc906c5fb029e71e87a339fcbaee9502f3d01dfd203dbd04797c33370dd0626baabfb9577ca1c294d1d8c6b82ac9624496f04893ad6b2222799cfd1d4ec525b011ecf72b01f6f3b8a6a165f0169fa7cc0960025787d4253e1064e71190d36965605adb850e72e17685e35772cdd3fdfb3d505e96e5eb0ecf8c11bcef62c79e0d49e3ebc76e56d18753403a880b7d7ed399c0e143df235ac8b0748d99e1b0cdcc511abc079c1bdbfead04265d9ad44e5dd7c0e97e4afbacba478539071db02315cc9326c8edb3d8530c7fc78af9ca12b241c04f87bffab95d85f8486ff01aec75e7e38a75ff023e4b2b0f59999c4ac067b500863a63de803da2c89de74878879a39aec6cf800b117ef89ea068a71db5ef70200163d1b4beaeea8c642430e15a64baefd350cb16ca5dae6563c13162904908301485d2c4e5bac6d55dd947a169a38df2848d5e227482760f6d818c45f66a6380507d691ef87e3550626254da3ec65411e8e5aa2ab4846222e208c9ba18cd5ee09617398af31b9eac38b59180bfaec538e5542d698da20016720ced6edb7ba270059c1e1e7107d71524e4a9cf562b5da263b52368f477c5205c768ac36975a250310c37d1f40f5a6eac857ed6082c12f5cf20a0403afcde3f1ea2e4743cb1ba10fd5d92038b1fc65d09467aeac9fe7cd24f78b9376d47d2ef1d3677ede62b2640544dd1b301292b8d082a97bd910ca24fbb5eea878f2cfa4e983bb25a8a66a25065988477eec0c1815a3fa2ff421621707954e9eacdf823eea02c2e3742797c6097e570479b36ca4580c5be9bab187de6a1fa6609768b3fa6448b5bc56d6de820d") + assert.Nil(t, err) for i := 0; i < maxCount; i++ { sign := Sign{} copy(sign[:], tmp[64*i:64*(i+1)]) diff --git a/plugin/dapp/privacy/executor/exec_del_local.go b/plugin/dapp/privacy/executor/exec_del_local.go index 4aa081bfe12cde14e7fc44e1a319e5fb915fcf58..04eff960b496640ea40d88cc60a467a689757d1b 100644 --- a/plugin/dapp/privacy/executor/exec_del_local.go +++ b/plugin/dapp/privacy/executor/exec_del_local.go @@ -13,10 +13,6 @@ import ( func (p *privacy) execDelLocal(tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { txhashstr := common.Bytes2Hex(tx.Hash()) dbSet := &types.LocalDBSet{} - if receiptData.GetTy() != types.ExecOk { - privacylog.Error("execDelLocal", "txhash", txhashstr, "receipt.GetTy() = ", receiptData.GetTy()) - return dbSet, nil - } localDB := p.GetLocalDB() for i, item := range receiptData.Logs { if item.Ty != ty.TyLogPrivacyOutput { diff --git a/plugin/dapp/privacy/executor/privacy.go b/plugin/dapp/privacy/executor/privacy.go index fecb4fead704e0f025d92baa9e621650ba032916..d7fddc2e3da1d894cf2c859e0a3af68e84e9b2e3 100644 --- a/plugin/dapp/privacy/executor/privacy.go +++ b/plugin/dapp/privacy/executor/privacy.go @@ -272,7 +272,7 @@ func (p *privacy) CheckTx(tx *types.Transaction, index int) error { totalOutput += output.Amount } - feeAmount := int64(0) + var feeAmount int64 if action.Ty == pty.ActionPrivacy2Privacy { feeAmount = totalInput - totalOutput } else { @@ -331,3 +331,8 @@ func (p *privacy) checkPubKeyValid(keys [][]byte, pubkeys [][]byte) (bool, int32 return true, invalidIndex } + +// CheckReceiptExecOk return true to check if receipt ty is ok +func (p *privacy) CheckReceiptExecOk() bool { + return true +} diff --git a/plugin/dapp/privacy/wallet/privacy.go b/plugin/dapp/privacy/wallet/privacy.go index 9f3dd57c3faf6ec65222cec287fa26297fc0d8fc..f2c225b289afe0d2c19b2e93534227331c816f8d 100644 --- a/plugin/dapp/privacy/wallet/privacy.go +++ b/plugin/dapp/privacy/wallet/privacy.go @@ -38,7 +38,7 @@ func (policy *privacyPolicy) rescanAllTxAddToUpdateUTXOs() { go policy.rescanReqTxDetailByAddr(acc.Addr, policy.rescanwg) } policy.rescanwg.Wait() - bizlog.Debug("rescanAllTxToUpdateUTXOs sucess!") + bizlog.Debug("rescanAllTxToUpdateUTXOs success!") } //从blockchain模块同步addr参与的所有交易详细信息 @@ -312,8 +312,8 @@ func (policy *privacyPolicy) showPrivacyKeyPair(reqAddr *types.ReqString) (*priv return nil, err } - pair := privacyInfo.ViewPubkey[:] - pair = append(pair, privacyInfo.SpendPubkey[:]...) + //pair := privacyInfo.ViewPubkey[:] + //pair = append(pair, privacyInfo.SpendPubkey[:]...) replyPrivacyPkPair := &privacytypes.ReplyPrivacyPkPair{ ShowSuccessful: true, @@ -333,6 +333,10 @@ func (policy *privacyPolicy) getPrivacyAccountInfo(req *privacytypes.ReqPPrivacy // 搜索可用余额 privacyDBStore, err := policy.store.listAvailableUTXOs(token, addr) + if err != nil { + bizlog.Error("getPrivacyAccountInfo", "listAvailableUTXOs") + return nil, err + } utxos := make([]*privacytypes.UTXO, 0) for _, ele := range privacyDBStore { utxoBasic := &privacytypes.UTXOBasic{ @@ -820,7 +824,7 @@ func (policy *privacyPolicy) rescanReqUtxosByAddr(addrs []string) { defer policy.getWalletOperate().GetWaitGroup().Done() bizlog.Debug("RescanAllUTXO begin!") policy.reqUtxosByAddr(addrs) - bizlog.Debug("RescanAllUTXO sucess!") + bizlog.Debug("RescanAllUTXO success!") } func (policy *privacyPolicy) reqUtxosByAddr(addrs []string) { diff --git a/plugin/dapp/privacy/wallet/privacybizpolicy_test.go b/plugin/dapp/privacy/wallet/privacybizpolicy_test.go index 02348db5b34e6e8929b9c2d06c81d9c89d931f2c..cdc6a5e9a11b69c98b3c7bbb04e948b133722c15 100644 --- a/plugin/dapp/privacy/wallet/privacybizpolicy_test.go +++ b/plugin/dapp/privacy/wallet/privacybizpolicy_test.go @@ -118,7 +118,7 @@ func (mock *testDataMock) importPrivateKey(PrivKey *types.ReqWalletImportPrivkey defer wallet.GetMutex().Unlock() ok, err := wallet.CheckWalletStatus() - if !ok { + if !ok || err != nil { return } @@ -128,7 +128,7 @@ func (mock *testDataMock) importPrivateKey(PrivKey *types.ReqWalletImportPrivkey //校验label是否已经被使用 Account, err := wallet.GetAccountByLabel(PrivKey.GetLabel()) - if Account != nil { + if Account != nil || err != nil { return } @@ -161,7 +161,7 @@ func (mock *testDataMock) importPrivateKey(PrivKey *types.ReqWalletImportPrivkey Encrypteredstr := common.ToHex(Encryptered) //校验PrivKey对应的addr是否已经存在钱包中 Account, err = wallet.GetAccountByAddr(addr) - if Account != nil { + if Account != nil || err != nil { if Account.Privkey == Encrypteredstr { return } else { @@ -277,7 +277,7 @@ func Test_EnablePrivacy(t *testing.T) { req: &ty.ReqEnablePrivacy{Addrs: []string{testAddrs[0]}}, needReply: &ty.RepEnablePrivacy{ Results: []*ty.PriAddrResult{ - {IsOK: true, Addr: testAddrs[0]}}, + {Addr: testAddrs[0], Msg: "ErrAddrNotExist"}}, }, }, } @@ -305,14 +305,15 @@ func Test_ShowPrivacyKey(t *testing.T) { }{ { req: &types.ReqString{Data: testAddrs[1]}, - needError: ty.ErrPrivacyNotEnabled, + needError: types.ErrAddrNotExist, }, { req: &types.ReqString{Data: testAddrs[0]}, - needReply: &ty.ReplyPrivacyPkPair{ + /*needReply: &ty.ReplyPrivacyPkPair{ ShowSuccessful: true, Pubkeypair: "92fe6cfec2e19cd15f203f83b5d440ddb63d0cb71559f96dc81208d819fea85886b08f6e874fca15108d244b40f9086d8c03260d4b954a40dfb3cbe41ebc7389", - }, + },*/ + needError: types.ErrAddrNotExist, }, } @@ -349,6 +350,7 @@ func Test_CreateUTXOs(t *testing.T) { Sender: testAddrs[0], Pubkeypair: testPubkeyPairs[0], }, + needError: types.ErrAddrNotExist, }, } @@ -379,6 +381,7 @@ func Test_SendPublic2PrivacyTransaction(t *testing.T) { Pubkeypair: testPubkeyPairs[0], }, needReply: &types.Reply{IsOk: true}, + needError: types.ErrAddrNotExist, }, } @@ -418,6 +421,7 @@ func Test_SendPrivacy2PrivacyTransaction(t *testing.T) { Pubkeypair: testPubkeyPairs[1], }, needReply: &types.Reply{IsOk: true}, + needError: types.ErrAddrNotExist, }, } @@ -457,6 +461,7 @@ func Test_SendPrivacy2PublicTransaction(t *testing.T) { Receiver: testAddrs[0], }, needReply: &types.Reply{IsOk: true}, + needError: types.ErrAddrNotExist, }, } @@ -496,6 +501,7 @@ func Test_CreateTransaction(t *testing.T) { From: testAddrs[0], Pubkeypair: testPubkeyPairs[0], }, + //needError:types.ErrAddrNotExist, }, { // 私对私测试 req: &types.ReqCreateTransaction{ @@ -505,6 +511,7 @@ func Test_CreateTransaction(t *testing.T) { From: testAddrs[0], Pubkeypair: testPubkeyPairs[1], }, + needError: types.ErrAddrNotExist, }, { // 私对公测试 req: &types.ReqCreateTransaction{ @@ -514,6 +521,7 @@ func Test_CreateTransaction(t *testing.T) { From: testAddrs[0], Pubkeypair: testPubkeyPairs[0], }, + needError: types.ErrAddrNotExist, }, } for index, testCase := range testCases { @@ -621,7 +629,7 @@ func Test_RescanUTXOs(t *testing.T) { Addrs: testAddrs, Flag: 0, }, - needError: ty.ErrPrivacyNotEnabled, + needError: types.ErrAccountNotExist, }, { enable: true, @@ -629,6 +637,7 @@ func Test_RescanUTXOs(t *testing.T) { Addrs: testAddrs, Flag: 0, }, + needError: types.ErrAccountNotExist, }, } for index, testCase := range testCases { diff --git a/plugin/dapp/privacy/wallet/privacystore_test.go b/plugin/dapp/privacy/wallet/privacystore_test.go index 5190e5ff8a228abde3ae1a39c59250ded8835ac1..14fa7bac612f19ea80a507143fa2f430c6faef24 100644 --- a/plugin/dapp/privacy/wallet/privacystore_test.go +++ b/plugin/dapp/privacy/wallet/privacystore_test.go @@ -255,8 +255,10 @@ func testStore_listAvailableUTXOs(t *testing.T) { err = store.Set(key, []byte("AccKey")) assert.NoError(t, err) utxos, err = store.listAvailableUTXOs(token, addr) + assert.Nil(t, utxos) assert.NotNil(t, err) err = store.Set([]byte("AccKey"), bt) + assert.NoError(t, err) utxos, err = store.listAvailableUTXOs(token, addr) assert.NoError(t, err) assert.Equal(t, 1, len(utxos)) @@ -290,6 +292,7 @@ func testStore_getAccountByAddr(t *testing.T) { bt, err := proto.Marshal(account) assert.NoError(t, err) err = store.Set(calcAddrKey(addr), bt) + assert.NoError(t, err) was, err = store.getAccountByAddr(addr) assert.Equal(t, true, proto.Equal(was, account)) assert.NoError(t, err) @@ -345,6 +348,7 @@ func testStore_getVersion(t *testing.T) { bt, err = json.Marshal(PRIVACYDBVERSION) assert.NoError(t, err) err = store.Set(calcPrivacyDBVersion(), bt) + assert.NoError(t, err) version = store.getVersion() assert.Equal(t, PRIVACYDBVERSION, version) } diff --git a/plugin/dapp/relay/executor/relay.go b/plugin/dapp/relay/executor/relay.go index ad7e38041431d31c96ad5d76932621fbbf991b68..5d2f67951502745ef017405bcd133ec56f86ccc6 100644 --- a/plugin/dapp/relay/executor/relay.go +++ b/plugin/dapp/relay/executor/relay.go @@ -243,3 +243,8 @@ func deleteCreateOrderKeyValue(kv []*types.KeyValue, order *ty.RelayOrder, statu return kv } + +// CheckReceiptExecOk return true to check if receipt ty is ok +func (r *relay) CheckReceiptExecOk() bool { + return true +} diff --git a/plugin/dapp/retrieve/executor/exec_del_local.go b/plugin/dapp/retrieve/executor/exec_del_local.go index 83639133631f55af0a5650f00f8c3751d6f3b68b..6696bbe21be0da56a8f14628bd6e5cb2aa269a7e 100755 --- a/plugin/dapp/retrieve/executor/exec_del_local.go +++ b/plugin/dapp/retrieve/executor/exec_del_local.go @@ -51,9 +51,6 @@ func DelRetrieveInfo(info *rt.RetrieveQuery, Status int64, db dbm.KVDB) (*types. // ExecDelLocal_Backup Action func (c *Retrieve) ExecDelLocal_Backup(backup *rt.BackupRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { set := &types.LocalDBSet{} - if receiptData.GetTy() != types.ExecOk { - return set, nil - } rlog.Debug("Retrieve ExecDelLocal_Backup") 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 // ExecDelLocal_Prepare Action func (c *Retrieve) ExecDelLocal_Prepare(pre *rt.PrepareRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { set := &types.LocalDBSet{} - if receiptData.GetTy() != types.ExecOk { - return set, nil - } rlog.Debug("Retrieve ExecDelLocal_Prepare") 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 // ExecDelLocal_Perform Action func (c *Retrieve) ExecDelLocal_Perform(perf *rt.PerformRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { set := &types.LocalDBSet{} - if receiptData.GetTy() != types.ExecOk { - return set, nil - } rlog.Debug("Retrieve ExecDelLocal_Perform") 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 // ExecDelLocal_Cancel Action func (c *Retrieve) ExecDelLocal_Cancel(cancel *rt.CancelRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { set := &types.LocalDBSet{} - if receiptData.GetTy() != types.ExecOk { - return set, nil - } rlog.Debug("Retrieve ExecDelLocal_Cancel") info := rt.RetrieveQuery{BackupAddress: cancel.BackupAddress, DefaultAddress: cancel.DefaultAddress, DelayPeriod: zeroDelay, PrepareTime: zeroPrepareTime, RemainTime: zeroRemainTime, Status: retrieveCancel} diff --git a/plugin/dapp/retrieve/executor/exec_local.go b/plugin/dapp/retrieve/executor/exec_local.go index daf060a12dbef8b92e677bd27d2664da2641b97e..e49239975b2fe3338a23501299d8726456504bee 100755 --- a/plugin/dapp/retrieve/executor/exec_local.go +++ b/plugin/dapp/retrieve/executor/exec_local.go @@ -54,9 +54,6 @@ func SaveRetrieveInfo(info *rt.RetrieveQuery, Status int64, db dbm.KVDB) (*types // ExecLocal_Backup Action func (c *Retrieve) ExecLocal_Backup(backup *rt.BackupRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { set := &types.LocalDBSet{} - if receiptData.GetTy() != types.ExecOk { - return set, nil - } rlog.Debug("Retrieve ExecLocal_Backup") 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()) @@ -74,9 +71,6 @@ func (c *Retrieve) ExecLocal_Backup(backup *rt.BackupRetrieve, tx *types.Transac // ExecLocal_Prepare Action func (c *Retrieve) ExecLocal_Prepare(pre *rt.PrepareRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { set := &types.LocalDBSet{} - if receiptData.GetTy() != types.ExecOk { - return set, nil - } rlog.Debug("Retrieve ExecLocal_Prepare") 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 // ExecLocal_Perform Action func (c *Retrieve) ExecLocal_Perform(perf *rt.PerformRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { set := &types.LocalDBSet{} - if receiptData.GetTy() != types.ExecOk { - return set, nil - } rlog.Debug("Retrieve ExecLocal_Perf") 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 // ExecLocal_Cancel Action func (c *Retrieve) ExecLocal_Cancel(cancel *rt.CancelRetrieve, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { set := &types.LocalDBSet{} - if receiptData.GetTy() != types.ExecOk { - return set, nil - } rlog.Debug("Retrieve ExecLocal_Cancel") info := rt.RetrieveQuery{BackupAddress: cancel.BackupAddress, DefaultAddress: cancel.DefaultAddress, DelayPeriod: zeroDelay, PrepareTime: zeroPrepareTime, RemainTime: zeroRemainTime, Status: retrieveCancel} diff --git a/plugin/dapp/retrieve/executor/retrieve.go b/plugin/dapp/retrieve/executor/retrieve.go index b4ee87343b8bfd7e37a7e76c63cf80e8f74d1c4e..529934055405d5f360f8a837d7b19164d9ddc7cb 100755 --- a/plugin/dapp/retrieve/executor/retrieve.go +++ b/plugin/dapp/retrieve/executor/retrieve.go @@ -82,3 +82,8 @@ func getRetrieveInfo(db dbm.KVDB, backupAddr string, defaultAddr string) (*rt.Re } return &info, nil } + +// CheckReceiptExecOk return true to check if receipt ty is ok +func (r *Retrieve) CheckReceiptExecOk() bool { + return true +} diff --git a/plugin/dapp/retrieve/executor/retrieve_test.go b/plugin/dapp/retrieve/executor/retrieve_test.go index a49efaf4358f20ba9faa0b87a30bbaf946d3ea0c..9297a3e277868d95d9fa9ae24c72e1b308c523bd 100755 --- a/plugin/dapp/retrieve/executor/retrieve_test.go +++ b/plugin/dapp/retrieve/executor/retrieve_test.go @@ -344,7 +344,7 @@ func estRetrievePerform(t *testing.T) { func estRetrieveCancel(t *testing.T) { 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") var hashes [][]byte diff --git a/plugin/dapp/ticket/executor/exec_del_local.go b/plugin/dapp/ticket/executor/exec_del_local.go index 0b49e7ecdc5d1acfd34e5df443adec24e1ba08be..d0e645832da2ed094ae1a6af93cad6aae5fa35b2 100755 --- a/plugin/dapp/ticket/executor/exec_del_local.go +++ b/plugin/dapp/ticket/executor/exec_del_local.go @@ -11,9 +11,6 @@ import ( func (t *Ticket) execDelLocal(receiptData *types.ReceiptData) (*types.LocalDBSet, error) { dbSet := &types.LocalDBSet{} - if receiptData.GetTy() != types.ExecOk { - return dbSet, nil - } for _, item := range receiptData.Logs { //这三个是ticket 的log if item.Ty == ty.TyLogNewTicket || item.Ty == ty.TyLogMinerTicket || item.Ty == ty.TyLogCloseTicket { diff --git a/plugin/dapp/ticket/executor/exec_local.go b/plugin/dapp/ticket/executor/exec_local.go index 77637c96a3eea64dbc2e690a91a9025132986905..6fec6f1b5489cbfb8e68a4f1cbe68058dd688481 100644 --- a/plugin/dapp/ticket/executor/exec_local.go +++ b/plugin/dapp/ticket/executor/exec_local.go @@ -11,9 +11,6 @@ import ( func (t *Ticket) execLocal(receiptData *types.ReceiptData) (*types.LocalDBSet, error) { dbSet := &types.LocalDBSet{} - if receiptData.GetTy() != types.ExecOk { - return dbSet, nil - } for _, item := range receiptData.Logs { //这三个是ticket 的log if item.Ty == ty.TyLogNewTicket || item.Ty == ty.TyLogMinerTicket || item.Ty == ty.TyLogCloseTicket { diff --git a/plugin/dapp/ticket/executor/ticket.go b/plugin/dapp/ticket/executor/ticket.go index 5c6e27356c95ccaeaad2ae846f61ba20a6df08e1..bcad88c9921974d7400757a331e659c582f8fb21 100644 --- a/plugin/dapp/ticket/executor/ticket.go +++ b/plugin/dapp/ticket/executor/ticket.go @@ -186,3 +186,8 @@ func (t *Ticket) CheckTx(tx *types.Transaction, index int) error { } return nil } + +// CheckReceiptExecOk return true to check if receipt ty is ok +func (t *Ticket) CheckReceiptExecOk() bool { + return true +} diff --git a/plugin/dapp/ticket/types/ticket.go b/plugin/dapp/ticket/types/ticket.go old mode 100644 new mode 100755 index 25d4284f7951334eef3f7b8873b46e19287c366e..e84562962641a4f72525dc9b7b867963e89229ae --- a/plugin/dapp/ticket/types/ticket.go +++ b/plugin/dapp/ticket/types/ticket.go @@ -59,7 +59,7 @@ func init() { types.AllowUserExec = append(types.AllowUserExec, []byte(TicketX)) types.RegistorExecutor(TicketX, NewType()) types.RegisterDappFork(TicketX, "Enable", 0) - types.RegisterDappFork(TicketX, "ForkTicketId", 1200000) + types.RegisterDappFork(TicketX, "ForkTicketId", 1062000) } // TicketType ticket exec type diff --git a/plugin/dapp/token/executor/token.go b/plugin/dapp/token/executor/token.go index bd83caf62fd603afc65ff00f503225e255e11fc0..16f46349a9fdaaf4dedec5e5dc3e1f2a083fe984 100644 --- a/plugin/dapp/token/executor/token.go +++ b/plugin/dapp/token/executor/token.go @@ -338,3 +338,8 @@ func (t *token) getTxByToken(req *tokenty.ReqTokenTx) (types.Message, error) { } return &replyTxInfos, nil } + +// CheckReceiptExecOk return true to check if receipt ty is ok +func (t *token) CheckReceiptExecOk() bool { + return true +} diff --git a/plugin/dapp/trade/executor/trade.go b/plugin/dapp/trade/executor/trade.go index dde92b973f8524dd1eb628eb7e1f70b1dcad4fbc..1a5d869779f66fcf2a07f3094d280cf3d39e950b 100644 --- a/plugin/dapp/trade/executor/trade.go +++ b/plugin/dapp/trade/executor/trade.go @@ -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 { return genBuyMarketOrderKeyValue(kv, receipt, status, height, nil) } + +// CheckReceiptExecOk return true to check if receipt ty is ok +func (t *trade) CheckReceiptExecOk() bool { + return true +} diff --git a/plugin/dapp/valnode/executor/exec_del_local.go b/plugin/dapp/valnode/executor/exec_del_local.go index aa6447bd3b306ab78c351f6ff247ef69a0d3e9b5..af8f57de998ce1eada8d206075b21f352e6d14bb 100644 --- a/plugin/dapp/valnode/executor/exec_del_local.go +++ b/plugin/dapp/valnode/executor/exec_del_local.go @@ -12,9 +12,6 @@ import ( // ExecDelLocal_Node method func (val *ValNode) ExecDelLocal_Node(node *pty.ValNode, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) { set := &types.LocalDBSet{} - if receipt.GetTy() != types.ExecOk { - return set, nil - } key := CalcValNodeUpdateHeightIndexKey(val.GetHeight(), index) set.KV = append(set.KV, &types.KeyValue{Key: key, Value: nil}) return set, nil @@ -23,9 +20,6 @@ func (val *ValNode) ExecDelLocal_Node(node *pty.ValNode, tx *types.Transaction, // ExecDelLocal_BlockInfo method func (val *ValNode) ExecDelLocal_BlockInfo(blockInfo *pty.TendermintBlockInfo, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) { set := &types.LocalDBSet{} - if receipt.GetTy() != types.ExecOk { - return set, nil - } key := CalcValNodeBlockInfoHeightKey(val.GetHeight()) set.KV = append(set.KV, &types.KeyValue{Key: key, Value: nil}) return set, nil diff --git a/plugin/dapp/valnode/executor/exec_local.go b/plugin/dapp/valnode/executor/exec_local.go index 5bf80ec55707680e290141d9d4c281c58206edb0..0b4b1377120e222aa7e04f2bf9572598d670a75e 100644 --- a/plugin/dapp/valnode/executor/exec_local.go +++ b/plugin/dapp/valnode/executor/exec_local.go @@ -14,9 +14,6 @@ import ( // ExecLocal_Node method func (val *ValNode) ExecLocal_Node(node *pty.ValNode, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) { set := &types.LocalDBSet{} - if receipt.GetTy() != types.ExecOk { - return set, nil - } if len(node.GetPubKey()) == 0 { return nil, errors.New("validator pubkey is empty") } @@ -32,9 +29,6 @@ func (val *ValNode) ExecLocal_Node(node *pty.ValNode, tx *types.Transaction, rec // ExecLocal_BlockInfo method func (val *ValNode) ExecLocal_BlockInfo(blockInfo *pty.TendermintBlockInfo, tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) { set := &types.LocalDBSet{} - if receipt.GetTy() != types.ExecOk { - return set, nil - } key := CalcValNodeBlockInfoHeightKey(val.GetHeight()) set.KV = append(set.KV, &types.KeyValue{Key: key, Value: types.Encode(blockInfo)}) return set, nil diff --git a/plugin/dapp/valnode/executor/valnode.go b/plugin/dapp/valnode/executor/valnode.go index 7b7baf8b6cc3dac5314089eb05672b82a322785f..06ec9d8938ccf37976403d7502dea81ad4e5c083 100644 --- a/plugin/dapp/valnode/executor/valnode.go +++ b/plugin/dapp/valnode/executor/valnode.go @@ -68,3 +68,8 @@ func CalcValNodeUpdateHeightKey(height int64) []byte { func CalcValNodeBlockInfoHeightKey(height int64) []byte { 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 +} diff --git a/vendor/github.com/33cn/chain33/system/dapp/commands/version.go b/vendor/github.com/33cn/chain33/system/dapp/commands/version.go index 3569a420c396f97985098169526fffe745bcfe3c..92a1ae17d6f21b4277815926b40454f37b4453b3 100644 --- a/vendor/github.com/33cn/chain33/system/dapp/commands/version.go +++ b/vendor/github.com/33cn/chain33/system/dapp/commands/version.go @@ -26,5 +26,4 @@ func version(cmd *cobra.Command, args []string) { var res types.NodeVersion ctx := jsonclient.NewRPCCtx(rpcLaddr, "Chain33.Version", nil, &res) ctx.Run() - }