@@ -25,11 +25,15 @@ import (
25
25
"github.com/hyperledger/fabric/gossip/api"
26
26
gossipCommon "github.com/hyperledger/fabric/gossip/common"
27
27
"github.com/hyperledger/fabric/gossip/gossip"
28
+ "github.com/hyperledger/fabric/gossip/identity"
28
29
"github.com/hyperledger/fabric/gossip/integration"
29
30
"github.com/hyperledger/fabric/gossip/state"
30
31
"github.com/hyperledger/fabric/gossip/util"
32
+ "github.com/hyperledger/fabric/peer/gossip/mcs"
33
+ "github.com/hyperledger/fabric/peer/gossip/sa"
31
34
"github.com/hyperledger/fabric/protos/common"
32
35
proto "github.com/hyperledger/fabric/protos/gossip"
36
+ "github.com/spf13/viper"
33
37
"google.golang.org/grpc"
34
38
)
35
39
@@ -74,6 +78,8 @@ type gossipServiceImpl struct {
74
78
deliveryService deliverclient.DeliverService
75
79
deliveryFactory DeliveryServiceFactory
76
80
lock sync.RWMutex
81
+ msgCrypto identity.Mapper
82
+ peerIdentity []byte
77
83
}
78
84
79
85
// This is an implementation of api.JoinChannelMessage.
@@ -93,13 +99,13 @@ func (jcm *joinChannelMessage) AnchorPeers() []api.AnchorPeer {
93
99
var logger = util .GetLogger (util .LoggingServiceModule , "" )
94
100
95
101
// InitGossipService initialize gossip service
96
- func InitGossipService (identity []byte , endpoint string , s * grpc.Server , bootPeers ... string ) {
97
- InitGossipServiceCustomDeliveryFactory (identity , endpoint , s , & deliveryFactoryImpl {}, bootPeers ... )
102
+ func InitGossipService (peerIdentity []byte , endpoint string , s * grpc.Server , bootPeers ... string ) {
103
+ InitGossipServiceCustomDeliveryFactory (peerIdentity , endpoint , s , & deliveryFactoryImpl {}, bootPeers ... )
98
104
}
99
105
100
106
// InitGossipService initialize gossip service with customize delivery factory
101
107
// implementation, might be useful for testing and mocking purposes
102
- func InitGossipServiceCustomDeliveryFactory (identity []byte , endpoint string , s * grpc.Server , factory DeliveryServiceFactory , bootPeers ... string ) {
108
+ func InitGossipServiceCustomDeliveryFactory (peerIdentity []byte , endpoint string , s * grpc.Server , factory DeliveryServiceFactory , bootPeers ... string ) {
103
109
once .Do (func () {
104
110
logger .Info ("Initialize gossip with endpoint" , endpoint , "and bootstrap set" , bootPeers )
105
111
dialOpts := []grpc.DialOption {}
@@ -109,11 +115,29 @@ func InitGossipServiceCustomDeliveryFactory(identity []byte, endpoint string, s
109
115
dialOpts = append (dialOpts , grpc .WithInsecure ())
110
116
}
111
117
112
- gossip := integration .NewGossipComponent (identity , endpoint , s , dialOpts , bootPeers ... )
118
+ cryptSvc := mcs .NewMessageCryptoService ()
119
+ secAdv := sa .NewSecurityAdvisor ()
120
+
121
+ if overrideEndpoint := viper .GetString ("peer.gossip.endpoint" ); overrideEndpoint != "" {
122
+ endpoint = overrideEndpoint
123
+ }
124
+
125
+ if viper .GetBool ("peer.gossip.ignoreSecurity" ) {
126
+ sec := & secImpl {[]byte (endpoint )}
127
+ cryptSvc = sec
128
+ secAdv = sec
129
+ peerIdentity = []byte (endpoint )
130
+ }
131
+
132
+ idMapper := identity .NewIdentityMapper (cryptSvc )
133
+
134
+ gossip := integration .NewGossipComponent (peerIdentity , endpoint , s , secAdv , cryptSvc , idMapper , dialOpts , bootPeers ... )
113
135
gossipServiceInstance = & gossipServiceImpl {
114
136
gossipSvc : gossip ,
115
137
chains : make (map [string ]state.GossipStateProvider ),
116
138
deliveryFactory : factory ,
139
+ msgCrypto : idMapper ,
140
+ peerIdentity : peerIdentity ,
117
141
}
118
142
})
119
143
}
@@ -196,3 +220,35 @@ func (g *gossipServiceImpl) Stop() {
196
220
g .deliveryService .Stop ()
197
221
}
198
222
}
223
+
224
+ type secImpl struct {
225
+ identity []byte
226
+ }
227
+
228
+ func (* secImpl ) OrgByPeerIdentity (api.PeerIdentityType ) api.OrgIdentityType {
229
+ return api .OrgIdentityType ("DEFAULT" )
230
+ }
231
+
232
+ func (s * secImpl ) GetPKIidOfCert (peerIdentity api.PeerIdentityType ) gossipCommon.PKIidType {
233
+ return gossipCommon .PKIidType (peerIdentity )
234
+ }
235
+
236
+ func (s * secImpl ) VerifyBlock (chainID gossipCommon.ChainID , signedBlock api.SignedBlock ) error {
237
+ return nil
238
+ }
239
+
240
+ func (s * secImpl ) Sign (msg []byte ) ([]byte , error ) {
241
+ return msg , nil
242
+ }
243
+
244
+ func (s * secImpl ) Verify (peerIdentity api.PeerIdentityType , signature , message []byte ) error {
245
+ return nil
246
+ }
247
+
248
+ func (s * secImpl ) VerifyByChannel (chainID gossipCommon.ChainID , peerIdentity api.PeerIdentityType , signature , message []byte ) error {
249
+ return nil
250
+ }
251
+
252
+ func (s * secImpl ) ValidateIdentity (peerIdentity api.PeerIdentityType ) error {
253
+ return nil
254
+ }
0 commit comments