-
Notifications
You must be signed in to change notification settings - Fork 3
/
controller.go
54 lines (44 loc) · 951 Bytes
/
controller.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
package main
import "github.com/astaxie/beego/logs"
type dispatchType int
const (
s2sType dispatchType = 1 << iota
s2mType
m2sType
n2mType
)
func dispatch() {
// rangeAccount(client)
inputs(client)
spendableCount := len(input)
if spendableCount == 0 {
logs.Error("There is no spendable transaction.")
}
// whether to create transaction recursively
recursionConf := conf.DefaultBool("recursion", DefaultRecursion)
if !isEmpty() {
switch t := getDispatchType(); t {
case m2sType:
m2sTx(recursionConf)
case s2mType:
s2mTx(recursionConf)
case s2sType:
s2sTx(recursionConf)
case n2mType:
n2mTx(recursionConf)
}
}
// output tip message
logs.Info("Create Transactions Complete!\n")
}
func isEmpty() bool {
// stop if no input data
return len(input) == 0
}
func getDispatchType() dispatchType {
dispatch, err := conf.Int("dispatch::type")
if err != nil {
panic(err)
}
return dispatchType(dispatch)
}