github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/network/message_scope.go (about)

     1  package network
     2  
     3  import (
     4  	"github.com/onflow/flow-go/model/flow"
     5  	"github.com/onflow/flow-go/network/channels"
     6  	"github.com/onflow/flow-go/network/message"
     7  )
     8  
     9  // IncomingMessageScope defines the interface for incoming message scopes, i.e., self-contained messages that have been
    10  // received on the wire and are ready to be processed.
    11  type IncomingMessageScope interface {
    12  	// OriginId returns the origin node ID.
    13  	OriginId() flow.Identifier
    14  
    15  	// Proto returns the raw message received.
    16  	Proto() *message.Message
    17  
    18  	// DecodedPayload returns the decoded payload of the message.
    19  	DecodedPayload() interface{}
    20  
    21  	// Protocol returns the type of protocol used to receive the message.
    22  	Protocol() message.ProtocolType
    23  
    24  	// Channel returns the channel of the message.
    25  	Channel() channels.Channel
    26  
    27  	// Size returns the size of the message.
    28  	Size() int
    29  
    30  	// TargetIDs returns the target node IDs, i.e., the intended recipients.
    31  	TargetIDs() flow.IdentifierList
    32  
    33  	// EventID returns the hash of the payload and channel.
    34  	EventID() []byte
    35  
    36  	// PayloadType returns the type of the decoded payload.
    37  	PayloadType() string
    38  }
    39  
    40  // OutgoingMessageScope defines the interface for building outgoing message scopes, i.e., self-contained messages
    41  // that are ready to be sent on the wire.
    42  type OutgoingMessageScope interface {
    43  	// TargetIds returns the target node IDs.
    44  	TargetIds() flow.IdentifierList
    45  
    46  	// Size returns the size of the message.
    47  	Size() int
    48  
    49  	// PayloadType returns the type of the payload to be sent.
    50  	PayloadType() string
    51  
    52  	// Topic returns the topic, i.e., channel-id/spork-id.
    53  	Topic() channels.Topic
    54  
    55  	// Proto returns the raw proto message sent on the wire.
    56  	Proto() *message.Message
    57  }