def getABStubForComposeService(self, context, composeService): 'Return a Stub for the supplied composeService, will cache' if composeService in self.atomicBroadcastStubsDict: return self.atomicBroadcastStubsDict[composeService] # Get the IP address of the server that the user registered on root_certificates = self.directory.getTrustedRootsForOrdererNetworkAsPEM() ipAddress, port = bdd_test_util.getPortHostMapping(context.compose_containers, composeService, 7050) # print("ipAddress in getABStubForComposeService == {0}:{1}".format(ipAddress, port)) channel = bdd_grpc_util.getGRPCChannel(ipAddress=ipAddress, port=port, root_certificates=root_certificates, ssl_target_name_override=composeService) newABStub = ab_pb2_grpc.AtomicBroadcastStub(channel) self.atomicBroadcastStubsDict[composeService] = newABStub return newABStub
def getABStubForComposeService(self, context, composeService, port=7050): 'Return a Stub for the supplied composeService, will cache' if composeService in self.atomicBroadcastStubsDict: return self.atomicBroadcastStubsDict[composeService] # Get the IP address of the server that the user registered on root_certificates = self.directory.getTrustedRootsForOrdererNetworkAsPEM() peer_root_certificates = self.directory.getTrustedRootsForPeerNetworkAsPEM() ipAddress, port_to_use = bdd_test_util.getPortHostMapping(context.compose_containers, composeService, port) # print("ipAddress in getABStubForComposeService == {0}:{1}".format(ipAddress, port)) channel = bdd_grpc_util.getGRPCChannel(ipAddress=ipAddress, port=port_to_use, root_certificates="".join([peer_root_certificates, root_certificates]), ssl_target_name_override=composeService) # Added logic to choose between ab.Deliver and events.Deliver for orderer vs peer respectively. newABStub = ab_pb2_grpc.AtomicBroadcastStub(channel) if bootstrap_util.OrdererGensisBlockCompositionCallback.DISCRIMINATOR in composeService else events_pb2_grpc.DeliverStub(channel) self.atomicBroadcastStubsDict[composeService] = newABStub return newABStub