Commit 9ea7ec98 authored by wjx@disanbo.com's avatar wjx@disanbo.com

fix vet

parent c2dcd5af
...@@ -124,9 +124,8 @@ func (lott *Lottery) findLotteryDrawRecord(key []byte) (*pty.LotteryDrawRecord, ...@@ -124,9 +124,8 @@ func (lott *Lottery) findLotteryDrawRecord(key []byte) (*pty.LotteryDrawRecord,
func (lott *Lottery) saveLotteryBuy(lotterylog *pty.ReceiptLottery) (kvs []*types.KeyValue) { func (lott *Lottery) saveLotteryBuy(lotterylog *pty.ReceiptLottery) (kvs []*types.KeyValue) {
key := calcLotteryBuyKey(lotterylog.LotteryId, lotterylog.Addr, lotterylog.Round, lotterylog.Index) key := calcLotteryBuyKey(lotterylog.LotteryId, lotterylog.Addr, lotterylog.Round, lotterylog.Index)
kv := &types.KeyValue{} record := &pty.LotteryBuyRecord{Number: lotterylog.Number, Amount: lotterylog.Amount, Round: lotterylog.Round, Type: 0, Way: lotterylog.Way, Index: lotterylog.Index, Time: lotterylog.Time, TxHash: lotterylog.TxHash}
record := &pty.LotteryBuyRecord{lotterylog.Number, lotterylog.Amount, lotterylog.Round, 0, lotterylog.Way, lotterylog.Index, lotterylog.Time, lotterylog.TxHash} kv := &types.KeyValue{Key: key, Value: types.Encode(record)}
kv = &types.KeyValue{key, types.Encode(record)}
kvs = append(kvs, kv) kvs = append(kvs, kv)
return kvs return kvs
...@@ -135,7 +134,7 @@ func (lott *Lottery) saveLotteryBuy(lotterylog *pty.ReceiptLottery) (kvs []*type ...@@ -135,7 +134,7 @@ func (lott *Lottery) saveLotteryBuy(lotterylog *pty.ReceiptLottery) (kvs []*type
func (lott *Lottery) deleteLotteryBuy(lotterylog *pty.ReceiptLottery) (kvs []*types.KeyValue) { func (lott *Lottery) deleteLotteryBuy(lotterylog *pty.ReceiptLottery) (kvs []*types.KeyValue) {
key := calcLotteryBuyKey(lotterylog.LotteryId, lotterylog.Addr, lotterylog.Round, lotterylog.Index) key := calcLotteryBuyKey(lotterylog.LotteryId, lotterylog.Addr, lotterylog.Round, lotterylog.Index)
kv := &types.KeyValue{key, nil} kv := &types.KeyValue{Key: key, Value: nil}
kvs = append(kvs, kv) kvs = append(kvs, kv)
return kvs return kvs
} }
...@@ -162,7 +161,6 @@ func (lott *Lottery) updateLotteryBuy(lotterylog *pty.ReceiptLottery, isAdd bool ...@@ -162,7 +161,6 @@ func (lott *Lottery) updateLotteryBuy(lotterylog *pty.ReceiptLottery, isAdd bool
if err != nil || record == nil { if err != nil || record == nil {
return kvs return kvs
} }
kv := &types.KeyValue{}
if isAdd { if isAdd {
llog.Debug("updateLotteryBuy update key") llog.Debug("updateLotteryBuy update key")
...@@ -171,7 +169,7 @@ func (lott *Lottery) updateLotteryBuy(lotterylog *pty.ReceiptLottery, isAdd bool ...@@ -171,7 +169,7 @@ func (lott *Lottery) updateLotteryBuy(lotterylog *pty.ReceiptLottery, isAdd bool
record.Type = 0 record.Type = 0
} }
kv = &types.KeyValue{key, types.Encode(record)} kv := &types.KeyValue{Key: key, Value: types.Encode(record)}
kvs = append(kvs, kv) kvs = append(kvs, kv)
} }
} }
...@@ -182,16 +180,15 @@ func (lott *Lottery) updateLotteryBuy(lotterylog *pty.ReceiptLottery, isAdd bool ...@@ -182,16 +180,15 @@ func (lott *Lottery) updateLotteryBuy(lotterylog *pty.ReceiptLottery, isAdd bool
func (lott *Lottery) saveLotteryDraw(lotterylog *pty.ReceiptLottery) (kvs []*types.KeyValue) { func (lott *Lottery) saveLotteryDraw(lotterylog *pty.ReceiptLottery) (kvs []*types.KeyValue) {
key := calcLotteryDrawKey(lotterylog.LotteryId, lotterylog.Round) key := calcLotteryDrawKey(lotterylog.LotteryId, lotterylog.Round)
kv := &types.KeyValue{} record := &pty.LotteryDrawRecord{Number: lotterylog.LuckyNumber, Round: lotterylog.Round, Time: lotterylog.Time, TxHash: lotterylog.TxHash}
record := &pty.LotteryDrawRecord{lotterylog.LuckyNumber, lotterylog.Round, lotterylog.Time, lotterylog.TxHash} kv := &types.KeyValue{Key: key, Value: types.Encode(record)}
kv = &types.KeyValue{key, types.Encode(record)}
kvs = append(kvs, kv) kvs = append(kvs, kv)
return kvs return kvs
} }
func (lott *Lottery) deleteLotteryDraw(lotterylog *pty.ReceiptLottery) (kvs []*types.KeyValue) { func (lott *Lottery) deleteLotteryDraw(lotterylog *pty.ReceiptLottery) (kvs []*types.KeyValue) {
key := calcLotteryDrawKey(lotterylog.LotteryId, lotterylog.Round) key := calcLotteryDrawKey(lotterylog.LotteryId, lotterylog.Round)
kv := &types.KeyValue{key, nil} kv := &types.KeyValue{Key: key, Value: nil}
kvs = append(kvs, kv) kvs = append(kvs, kv)
return kvs return kvs
} }
......
...@@ -20,7 +20,7 @@ func (action *Action) getTxActions(height int64, blockNum int64) ([]*tickettypes ...@@ -20,7 +20,7 @@ func (action *Action) getTxActions(height int64, blockNum int64) ([]*tickettypes
var txActions []*tickettypes.TicketAction var txActions []*tickettypes.TicketAction
llog.Error("getTxActions", "height", height, "blockNum", blockNum) llog.Error("getTxActions", "height", height, "blockNum", blockNum)
if !types.IsPara() { if !types.IsPara() {
req := &types.ReqBlocks{height - blockNum + 1, height, false, []string{""}} req := &types.ReqBlocks{Start: height - blockNum + 1, End: height, IsDetail: false, Pid: []string{""}}
blockDetails, err := action.api.GetBlocks(req) blockDetails, err := action.api.GetBlocks(req)
if err != nil { if err != nil {
...@@ -65,7 +65,7 @@ func (action *Action) getTxActions(height int64, blockNum int64) ([]*tickettypes ...@@ -65,7 +65,7 @@ func (action *Action) getTxActions(height int64, blockNum int64) ([]*tickettypes
// GetMainHeightByTxHash get Block height // GetMainHeightByTxHash get Block height
func (action *Action) GetMainHeightByTxHash(txHash []byte) int64 { func (action *Action) GetMainHeightByTxHash(txHash []byte) int64 {
for i := 0; i < retryNum; i++ { for i := 0; i < retryNum; i++ {
req := &types.ReqHash{txHash} req := &types.ReqHash{Hash: txHash}
txDetail, err := action.grpcClient.QueryTransaction(context.Background(), req) txDetail, err := action.grpcClient.QueryTransaction(context.Background(), req)
if err != nil { if err != nil {
time.Sleep(time.Second) time.Sleep(time.Second)
...@@ -79,7 +79,7 @@ func (action *Action) GetMainHeightByTxHash(txHash []byte) int64 { ...@@ -79,7 +79,7 @@ func (action *Action) GetMainHeightByTxHash(txHash []byte) int64 {
// GetBlocksOnMain get Block from main chain // GetBlocksOnMain get Block from main chain
func (action *Action) GetBlocksOnMain(start int64, end int64) (*types.BlockDetails, error) { func (action *Action) GetBlocksOnMain(start int64, end int64) (*types.BlockDetails, error) {
req := &types.ReqBlocks{start, end, false, []string{""}} req := &types.ReqBlocks{Start: start, End: end, IsDetail: false, Pid: []string{""}}
getBlockSucc := false getBlockSucc := false
var reply *types.Reply var reply *types.Reply
var err error var err error
......
...@@ -79,7 +79,7 @@ func NewLotteryDB(lotteryID string, purBlock int64, drawBlock int64, ...@@ -79,7 +79,7 @@ func NewLotteryDB(lotteryID string, purBlock int64, drawBlock int64,
lott.MissingRecords = make([]*pty.MissingRecord, 5) lott.MissingRecords = make([]*pty.MissingRecord, 5)
for index := range lott.MissingRecords { for index := range lott.MissingRecords {
tempTimes := make([]int32, 10) tempTimes := make([]int32, 10)
lott.MissingRecords[index] = &pty.MissingRecord{tempTimes} lott.MissingRecords[index] = &pty.MissingRecord{Times: tempTimes}
} }
return lott return lott
} }
...@@ -87,7 +87,7 @@ func NewLotteryDB(lotteryID string, purBlock int64, drawBlock int64, ...@@ -87,7 +87,7 @@ func NewLotteryDB(lotteryID string, purBlock int64, drawBlock int64,
// GetKVSet for LotteryDB // GetKVSet for LotteryDB
func (lott *LotteryDB) GetKVSet() (kvset []*types.KeyValue) { func (lott *LotteryDB) GetKVSet() (kvset []*types.KeyValue) {
value := types.Encode(&lott.Lottery) value := types.Encode(&lott.Lottery)
kvset = append(kvset, &types.KeyValue{Key(lott.LotteryId), value}) kvset = append(kvset, &types.KeyValue{Key: Key(lott.LotteryId), Value: value})
return kvset return kvset
} }
...@@ -230,7 +230,7 @@ func (action *Action) LotteryCreate(create *pty.LotteryCreate) (*types.Receipt, ...@@ -230,7 +230,7 @@ func (action *Action) LotteryCreate(create *pty.LotteryCreate) (*types.Receipt,
receiptLog := action.GetReceiptLog(&lott.Lottery, 0, pty.TyLogLotteryCreate, 0, 0, 0, 0, 0, nil) receiptLog := action.GetReceiptLog(&lott.Lottery, 0, pty.TyLogLotteryCreate, 0, 0, 0, 0, 0, nil)
logs = append(logs, receiptLog) logs = append(logs, receiptLog)
receipt = &types.Receipt{types.ExecOk, kv, logs} receipt = &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}
return receipt, nil return receipt, nil
} }
...@@ -316,7 +316,7 @@ func (action *Action) LotteryBuy(buy *pty.LotteryBuy) (*types.Receipt, error) { ...@@ -316,7 +316,7 @@ func (action *Action) LotteryBuy(buy *pty.LotteryBuy) (*types.Receipt, error) {
lott.Records = make(map[string]*pty.PurchaseRecords) lott.Records = make(map[string]*pty.PurchaseRecords)
} }
newRecord := &pty.PurchaseRecord{buy.GetAmount(), buy.GetNumber(), action.GetIndex(), buy.GetWay()} newRecord := &pty.PurchaseRecord{Amount: buy.GetAmount(), Number: buy.GetNumber(), Index: action.GetIndex(), Way: buy.GetWay()}
llog.Debug("LotteryBuy", "amount", buy.GetAmount(), "number", buy.GetNumber()) llog.Debug("LotteryBuy", "amount", buy.GetAmount(), "number", buy.GetNumber())
/********** /**********
...@@ -360,7 +360,7 @@ func (action *Action) LotteryBuy(buy *pty.LotteryBuy) (*types.Receipt, error) { ...@@ -360,7 +360,7 @@ func (action *Action) LotteryBuy(buy *pty.LotteryBuy) (*types.Receipt, error) {
receiptLog := action.GetReceiptLog(&lott.Lottery, preStatus, pty.TyLogLotteryBuy, lott.Round, buy.GetNumber(), buy.GetAmount(), buy.GetWay(), 0, nil) receiptLog := action.GetReceiptLog(&lott.Lottery, preStatus, pty.TyLogLotteryBuy, lott.Round, buy.GetNumber(), buy.GetAmount(), buy.GetWay(), 0, nil)
logs = append(logs, receiptLog) logs = append(logs, receiptLog)
receipt = &types.Receipt{types.ExecOk, kv, logs} receipt = &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}
return receipt, nil return receipt, nil
} }
...@@ -424,7 +424,7 @@ func (action *Action) LotteryDraw(draw *pty.LotteryDraw) (*types.Receipt, error) ...@@ -424,7 +424,7 @@ func (action *Action) LotteryDraw(draw *pty.LotteryDraw) (*types.Receipt, error)
receiptLog := action.GetReceiptLog(&lott.Lottery, preStatus, pty.TyLogLotteryDraw, lott.Round, 0, 0, 0, lott.LuckyNumber, updateInfo) receiptLog := action.GetReceiptLog(&lott.Lottery, preStatus, pty.TyLogLotteryDraw, lott.Round, 0, 0, 0, lott.LuckyNumber, updateInfo)
logs = append(logs, receiptLog) logs = append(logs, receiptLog)
receipt = &types.Receipt{types.ExecOk, kv, logs} receipt = &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}
return receipt, nil return receipt, nil
} }
...@@ -502,7 +502,7 @@ func (action *Action) LotteryClose(draw *pty.LotteryClose) (*types.Receipt, erro ...@@ -502,7 +502,7 @@ func (action *Action) LotteryClose(draw *pty.LotteryClose) (*types.Receipt, erro
receiptLog := action.GetReceiptLog(&lott.Lottery, preStatus, pty.TyLogLotteryClose, 0, 0, 0, 0, 0, nil) receiptLog := action.GetReceiptLog(&lott.Lottery, preStatus, pty.TyLogLotteryClose, 0, 0, 0, 0, 0, nil)
logs = append(logs, receiptLog) logs = append(logs, receiptLog)
return &types.Receipt{types.ExecOk, kv, logs}, nil return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil
} }
// GetCalculableHash return hash for calculation // GetCalculableHash return hash for calculation
...@@ -513,7 +513,7 @@ func (action *Action) GetCalculableHash(beg, end int64, randMolNum int64) ([]byt ...@@ -513,7 +513,7 @@ func (action *Action) GetCalculableHash(beg, end int64, randMolNum int64) ([]byt
//last := []byte("last") //last := []byte("last")
newmodify := "" newmodify := ""
for i := beg; i < end; i += randMolNum { for i := beg; i < end; i += randMolNum {
req := &types.ReqBlocks{i, i, false, []string{""}} req := &types.ReqBlocks{Start: i, End: i, IsDetail: false, Pid: []string{""}}
blocks, err := action.api.GetBlocks(req) blocks, err := action.api.GetBlocks(req)
if err != nil { if err != nil {
return []byte{}, err return []byte{}, err
...@@ -617,7 +617,7 @@ func (action *Action) checkDraw(lott *LotteryDB) (*types.Receipt, *pty.LotteryUp ...@@ -617,7 +617,7 @@ func (action *Action) checkDraw(lott *LotteryDB) (*types.Receipt, *pty.LotteryUp
for _, rec := range lott.Records[addr].Record { for _, rec := range lott.Records[addr].Record {
fund, fundType := checkFundAmount(luckynum, rec.Number, rec.Way) fund, fundType := checkFundAmount(luckynum, rec.Number, rec.Way)
if fund != 0 { if fund != 0 {
newUpdateRec := &pty.LotteryUpdateRec{rec.Index, fundType} newUpdateRec := &pty.LotteryUpdateRec{Index: rec.Index, Type: fundType}
if update, ok := updateInfo.BuyInfo[addr]; ok { if update, ok := updateInfo.BuyInfo[addr]; ok {
update.Records = append(update.Records, newUpdateRec) update.Records = append(update.Records, newUpdateRec)
} else { } else {
...@@ -693,7 +693,7 @@ func (action *Action) checkDraw(lott *LotteryDB) (*types.Receipt, *pty.LotteryUp ...@@ -693,7 +693,7 @@ func (action *Action) checkDraw(lott *LotteryDB) (*types.Receipt, *pty.LotteryUp
lott.LastTransToDrawStateOnMain = mainHeight lott.LastTransToDrawStateOnMain = mainHeight
} }
return &types.Receipt{types.ExecOk, kv, logs}, &updateInfo, nil return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, &updateInfo, nil
} }
func (action *Action) recordMissing(lott *LotteryDB) { func (action *Action) recordMissing(lott *LotteryDB) {
temp := int32(lott.LuckyNumber) temp := int32(lott.LuckyNumber)
......
...@@ -15,10 +15,10 @@ func (l *Lottery) Query_GetLotteryNormalInfo(param *pty.ReqLotteryInfo) (types.M ...@@ -15,10 +15,10 @@ func (l *Lottery) Query_GetLotteryNormalInfo(param *pty.ReqLotteryInfo) (types.M
if err != nil { if err != nil {
return nil, err return nil, err
} }
return &pty.ReplyLotteryNormalInfo{lottery.CreateHeight, return &pty.ReplyLotteryNormalInfo{CreateHeight: lottery.CreateHeight,
lottery.PurBlockNum, PurBlockNum: lottery.PurBlockNum,
lottery.DrawBlockNum, DrawBlockNum: lottery.DrawBlockNum,
lottery.CreateAddr}, nil CreateAddr: lottery.CreateAddr}, nil
} }
// Query_GetLotteryPurchaseAddr for current round // Query_GetLotteryPurchaseAddr for current round
......
...@@ -53,7 +53,7 @@ func (lottery *LotteryType) GetPayload() types.Message { ...@@ -53,7 +53,7 @@ func (lottery *LotteryType) GetPayload() types.Message {
// CreateTx method // CreateTx method
func (lottery LotteryType) CreateTx(action string, message json.RawMessage) (*types.Transaction, error) { func (lottery LotteryType) CreateTx(action string, message json.RawMessage) (*types.Transaction, error) {
llog.Debug("lottery.CreateTx", "action", action) llog.Debug("lottery.CreateTx", "action", action)
var tx *types.Transaction
if action == "LotteryCreate" { if action == "LotteryCreate" {
var param LotteryCreateTx var param LotteryCreateTx
err := json.Unmarshal(message, &param) err := json.Unmarshal(message, &param)
...@@ -89,8 +89,6 @@ func (lottery LotteryType) CreateTx(action string, message json.RawMessage) (*ty ...@@ -89,8 +89,6 @@ func (lottery LotteryType) CreateTx(action string, message json.RawMessage) (*ty
} else { } else {
return nil, types.ErrNotSupport return nil, types.ErrNotSupport
} }
return tx, nil
} }
// GetTypeMap method // GetTypeMap method
......
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