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