Commit b35ffc11 authored by 张振华's avatar 张振华

linter

parent ca870478
...@@ -139,7 +139,7 @@ func guessBet(cmd *cobra.Command, args []string) { ...@@ -139,7 +139,7 @@ func guessBet(cmd *cobra.Command, args []string) {
fee, _ := cmd.Flags().GetFloat64("fee") fee, _ := cmd.Flags().GetFloat64("fee")
params := &pkt.GuessBetTxReq{ params := &pkt.GuessBetTxReq{
GameId: gameID, GameID: gameID,
Option: option, Option: option,
Bets: betsNumber, Bets: betsNumber,
Fee: int64(fee * float64(1e8)), Fee: int64(fee * float64(1e8)),
...@@ -173,7 +173,7 @@ func guessStopBet(cmd *cobra.Command, args []string) { ...@@ -173,7 +173,7 @@ func guessStopBet(cmd *cobra.Command, args []string) {
fee, _ := cmd.Flags().GetFloat64("fee") fee, _ := cmd.Flags().GetFloat64("fee")
params := &pkt.GuessStopBetTxReq{ params := &pkt.GuessStopBetTxReq{
GameId: gameID, GameID: gameID,
Fee: int64(fee * float64(1e8)), Fee: int64(fee * float64(1e8)),
} }
...@@ -204,7 +204,7 @@ func guessAbort(cmd *cobra.Command, args []string) { ...@@ -204,7 +204,7 @@ func guessAbort(cmd *cobra.Command, args []string) {
gameID, _ := cmd.Flags().GetString("gameId") gameID, _ := cmd.Flags().GetString("gameId")
fee, _ := cmd.Flags().GetFloat64("fee") fee, _ := cmd.Flags().GetFloat64("fee")
params := &pkt.GuessAbortTxReq{ params := &pkt.GuessAbortTxReq{
GameId: gameID, GameID: gameID,
Fee: int64(fee * float64(1e8)), Fee: int64(fee * float64(1e8)),
} }
...@@ -241,7 +241,7 @@ func guessPublish(cmd *cobra.Command, args []string) { ...@@ -241,7 +241,7 @@ func guessPublish(cmd *cobra.Command, args []string) {
fee, _ := cmd.Flags().GetFloat64("fee") fee, _ := cmd.Flags().GetFloat64("fee")
params := &pkt.GuessPublishTxReq{ params := &pkt.GuessPublishTxReq{
GameId: gameID, GameID: gameID,
Result: result, Result: result,
Fee: int64(fee * float64(1e8)), Fee: int64(fee * float64(1e8)),
} }
...@@ -300,7 +300,7 @@ func guessQuery(cmd *cobra.Command, args []string) { ...@@ -300,7 +300,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
case 1: case 1:
gameIds := strings.Split(gameIDs, ";") gameIds := strings.Split(gameIDs, ";")
req := &pkt.QueryGuessGameInfos{ req := &pkt.QueryGuessGameInfos{
GameIds: gameIds, GameIDs: gameIds,
} }
params.FuncName = pkt.FuncName_QueryGamesByIds params.FuncName = pkt.FuncName_QueryGamesByIds
params.Payload = types.MustPBToJSON(req) params.Payload = types.MustPBToJSON(req)
...@@ -310,7 +310,7 @@ func guessQuery(cmd *cobra.Command, args []string) { ...@@ -310,7 +310,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
case 2: case 2:
req := &pkt.QueryGuessGameInfo{ req := &pkt.QueryGuessGameInfo{
GameId: gameID, GameID: gameID,
} }
params.FuncName = pkt.FuncName_QueryGameById params.FuncName = pkt.FuncName_QueryGameById
params.Payload = types.MustPBToJSON(req) params.Payload = types.MustPBToJSON(req)
......
...@@ -24,9 +24,9 @@ func (g *Guess) rollbackIndex(log *pkt.ReceiptGuessGame) (kvs []*types.KeyValue) ...@@ -24,9 +24,9 @@ func (g *Guess) rollbackIndex(log *pkt.ReceiptGuessGame) (kvs []*types.KeyValue)
//如果发生了状态变化,恢复老状态的记录,删除新添加的状态记录 //如果发生了状态变化,恢复老状态的记录,删除新添加的状态记录
if log.StatusChange { if log.StatusChange {
kvs = append(kvs, addGuessGameStatusIndexKey(log.PreStatus, log.GameId, log.PreIndex)) kvs = append(kvs, addGuessGameStatusIndexKey(log.PreStatus, log.GameID, log.PreIndex))
kvs = append(kvs, addGuessGameAdminStatusIndexKey(log.PreStatus, log.AdminAddr, log.GameId, log.PreIndex)) kvs = append(kvs, addGuessGameAdminStatusIndexKey(log.PreStatus, log.AdminAddr, log.GameID, log.PreIndex))
kvs = append(kvs, addGuessGameCategoryStatusIndexKey(log.PreStatus, log.Category, log.GameId, log.PreIndex)) kvs = append(kvs, addGuessGameCategoryStatusIndexKey(log.PreStatus, log.Category, log.GameID, log.PreIndex))
kvs = append(kvs, delGuessGameStatusIndexKey(log.Status, log.Index)) kvs = append(kvs, delGuessGameStatusIndexKey(log.Status, log.Index))
kvs = append(kvs, delGuessGameAdminStatusIndexKey(log.Status, log.AdminAddr, log.Index)) kvs = append(kvs, delGuessGameAdminStatusIndexKey(log.Status, log.AdminAddr, log.Index))
...@@ -34,20 +34,20 @@ func (g *Guess) rollbackIndex(log *pkt.ReceiptGuessGame) (kvs []*types.KeyValue) ...@@ -34,20 +34,20 @@ func (g *Guess) rollbackIndex(log *pkt.ReceiptGuessGame) (kvs []*types.KeyValue)
} }
} else if log.StatusChange { } else if log.StatusChange {
//其他状态时的状态发生变化的情况,要将老状态对应的记录恢复,同时删除新加的状态记录;对于每个地址的下注记录也需要遍历处理。 //其他状态时的状态发生变化的情况,要将老状态对应的记录恢复,同时删除新加的状态记录;对于每个地址的下注记录也需要遍历处理。
kvs = append(kvs, addGuessGameStatusIndexKey(log.PreStatus, log.GameId, log.PreIndex)) kvs = append(kvs, addGuessGameStatusIndexKey(log.PreStatus, log.GameID, log.PreIndex))
kvs = append(kvs, addGuessGameAdminStatusIndexKey(log.PreStatus, log.AdminAddr, log.GameId, log.PreIndex)) kvs = append(kvs, addGuessGameAdminStatusIndexKey(log.PreStatus, log.AdminAddr, log.GameID, log.PreIndex))
kvs = append(kvs, addGuessGameCategoryStatusIndexKey(log.PreStatus, log.Category, log.GameId, log.PreIndex)) kvs = append(kvs, addGuessGameCategoryStatusIndexKey(log.PreStatus, log.Category, log.GameID, log.PreIndex))
kvs = append(kvs, delGuessGameStatusIndexKey(log.Status, log.Index)) kvs = append(kvs, delGuessGameStatusIndexKey(log.Status, log.Index))
kvs = append(kvs, delGuessGameAdminStatusIndexKey(log.Status, log.AdminAddr, log.Index)) kvs = append(kvs, delGuessGameAdminStatusIndexKey(log.Status, log.AdminAddr, log.Index))
kvs = append(kvs, delGuessGameCategoryStatusIndexKey(log.Status, log.Category, log.Index)) kvs = append(kvs, delGuessGameCategoryStatusIndexKey(log.Status, log.Category, log.Index))
//从game中遍历每个地址的记录进行删除新增记录,回复老记录 //从game中遍历每个地址的记录进行删除新增记录,回复老记录
game, err := readGame(g.GetStateDB(), log.GameId) game, err := readGame(g.GetStateDB(), log.GameID)
if err == nil { if err == nil {
for i := 0; i < len(game.Plays); i++ { for i := 0; i < len(game.Plays); i++ {
player := game.Plays[i] player := game.Plays[i]
kvs = append(kvs, addGuessGameAddrStatusIndexKey(log.PreStatus, player.Addr, log.GameId, player.Bet.PreIndex)) kvs = append(kvs, addGuessGameAddrStatusIndexKey(log.PreStatus, player.Addr, log.GameID, player.Bet.PreIndex))
kvs = append(kvs, delGuessGameAddrStatusIndexKey(log.Status, player.Addr, log.Index)) kvs = append(kvs, delGuessGameAddrStatusIndexKey(log.Status, player.Addr, log.Index))
} }
} }
......
...@@ -13,19 +13,19 @@ func (g *Guess) updateIndex(log *pkt.ReceiptGuessGame) (kvs []*types.KeyValue) { ...@@ -13,19 +13,19 @@ func (g *Guess) updateIndex(log *pkt.ReceiptGuessGame) (kvs []*types.KeyValue) {
//新创建游戏 //新创建游戏
if log.Status == pkt.GuessGameStatusStart { if log.Status == pkt.GuessGameStatusStart {
//kvs = append(kvs, addGuessGameAddrIndexKey(log.Status, log.Addr, log.GameId, log.Index)) //kvs = append(kvs, addGuessGameAddrIndexKey(log.Status, log.Addr, log.GameId, log.Index))
kvs = append(kvs, addGuessGameStatusIndexKey(log.Status, log.GameId, log.Index)) kvs = append(kvs, addGuessGameStatusIndexKey(log.Status, log.GameID, log.Index))
kvs = append(kvs, addGuessGameAdminIndexKey(log.Status, log.AdminAddr, log.GameId, log.Index)) kvs = append(kvs, addGuessGameAdminIndexKey(log.Status, log.AdminAddr, log.GameID, log.Index))
kvs = append(kvs, addGuessGameAdminStatusIndexKey(log.Status, log.AdminAddr, log.GameId, log.Index)) kvs = append(kvs, addGuessGameAdminStatusIndexKey(log.Status, log.AdminAddr, log.GameID, log.Index))
kvs = append(kvs, addGuessGameCategoryStatusIndexKey(log.Status, log.Category, log.GameId, log.Index)) kvs = append(kvs, addGuessGameCategoryStatusIndexKey(log.Status, log.Category, log.GameID, log.Index))
} else if log.Status == pkt.GuessGameStatusBet { } else if log.Status == pkt.GuessGameStatusBet {
//如果是下注状态,则有用户进行了下注操作 //如果是下注状态,则有用户进行了下注操作
kvs = append(kvs, addGuessGameAddrIndexKey(log.Status, log.Addr, log.GameId, log.Index)) kvs = append(kvs, addGuessGameAddrIndexKey(log.Status, log.Addr, log.GameID, log.Index))
kvs = append(kvs, addGuessGameAddrStatusIndexKey(log.Status, log.Addr, log.GameId, log.Index)) kvs = append(kvs, addGuessGameAddrStatusIndexKey(log.Status, log.Addr, log.GameID, log.Index))
//如果发生了状态变化,则是从start->bet,对于老状态的记录进行删除操作,并增加新状态记录 //如果发生了状态变化,则是从start->bet,对于老状态的记录进行删除操作,并增加新状态记录
if log.StatusChange { if log.StatusChange {
kvs = append(kvs, addGuessGameStatusIndexKey(log.Status, log.GameId, log.Index)) kvs = append(kvs, addGuessGameStatusIndexKey(log.Status, log.GameID, log.Index))
kvs = append(kvs, addGuessGameAdminStatusIndexKey(log.Status, log.AdminAddr, log.GameId, log.Index)) kvs = append(kvs, addGuessGameAdminStatusIndexKey(log.Status, log.AdminAddr, log.GameID, log.Index))
kvs = append(kvs, addGuessGameCategoryStatusIndexKey(log.Status, log.Category, log.GameId, log.Index)) kvs = append(kvs, addGuessGameCategoryStatusIndexKey(log.Status, log.Category, log.GameID, log.Index))
kvs = append(kvs, delGuessGameStatusIndexKey(log.PreStatus, log.PreIndex)) kvs = append(kvs, delGuessGameStatusIndexKey(log.PreStatus, log.PreIndex))
kvs = append(kvs, delGuessGameAdminStatusIndexKey(log.PreStatus, log.AdminAddr, log.PreIndex)) kvs = append(kvs, delGuessGameAdminStatusIndexKey(log.PreStatus, log.AdminAddr, log.PreIndex))
...@@ -33,20 +33,20 @@ func (g *Guess) updateIndex(log *pkt.ReceiptGuessGame) (kvs []*types.KeyValue) { ...@@ -33,20 +33,20 @@ func (g *Guess) updateIndex(log *pkt.ReceiptGuessGame) (kvs []*types.KeyValue) {
} }
} else if log.StatusChange { } else if log.StatusChange {
//其他状态时的状态发生变化,要将老状态对应的记录删除,同时加入新状态记录;对于每个地址的下注记录也需要遍历处理。 //其他状态时的状态发生变化,要将老状态对应的记录删除,同时加入新状态记录;对于每个地址的下注记录也需要遍历处理。
kvs = append(kvs, addGuessGameStatusIndexKey(log.Status, log.GameId, log.Index)) kvs = append(kvs, addGuessGameStatusIndexKey(log.Status, log.GameID, log.Index))
kvs = append(kvs, addGuessGameAdminStatusIndexKey(log.Status, log.AdminAddr, log.GameId, log.Index)) kvs = append(kvs, addGuessGameAdminStatusIndexKey(log.Status, log.AdminAddr, log.GameID, log.Index))
kvs = append(kvs, addGuessGameCategoryStatusIndexKey(log.Status, log.Category, log.GameId, log.Index)) kvs = append(kvs, addGuessGameCategoryStatusIndexKey(log.Status, log.Category, log.GameID, log.Index))
kvs = append(kvs, delGuessGameStatusIndexKey(log.PreStatus, log.PreIndex)) kvs = append(kvs, delGuessGameStatusIndexKey(log.PreStatus, log.PreIndex))
kvs = append(kvs, delGuessGameAdminStatusIndexKey(log.PreStatus, log.AdminAddr, log.PreIndex)) kvs = append(kvs, delGuessGameAdminStatusIndexKey(log.PreStatus, log.AdminAddr, log.PreIndex))
kvs = append(kvs, delGuessGameCategoryStatusIndexKey(log.PreStatus, log.Category, log.PreIndex)) kvs = append(kvs, delGuessGameCategoryStatusIndexKey(log.PreStatus, log.Category, log.PreIndex))
//从game中遍历每个地址的记录进行新状态记录的增和老状态记录的删除 //从game中遍历每个地址的记录进行新状态记录的增和老状态记录的删除
game, err := readGame(g.GetStateDB(), log.GameId) game, err := readGame(g.GetStateDB(), log.GameID)
if err == nil { if err == nil {
for i := 0; i < len(game.Plays); i++ { for i := 0; i < len(game.Plays); i++ {
player := game.Plays[i] player := game.Plays[i]
kvs = append(kvs, addGuessGameAddrStatusIndexKey(log.Status, player.Addr, log.GameId, log.Index)) kvs = append(kvs, addGuessGameAddrStatusIndexKey(log.Status, player.Addr, log.GameID, log.Index))
kvs = append(kvs, delGuessGameAddrStatusIndexKey(log.PreStatus, player.Addr, player.Bet.PreIndex)) kvs = append(kvs, delGuessGameAddrStatusIndexKey(log.PreStatus, player.Addr, player.Bet.PreIndex))
} }
} }
......
...@@ -139,8 +139,8 @@ func readGame(db dbm.KV, id string) (*pkt.GuessGame, error) { ...@@ -139,8 +139,8 @@ func readGame(db dbm.KV, id string) (*pkt.GuessGame, error) {
//Infos 根据游戏id列表查询多个游戏详情信息 //Infos 根据游戏id列表查询多个游戏详情信息
func Infos(db dbm.KV, infos *pkt.QueryGuessGameInfos) (types.Message, error) { func Infos(db dbm.KV, infos *pkt.QueryGuessGameInfos) (types.Message, error) {
var games []*pkt.GuessGame var games []*pkt.GuessGame
for i := 0; i < len(infos.GameIds); i++ { for i := 0; i < len(infos.GameIDs); i++ {
id := infos.GameIds[i] id := infos.GameIDs[i]
game, err := readGame(db, id) game, err := readGame(db, id)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -302,8 +302,8 @@ func getGameListByCategoryStatus(db dbm.Lister, category string, status int32, i ...@@ -302,8 +302,8 @@ func getGameListByCategoryStatus(db dbm.Lister, category string, status int32, i
func (action *Action) saveGame(game *pkt.GuessGame) (kvset []*types.KeyValue) { func (action *Action) saveGame(game *pkt.GuessGame) (kvset []*types.KeyValue) {
value := types.Encode(game) value := types.Encode(game)
action.db.Set(Key(game.GetGameId()), value) action.db.Set(Key(game.GetGameID()), value)
kvset = append(kvset, &types.KeyValue{Key: Key(game.GameId), Value: value}) kvset = append(kvset, &types.KeyValue{Key: Key(game.GameID), Value: value})
return kvset return kvset
} }
...@@ -331,7 +331,7 @@ func (action *Action) GetReceiptLog(game *pkt.GuessGame, statusChange bool) *typ ...@@ -331,7 +331,7 @@ func (action *Action) GetReceiptLog(game *pkt.GuessGame, statusChange bool) *typ
} }
r.Index = game.Index r.Index = game.Index
r.GameId = game.GameId r.GameID = game.GameID
r.Status = game.Status r.Status = game.Status
r.AdminAddr = game.AdminAddr r.AdminAddr = game.AdminAddr
r.PreStatus = game.PreStatus r.PreStatus = game.PreStatus
...@@ -359,7 +359,7 @@ func (action *Action) readGame(id string) (*pkt.GuessGame, error) { ...@@ -359,7 +359,7 @@ func (action *Action) readGame(id string) (*pkt.GuessGame, error) {
// 新建一局游戏 // 新建一局游戏
func (action *Action) newGame(gameID string, start *pkt.GuessGameStart) (*pkt.GuessGame, error) { func (action *Action) newGame(gameID string, start *pkt.GuessGameStart) (*pkt.GuessGame, error) {
game := &pkt.GuessGame{ game := &pkt.GuessGame{
GameId: gameID, GameID: gameID,
Status: pkt.GuessGameActionStart, Status: pkt.GuessGameActionStart,
//StartTime: action.blocktime, //StartTime: action.blocktime,
StartTxHash: gameID, StartTxHash: gameID,
...@@ -468,10 +468,10 @@ func (action *Action) GameBet(pbBet *pkt.GuessGameBet) (*types.Receipt, error) { ...@@ -468,10 +468,10 @@ func (action *Action) GameBet(pbBet *pkt.GuessGameBet) (*types.Receipt, error) {
var logs []*types.ReceiptLog var logs []*types.ReceiptLog
var kv []*types.KeyValue var kv []*types.KeyValue
game, err := action.readGame(pbBet.GetGameId()) game, err := action.readGame(pbBet.GetGameID())
if err != nil { if err != 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
} }
...@@ -484,7 +484,7 @@ func (action *Action) GameBet(pbBet *pkt.GuessGameBet) (*types.Receipt, error) { ...@@ -484,7 +484,7 @@ func (action *Action) GameBet(pbBet *pkt.GuessGameBet) (*types.Receipt, error) {
canBet := action.RefreshStatusByTime(game) canBet := action.RefreshStatusByTime(game)
if canBet == false { if !canBet {
var receiptLog *types.ReceiptLog var receiptLog *types.ReceiptLog
if prevStatus != game.Status { if prevStatus != game.Status {
//状态发生了变化,且是变到了不可下注的状态,那么对于所有下注的addr来说,其addr:status主键的数据都需要更新 //状态发生了变化,且是变到了不可下注的状态,那么对于所有下注的addr来说,其addr:status主键的数据都需要更新
...@@ -529,7 +529,7 @@ func (action *Action) GameBet(pbBet *pkt.GuessGameBet) (*types.Receipt, error) { ...@@ -529,7 +529,7 @@ func (action *Action) GameBet(pbBet *pkt.GuessGameBet) (*types.Receipt, error) {
checkValue := pbBet.BetsNum checkValue := pbBet.BetsNum
if !action.CheckExecAccountBalance(action.fromaddr, checkValue, 0) { if !action.CheckExecAccountBalance(action.fromaddr, checkValue, 0) {
logger.Error("GameBet", "addr", action.fromaddr, "execaddr", action.execaddr, "id", logger.Error("GameBet", "addr", action.fromaddr, "execaddr", action.execaddr, "id",
pbBet.GetGameId(), "err", types.ErrNoBalance) pbBet.GetGameID(), "err", types.ErrNoBalance)
return nil, types.ErrNoBalance return nil, types.ErrNoBalance
} }
...@@ -562,10 +562,10 @@ func (action *Action) GameStopBet(pbBet *pkt.GuessGameStopBet) (*types.Receipt, ...@@ -562,10 +562,10 @@ func (action *Action) GameStopBet(pbBet *pkt.GuessGameStopBet) (*types.Receipt,
var logs []*types.ReceiptLog var logs []*types.ReceiptLog
var kv []*types.KeyValue var kv []*types.KeyValue
game, err := action.readGame(pbBet.GetGameId()) game, err := action.readGame(pbBet.GetGameID())
if err != nil { if err != 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
} }
...@@ -622,10 +622,10 @@ func (action *Action) GamePublish(publish *pkt.GuessGamePublish) (*types.Receipt ...@@ -622,10 +622,10 @@ func (action *Action) GamePublish(publish *pkt.GuessGamePublish) (*types.Receipt
var logs []*types.ReceiptLog var logs []*types.ReceiptLog
var kv []*types.KeyValue var kv []*types.KeyValue
game, err := action.readGame(publish.GetGameId()) game, err := action.readGame(publish.GetGameID())
if err != nil { if err != 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
} }
...@@ -706,7 +706,7 @@ func (action *Action) GamePublish(publish *pkt.GuessGamePublish) (*types.Receipt ...@@ -706,7 +706,7 @@ func (action *Action) GamePublish(publish *pkt.GuessGamePublish) (*types.Receipt
} }
if game.DevFeeFactor > 0 { if game.DevFeeFactor > 0 {
devFee = int64(totalBetsNumber) * game.DevFeeFactor / 1000 devFee = totalBetsNumber * game.DevFeeFactor / 1000
receipt, err := action.coinsAccount.ExecTransfer(game.AdminAddr, devAddr, action.execaddr, devFee) receipt, err := action.coinsAccount.ExecTransfer(game.AdminAddr, devAddr, action.execaddr, devFee)
if err != nil { if err != nil {
action.coinsAccount.ExecFrozen(game.AdminAddr, action.execaddr, devFee) // rollback action.coinsAccount.ExecFrozen(game.AdminAddr, action.execaddr, devFee) // rollback
...@@ -719,7 +719,7 @@ func (action *Action) GamePublish(publish *pkt.GuessGamePublish) (*types.Receipt ...@@ -719,7 +719,7 @@ func (action *Action) GamePublish(publish *pkt.GuessGamePublish) (*types.Receipt
} }
if game.PlatFeeFactor > 0 { if game.PlatFeeFactor > 0 {
platFee = int64(totalBetsNumber) * game.PlatFeeFactor / 1000 platFee = totalBetsNumber * game.PlatFeeFactor / 1000
receipt, err := action.coinsAccount.ExecTransfer(game.AdminAddr, platAddr, action.execaddr, platFee) receipt, err := action.coinsAccount.ExecTransfer(game.AdminAddr, platAddr, action.execaddr, platFee)
if err != nil { if err != nil {
action.coinsAccount.ExecFrozen(game.AdminAddr, action.execaddr, platFee) // rollback action.coinsAccount.ExecFrozen(game.AdminAddr, action.execaddr, platFee) // rollback
...@@ -736,7 +736,7 @@ func (action *Action) GamePublish(publish *pkt.GuessGamePublish) (*types.Receipt ...@@ -736,7 +736,7 @@ func (action *Action) GamePublish(publish *pkt.GuessGamePublish) (*types.Receipt
for j := 0; j < len(game.Plays); j++ { for j := 0; j < len(game.Plays); j++ {
player := game.Plays[j] player := game.Plays[j]
if player.Bet.Option == game.Result { if player.Bet.Option == game.Result {
value := int64(player.Bet.BetsNumber * winValue / winBetsNumber) value := player.Bet.BetsNumber * winValue / winBetsNumber
receipt, err := action.coinsAccount.ExecTransfer(game.AdminAddr, player.Addr, action.execaddr, value) receipt, err := action.coinsAccount.ExecTransfer(game.AdminAddr, player.Addr, action.execaddr, value)
if err != nil { if err != nil {
action.coinsAccount.ExecFrozen(player.Addr, action.execaddr, value) // rollback action.coinsAccount.ExecFrozen(player.Addr, action.execaddr, value) // rollback
...@@ -766,10 +766,10 @@ func (action *Action) GameAbort(pbend *pkt.GuessGameAbort) (*types.Receipt, erro ...@@ -766,10 +766,10 @@ func (action *Action) GameAbort(pbend *pkt.GuessGameAbort) (*types.Receipt, erro
var logs []*types.ReceiptLog var logs []*types.ReceiptLog
var kv []*types.KeyValue var kv []*types.KeyValue
game, err := action.readGame(pbend.GetGameId()) game, err := action.readGame(pbend.GetGameID())
if err != nil { if err != 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
} }
...@@ -796,7 +796,7 @@ func (action *Action) GameAbort(pbend *pkt.GuessGameAbort) (*types.Receipt, erro ...@@ -796,7 +796,7 @@ func (action *Action) GameAbort(pbend *pkt.GuessGameAbort) (*types.Receipt, erro
//激活冻结账户 //激活冻结账户
for i := 0; i < len(game.Plays); i++ { for i := 0; i < len(game.Plays); i++ {
player := game.Plays[i] player := game.Plays[i]
value := int64(player.Bet.BetsNumber) value := player.Bet.BetsNumber
receipt, err := action.coinsAccount.ExecActive(player.Addr, action.execaddr, value) receipt, err := action.coinsAccount.ExecActive(player.Addr, action.execaddr, value)
if err != nil { if err != nil {
logger.Error("GameAbort", "addr", player.Addr, "execaddr", action.execaddr, "amount", value, "err", err) logger.Error("GameAbort", "addr", player.Addr, "execaddr", action.execaddr, "amount", value, "err", err)
...@@ -864,8 +864,6 @@ func (action *Action) ChangeStatus(game *pkt.GuessGame, destStatus int32) { ...@@ -864,8 +864,6 @@ func (action *Action) ChangeStatus(game *pkt.GuessGame, destStatus int32) {
game.Status = destStatus game.Status = destStatus
game.Index = action.getIndex() game.Index = action.getIndex()
} }
return
} }
//ChangeAllAddrIndex 状态更新时,更新下注记录的历史信息 //ChangeAllAddrIndex 状态更新时,更新下注记录的历史信息
......
...@@ -81,7 +81,7 @@ func addGuessGameAddrIndexKey(status int32, addr, gameID string, index int64) *t ...@@ -81,7 +81,7 @@ func addGuessGameAddrIndexKey(status int32, addr, gameID string, index int64) *t
kv := &types.KeyValue{} kv := &types.KeyValue{}
kv.Key = calcGuessGameAddrKey(addr, index) kv.Key = calcGuessGameAddrKey(addr, index)
record := &pkt.GuessGameRecord{ record := &pkt.GuessGameRecord{
GameId: gameID, GameID: gameID,
Status: status, Status: status,
Index: index, Index: index,
} }
...@@ -100,7 +100,7 @@ func addGuessGameStatusIndexKey(status int32, gameID string, index int64) *types ...@@ -100,7 +100,7 @@ func addGuessGameStatusIndexKey(status int32, gameID string, index int64) *types
kv := &types.KeyValue{} kv := &types.KeyValue{}
kv.Key = calcGuessGameStatusKey(status, index) kv.Key = calcGuessGameStatusKey(status, index)
record := &pkt.GuessGameRecord{ record := &pkt.GuessGameRecord{
GameId: gameID, GameID: gameID,
Status: status, Status: status,
Index: index, Index: index,
} }
...@@ -119,7 +119,7 @@ func addGuessGameAddrStatusIndexKey(status int32, addr, gameID string, index int ...@@ -119,7 +119,7 @@ func addGuessGameAddrStatusIndexKey(status int32, addr, gameID string, index int
kv := &types.KeyValue{} kv := &types.KeyValue{}
kv.Key = calcGuessGameAddrStatusKey(addr, status, index) kv.Key = calcGuessGameAddrStatusKey(addr, status, index)
record := &pkt.GuessGameRecord{ record := &pkt.GuessGameRecord{
GameId: gameID, GameID: gameID,
Status: status, Status: status,
Index: index, Index: index,
} }
...@@ -138,7 +138,7 @@ func addGuessGameAdminIndexKey(status int32, addr, gameID string, index int64) * ...@@ -138,7 +138,7 @@ func addGuessGameAdminIndexKey(status int32, addr, gameID string, index int64) *
kv := &types.KeyValue{} kv := &types.KeyValue{}
kv.Key = calcGuessGameAdminKey(addr, index) kv.Key = calcGuessGameAdminKey(addr, index)
record := &pkt.GuessGameRecord{ record := &pkt.GuessGameRecord{
GameId: gameID, GameID: gameID,
Status: status, Status: status,
Index: index, Index: index,
} }
...@@ -157,7 +157,7 @@ func addGuessGameAdminStatusIndexKey(status int32, addr, gameID string, index in ...@@ -157,7 +157,7 @@ func addGuessGameAdminStatusIndexKey(status int32, addr, gameID string, index in
kv := &types.KeyValue{} kv := &types.KeyValue{}
kv.Key = calcGuessGameAdminStatusKey(addr, status, index) kv.Key = calcGuessGameAdminStatusKey(addr, status, index)
record := &pkt.GuessGameRecord{ record := &pkt.GuessGameRecord{
GameId: gameID, GameID: gameID,
Status: status, Status: status,
Index: index, Index: index,
} }
...@@ -176,7 +176,7 @@ func addGuessGameCategoryStatusIndexKey(status int32, category, gameID string, i ...@@ -176,7 +176,7 @@ func addGuessGameCategoryStatusIndexKey(status int32, category, gameID string, i
kv := &types.KeyValue{} kv := &types.KeyValue{}
kv.Key = calcGuessGameCategoryStatusKey(category, status, index) kv.Key = calcGuessGameCategoryStatusKey(category, status, index)
record := &pkt.GuessGameRecord{ record := &pkt.GuessGameRecord{
GameId: gameID, GameID: gameID,
Status: status, Status: status,
Index: index, Index: index,
} }
......
...@@ -16,7 +16,7 @@ func (g *Guess) Query_QueryGamesByIds(in *pkt.QueryGuessGameInfos) (types.Messag ...@@ -16,7 +16,7 @@ func (g *Guess) Query_QueryGamesByIds(in *pkt.QueryGuessGameInfos) (types.Messag
//Query_QueryGameById method //Query_QueryGameById method
func (g *Guess) Query_QueryGameById(in *pkt.QueryGuessGameInfo) (types.Message, error) { func (g *Guess) Query_QueryGameById(in *pkt.QueryGuessGameInfo) (types.Message, error) {
game, err := readGame(g.GetStateDB(), in.GetGameId()) game, err := readGame(g.GetStateDB(), in.GetGameID())
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
...@@ -6,7 +6,7 @@ package types; ...@@ -6,7 +6,7 @@ package types;
//GuessGame 竞猜游戏详情 //GuessGame 竞猜游戏详情
message GuessGame { message GuessGame {
string gameId = 1; //游戏ID string gameID = 1; //游戏ID
int32 status = 2; //游戏的状态:创建->投注->截止投注->开奖 int32 status = 2; //游戏的状态:创建->投注->截止投注->开奖
int32 preStatus = 3; int32 preStatus = 3;
int64 startTime = 4; //创建游戏的时间 int64 startTime = 4; //创建游戏的时间
...@@ -94,36 +94,36 @@ message GuessGameStart{ ...@@ -94,36 +94,36 @@ message GuessGameStart{
//GuessGameBet 参与游戏下注 //GuessGameBet 参与游戏下注
message GuessGameBet{ message GuessGameBet{
string gameId = 1; string gameID = 1;
string option = 2; string option = 2;
int64 betsNum = 3; int64 betsNum = 3;
} }
//GuessGameStopBet 游戏停止下注 //GuessGameStopBet 游戏停止下注
message GuessGameStopBet{ message GuessGameStopBet{
string gameId = 1; string gameID = 1;
} }
//GuessGameAbort 游戏异常终止,退还下注 //GuessGameAbort 游戏异常终止,退还下注
message GuessGameAbort{ message GuessGameAbort{
string gameId = 1; string gameID = 1;
} }
//GuessGamePublish 游戏结果揭晓 //GuessGamePublish 游戏结果揭晓
message GuessGamePublish{ message GuessGamePublish{
string gameId = 1; string gameID = 1;
string result = 2; string result = 2;
} }
//GuessGameQuery 查询游戏结果 //GuessGameQuery 查询游戏结果
message GuessGameQuery{ message GuessGameQuery{
string gameId = 1; string gameID = 1;
uint32 ty = 2; uint32 ty = 2;
} }
//QueryGuessGameInfo 游戏信息查询消息 //QueryGuessGameInfo 游戏信息查询消息
message QueryGuessGameInfo { message QueryGuessGameInfo {
string gameId = 1; string gameID = 1;
string addr = 2; string addr = 2;
int32 status = 3; int32 status = 3;
int64 index = 4; int64 index = 4;
...@@ -138,7 +138,7 @@ message ReplyGuessGameInfo { ...@@ -138,7 +138,7 @@ message ReplyGuessGameInfo {
//QueryGuessGameInfos 游戏信息列表查询消息 //QueryGuessGameInfos 游戏信息列表查询消息
message QueryGuessGameInfos { message QueryGuessGameInfos {
repeated string gameIds = 1; repeated string gameIDs = 1;
} }
//ReplyGuessGameInfos 游戏信息列表查询响应消息 //ReplyGuessGameInfos 游戏信息列表查询响应消息
...@@ -148,7 +148,7 @@ message ReplyGuessGameInfos { ...@@ -148,7 +148,7 @@ message ReplyGuessGameInfos {
//ReceiptGuessGame 竞猜游戏收据信息 //ReceiptGuessGame 竞猜游戏收据信息
message ReceiptGuessGame { message ReceiptGuessGame {
string gameId = 1; string gameID = 1;
int32 preStatus = 2; int32 preStatus = 2;
int32 status = 3; int32 status = 3;
string addr = 4; string addr = 4;
...@@ -178,7 +178,7 @@ message GuessStartTxReq { ...@@ -178,7 +178,7 @@ message GuessStartTxReq {
//GuessBetTxReq 构造bet交易的请求 //GuessBetTxReq 构造bet交易的请求
message GuessBetTxReq { message GuessBetTxReq {
string gameId = 1; string gameID = 1;
string option = 2; string option = 2;
int64 bets = 3; int64 bets = 3;
int64 fee = 4; int64 fee = 4;
...@@ -186,26 +186,26 @@ message GuessBetTxReq { ...@@ -186,26 +186,26 @@ message GuessBetTxReq {
//GuessStopBetTxReq 构造stopBet交易的请求 //GuessStopBetTxReq 构造stopBet交易的请求
message GuessStopBetTxReq { message GuessStopBetTxReq {
string gameId = 1; string gameID = 1;
int64 fee = 2; int64 fee = 2;
} }
//GuessAbortTxReq 构造abort交易的请求 //GuessAbortTxReq 构造abort交易的请求
message GuessAbortTxReq { message GuessAbortTxReq {
string gameId = 1; string gameID = 1;
int64 fee = 2; int64 fee = 2;
} }
//GuessPublishTxReq 构造publish交易的请求 //GuessPublishTxReq 构造publish交易的请求
message GuessPublishTxReq { message GuessPublishTxReq {
string gameId = 1; string gameID = 1;
string result = 2; string result = 2;
int64 fee = 3; int64 fee = 3;
} }
// GuessGameRecord game信息查询记录 // GuessGameRecord game信息查询记录
message GuessGameRecord { message GuessGameRecord {
string gameId = 1; string gameID = 1;
int32 status = 2; int32 status = 2;
int64 index = 3; int64 index = 3;
} }
......
...@@ -52,7 +52,7 @@ func (c *channelClient) GuessStart(ctx context.Context, parm *pb.GuessStartTxReq ...@@ -52,7 +52,7 @@ func (c *channelClient) GuessStart(ctx context.Context, parm *pb.GuessStartTxReq
//构造bet原始交易 //构造bet原始交易
func (c *channelClient) GuessBet(ctx context.Context, parm *pb.GuessBetTxReq) (*types.UnsignTx, error) { func (c *channelClient) GuessBet(ctx context.Context, parm *pb.GuessBetTxReq) (*types.UnsignTx, error) {
v := &pb.GuessGameBet{ v := &pb.GuessGameBet{
GameId: parm.GameId, GameID: parm.GameID,
Option: parm.Option, Option: parm.Option,
BetsNum: parm.Bets, BetsNum: parm.Bets,
} }
...@@ -81,7 +81,7 @@ func (c *channelClient) GuessBet(ctx context.Context, parm *pb.GuessBetTxReq) (* ...@@ -81,7 +81,7 @@ func (c *channelClient) GuessBet(ctx context.Context, parm *pb.GuessBetTxReq) (*
//构造stopBet原始交易 //构造stopBet原始交易
func (c *channelClient) GuessStopBet(ctx context.Context, parm *pb.GuessStopBetTxReq) (*types.UnsignTx, error) { func (c *channelClient) GuessStopBet(ctx context.Context, parm *pb.GuessStopBetTxReq) (*types.UnsignTx, error) {
v := &pb.GuessGameStopBet{ v := &pb.GuessGameStopBet{
GameId: parm.GameId, GameID: parm.GameID,
} }
val := &pb.GuessGameAction{ val := &pb.GuessGameAction{
...@@ -108,7 +108,7 @@ func (c *channelClient) GuessStopBet(ctx context.Context, parm *pb.GuessStopBetT ...@@ -108,7 +108,7 @@ func (c *channelClient) GuessStopBet(ctx context.Context, parm *pb.GuessStopBetT
//构造abort原始交易 //构造abort原始交易
func (c *channelClient) GuessAbort(ctx context.Context, parm *pb.GuessAbortTxReq) (*types.UnsignTx, error) { func (c *channelClient) GuessAbort(ctx context.Context, parm *pb.GuessAbortTxReq) (*types.UnsignTx, error) {
v := &pb.GuessGameAbort{ v := &pb.GuessGameAbort{
GameId: parm.GameId, GameID: parm.GameID,
} }
val := &pb.GuessGameAction{ val := &pb.GuessGameAction{
...@@ -134,7 +134,7 @@ func (c *channelClient) GuessAbort(ctx context.Context, parm *pb.GuessAbortTxReq ...@@ -134,7 +134,7 @@ func (c *channelClient) GuessAbort(ctx context.Context, parm *pb.GuessAbortTxReq
//构造publish原始交易 //构造publish原始交易
func (c *channelClient) GuessPublish(ctx context.Context, parm *pb.GuessPublishTxReq) (*types.UnsignTx, error) { func (c *channelClient) GuessPublish(ctx context.Context, parm *pb.GuessPublishTxReq) (*types.UnsignTx, error) {
v := &pb.GuessGamePublish{ v := &pb.GuessGamePublish{
GameId: parm.GameId, GameID: parm.GameID,
Result: parm.Result, Result: parm.Result,
} }
......
This diff is collapsed.
...@@ -22,7 +22,7 @@ type GuessGameStartTx struct { ...@@ -22,7 +22,7 @@ type GuessGameStartTx struct {
//GuessGameBetTx struct //GuessGameBetTx struct
type GuessGameBetTx struct { type GuessGameBetTx struct {
GameId string `json:"gameId,omitempty"` GameID string `json:"gameId,omitempty"`
Option string `json:"option,omitempty"` Option string `json:"option,omitempty"`
BetsNum int64 `json:"betsNum,omitempty"` BetsNum int64 `json:"betsNum,omitempty"`
Fee int64 `json:"fee,omitempty"` Fee int64 `json:"fee,omitempty"`
...@@ -30,19 +30,19 @@ type GuessGameBetTx struct { ...@@ -30,19 +30,19 @@ type GuessGameBetTx struct {
//GuessGameStopBetTx struct //GuessGameStopBetTx struct
type GuessGameStopBetTx struct { type GuessGameStopBetTx struct {
GameId string `json:"gameId,omitempty"` GameID string `json:"gameId,omitempty"`
Fee int64 `json:"fee,omitempty"` Fee int64 `json:"fee,omitempty"`
} }
//GuessGamePublishTx struct //GuessGamePublishTx struct
type GuessGamePublishTx struct { type GuessGamePublishTx struct {
GameId string `json:"gameId,omitempty"` GameID string `json:"gameId,omitempty"`
Result string `json:"result,omitempty"` Result string `json:"result,omitempty"`
Fee int64 `json:"fee,omitempty"` Fee int64 `json:"fee,omitempty"`
} }
//GuessGameAbortTx struct //GuessGameAbortTx struct
type GuessGameAbortTx struct { type GuessGameAbortTx struct {
GameId string `json:"gameId,omitempty"` GameID string `json:"gameId,omitempty"`
Fee int64 `json:"fee,omitempty"` Fee int64 `json:"fee,omitempty"`
} }
...@@ -164,7 +164,7 @@ func CreateRawGuessBetTx(parm *GuessGameBetTx) (*types.Transaction, error) { ...@@ -164,7 +164,7 @@ func CreateRawGuessBetTx(parm *GuessGameBetTx) (*types.Transaction, error) {
} }
v := &GuessGameBet{ v := &GuessGameBet{
GameId: parm.GameId, GameID: parm.GameID,
Option: parm.Option, Option: parm.Option,
BetsNum: parm.BetsNum, BetsNum: parm.BetsNum,
} }
...@@ -195,7 +195,7 @@ func CreateRawGuessStopBetTx(parm *GuessGameStopBetTx) (*types.Transaction, erro ...@@ -195,7 +195,7 @@ func CreateRawGuessStopBetTx(parm *GuessGameStopBetTx) (*types.Transaction, erro
} }
v := &GuessGameStopBet{ v := &GuessGameStopBet{
GameId: parm.GameId, GameID: parm.GameID,
} }
val := &GuessGameAction{ val := &GuessGameAction{
Ty: GuessGameActionStopBet, Ty: GuessGameActionStopBet,
...@@ -224,7 +224,7 @@ func CreateRawGuessPublishTx(parm *GuessGamePublishTx) (*types.Transaction, erro ...@@ -224,7 +224,7 @@ func CreateRawGuessPublishTx(parm *GuessGamePublishTx) (*types.Transaction, erro
} }
v := &GuessGamePublish{ v := &GuessGamePublish{
GameId: parm.GameId, GameID: parm.GameID,
Result: parm.Result, Result: parm.Result,
} }
...@@ -255,7 +255,7 @@ func CreateRawGuessAbortTx(parm *GuessGameAbortTx) (*types.Transaction, error) { ...@@ -255,7 +255,7 @@ func CreateRawGuessAbortTx(parm *GuessGameAbortTx) (*types.Transaction, error) {
} }
v := &GuessGameAbort{ v := &GuessGameAbort{
GameId: parm.GameId, GameID: parm.GameID,
} }
val := &GuessGameAction{ val := &GuessGameAction{
......
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