Commit 1128378d authored by pengjun's avatar pengjun Committed by vipwzw

fix go vet warning

parent 5f1f7406
...@@ -42,7 +42,7 @@ var ( ...@@ -42,7 +42,7 @@ var (
txs = []*types.Transaction{tx1, tx2, tx3, tx4, tx5, tx6, tx7, tx8, tx9, tx10, tx11, tx12} txs = []*types.Transaction{tx1, tx2, tx3, tx4, tx5, tx6, tx7, tx8, tx9, tx10, tx11, tx12}
privRaw, _ = common.FromHex("CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944") privRaw, _ = common.FromHex("CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944")
tr = &cty.CoinsAction_Transfer{&types.AssetsTransfer{Amount: int64(1e8)}} tr = &cty.CoinsAction_Transfer{Transfer: &types.AssetsTransfer{Amount: int64(1e8)}}
secpp256, _ = crypto.New(types.GetSignName("", types.SECP256K1)) secpp256, _ = crypto.New(types.GetSignName("", types.SECP256K1))
privKey, _ = secpp256.PrivKeyFromBytes(privRaw) privKey, _ = secpp256.PrivKeyFromBytes(privRaw)
tx14 = &types.Transaction{ tx14 = &types.Transaction{
......
...@@ -112,9 +112,9 @@ func certFromX509Cert(cert *x509.Certificate) (certificate, error) { ...@@ -112,9 +112,9 @@ func certFromX509Cert(cert *x509.Certificate) (certificate, error) {
// ParseECDSAPubKey2SM2PubKey 将ECDSA的公钥转成SM2公钥 // ParseECDSAPubKey2SM2PubKey 将ECDSA的公钥转成SM2公钥
func ParseECDSAPubKey2SM2PubKey(key *ecdsa.PublicKey) *sm2.PublicKey { func ParseECDSAPubKey2SM2PubKey(key *ecdsa.PublicKey) *sm2.PublicKey {
sm2Key := &sm2.PublicKey{ sm2Key := &sm2.PublicKey{
key.Curve, Curve: key.Curve,
key.X, X: key.X,
key.Y, Y: key.Y,
} }
return sm2Key return sm2Key
......
...@@ -91,7 +91,12 @@ func (c *Cert) CheckTx(tx *types.Transaction, index int) error { ...@@ -91,7 +91,12 @@ func (c *Cert) CheckTx(tx *types.Transaction, index int) error {
根据前缀查找证书变更记录,cert回滚、重启、同步用到 根据前缀查找证书变更记录,cert回滚、重启、同步用到
*/ */
func (c *Cert) loadHistoryByPrefix() error { func (c *Cert) loadHistoryByPrefix() error {
parm := &types.LocalDBList{[]byte("LODB-cert-"), nil, 0, 0} parm := &types.LocalDBList{
Prefix: []byte("LODB-cert-"),
Key: nil,
Direction: 0,
Count: 0,
}
result, err := c.DriverBase.GetApi().LocalList(parm) result, err := c.DriverBase.GetApi().LocalList(parm)
if err != nil { if err != nil {
return err return err
...@@ -120,7 +125,7 @@ func (c *Cert) loadHistoryByPrefix() error { ...@@ -120,7 +125,7 @@ func (c *Cert) loadHistoryByPrefix() error {
*/ */
func (c *Cert) loadHistoryByHeight() error { func (c *Cert) loadHistoryByHeight() error {
key := calcCertHeightKey(c.GetHeight()) key := calcCertHeightKey(c.GetHeight())
parm := &types.LocalDBGet{[][]byte{key}} parm := &types.LocalDBGet{Keys: [][]byte{key}}
result, err := c.DriverBase.GetApi().LocalGet(parm) result, err := c.DriverBase.GetApi().LocalGet(parm)
if err != nil { if err != nil {
return err return err
......
...@@ -28,13 +28,19 @@ func (c *Cert) ExecLocal_New(payload *ct.CertNew, tx *types.Transaction, receipt ...@@ -28,13 +28,19 @@ func (c *Cert) ExecLocal_New(payload *ct.CertNew, tx *types.Transaction, receipt
authority.Author.HistoryCertCache.CurHeight = c.GetHeight() authority.Author.HistoryCertCache.CurHeight = c.GetHeight()
authority.Author.HistoryCertCache.ToHistoryCertStore(historityCertdata) authority.Author.HistoryCertCache.ToHistoryCertStore(historityCertdata)
key := calcCertHeightKey(c.GetHeight()) key := calcCertHeightKey(c.GetHeight())
set.KV = append(set.KV, &types.KeyValue{key, types.Encode(historityCertdata)}) set.KV = append(set.KV, &types.KeyValue{
Key: key,
Value: types.Encode(historityCertdata),
})
// 构造非证书历史数据 // 构造非证书历史数据
noneCertdata := &types.HistoryCertStore{} noneCertdata := &types.HistoryCertStore{}
noneCertdata.NxtHeight = historityCertdata.CurHeigth noneCertdata.NxtHeight = historityCertdata.CurHeigth
noneCertdata.CurHeigth = 0 noneCertdata.CurHeigth = 0
set.KV = append(set.KV, &types.KeyValue{calcCertHeightKey(0), types.Encode(noneCertdata)}) set.KV = append(set.KV, &types.KeyValue{
Key: calcCertHeightKey(0),
Value: types.Encode(noneCertdata),
})
return &set, nil return &set, nil
} }
...@@ -52,14 +58,20 @@ func (c *Cert) ExecLocal_Update(payload *ct.CertUpdate, tx *types.Transaction, r ...@@ -52,14 +58,20 @@ func (c *Cert) ExecLocal_Update(payload *ct.CertUpdate, tx *types.Transaction, r
historityCertdata := &types.HistoryCertStore{} historityCertdata := &types.HistoryCertStore{}
authority.Author.HistoryCertCache.NxtHeight = c.GetHeight() authority.Author.HistoryCertCache.NxtHeight = c.GetHeight()
authority.Author.HistoryCertCache.ToHistoryCertStore(historityCertdata) authority.Author.HistoryCertCache.ToHistoryCertStore(historityCertdata)
set.KV = append(set.KV, &types.KeyValue{key, types.Encode(historityCertdata)}) set.KV = append(set.KV, &types.KeyValue{
Key: key,
Value: types.Encode(historityCertdata),
})
// 证书更新 // 证书更新
historityCertdata = &types.HistoryCertStore{} historityCertdata = &types.HistoryCertStore{}
authority.Author.ReloadCertByHeght(c.GetHeight()) authority.Author.ReloadCertByHeght(c.GetHeight())
authority.Author.HistoryCertCache.ToHistoryCertStore(historityCertdata) authority.Author.HistoryCertCache.ToHistoryCertStore(historityCertdata)
setKey := calcCertHeightKey(c.GetHeight()) setKey := calcCertHeightKey(c.GetHeight())
set.KV = append(set.KV, &types.KeyValue{setKey, types.Encode(historityCertdata)}) set.KV = append(set.KV, &types.KeyValue{
Key: setKey,
Value: types.Encode(historityCertdata),
})
return &set, nil return &set, nil
} }
......
...@@ -195,7 +195,7 @@ func pokerbullQuery(cmd *cobra.Command, args []string) { ...@@ -195,7 +195,7 @@ func pokerbullQuery(cmd *cobra.Command, args []string) {
var gameIDsS []string var gameIDsS []string
gameIDsS = append(gameIDsS, gameIDs) gameIDsS = append(gameIDsS, gameIDs)
gameIDsS = append(gameIDsS, gameIDs) gameIDsS = append(gameIDsS, gameIDs)
req := &pkt.QueryPBGameInfos{gameIDsS} req := &pkt.QueryPBGameInfos{GameIds: gameIDsS}
params.Payload = req params.Payload = req
var res pkt.ReplyPBGameList var res pkt.ReplyPBGameList
ctx := jsonrpc.NewRpcCtx(rpcLaddr, "Chain33.Query", params, &res) ctx := jsonrpc.NewRpcCtx(rpcLaddr, "Chain33.Query", params, &res)
......
...@@ -27,7 +27,7 @@ const ( ...@@ -27,7 +27,7 @@ const (
MaxPlayerNum = 5 MaxPlayerNum = 5
// MinPlayValue 最小赌注 // MinPlayValue 最小赌注
MinPlayValue = 10 * types.Coin MinPlayValue = 10 * types.Coin
// DefaultStyle 默认游戏类型 // DefaultStyle默认游戏类型
DefaultStyle = pkt.PlayStyleDefault DefaultStyle = pkt.PlayStyleDefault
) )
...@@ -125,7 +125,7 @@ func getGameListByAddr(db dbm.Lister, addr string, index int64) (types.Message, ...@@ -125,7 +125,7 @@ func getGameListByAddr(db dbm.Lister, addr string, index int64) (types.Message,
gameIds = append(gameIds, &record) gameIds = append(gameIds, &record)
} }
return &pkt.PBGameRecords{gameIds}, nil return &pkt.PBGameRecords{Records: gameIds}, nil
} }
func getGameListByStatus(db dbm.Lister, status int32, index int64) (types.Message, error) { func getGameListByStatus(db dbm.Lister, status int32, index int64) (types.Message, error) {
...@@ -150,7 +150,7 @@ func getGameListByStatus(db dbm.Lister, status int32, index int64) (types.Messag ...@@ -150,7 +150,7 @@ func getGameListByStatus(db dbm.Lister, status int32, index int64) (types.Messag
gameIds = append(gameIds, &record) gameIds = append(gameIds, &record)
} }
return &pkt.PBGameRecords{gameIds}, nil return &pkt.PBGameRecords{Records: gameIds}, nil
} }
func queryGameListByStatusAndPlayer(db dbm.Lister, stat int32, player int32, value int64) ([]string, error) { func queryGameListByStatusAndPlayer(db dbm.Lister, stat int32, player int32, value int64) ([]string, error) {
...@@ -175,7 +175,7 @@ func queryGameListByStatusAndPlayer(db dbm.Lister, stat int32, player int32, val ...@@ -175,7 +175,7 @@ func queryGameListByStatusAndPlayer(db dbm.Lister, stat int32, player int32, val
func (action *Action) saveGame(game *pkt.PokerBull) (kvset []*types.KeyValue) { func (action *Action) saveGame(game *pkt.PokerBull) (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(game.GameId), value}) kvset = append(kvset, &types.KeyValue{Key: Key(game.GameId), Value: value})
return kvset return kvset
} }
...@@ -614,7 +614,7 @@ func (action *Action) GameStart(start *pkt.PBGameStart) (*types.Receipt, error) ...@@ -614,7 +614,7 @@ func (action *Action) GameStart(start *pkt.PBGameStart) (*types.Receipt, error)
logs = append(logs, receiptLog) logs = append(logs, receiptLog)
kv = append(kv, action.saveGame(game)...) kv = append(kv, action.saveGame(game)...)
return &types.Receipt{types.ExecOk, kv, logs}, nil return &types.Receipt{Ty:types.ExecOk, KV: kv, Logs: logs}, nil
} }
func getReadyPlayerNum(players []*pkt.PBPlayer) int { func getReadyPlayerNum(players []*pkt.PBPlayer) int {
...@@ -712,7 +712,7 @@ func (action *Action) GameContinue(pbcontinue *pkt.PBGameContinue) (*types.Recei ...@@ -712,7 +712,7 @@ func (action *Action) GameContinue(pbcontinue *pkt.PBGameContinue) (*types.Recei
logs = append(logs, receiptLog) logs = append(logs, receiptLog)
kv = append(kv, action.saveGame(game)...) kv = append(kv, action.saveGame(game)...)
return &types.Receipt{types.ExecOk, kv, logs}, nil return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil
} }
// GameQuit 退出游戏 // GameQuit 退出游戏
...@@ -768,7 +768,7 @@ func (action *Action) GameQuit(pbend *pkt.PBGameQuit) (*types.Receipt, error) { ...@@ -768,7 +768,7 @@ func (action *Action) GameQuit(pbend *pkt.PBGameQuit) (*types.Receipt, error) {
receiptLog := action.GetReceiptLog(game) receiptLog := action.GetReceiptLog(game)
logs = append(logs, receiptLog) logs = append(logs, receiptLog)
kv = append(kv, action.saveGame(game)...) kv = append(kv, action.saveGame(game)...)
return &types.Receipt{types.ExecOk, kv, logs}, nil return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil
} }
// HandSlice 一手牌 // HandSlice 一手牌
......
...@@ -20,7 +20,7 @@ func (g *PokerBull) Query_QueryGameByID(in *pkt.QueryPBGameInfo) (types.Message, ...@@ -20,7 +20,7 @@ func (g *PokerBull) Query_QueryGameByID(in *pkt.QueryPBGameInfo) (types.Message,
if err != nil { if err != nil {
return nil, err return nil, err
} }
return &pkt.ReplyPBGame{game}, nil return &pkt.ReplyPBGame{Game: game}, nil
} }
// Query_QueryGameByAddr 根据地址查询游戏 // Query_QueryGameByAddr 根据地址查询游戏
......
...@@ -20,7 +20,7 @@ func (c *channelClient) Start(ctx context.Context, head *pb.PBGameStart) (*types ...@@ -20,7 +20,7 @@ func (c *channelClient) Start(ctx context.Context, head *pb.PBGameStart) (*types
val := &pb.PBGameAction{ val := &pb.PBGameAction{
Ty: pb.PBGameActionStart, Ty: pb.PBGameActionStart,
Value: &pb.PBGameAction_Start{head}, Value: &pb.PBGameAction_Start{Start: head},
} }
tx, err := types.CreateFormatTx(pb.PokerBullX, types.Encode(val)) tx, err := types.CreateFormatTx(pb.PokerBullX, types.Encode(val))
if err != nil { if err != nil {
...@@ -33,7 +33,7 @@ func (c *channelClient) Start(ctx context.Context, head *pb.PBGameStart) (*types ...@@ -33,7 +33,7 @@ func (c *channelClient) Start(ctx context.Context, head *pb.PBGameStart) (*types
func (c *channelClient) Continue(ctx context.Context, head *pb.PBGameContinue) (*types.UnsignTx, error) { func (c *channelClient) Continue(ctx context.Context, head *pb.PBGameContinue) (*types.UnsignTx, error) {
val := &pb.PBGameAction{ val := &pb.PBGameAction{
Ty: pb.PBGameActionContinue, Ty: pb.PBGameActionContinue,
Value: &pb.PBGameAction_Continue{head}, Value: &pb.PBGameAction_Continue{Continue:head},
} }
tx, err := types.CreateFormatTx(pb.PokerBullX, types.Encode(val)) tx, err := types.CreateFormatTx(pb.PokerBullX, types.Encode(val))
if err != nil { if err != nil {
...@@ -46,7 +46,7 @@ func (c *channelClient) Continue(ctx context.Context, head *pb.PBGameContinue) ( ...@@ -46,7 +46,7 @@ func (c *channelClient) Continue(ctx context.Context, head *pb.PBGameContinue) (
func (c *channelClient) Quit(ctx context.Context, head *pb.PBGameQuit) (*types.UnsignTx, error) { func (c *channelClient) Quit(ctx context.Context, head *pb.PBGameQuit) (*types.UnsignTx, error) {
val := &pb.PBGameAction{ val := &pb.PBGameAction{
Ty: pb.PBGameActionQuit, Ty: pb.PBGameActionQuit,
Value: &pb.PBGameAction_Quit{head}, Value: &pb.PBGameAction_Quit{Quit:head},
} }
tx, err := types.CreateFormatTx(pb.PokerBullX, types.Encode(val)) tx, err := types.CreateFormatTx(pb.PokerBullX, types.Encode(val))
if err != nil { if err != nil {
...@@ -59,7 +59,7 @@ func (c *channelClient) Quit(ctx context.Context, head *pb.PBGameQuit) (*types.U ...@@ -59,7 +59,7 @@ func (c *channelClient) Quit(ctx context.Context, head *pb.PBGameQuit) (*types.U
func (c *channelClient) Show(ctx context.Context, head *pb.PBGameQuery) (*types.UnsignTx, error) { func (c *channelClient) Show(ctx context.Context, head *pb.PBGameQuery) (*types.UnsignTx, error) {
val := &pb.PBGameAction{ val := &pb.PBGameAction{
Ty: pb.PBGameActionQuery, Ty: pb.PBGameActionQuery,
Value: &pb.PBGameAction_Query{head}, Value: &pb.PBGameAction_Query{Query:head},
} }
tx, err := types.CreateFormatTx(pb.PokerBullX, types.Encode(val)) tx, err := types.CreateFormatTx(pb.PokerBullX, types.Encode(val))
if err != nil { if err != 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