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