Commit bcc351de authored by pengjun's avatar pengjun Committed by vipwzw

#302 修复节点时区不一致引起的statehash不同

parent fe703ac7
...@@ -10,7 +10,6 @@ import ( ...@@ -10,7 +10,6 @@ import (
"strconv" "strconv"
"strings" "strings"
"time"
"github.com/33cn/chain33/account" "github.com/33cn/chain33/account"
"github.com/33cn/chain33/common" "github.com/33cn/chain33/common"
...@@ -510,7 +509,7 @@ func (action *Action) newGame(gameID string, start *pkt.PBGameStart) (*pkt.Poker ...@@ -510,7 +509,7 @@ func (action *Action) newGame(gameID string, start *pkt.PBGameStart) (*pkt.Poker
game = &pkt.PokerBull{ game = &pkt.PokerBull{
GameId: gameID, GameId: gameID,
Status: pkt.PBGameActionStart, Status: pkt.PBGameActionStart,
StartTime: time.Unix(action.blocktime, 0).Format("2006-01-02 15:04:05"), StartTime: action.blocktime,
StartTxHash: gameID, StartTxHash: gameID,
Value: start.GetValue(), Value: start.GetValue(),
Poker: NewPoker(), Poker: NewPoker(),
...@@ -649,7 +648,6 @@ func (action *Action) GameStart(start *pkt.PBGameStart) (*types.Receipt, error) ...@@ -649,7 +648,6 @@ func (action *Action) GameStart(start *pkt.PBGameStart) (*types.Receipt, error)
Address: action.fromaddr, Address: action.fromaddr,
TxHash: txrng, TxHash: txrng,
Ready: false, Ready: false,
MatchTime: time.Unix(action.blocktime, 0).Format("2006-01-02 15:04:05"),
}) })
// 如果人数达标,则发牌计算斗牛结果 // 如果人数达标,则发牌计算斗牛结果
...@@ -759,7 +757,6 @@ func (action *Action) GameContinue(pbcontinue *pkt.PBGameContinue) (*types.Recei ...@@ -759,7 +757,6 @@ func (action *Action) GameContinue(pbcontinue *pkt.PBGameContinue) (*types.Recei
} }
pbplayer.TxHash = txrng pbplayer.TxHash = txrng
pbplayer.Ready = true pbplayer.Ready = true
pbplayer.MatchTime = time.Unix(action.blocktime, 0).Format("2006-01-02 15:04:05")
if getReadyPlayerNum(game.Players) == int(game.PlayerNum) { if getReadyPlayerNum(game.Players) == int(game.PlayerNum) {
logger.Info(fmt.Sprintf("Game starting: %s round: %d", game.GameId, game.Round)) logger.Info(fmt.Sprintf("Game starting: %s round: %d", game.GameId, game.Round))
...@@ -864,7 +861,7 @@ func (action *Action) GameQuit(pbquit *pkt.PBGameQuit) (*types.Receipt, error) { ...@@ -864,7 +861,7 @@ func (action *Action) GameQuit(pbquit *pkt.PBGameQuit) (*types.Receipt, error) {
game.Status = pkt.PBGameActionQuit game.Status = pkt.PBGameActionQuit
game.PrevIndex = game.Index game.PrevIndex = game.Index
game.Index = action.getIndex(game) game.Index = action.getIndex(game)
game.QuitTime = time.Unix(action.blocktime, 0).Format("2006-01-02 15:04:05") game.QuitTime = action.blocktime
game.QuitTxHash = common.ToHex(action.txhash) game.QuitTxHash = common.ToHex(action.txhash)
receiptLog := action.GetReceiptLog(game) receiptLog := action.GetReceiptLog(game)
...@@ -946,7 +943,6 @@ func (action *Action) GamePlay(pbplay *pkt.PBGamePlay) (*types.Receipt, error) { ...@@ -946,7 +943,6 @@ func (action *Action) GamePlay(pbplay *pkt.PBGamePlay) (*types.Receipt, error) {
// 更新玩家信息 // 更新玩家信息
for i, player := range game.Players { for i, player := range game.Players {
player.TxHash = rands[i] player.TxHash = rands[i]
player.MatchTime = time.Unix(action.blocktime, 0).Format("2006-01-02 15:04:05")
} }
game.Round++ game.Round++
...@@ -974,14 +970,13 @@ func (action *Action) GamePlay(pbplay *pkt.PBGamePlay) (*types.Receipt, error) { ...@@ -974,14 +970,13 @@ func (action *Action) GamePlay(pbplay *pkt.PBGamePlay) (*types.Receipt, error) {
player := &pkt.PBPlayer{ player := &pkt.PBPlayer{
Address: addr, Address: addr,
TxHash: rands[i], TxHash: rands[i],
MatchTime: time.Unix(action.blocktime, 0).Format("2006-01-02 15:04:05"),
} }
game.Players = append(game.Players, player) game.Players = append(game.Players, player)
} }
game.Status = pkt.PBGameActionQuit // 更新游戏状态 game.Status = pkt.PBGameActionQuit // 更新游戏状态
game.PreStatus = pkt.PBGameActionStart game.PreStatus = pkt.PBGameActionStart
game.QuitTime = time.Unix(action.blocktime, 0).Format("2006-01-02 15:04:05") game.QuitTime = action.blocktime
game.QuitTxHash = common.ToHex(action.txhash) game.QuitTxHash = common.ToHex(action.txhash)
} }
......
...@@ -6,7 +6,7 @@ package types; ...@@ -6,7 +6,7 @@ package types;
message PokerBull { message PokerBull {
string gameId = 1; //默认是由创建这局游戏的txHash作为gameId string gameId = 1; //默认是由创建这局游戏的txHash作为gameId
int32 status = 2; // Start 1 -> Continue 2 -> Quit 3 int32 status = 2; // Start 1 -> Continue 2 -> Quit 3
string startTime = 3; //开始时间 int64 startTime = 3; //开始时间
string startTxHash = 4; //游戏启动交易hash string startTxHash = 4; //游戏启动交易hash
int64 value = 5; //赌注 int64 value = 5; //赌注
PBPoker poker = 6; //扑克牌 PBPoker poker = 6; //扑克牌
...@@ -15,7 +15,7 @@ message PokerBull { ...@@ -15,7 +15,7 @@ message PokerBull {
repeated PBResult results = 9; //游戏结果集 repeated PBResult results = 9; //游戏结果集
int64 index = 10; //索引 int64 index = 10; //索引
int64 prevIndex = 11; //上级索引 int64 prevIndex = 11; //上级索引
string quitTime = 12; //游戏结束时间 int64 quitTime = 12; //游戏结束时间
string quitTxHash = 13; //游戏结束交易hash string quitTxHash = 13; //游戏结束交易hash
string dealerAddr = 14; //下局庄家地址 string dealerAddr = 14; //下局庄家地址
bool isWaiting = 15; //游戏是否处于等待状态 bool isWaiting = 15; //游戏是否处于等待状态
...@@ -30,7 +30,6 @@ message PBHand { ...@@ -30,7 +30,6 @@ message PBHand {
string address = 3; //玩家地址 string address = 3; //玩家地址
bool isWin = 4; //是否赢庄家 bool isWin = 4; //是否赢庄家
int32 leverage = 5; //赌注倍数 int32 leverage = 5; //赌注倍数
string roundTime = 6; //本回合开始时间
} }
//玩家 //玩家
...@@ -39,7 +38,6 @@ message PBPlayer { ...@@ -39,7 +38,6 @@ message PBPlayer {
string address = 2; //玩家地址 string address = 2; //玩家地址
int64 txHash = 3; //发牌随机数因子txhash的整数格式 int64 txHash = 3; //发牌随机数因子txhash的整数格式
bool ready = 4; //continue状态下,是否ready bool ready = 4; //continue状态下,是否ready
string matchTime = 5; //玩家匹配时间
} }
//本局游戏结果 //本局游戏结果
......
This diff is collapsed.
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