forked from hiero-ledger/hiero-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
channel.go
79 lines (62 loc) · 1.77 KB
/
channel.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
package hedera
import (
"github.com/hashgraph/hedera-sdk-go/v2/proto"
"google.golang.org/grpc"
)
type channel struct {
crypto proto.CryptoServiceClient
file proto.FileServiceClient
contract proto.SmartContractServiceClient
topic proto.ConsensusServiceClient
freeze proto.FreezeServiceClient
network proto.NetworkServiceClient
token proto.TokenServiceClient
client *grpc.ClientConn
}
func newChannel(client *grpc.ClientConn) channel {
return channel{
client: client,
}
}
func (channel channel) getCrypto() proto.CryptoServiceClient {
if channel.crypto == nil {
channel.crypto = proto.NewCryptoServiceClient(channel.client)
}
return channel.crypto
}
func (channel channel) getFile() proto.FileServiceClient {
if channel.file == nil {
channel.file = proto.NewFileServiceClient(channel.client)
}
return channel.file
}
func (channel channel) getContract() proto.SmartContractServiceClient {
if channel.contract == nil {
channel.contract = proto.NewSmartContractServiceClient(channel.client)
}
return channel.contract
}
func (channel channel) getTopic() proto.ConsensusServiceClient {
if channel.topic == nil {
channel.topic = proto.NewConsensusServiceClient(channel.client)
}
return channel.topic
}
func (channel channel) getFreeze() proto.FreezeServiceClient {
if channel.freeze == nil {
channel.freeze = proto.NewFreezeServiceClient(channel.client)
}
return channel.freeze
}
func (channel channel) getNetwork() proto.NetworkServiceClient {
if channel.network == nil {
channel.network = proto.NewNetworkServiceClient(channel.client)
}
return channel.network
}
func (channel channel) getToken() proto.TokenServiceClient {
if channel.token == nil {
channel.token = proto.NewTokenServiceClient(channel.client)
}
return channel.token
}