github.com/myafeier/fabric@v1.0.1-0.20170722181825-3a4b1f2bce86/gossip/comm/msg.go (about)

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package comm
     8  
     9  import (
    10  	"sync"
    11  
    12  	proto "github.com/hyperledger/fabric/protos/gossip"
    13  )
    14  
    15  // ReceivedMessageImpl is an implementation of ReceivedMessage
    16  type ReceivedMessageImpl struct {
    17  	*proto.SignedGossipMessage
    18  	lock     sync.Locker
    19  	conn     *connection
    20  	connInfo *proto.ConnectionInfo
    21  }
    22  
    23  // GetSourceEnvelope Returns the Envelope the ReceivedMessage was
    24  // constructed with
    25  func (m *ReceivedMessageImpl) GetSourceEnvelope() *proto.Envelope {
    26  	return m.Envelope
    27  }
    28  
    29  // Respond sends a msg to the source that sent the ReceivedMessageImpl
    30  func (m *ReceivedMessageImpl) Respond(msg *proto.GossipMessage) {
    31  	sMsg, err := msg.NoopSign()
    32  	if err != nil {
    33  		m.conn.logger.Error("Failed creating SignedGossipMessage:", err)
    34  		return
    35  	}
    36  	m.conn.send(sMsg, func(e error) {})
    37  }
    38  
    39  // GetGossipMessage returns the inner GossipMessage
    40  func (m *ReceivedMessageImpl) GetGossipMessage() *proto.SignedGossipMessage {
    41  	return m.SignedGossipMessage
    42  }
    43  
    44  // GetConnectionInfo returns information about the remote peer
    45  // that send the message
    46  func (m *ReceivedMessageImpl) GetConnectionInfo() *proto.ConnectionInfo {
    47  	return m.connInfo
    48  }