@@ -28,6 +28,7 @@ import (
28
28
"crypto/tls"
29
29
"os"
30
30
31
+ "github.com/hyperledger/fabric/gossip/common"
31
32
"github.com/hyperledger/fabric/gossip/proto"
32
33
"github.com/hyperledger/fabric/gossip/util"
33
34
"github.com/op/go-logging"
@@ -62,7 +63,7 @@ func (c *commImpl) SetDialOpts(opts ...grpc.DialOption) {
62
63
}
63
64
64
65
// NewCommInstanceWithServer creates a comm instance that creates an underlying gRPC server
65
- func NewCommInstanceWithServer (port int , sec SecurityProvider , pkID PKIidType , dialOpts ... grpc.DialOption ) (Comm , error ) {
66
+ func NewCommInstanceWithServer (port int , sec SecurityProvider , pkID common. PKIidType , dialOpts ... grpc.DialOption ) (Comm , error ) {
66
67
var ll net.Listener
67
68
var s * grpc.Server
68
69
var secOpt grpc.DialOption
@@ -86,11 +87,11 @@ func NewCommInstanceWithServer(port int, sec SecurityProvider, pkID PKIidType, d
86
87
gSrv : s ,
87
88
msgPublisher : NewChannelDemultiplexer (),
88
89
lock : & sync.RWMutex {},
89
- deadEndpoints : make (chan PKIidType , 100 ),
90
+ deadEndpoints : make (chan common. PKIidType , 100 ),
90
91
stopping : int32 (0 ),
91
92
exitChan : make (chan struct {}, 1 ),
92
93
subscriptions : make ([]chan ReceivedMessage , 0 ),
93
- blackListedPKIIDs : make ([]PKIidType , 0 ),
94
+ blackListedPKIIDs : make ([]common. PKIidType , 0 ),
94
95
}
95
96
commInst .connStore = newConnStore (commInst , pkID , commInst .logger )
96
97
@@ -112,7 +113,7 @@ func NewCommInstanceWithServer(port int, sec SecurityProvider, pkID PKIidType, d
112
113
}
113
114
114
115
// NewCommInstance creates a new comm instance that binds itself to the given gRPC server
115
- func NewCommInstance (s * grpc.Server , sec SecurityProvider , PKIID PKIidType , dialOpts ... grpc.DialOption ) (Comm , error ) {
116
+ func NewCommInstance (s * grpc.Server , sec SecurityProvider , PKIID common. PKIidType , dialOpts ... grpc.DialOption ) (Comm , error ) {
116
117
commInst , err := NewCommInstanceWithServer (- 1 , sec , PKIID )
117
118
if err != nil {
118
119
return nil , err
@@ -128,7 +129,7 @@ type commImpl struct {
128
129
connStore * connectionStore
129
130
PKIID []byte
130
131
port int
131
- deadEndpoints chan PKIidType
132
+ deadEndpoints chan common. PKIidType
132
133
msgPublisher * ChannelDeMultiplexer
133
134
lock * sync.RWMutex
134
135
lsnr net.Listener
@@ -137,10 +138,10 @@ type commImpl struct {
137
138
stopping int32
138
139
stopWG sync.WaitGroup
139
140
subscriptions []chan ReceivedMessage
140
- blackListedPKIIDs []PKIidType
141
+ blackListedPKIIDs []common. PKIidType
141
142
}
142
143
143
- func (c * commImpl ) createConnection (endpoint string , expectedPKIID PKIidType ) (* connection , error ) {
144
+ func (c * commImpl ) createConnection (endpoint string , expectedPKIID common. PKIidType ) (* connection , error ) {
144
145
c .logger .Debug ("Entering" , endpoint , expectedPKIID )
145
146
defer c .logger .Debug ("Exiting" )
146
147
if c .isStopping () {
@@ -204,7 +205,7 @@ func (c *commImpl) Send(msg *proto.GossipMessage, peers ...*RemotePeer) {
204
205
}
205
206
}
206
207
207
- func (c * commImpl ) BlackListPKIid (PKIID PKIidType ) {
208
+ func (c * commImpl ) BlackListPKIid (PKIID common. PKIidType ) {
208
209
c .logger .Info ("Entering" , PKIID )
209
210
defer c .logger .Info ("Exiting" )
210
211
c .lock .Lock ()
@@ -213,7 +214,7 @@ func (c *commImpl) BlackListPKIid(PKIID PKIidType) {
213
214
c .blackListedPKIIDs = append (c .blackListedPKIIDs , PKIID )
214
215
}
215
216
216
- func (c * commImpl ) isPKIblackListed (p PKIidType ) bool {
217
+ func (c * commImpl ) isPKIblackListed (p common. PKIidType ) bool {
217
218
c .lock .RLock ()
218
219
defer c .lock .RUnlock ()
219
220
for _ , pki := range c .blackListedPKIIDs {
@@ -251,7 +252,7 @@ func (c *commImpl) isStopping() bool {
251
252
return atomic .LoadInt32 (& c .stopping ) == int32 (1 )
252
253
}
253
254
254
- func (c * commImpl ) Probe (endpoint string , pkiID PKIidType ) error {
255
+ func (c * commImpl ) Probe (endpoint string , pkiID common. PKIidType ) error {
255
256
if c .isStopping () {
256
257
return fmt .Errorf ("Stopping!" )
257
258
}
@@ -274,7 +275,7 @@ func (c *commImpl) Probe(endpoint string, pkiID PKIidType) error {
274
275
return err
275
276
}
276
277
277
- func (c * commImpl ) Accept (acceptor util .MessageAcceptor ) <- chan ReceivedMessage {
278
+ func (c * commImpl ) Accept (acceptor common .MessageAcceptor ) <- chan ReceivedMessage {
278
279
genericChan := c .msgPublisher .AddChannel (acceptor )
279
280
specificChan := make (chan ReceivedMessage , 10 )
280
281
@@ -311,7 +312,7 @@ func (c *commImpl) Accept(acceptor util.MessageAcceptor) <-chan ReceivedMessage
311
312
return specificChan
312
313
}
313
314
314
- func (c * commImpl ) PresumedDead () <- chan PKIidType {
315
+ func (c * commImpl ) PresumedDead () <- chan common. PKIidType {
315
316
return c .deadEndpoints
316
317
}
317
318
@@ -351,7 +352,7 @@ func (c *commImpl) Stop() {
351
352
c .stopWG .Wait ()
352
353
}
353
354
354
- func (c * commImpl ) GetPKIid () PKIidType {
355
+ func (c * commImpl ) GetPKIid () common. PKIidType {
355
356
return c .PKIID
356
357
}
357
358
@@ -366,7 +367,7 @@ func extractRemoteAddress(stream stream) string {
366
367
return remoteAddress
367
368
}
368
369
369
- func (c * commImpl ) authenticateRemotePeer (stream stream ) (PKIidType , error ) {
370
+ func (c * commImpl ) authenticateRemotePeer (stream stream ) (common. PKIidType , error ) {
370
371
ctx := stream .Context ()
371
372
remoteAddress := extractRemoteAddress (stream )
372
373
tlsUnique := ExtractTLSUnique (ctx )
@@ -455,7 +456,7 @@ func (c *commImpl) Ping(context.Context, *proto.Empty) (*proto.Empty, error) {
455
456
return & proto.Empty {}, nil
456
457
}
457
458
458
- func (c * commImpl ) disconnect (pkiID PKIidType ) {
459
+ func (c * commImpl ) disconnect (pkiID common. PKIidType ) {
459
460
if c .isStopping () {
460
461
return
461
462
}
@@ -485,7 +486,7 @@ func readWithTimeout(stream interface{}, timeout time.Duration) *proto.GossipMes
485
486
}
486
487
}
487
488
488
- func createConnectionMsg (pkiID PKIidType , sig []byte ) * proto.GossipMessage {
489
+ func createConnectionMsg (pkiID common. PKIidType , sig []byte ) * proto.GossipMessage {
489
490
return & proto.GossipMessage {
490
491
Nonce : 0 ,
491
492
Content : & proto.GossipMessage_Conn {
0 commit comments