forked from akash-network/provider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
session.go
55 lines (45 loc) · 1.27 KB
/
session.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
package session
import (
"github.com/tendermint/tendermint/libs/log"
aclient "github.com/akash-network/akash-api/go/node/client/v1beta2"
ptypes "github.com/akash-network/akash-api/go/node/provider/v1beta3"
)
// Session interface wraps Log, Client, Provider and ForModule methods
type Session interface {
Log() log.Logger
Client() aclient.Client
Provider() *ptypes.Provider
ForModule(string) Session
CreatedAtBlockHeight() int64
}
// New returns new session instance with provided details
func New(log log.Logger, client aclient.Client, provider *ptypes.Provider, createdAtBlockHeight int64) Session {
return session{
client: client,
provider: provider,
log: log,
createdAtBlockHeight: createdAtBlockHeight,
}
}
type session struct {
client aclient.Client
provider *ptypes.Provider
log log.Logger
createdAtBlockHeight int64
}
func (s session) Log() log.Logger {
return s.log
}
func (s session) Client() aclient.Client {
return s.client
}
func (s session) Provider() *ptypes.Provider {
return s.provider
}
func (s session) ForModule(name string) Session {
s.log = s.log.With("module", name)
return s
}
func (s session) CreatedAtBlockHeight() int64 {
return s.createdAtBlockHeight
}