Commit 4315b7b3 authored by vipwzw's avatar vipwzw

auto ci

parent 074b7990
...@@ -6,12 +6,13 @@ package commands ...@@ -6,12 +6,13 @@ package commands
import ( import (
"fmt" "fmt"
"strings"
jsonrpc "github.com/33cn/chain33/rpc/jsonclient" jsonrpc "github.com/33cn/chain33/rpc/jsonclient"
rpctypes "github.com/33cn/chain33/rpc/types" rpctypes "github.com/33cn/chain33/rpc/types"
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
gty "github.com/33cn/plugin/plugin/dapp/guess/types" gty "github.com/33cn/plugin/plugin/dapp/guess/types"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"strings"
) )
//GuessCmd Guess合约命令行 //GuessCmd Guess合约命令行
......
...@@ -6,12 +6,13 @@ package executor ...@@ -6,12 +6,13 @@ package executor
import ( import (
"fmt" "fmt"
"github.com/33cn/chain33/common/db/table" "github.com/33cn/chain33/common/db/table"
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
gty "github.com/33cn/plugin/plugin/dapp/guess/types" gty "github.com/33cn/plugin/plugin/dapp/guess/types"
) )
func (g *Guess) rollbackGame(game *gty.GuessGame, log *gty.ReceiptGuessGame){ func (g *Guess) rollbackGame(game *gty.GuessGame, log *gty.ReceiptGuessGame) {
if game == nil || log == nil { if game == nil || log == nil {
return return
} }
...@@ -35,7 +36,7 @@ func (g *Guess) rollbackGame(game *gty.GuessGame, log *gty.ReceiptGuessGame){ ...@@ -35,7 +36,7 @@ func (g *Guess) rollbackGame(game *gty.GuessGame, log *gty.ReceiptGuessGame){
game.BetStat.TotalBetsNumber -= log.BetsNumber game.BetStat.TotalBetsNumber -= log.BetsNumber
for i := 0; i < len(game.BetStat.Items); i++ { for i := 0; i < len(game.BetStat.Items); i++ {
item := game.BetStat.Items[i] item := game.BetStat.Items[i]
if item.Option == log.Option{ if item.Option == log.Option {
item.BetsTimes-- item.BetsTimes--
item.BetsNumber -= log.BetsNumber item.BetsNumber -= log.BetsNumber
break break
......
...@@ -7,11 +7,12 @@ package executor ...@@ -7,11 +7,12 @@ package executor
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/common/db/table"
"strings" "strings"
"time" "time"
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/common/db/table"
"github.com/33cn/chain33/client" "github.com/33cn/chain33/client"
"google.golang.org/grpc" "google.golang.org/grpc"
...@@ -414,7 +415,7 @@ func (action *Action) GameBet(pbBet *gty.GuessGameBet) (*types.Receipt, error) { ...@@ -414,7 +415,7 @@ func (action *Action) GameBet(pbBet *gty.GuessGameBet) (*types.Receipt, error) {
var kv []*types.KeyValue var kv []*types.KeyValue
game, err := QueryGameInfo(action.localDB, []byte(pbBet.GetGameID())) game, err := QueryGameInfo(action.localDB, []byte(pbBet.GetGameID()))
if err != nil || game == nil{ if err != nil || game == nil {
logger.Error("GameBet", "addr", action.fromaddr, "execaddr", action.execaddr, "get game failed", logger.Error("GameBet", "addr", action.fromaddr, "execaddr", action.execaddr, "get game failed",
pbBet.GetGameID(), "err", err) pbBet.GetGameID(), "err", err)
return nil, err return nil, err
...@@ -464,7 +465,7 @@ func (action *Action) GameBet(pbBet *gty.GuessGameBet) (*types.Receipt, error) { ...@@ -464,7 +465,7 @@ func (action *Action) GameBet(pbBet *gty.GuessGameBet) (*types.Receipt, error) {
pbBet.BetsNum = game.GetMaxBetsOneTime() pbBet.BetsNum = game.GetMaxBetsOneTime()
} }
if game.BetsNumber + pbBet.GetBetsNum() > game.MaxBetsNumber { if game.BetsNumber+pbBet.GetBetsNum() > game.MaxBetsNumber {
logger.Error("GameBet", "addr", action.fromaddr, "execaddr", action.execaddr, "MaxBetsNumber over limit", logger.Error("GameBet", "addr", action.fromaddr, "execaddr", action.execaddr, "MaxBetsNumber over limit",
game.MaxBetsNumber, "current Bets Number", game.BetsNumber) game.MaxBetsNumber, "current Bets Number", game.BetsNumber)
return nil, types.ErrInvalidParam return nil, types.ErrInvalidParam
...@@ -510,7 +511,7 @@ func (action *Action) GameStopBet(pbBet *gty.GuessGameStopBet) (*types.Receipt, ...@@ -510,7 +511,7 @@ func (action *Action) GameStopBet(pbBet *gty.GuessGameStopBet) (*types.Receipt,
var kv []*types.KeyValue var kv []*types.KeyValue
game, err := QueryGameInfo(action.localDB, []byte(pbBet.GetGameID())) game, err := QueryGameInfo(action.localDB, []byte(pbBet.GetGameID()))
if err != nil || game == nil{ if err != nil || game == nil {
logger.Error("GameStopBet", "addr", action.fromaddr, "execaddr", action.execaddr, "get game failed", logger.Error("GameStopBet", "addr", action.fromaddr, "execaddr", action.execaddr, "get game failed",
pbBet.GetGameID(), "err", err) pbBet.GetGameID(), "err", err)
return nil, err return nil, err
...@@ -572,7 +573,7 @@ func (action *Action) GamePublish(publish *gty.GuessGamePublish) (*types.Receipt ...@@ -572,7 +573,7 @@ func (action *Action) GamePublish(publish *gty.GuessGamePublish) (*types.Receipt
var kv []*types.KeyValue var kv []*types.KeyValue
game, err := QueryGameInfo(action.localDB, []byte(publish.GetGameID())) game, err := QueryGameInfo(action.localDB, []byte(publish.GetGameID()))
if err != nil || game == nil{ if err != nil || game == nil {
logger.Error("GamePublish", "addr", action.fromaddr, "execaddr", action.execaddr, "get game failed", logger.Error("GamePublish", "addr", action.fromaddr, "execaddr", action.execaddr, "get game failed",
publish.GetGameID(), "err", err) publish.GetGameID(), "err", err)
return nil, err return nil, err
...@@ -718,7 +719,7 @@ func (action *Action) GameAbort(pbend *gty.GuessGameAbort) (*types.Receipt, erro ...@@ -718,7 +719,7 @@ func (action *Action) GameAbort(pbend *gty.GuessGameAbort) (*types.Receipt, erro
var kv []*types.KeyValue var kv []*types.KeyValue
game, err := QueryGameInfo(action.localDB, []byte(pbend.GetGameID())) game, err := QueryGameInfo(action.localDB, []byte(pbend.GetGameID()))
if err != nil || game == nil{ if err != nil || game == nil {
logger.Error("GameAbort", "addr", action.fromaddr, "execaddr", action.execaddr, "get game failed", logger.Error("GameAbort", "addr", action.fromaddr, "execaddr", action.execaddr, "get game failed",
pbend.GetGameID(), "err", err) pbend.GetGameID(), "err", err)
return nil, err return nil, err
......
...@@ -6,6 +6,7 @@ package executor ...@@ -6,6 +6,7 @@ package executor
import ( import (
"fmt" "fmt"
"github.com/33cn/chain33/common/db/table" "github.com/33cn/chain33/common/db/table"
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
gty "github.com/33cn/plugin/plugin/dapp/guess/types" gty "github.com/33cn/plugin/plugin/dapp/guess/types"
......
...@@ -6,10 +6,11 @@ package types ...@@ -6,10 +6,11 @@ package types
import ( import (
context "context" context "context"
fmt "fmt" fmt "fmt"
math "math"
types "github.com/33cn/chain33/types" types "github.com/33cn/chain33/types"
proto "github.com/golang/protobuf/proto" proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc" grpc "google.golang.org/grpc"
math "math"
) )
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
......
...@@ -73,7 +73,7 @@ var opt_guess_game = &table.Option{ ...@@ -73,7 +73,7 @@ var opt_guess_game = &table.Option{
Prefix: "LODB_guess", Prefix: "LODB_guess",
Name: "game", Name: "game",
Primary: "startindex", Primary: "startindex",
Index: []string{"gameid", "status","admin","admin_status", "category_status"}, Index: []string{"gameid", "status", "admin", "admin_status", "category_status"},
} }
//NewTable 新建表 //NewTable 新建表
...@@ -112,9 +112,9 @@ func (tx *GuessGameRow) SetPayload(data types.Message) error { ...@@ -112,9 +112,9 @@ func (tx *GuessGameRow) SetPayload(data types.Message) error {
//Get 按照indexName 查询 indexValue //Get 按照indexName 查询 indexValue
func (tx *GuessGameRow) Get(key string) ([]byte, error) { func (tx *GuessGameRow) Get(key string) ([]byte, error) {
if key == "startindex"{ if key == "startindex" {
return []byte(fmt.Sprintf("%018d", tx.StartIndex)), nil return []byte(fmt.Sprintf("%018d", tx.StartIndex)), nil
}else if key == "gameid" { } else if key == "gameid" {
return []byte(fmt.Sprintf("%s", tx.GameID)), nil return []byte(fmt.Sprintf("%s", tx.GameID)), nil
} else if key == "status" { } else if key == "status" {
return []byte(fmt.Sprintf("%2d", tx.Status)), nil return []byte(fmt.Sprintf("%2d", tx.Status)), nil
......
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