private string ParseEndpoint(Protos.Discovery.Peer peerRet) { if (null == Endpoint) { try { Envelope membershipInfo = peerRet.MembershipInfo; ByteString membershipInfoPayloadBytes = membershipInfo.Payload; GossipMessage gossipMessageMemberInfo = GossipMessage.Parser.ParseFrom(membershipInfoPayloadBytes); if (GossipMessage.ContentOneofCase.AliveMsg != gossipMessageMemberInfo.ContentCase) { throw new ArgumentException("Error " + gossipMessageMemberInfo.ContentCase + " Expected AliveMsg"); } AliveMessage aliveMsg = gossipMessageMemberInfo.AliveMsg; Endpoint = aliveMsg.Membership.Endpoint; if (Endpoint != null) { Endpoint = Endpoint.ToLowerInvariant().Trim(); //makes easier on comparing. } } catch (InvalidProtocolBufferException e) { throw new InvalidProtocolBufferRuntimeException(e); } } return(Endpoint); }
private long ParseLedgerHeight(Protos.Discovery.Peer peerRet) { if (-1L == LedgerHeight) { try { Envelope stateInfo = peerRet.StateInfo; GossipMessage stateInfoGossipMessage = GossipMessage.Parser.ParseFrom(stateInfo.Payload); if (stateInfoGossipMessage.ContentCase != GossipMessage.ContentOneofCase.StateInfo) { throw new ArgumentException("Error " + stateInfoGossipMessage.ContentCase + " Expected StateInfo"); } StateInfo stateInfo1 = stateInfoGossipMessage.StateInfo; LedgerHeight = (long)stateInfo1.Properties.LedgerHeight; chaincodesList = stateInfo1.Properties.Chaincodes.ToList(); } catch (InvalidProtocolBufferException e) { throw new InvalidProtocolBufferRuntimeException(e); } } return(LedgerHeight); }
public SDEndorser(Channel channel, Protos.Discovery.Peer peerRet, IEnumerable <byte[]> tlsCerts, IEnumerable <byte[]> tlsIntermediateCerts) { Channel = channel; TLSCerts = tlsCerts.ToList(); TLSIntermediateCerts = tlsIntermediateCerts.ToList(); ParseEndpoint(peerRet); ParseLedgerHeight(peerRet); ParseIdentity(peerRet); }
private void ParseIdentity(Protos.Discovery.Peer peerRet) { try { SerializedIdentity serializedIdentity = SerializedIdentity.Parser.ParseFrom(peerRet.Identity); MspId = serializedIdentity.Mspid; } catch (Exception e) { throw new InvalidProtocolBufferRuntimeException(e); } }