github.com/adnan-c/fabric_e2e_couchdb@v0.6.1-preview.0.20170228180935-21ce6b23cf91/gossip/comm/msg.go (about) 1 /* 2 Copyright IBM Corp. 2016 All Rights Reserved. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package comm 18 19 import ( 20 "sync" 21 22 "github.com/hyperledger/fabric/gossip/common" 23 proto "github.com/hyperledger/fabric/protos/gossip" 24 ) 25 26 // ReceivedMessageImpl is an implementation of ReceivedMessage 27 type ReceivedMessageImpl struct { 28 *proto.SignedGossipMessage 29 lock sync.Locker 30 conn *connection 31 } 32 33 // GetSourceEnvelope Returns the Envelope the ReceivedMessage was 34 // constructed with 35 func (m *ReceivedMessageImpl) GetSourceEnvelope() *proto.Envelope { 36 return m.Envelope 37 } 38 39 // Respond sends a msg to the source that sent the ReceivedMessageImpl 40 func (m *ReceivedMessageImpl) Respond(msg *proto.GossipMessage) { 41 m.conn.send(msg.NoopSign(), func(e error) {}) 42 } 43 44 // GetGossipMessage returns the inner GossipMessage 45 func (m *ReceivedMessageImpl) GetGossipMessage() *proto.SignedGossipMessage { 46 return m.SignedGossipMessage 47 } 48 49 // GetPKIID returns the PKI-ID of the remote peer 50 // that sent the message 51 func (m *ReceivedMessageImpl) GetPKIID() common.PKIidType { 52 return m.conn.pkiID 53 }