/
context.go
85 lines (70 loc) · 1.34 KB
/
context.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package common
import (
"github.com/jinzhu/gorm"
"github.com/op/go-logging"
)
type Context interface {
GetAppRoot() string
GetLogger() *logging.Logger
GetCoreDB() *gorm.DB
GetPriceDB() *gorm.DB
GetUser() UserContext
SetUser(user UserContext)
GetDebug() bool
GetSSL() bool
GetIPC() string
GetKeystore() string
GetEthereumMode() string
Close()
}
type Ctx struct {
AppRoot string
Logger *logging.Logger
CoreDB *gorm.DB
PriceDB *gorm.DB
User UserContext
Debug bool
SSL bool
IPC string
Keystore string
EthereumMode string
Context
}
func (c *Ctx) GetAppRoot() string {
return c.AppRoot
}
func (c *Ctx) GetLogger() *logging.Logger {
return c.Logger
}
func (c *Ctx) GetCoreDB() *gorm.DB {
return c.CoreDB
}
func (c *Ctx) GetPriceDB() *gorm.DB {
return c.PriceDB
}
func (c *Ctx) GetUser() UserContext {
return c.User
}
func (c *Ctx) SetUser(user UserContext) {
c.User = user
}
func (c *Ctx) GetDebug() bool {
return c.Debug
}
func (c *Ctx) GetSSL() bool {
return c.SSL
}
func (c *Ctx) GetIPC() string {
return c.IPC
}
func (c *Ctx) GetKeystore() string {
return c.Keystore
}
func (c *Ctx) GetEthereumMode() string {
return c.EthereumMode
}
func (c *Ctx) Close() {
c.GetLogger().Debugf("[common.Context] Closing context")
c.GetCoreDB().Close()
c.GetPriceDB().Close()
}