github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/network/message/protocols.go (about) 1 package message 2 3 const ( 4 // ProtocolTypeUnicast is protocol type for unicast messages. 5 ProtocolTypeUnicast ProtocolType = "unicast" 6 // ProtocolTypePubSub is the protocol type for pubsub messages. 7 ProtocolTypePubSub ProtocolType = "pubsub" 8 ) 9 10 // ProtocolType defines the type of the protocol a message is sent over. Currently, we have two types of protocols: 11 // - unicast: a message is sent to a single node through a direct connection. 12 // - pubsub: a message is sent to one or more nodes through a pubsub channel. 13 type ProtocolType string 14 15 func (m ProtocolType) String() string { 16 return string(m) 17 } 18 19 type Protocols []ProtocolType 20 21 // Contains returns true if the protocol is in the list of Protocols. 22 func (pr Protocols) Contains(protocol ProtocolType) bool { 23 for _, p := range pr { 24 if p == protocol { 25 return true 26 } 27 } 28 29 return false 30 }