-
Notifications
You must be signed in to change notification settings - Fork 1
/
exec_del_local.go
executable file
·61 lines (52 loc) · 2.13 KB
/
exec_del_local.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package executor
import (
//"github.com/assetcloud/chain/common"
"github.com/assetcloud/chain/types"
pty "github.com/assetcloud/plugin/plugin/dapp/lottery/types"
)
func (l *Lottery) execDelLocal(tx *types.Transaction, receiptData *types.ReceiptData) (*types.LocalDBSet, error) {
set := &types.LocalDBSet{}
for _, item := range receiptData.Logs {
switch item.Ty {
case pty.TyLogLotteryCreate, pty.TyLogLotteryBuy, pty.TyLogLotteryDraw, pty.TyLogLotteryClose:
var lotterylog pty.ReceiptLottery
err := types.Decode(item.Log, &lotterylog)
if err != nil {
return nil, err
}
kv := l.deleteLottery(&lotterylog)
set.KV = append(set.KV, kv...)
if item.Ty == pty.TyLogLotteryBuy {
kv := l.deleteLotteryBuy(&lotterylog)
set.KV = append(set.KV, kv...)
} else if item.Ty == pty.TyLogLotteryDraw {
kv := l.deleteLotteryDraw(&lotterylog)
set.KV = append(set.KV, kv...)
kv = l.updateLotteryBuy(&lotterylog, false)
set.KV = append(set.KV, kv...)
kv = l.deleteLotteryGain(&lotterylog)
set.KV = append(set.KV, kv...)
}
}
}
return set, nil
}
// ExecDelLocal_Create Action
func (l *Lottery) ExecDelLocal_Create(payload *pty.LotteryCreate, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return l.execDelLocal(tx, receiptData)
}
// ExecDelLocal_Buy Action
func (l *Lottery) ExecDelLocal_Buy(payload *pty.LotteryBuy, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return l.execDelLocal(tx, receiptData)
}
// ExecDelLocal_Draw Action
func (l *Lottery) ExecDelLocal_Draw(payload *pty.LotteryDraw, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return l.execDelLocal(tx, receiptData)
}
// ExecDelLocal_Close Action
func (l *Lottery) ExecDelLocal_Close(payload *pty.LotteryClose, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
return l.execDelLocal(tx, receiptData)
}