-
Notifications
You must be signed in to change notification settings - Fork 1
/
exec.go
42 lines (37 loc) · 1.28 KB
/
exec.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
// 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 wallet
import (
"github.com/assetcloud/chain/types"
ty "github.com/assetcloud/plugin/plugin/dapp/ticket/types"
)
// On_CloseTickets close ticket
func (policy *ticketPolicy) On_CloseTickets(req *ty.TicketClose) (types.Message, error) {
operater := policy.getWalletOperate()
reply, err := policy.forceCloseTicket(operater.GetBlockHeight()+1, req.MinerAddress)
if err != nil {
bizlog.Error("onCloseTickets", "forceCloseTicket error", err.Error())
} else {
go func() {
if len(reply.Hashes) > 0 {
operater.WaitTxs(reply.Hashes)
FlushTicket(policy.getAPI())
}
}()
}
return reply, err
}
// On_WalletGetTickets get ticket
func (policy *ticketPolicy) On_WalletGetTickets(req *types.ReqNil) (types.Message, error) {
tickets, privs, err := policy.getTicketsByStatus(1)
tks := &ty.ReplyWalletTickets{Tickets: tickets, Privkeys: privs}
return tks, err
}
// On_WalletAutoMiner auto mine
func (policy *ticketPolicy) On_WalletAutoMiner(req *ty.MinerFlag) (types.Message, error) {
policy.store.SetAutoMinerFlag(req.Flag)
policy.setAutoMining(req.Flag)
FlushTicket(policy.getAPI())
return &types.Reply{IsOk: true}, nil
}