Commit 46274e2e authored by weijixing's avatar weijixing

fix lottery linter warning

parent eacf28fd
...@@ -9,21 +9,25 @@ import ( ...@@ -9,21 +9,25 @@ import (
pty "github.com/33cn/plugin/plugin/dapp/lottery/types" pty "github.com/33cn/plugin/plugin/dapp/lottery/types"
) )
// Exec_Create Action
func (l *Lottery) Exec_Create(payload *pty.LotteryCreate, tx *types.Transaction, index int) (*types.Receipt, error) { func (l *Lottery) Exec_Create(payload *pty.LotteryCreate, tx *types.Transaction, index int) (*types.Receipt, error) {
actiondb := NewLotteryAction(l, tx, index) actiondb := NewLotteryAction(l, tx, index)
return actiondb.LotteryCreate(payload) return actiondb.LotteryCreate(payload)
} }
// Exec_Buy Action
func (l *Lottery) Exec_Buy(payload *pty.LotteryBuy, tx *types.Transaction, index int) (*types.Receipt, error) { func (l *Lottery) Exec_Buy(payload *pty.LotteryBuy, tx *types.Transaction, index int) (*types.Receipt, error) {
actiondb := NewLotteryAction(l, tx, index) actiondb := NewLotteryAction(l, tx, index)
return actiondb.LotteryBuy(payload) return actiondb.LotteryBuy(payload)
} }
// Exec_Draw Action
func (l *Lottery) Exec_Draw(payload *pty.LotteryDraw, tx *types.Transaction, index int) (*types.Receipt, error) { func (l *Lottery) Exec_Draw(payload *pty.LotteryDraw, tx *types.Transaction, index int) (*types.Receipt, error) {
actiondb := NewLotteryAction(l, tx, index) actiondb := NewLotteryAction(l, tx, index)
return actiondb.LotteryDraw(payload) return actiondb.LotteryDraw(payload)
} }
// Exec_Close Action
func (l *Lottery) Exec_Close(payload *pty.LotteryClose, tx *types.Transaction, index int) (*types.Receipt, error) { func (l *Lottery) Exec_Close(payload *pty.LotteryClose, tx *types.Transaction, index int) (*types.Receipt, error) {
actiondb := NewLotteryAction(l, tx, index) actiondb := NewLotteryAction(l, tx, index)
return actiondb.LotteryClose(payload) return actiondb.LotteryClose(payload)
......
...@@ -41,18 +41,22 @@ func (l *Lottery) execDelLocal(tx *types.Transaction, receiptData *types.Receipt ...@@ -41,18 +41,22 @@ func (l *Lottery) execDelLocal(tx *types.Transaction, receiptData *types.Receipt
} }
// ExecDelLocal_Create Action
func (l *Lottery) ExecDelLocal_Create(payload *pty.LotteryCreate, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (l *Lottery) ExecDelLocal_Create(payload *pty.LotteryCreate, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return nil, nil return nil, nil
} }
// ExecDelLocal_Buy Action
func (l *Lottery) ExecDelLocal_Buy(payload *pty.LotteryBuy, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (l *Lottery) ExecDelLocal_Buy(payload *pty.LotteryBuy, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return nil, nil return nil, nil
} }
// ExecDelLocal_Draw Action
func (l *Lottery) ExecDelLocal_Draw(payload *pty.LotteryDraw, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (l *Lottery) ExecDelLocal_Draw(payload *pty.LotteryDraw, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return nil, nil return nil, nil
} }
// ExecDelLocal_Close Action
func (l *Lottery) ExecDelLocal_Close(payload *pty.LotteryClose, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (l *Lottery) ExecDelLocal_Close(payload *pty.LotteryClose, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return nil, nil return nil, nil
} }
...@@ -40,18 +40,22 @@ func (l *Lottery) execLocal(tx *types.Transaction, receipt *types.ReceiptData) ( ...@@ -40,18 +40,22 @@ func (l *Lottery) execLocal(tx *types.Transaction, receipt *types.ReceiptData) (
return set, nil return set, nil
} }
// ExecLocal_Create Action
func (l *Lottery) ExecLocal_Create(payload *pty.LotteryCreate, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (l *Lottery) ExecLocal_Create(payload *pty.LotteryCreate, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return l.execLocal(tx, receiptData) return l.execLocal(tx, receiptData)
} }
// ExecLocal_Buy Action
func (l *Lottery) ExecLocal_Buy(payload *pty.LotteryBuy, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (l *Lottery) ExecLocal_Buy(payload *pty.LotteryBuy, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return l.execLocal(tx, receiptData) return l.execLocal(tx, receiptData)
} }
// ExecLocal_Draw Action
func (l *Lottery) ExecLocal_Draw(payload *pty.LotteryDraw, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (l *Lottery) ExecLocal_Draw(payload *pty.LotteryDraw, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return l.execLocal(tx, receiptData) return l.execLocal(tx, receiptData)
} }
// ExecLocal_Close Action
func (l *Lottery) ExecLocal_Close(payload *pty.LotteryClose, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) { func (l *Lottery) ExecLocal_Close(payload *pty.LotteryClose, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return l.execLocal(tx, receiptData) return l.execLocal(tx, receiptData)
} }
...@@ -6,32 +6,32 @@ package executor ...@@ -6,32 +6,32 @@ package executor
import "fmt" import "fmt"
func calcLotteryBuyPrefix(lotteryId string, addr string) []byte { func calcLotteryBuyPrefix(lotteryID string, addr string) []byte {
key := fmt.Sprintf("LODB-lottery-buy:%s:%s", lotteryId, addr) key := fmt.Sprintf("LODB-lottery-buy:%s:%s", lotteryID, addr)
return []byte(key) return []byte(key)
} }
func calcLotteryBuyRoundPrefix(lotteryId string, addr string, round int64) []byte { func calcLotteryBuyRoundPrefix(lotteryID string, addr string, round int64) []byte {
key := fmt.Sprintf("LODB-lottery-buy:%s:%s:%10d", lotteryId, addr, round) key := fmt.Sprintf("LODB-lottery-buy:%s:%s:%10d", lotteryID, addr, round)
return []byte(key) return []byte(key)
} }
func calcLotteryBuyKey(lotteryId string, addr string, round int64, index int64) []byte { func calcLotteryBuyKey(lotteryID string, addr string, round int64, index int64) []byte {
key := fmt.Sprintf("LODB-lottery-buy:%s:%s:%10d:%18d", lotteryId, addr, round, index) key := fmt.Sprintf("LODB-lottery-buy:%s:%s:%10d:%18d", lotteryID, addr, round, index)
return []byte(key) return []byte(key)
} }
func calcLotteryDrawPrefix(lotteryId string) []byte { func calcLotteryDrawPrefix(lotteryID string) []byte {
key := fmt.Sprintf("LODB-lottery-draw:%s", lotteryId) key := fmt.Sprintf("LODB-lottery-draw:%s", lotteryID)
return []byte(key) return []byte(key)
} }
func calcLotteryDrawKey(lotteryId string, round int64) []byte { func calcLotteryDrawKey(lotteryID string, round int64) []byte {
key := fmt.Sprintf("LODB-lottery-draw:%s:%10d", lotteryId, round) key := fmt.Sprintf("LODB-lottery-draw:%s:%10d", lotteryID, round)
return []byte(key) return []byte(key)
} }
func calcLotteryKey(lotteryId string, status int32) []byte { func calcLotteryKey(lotteryID string, status int32) []byte {
key := fmt.Sprintf("LODB-lottery-:%d:%s", status, lotteryId) key := fmt.Sprintf("LODB-lottery-:%d:%s", status, lotteryID)
return []byte(key) return []byte(key)
} }
...@@ -27,6 +27,7 @@ type subConfig struct { ...@@ -27,6 +27,7 @@ type subConfig struct {
var cfg subConfig var cfg subConfig
// Init lottery
func Init(name string, sub []byte) { func Init(name string, sub []byte) {
driverName := GetName() driverName := GetName()
if name != driverName { if name != driverName {
...@@ -38,10 +39,12 @@ func Init(name string, sub []byte) { ...@@ -38,10 +39,12 @@ func Init(name string, sub []byte) {
drivers.Register(driverName, newLottery, types.GetDappFork(driverName, "Enable")) drivers.Register(driverName, newLottery, types.GetDappFork(driverName, "Enable"))
} }
// GetName for lottery
func GetName() string { func GetName() string {
return newLottery().GetName() return newLottery().GetName()
} }
// Lottery driver
type Lottery struct { type Lottery struct {
drivers.DriverBase drivers.DriverBase
} }
...@@ -53,7 +56,8 @@ func newLottery() drivers.Driver { ...@@ -53,7 +56,8 @@ func newLottery() drivers.Driver {
return l return l
} }
func (l *Lottery) GetDriverName() string { // GetDriverName for lottery
func (lott *Lottery) GetDriverName() string {
return pty.LotteryX return pty.LotteryX
} }
...@@ -210,20 +214,21 @@ func (lott *Lottery) deleteLottery(lotterylog *pty.ReceiptLottery) (kvs []*types ...@@ -210,20 +214,21 @@ func (lott *Lottery) deleteLottery(lotterylog *pty.ReceiptLottery) (kvs []*types
return kvs return kvs
} }
func addlottery(lotteryId string, status int32) *types.KeyValue { func addlottery(lotteryID string, status int32) *types.KeyValue {
kv := &types.KeyValue{} kv := &types.KeyValue{}
kv.Key = calcLotteryKey(lotteryId, status) kv.Key = calcLotteryKey(lotteryID, status)
kv.Value = []byte(lotteryId) kv.Value = []byte(lotteryID)
return kv return kv
} }
func dellottery(lotteryId string, status int32) *types.KeyValue { func dellottery(lotteryID string, status int32) *types.KeyValue {
kv := &types.KeyValue{} kv := &types.KeyValue{}
kv.Key = calcLotteryKey(lotteryId, status) kv.Key = calcLotteryKey(lotteryID, status)
kv.Value = nil kv.Value = nil
return kv return kv
} }
// GetPayloadValue lotteryAction
func (lott *Lottery) GetPayloadValue() types.Message { func (lott *Lottery) GetPayloadValue() types.Message {
return &pty.LotteryAction{} return &pty.LotteryAction{}
} }
...@@ -36,32 +36,33 @@ func (action *Action) getTxActions(height int64, blockNum int64) ([]*tickettypes ...@@ -36,32 +36,33 @@ func (action *Action) getTxActions(height int64, blockNum int64) ([]*tickettypes
txActions = append(txActions, ticketAction) txActions = append(txActions, ticketAction)
} }
return txActions, nil return txActions, nil
} else { }
//block height on main
mainHeight := action.GetMainHeightByTxHash(action.txhash)
if mainHeight < 0 {
llog.Error("LotteryCreate", "mainHeight", mainHeight)
return nil, pty.ErrLotteryStatus
}
blockDetails, err := action.GetBlocksOnMain(mainHeight-blockNum, mainHeight-1) //block height on main
if err != nil { mainHeight := action.GetMainHeightByTxHash(action.txhash)
llog.Error("LotteryCreate", "mainHeight", mainHeight) if mainHeight < 0 {
return nil, pty.ErrLotteryStatus llog.Error("LotteryCreate", "mainHeight", mainHeight)
} return nil, pty.ErrLotteryStatus
}
for _, block := range blockDetails.Items { blockDetails, err := action.GetBlocksOnMain(mainHeight-blockNum, mainHeight-1)
ticketAction, err := action.getMinerTx(block.Block) if err != nil {
if err != nil { llog.Error("LotteryCreate", "mainHeight", mainHeight)
return txActions, err return nil, pty.ErrLotteryStatus
} }
txActions = append(txActions, ticketAction)
for _, block := range blockDetails.Items {
ticketAction, err := action.getMinerTx(block.Block)
if err != nil {
return txActions, err
} }
return txActions, nil txActions = append(txActions, ticketAction)
} }
return txActions, nil
} }
//TransactionDetail // 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{txHash}
...@@ -76,6 +77,7 @@ func (action *Action) GetMainHeightByTxHash(txHash []byte) int64 { ...@@ -76,6 +77,7 @@ func (action *Action) GetMainHeightByTxHash(txHash []byte) int64 {
return -1 return -1
} }
// 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, end, false, []string{""}}
getBlockSucc := false getBlockSucc := false
......
This diff is collapsed.
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
pty "github.com/33cn/plugin/plugin/dapp/lottery/types" pty "github.com/33cn/plugin/plugin/dapp/lottery/types"
) )
// Query_GetLotteryNormalInfo not changed info
func (l *Lottery) Query_GetLotteryNormalInfo(param *pty.ReqLotteryInfo) (types.Message, error) { func (l *Lottery) Query_GetLotteryNormalInfo(param *pty.ReqLotteryInfo) (types.Message, error) {
lottery, err := findLottery(l.GetStateDB(), param.GetLotteryId()) lottery, err := findLottery(l.GetStateDB(), param.GetLotteryId())
if err != nil { if err != nil {
...@@ -20,6 +21,7 @@ func (l *Lottery) Query_GetLotteryNormalInfo(param *pty.ReqLotteryInfo) (types.M ...@@ -20,6 +21,7 @@ func (l *Lottery) Query_GetLotteryNormalInfo(param *pty.ReqLotteryInfo) (types.M
lottery.CreateAddr}, nil lottery.CreateAddr}, nil
} }
// Query_GetLotteryPurchaseAddr for current round
func (l *Lottery) Query_GetLotteryPurchaseAddr(param *pty.ReqLotteryInfo) (types.Message, error) { func (l *Lottery) Query_GetLotteryPurchaseAddr(param *pty.ReqLotteryInfo) (types.Message, error) {
lottery, err := findLottery(l.GetStateDB(), param.GetLotteryId()) lottery, err := findLottery(l.GetStateDB(), param.GetLotteryId())
if err != nil { if err != nil {
...@@ -33,6 +35,7 @@ func (l *Lottery) Query_GetLotteryPurchaseAddr(param *pty.ReqLotteryInfo) (types ...@@ -33,6 +35,7 @@ func (l *Lottery) Query_GetLotteryPurchaseAddr(param *pty.ReqLotteryInfo) (types
return reply, nil return reply, nil
} }
// Query_GetLotteryCurrentInfo state
func (l *Lottery) Query_GetLotteryCurrentInfo(param *pty.ReqLotteryInfo) (types.Message, error) { func (l *Lottery) Query_GetLotteryCurrentInfo(param *pty.ReqLotteryInfo) (types.Message, error) {
lottery, err := findLottery(l.GetStateDB(), param.GetLotteryId()) lottery, err := findLottery(l.GetStateDB(), param.GetLotteryId())
if err != nil { if err != nil {
...@@ -54,10 +57,12 @@ func (l *Lottery) Query_GetLotteryCurrentInfo(param *pty.ReqLotteryInfo) (types. ...@@ -54,10 +57,12 @@ func (l *Lottery) Query_GetLotteryCurrentInfo(param *pty.ReqLotteryInfo) (types.
return reply, nil return reply, nil
} }
// Query_GetLotteryHistoryLuckyNumber for all history
func (l *Lottery) Query_GetLotteryHistoryLuckyNumber(param *pty.ReqLotteryLuckyHistory) (types.Message, error) { func (l *Lottery) Query_GetLotteryHistoryLuckyNumber(param *pty.ReqLotteryLuckyHistory) (types.Message, error) {
return ListLotteryLuckyHistory(l.GetLocalDB(), l.GetStateDB(), param) return ListLotteryLuckyHistory(l.GetLocalDB(), l.GetStateDB(), param)
} }
// Query_GetLotteryRoundLuckyNumber for each round
func (l *Lottery) Query_GetLotteryRoundLuckyNumber(param *pty.ReqLotteryLuckyInfo) (types.Message, error) { func (l *Lottery) Query_GetLotteryRoundLuckyNumber(param *pty.ReqLotteryLuckyInfo) (types.Message, error) {
// var req pty.ReqLotteryLuckyInfo // var req pty.ReqLotteryLuckyInfo
var records []*pty.LotteryDrawRecord var records []*pty.LotteryDrawRecord
...@@ -77,10 +82,12 @@ func (l *Lottery) Query_GetLotteryRoundLuckyNumber(param *pty.ReqLotteryLuckyInf ...@@ -77,10 +82,12 @@ func (l *Lottery) Query_GetLotteryRoundLuckyNumber(param *pty.ReqLotteryLuckyInf
return &pty.LotteryDrawRecords{Records: records}, nil return &pty.LotteryDrawRecords{Records: records}, nil
} }
// Query_GetLotteryHistoryBuyInfo for all history
func (l *Lottery) Query_GetLotteryHistoryBuyInfo(param *pty.ReqLotteryBuyHistory) (types.Message, error) { func (l *Lottery) Query_GetLotteryHistoryBuyInfo(param *pty.ReqLotteryBuyHistory) (types.Message, error) {
return ListLotteryBuyRecords(l.GetLocalDB(), l.GetStateDB(), param) return ListLotteryBuyRecords(l.GetLocalDB(), l.GetStateDB(), param)
} }
// Query_GetLotteryBuyRoundInfo for each round
func (l *Lottery) Query_GetLotteryBuyRoundInfo(param *pty.ReqLotteryBuyInfo) (types.Message, error) { func (l *Lottery) Query_GetLotteryBuyRoundInfo(param *pty.ReqLotteryBuyInfo) (types.Message, error) {
key := calcLotteryBuyRoundPrefix(param.LotteryId, param.Addr, param.Round) key := calcLotteryBuyRoundPrefix(param.LotteryId, param.Addr, param.Round)
record, err := l.findLotteryBuyRecords(key) record, err := l.findLotteryBuyRecords(key)
......
...@@ -6,6 +6,7 @@ package types ...@@ -6,6 +6,7 @@ package types
import "errors" import "errors"
// Errors for lottery
var ( var (
ErrNoPrivilege = errors.New("ErrNoPrivilege") ErrNoPrivilege = errors.New("ErrNoPrivilege")
ErrLotteryStatus = errors.New("ErrLotteryStatus") ErrLotteryStatus = errors.New("ErrLotteryStatus")
......
...@@ -23,17 +23,20 @@ func init() { ...@@ -23,17 +23,20 @@ func init() {
types.RegisterDappFork(LotteryX, "Enable", 0) types.RegisterDappFork(LotteryX, "Enable", 0)
} }
// LotteryType def
type LotteryType struct { type LotteryType struct {
types.ExecTypeBase types.ExecTypeBase
} }
// NewType method
func NewType() *LotteryType { func NewType() *LotteryType {
c := &LotteryType{} c := &LotteryType{}
c.SetChild(c) c.SetChild(c)
return c return c
} }
func (at *LotteryType) GetLogMap() map[int64]*types.LogInfo { // GetLogMap method
func (lottery *LotteryType) GetLogMap() map[int64]*types.LogInfo {
return map[int64]*types.LogInfo{ return map[int64]*types.LogInfo{
TyLogLotteryCreate: {reflect.TypeOf(ReceiptLottery{}), "LogLotteryCreate"}, TyLogLotteryCreate: {reflect.TypeOf(ReceiptLottery{}), "LogLotteryCreate"},
TyLogLotteryBuy: {reflect.TypeOf(ReceiptLottery{}), "LogLotteryBuy"}, TyLogLotteryBuy: {reflect.TypeOf(ReceiptLottery{}), "LogLotteryBuy"},
...@@ -42,10 +45,12 @@ func (at *LotteryType) GetLogMap() map[int64]*types.LogInfo { ...@@ -42,10 +45,12 @@ func (at *LotteryType) GetLogMap() map[int64]*types.LogInfo {
} }
} }
func (at *LotteryType) GetPayload() types.Message { // GetPayload method
func (lottery *LotteryType) GetPayload() types.Message {
return &LotteryAction{} return &LotteryAction{}
} }
// 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 var tx *types.Transaction
...@@ -88,7 +93,8 @@ func (lottery LotteryType) CreateTx(action string, message json.RawMessage) (*ty ...@@ -88,7 +93,8 @@ func (lottery LotteryType) CreateTx(action string, message json.RawMessage) (*ty
return tx, nil return tx, nil
} }
func (lott LotteryType) GetTypeMap() map[string]int32 { // GetTypeMap method
func (lottery LotteryType) GetTypeMap() map[string]int32 {
return map[string]int32{ return map[string]int32{
"Create": LotteryActionCreate, "Create": LotteryActionCreate,
"Buy": LotteryActionBuy, "Buy": LotteryActionBuy,
...@@ -97,6 +103,7 @@ func (lott LotteryType) GetTypeMap() map[string]int32 { ...@@ -97,6 +103,7 @@ func (lott LotteryType) GetTypeMap() map[string]int32 {
} }
} }
// CreateRawLotteryCreateTx method
func CreateRawLotteryCreateTx(parm *LotteryCreateTx) (*types.Transaction, error) { func CreateRawLotteryCreateTx(parm *LotteryCreateTx) (*types.Transaction, error) {
if parm == nil { if parm == nil {
llog.Error("CreateRawLotteryCreateTx", "parm", parm) llog.Error("CreateRawLotteryCreateTx", "parm", parm)
...@@ -125,6 +132,7 @@ func CreateRawLotteryCreateTx(parm *LotteryCreateTx) (*types.Transaction, error) ...@@ -125,6 +132,7 @@ func CreateRawLotteryCreateTx(parm *LotteryCreateTx) (*types.Transaction, error)
return tx, nil return tx, nil
} }
// CreateRawLotteryBuyTx method
func CreateRawLotteryBuyTx(parm *LotteryBuyTx) (*types.Transaction, error) { func CreateRawLotteryBuyTx(parm *LotteryBuyTx) (*types.Transaction, error) {
if parm == nil { if parm == nil {
llog.Error("CreateRawLotteryBuyTx", "parm", parm) llog.Error("CreateRawLotteryBuyTx", "parm", parm)
...@@ -132,7 +140,7 @@ func CreateRawLotteryBuyTx(parm *LotteryBuyTx) (*types.Transaction, error) { ...@@ -132,7 +140,7 @@ func CreateRawLotteryBuyTx(parm *LotteryBuyTx) (*types.Transaction, error) {
} }
v := &LotteryBuy{ v := &LotteryBuy{
LotteryId: parm.LotteryId, LotteryId: parm.LotteryID,
Amount: parm.Amount, Amount: parm.Amount,
Number: parm.Number, Number: parm.Number,
Way: parm.Way, Way: parm.Way,
...@@ -155,6 +163,7 @@ func CreateRawLotteryBuyTx(parm *LotteryBuyTx) (*types.Transaction, error) { ...@@ -155,6 +163,7 @@ func CreateRawLotteryBuyTx(parm *LotteryBuyTx) (*types.Transaction, error) {
return tx, nil return tx, nil
} }
// CreateRawLotteryDrawTx method
func CreateRawLotteryDrawTx(parm *LotteryDrawTx) (*types.Transaction, error) { func CreateRawLotteryDrawTx(parm *LotteryDrawTx) (*types.Transaction, error) {
if parm == nil { if parm == nil {
llog.Error("CreateRawLotteryDrawTx", "parm", parm) llog.Error("CreateRawLotteryDrawTx", "parm", parm)
...@@ -162,7 +171,7 @@ func CreateRawLotteryDrawTx(parm *LotteryDrawTx) (*types.Transaction, error) { ...@@ -162,7 +171,7 @@ func CreateRawLotteryDrawTx(parm *LotteryDrawTx) (*types.Transaction, error) {
} }
v := &LotteryDraw{ v := &LotteryDraw{
LotteryId: parm.LotteryId, LotteryId: parm.LotteryID,
} }
draw := &LotteryAction{ draw := &LotteryAction{
Ty: LotteryActionDraw, Ty: LotteryActionDraw,
...@@ -182,6 +191,7 @@ func CreateRawLotteryDrawTx(parm *LotteryDrawTx) (*types.Transaction, error) { ...@@ -182,6 +191,7 @@ func CreateRawLotteryDrawTx(parm *LotteryDrawTx) (*types.Transaction, error) {
return tx, nil return tx, nil
} }
// CreateRawLotteryCloseTx method
func CreateRawLotteryCloseTx(parm *LotteryCloseTx) (*types.Transaction, error) { func CreateRawLotteryCloseTx(parm *LotteryCloseTx) (*types.Transaction, error) {
if parm == nil { if parm == nil {
llog.Error("CreateRawLotteryCloseTx", "parm", parm) llog.Error("CreateRawLotteryCloseTx", "parm", parm)
...@@ -189,7 +199,7 @@ func CreateRawLotteryCloseTx(parm *LotteryCloseTx) (*types.Transaction, error) { ...@@ -189,7 +199,7 @@ func CreateRawLotteryCloseTx(parm *LotteryCloseTx) (*types.Transaction, error) {
} }
v := &LotteryClose{ v := &LotteryClose{
LotteryId: parm.LotteryId, LotteryId: parm.LotteryID,
} }
close := &LotteryAction{ close := &LotteryAction{
Ty: LotteryActionClose, Ty: LotteryActionClose,
......
...@@ -4,26 +4,30 @@ ...@@ -4,26 +4,30 @@
package types package types
// LotteryCreateTx for construction
type LotteryCreateTx struct { type LotteryCreateTx struct {
PurBlockNum int64 `json:"purBlockNum"` PurBlockNum int64 `json:"purBlockNum"`
DrawBlockNum int64 `json:"drawBlockNum"` DrawBlockNum int64 `json:"drawBlockNum"`
Fee int64 `json:"fee"` Fee int64 `json:"fee"`
} }
// LotteryBuyTx for construction
type LotteryBuyTx struct { type LotteryBuyTx struct {
LotteryId string `json:"lotteryId"` LotteryID string `json:"lotteryId"`
Amount int64 `json:"amount"` Amount int64 `json:"amount"`
Number int64 `json:"number"` Number int64 `json:"number"`
Way int64 `json:"way"` Way int64 `json:"way"`
Fee int64 `json:"fee"` Fee int64 `json:"fee"`
} }
// LotteryDrawTx for construction
type LotteryDrawTx struct { type LotteryDrawTx struct {
LotteryId string `json:"lotteryId"` LotteryID string `json:"lotteryId"`
Fee int64 `json:"fee"` Fee int64 `json:"fee"`
} }
// LotteryCloseTx for construction
type LotteryCloseTx struct { type LotteryCloseTx struct {
LotteryId string `json:"lotteryId"` LotteryID string `json:"lotteryId"`
Fee int64 `json:"fee"` Fee int64 `json:"fee"`
} }
...@@ -19,6 +19,7 @@ const ( ...@@ -19,6 +19,7 @@ const (
TyLogLotteryClose = 804 TyLogLotteryClose = 804
) )
// Lottery name
const ( const (
LotteryX = "lottery" LotteryX = "lottery"
) )
......
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