github.com/ewagmig/fabric@v2.1.1+incompatible/gossip/protoext/receivedmessage.go (about)

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package protoext
     8  
     9  import (
    10  	"fmt"
    11  
    12  	"github.com/hyperledger/fabric-protos-go/gossip"
    13  	"github.com/hyperledger/fabric/gossip/api"
    14  	"github.com/hyperledger/fabric/gossip/common"
    15  )
    16  
    17  // ReceivedMessage is a GossipMessage wrapper that
    18  // enables the user to send a message to the origin from which
    19  // the ReceivedMessage was sent from.
    20  // It also allows to know the identity of the sender,
    21  // to obtain the raw bytes the GossipMessage was un-marshaled from,
    22  // and the signature over these raw bytes.
    23  type ReceivedMessage interface {
    24  	// Respond sends a GossipMessage to the origin from which this ReceivedMessage was sent from
    25  	Respond(msg *gossip.GossipMessage)
    26  
    27  	// GetGossipMessage returns the underlying GossipMessage
    28  	GetGossipMessage() *SignedGossipMessage
    29  
    30  	// GetSourceMessage Returns the Envelope the ReceivedMessage was
    31  	// constructed with
    32  	GetSourceEnvelope() *gossip.Envelope
    33  
    34  	// GetConnectionInfo returns information about the remote peer
    35  	// that sent the message
    36  	GetConnectionInfo() *ConnectionInfo
    37  
    38  	// Ack returns to the sender an acknowledgement for the message
    39  	// An ack can receive an error that indicates that the operation related
    40  	// to the message has failed
    41  	Ack(err error)
    42  }
    43  
    44  // ConnectionInfo represents information about
    45  // the remote peer that sent a certain ReceivedMessage
    46  type ConnectionInfo struct {
    47  	ID       common.PKIidType
    48  	Auth     *AuthInfo
    49  	Identity api.PeerIdentityType
    50  	Endpoint string
    51  }
    52  
    53  // String returns a string representation of this ConnectionInfo
    54  func (c *ConnectionInfo) String() string {
    55  	return fmt.Sprintf("%s %v", c.Endpoint, c.ID)
    56  }
    57  
    58  // AuthInfo represents the authentication
    59  // data that was provided by the remote peer
    60  // at the connection time
    61  type AuthInfo struct {
    62  	SignedData []byte
    63  	Signature  []byte
    64  }