@@ -12,34 +12,46 @@ import (
12
12
"github.com/hyperledger/fabric/cmd/common"
13
13
"github.com/hyperledger/fabric/cmd/common/comm"
14
14
"github.com/hyperledger/fabric/cmd/common/signer"
15
- discovery "github.com/hyperledger/fabric/discovery/client"
16
- . "github.com/hyperledger/fabric/protos/discovery"
15
+ discoveryclient "github.com/hyperledger/fabric/discovery/client"
16
+ "github.com/hyperledger/fabric/protos/discovery"
17
17
"github.com/hyperledger/fabric/protoutil"
18
18
"github.com/pkg/errors"
19
19
)
20
20
21
- //go:generate mockery -dir ../client/ -name LocalResponse -case underscore -output mocks/
22
- //go:generate mockery -dir ../client/ -name ChannelResponse -case underscore -output mocks/
21
+ //go:generate mockery -dir . -name LocalResponse -case underscore -output mocks/
22
+
23
+ // LocalResponse is the local interface used to generate mocks for foreign interface.
24
+ type LocalResponse interface {
25
+ discoveryclient.LocalResponse
26
+ }
27
+
28
+ //go:generate mockery -dir . -name ChannelResponse -case underscore -output mocks/
29
+
30
+ // ChannelResponse is the local interface used to generate mocks for foreign interface.
31
+ type ChannelResponse interface {
32
+ discoveryclient.ChannelResponse
33
+ }
34
+
23
35
//go:generate mockery -dir . -name ServiceResponse -case underscore -output mocks/
24
36
25
37
// ServiceResponse represents a response sent from the discovery service
26
38
type ServiceResponse interface {
27
39
// ForChannel returns a ChannelResponse in the context of a given channel
28
- ForChannel (string ) discovery .ChannelResponse
40
+ ForChannel (string ) discoveryclient .ChannelResponse
29
41
30
42
// ForLocal returns a LocalResponse in the context of no channel
31
- ForLocal () discovery .LocalResponse
43
+ ForLocal () discoveryclient .LocalResponse
32
44
33
45
// Raw returns the raw response from the server
34
- Raw () * Response
46
+ Raw () * discovery. Response
35
47
}
36
48
37
49
type response struct {
38
- raw * Response
39
- discovery .Response
50
+ raw * discovery. Response
51
+ discoveryclient .Response
40
52
}
41
53
42
- func (r * response ) Raw () * Response {
54
+ func (r * response ) Raw () * discovery. Response {
43
55
return r .raw
44
56
}
45
57
@@ -49,7 +61,7 @@ type ClientStub struct {
49
61
}
50
62
51
63
// Send sends the request, and receives a response
52
- func (stub * ClientStub ) Send (server string , conf common.Config , req * discovery .Request ) (ServiceResponse , error ) {
64
+ func (stub * ClientStub ) Send (server string , conf common.Config , req * discoveryclient .Request ) (ServiceResponse , error ) {
53
65
comm , err := comm .NewClient (conf .TLSConfig )
54
66
if err != nil {
55
67
return nil , err
@@ -61,9 +73,9 @@ func (stub *ClientStub) Send(server string, conf common.Config, req *discovery.R
61
73
timeout , cancel := context .WithTimeout (context .Background (), defaultTimeout )
62
74
defer cancel ()
63
75
64
- disc := discovery .NewClient (comm .NewDialer (server ), signer .Sign , 0 )
76
+ disc := discoveryclient .NewClient (comm .NewDialer (server ), signer .Sign , 0 )
65
77
66
- resp , err := disc .Send (timeout , req , & AuthInfo {
78
+ resp , err := disc .Send (timeout , req , & discovery. AuthInfo {
67
79
ClientIdentity : signer .Creator ,
68
80
ClientTlsCertHash : comm .TLSCertHash ,
69
81
})
@@ -81,7 +93,7 @@ type RawStub struct {
81
93
}
82
94
83
95
// Send sends the request, and receives a response
84
- func (stub * RawStub ) Send (server string , conf common.Config , req * discovery .Request ) (ServiceResponse , error ) {
96
+ func (stub * RawStub ) Send (server string , conf common.Config , req * discoveryclient .Request ) (ServiceResponse , error ) {
85
97
comm , err := comm .NewClient (conf .TLSConfig )
86
98
if err != nil {
87
99
return nil , err
@@ -93,7 +105,7 @@ func (stub *RawStub) Send(server string, conf common.Config, req *discovery.Requ
93
105
timeout , cancel := context .WithTimeout (context .Background (), defaultTimeout )
94
106
defer cancel ()
95
107
96
- req .Authentication = & AuthInfo {
108
+ req .Authentication = & discovery. AuthInfo {
97
109
ClientIdentity : signer .Creator ,
98
110
ClientTlsCertHash : comm .TLSCertHash ,
99
111
}
@@ -108,7 +120,7 @@ func (stub *RawStub) Send(server string, conf common.Config, req *discovery.Requ
108
120
if err != nil {
109
121
return nil , err
110
122
}
111
- resp , err := NewDiscoveryClient (cc ).Discover (timeout , & SignedRequest {
123
+ resp , err := discovery . NewDiscoveryClient (cc ).Discover (timeout , & discovery. SignedRequest {
112
124
Payload : payload ,
113
125
Signature : sig ,
114
126
})
0 commit comments