Documentation ¶
Index ¶
- Constants
- Variables
- func Marshal(msg *GossipMsg) []byte
- func RegisterGossipServer(s grpc.ServiceRegistrar, srv GossipServer)
- type Ack
- type Fingerprint
- type FingerprintDigest
- type GossipClient
- type GossipMsg
- func (*GossipMsg) Descriptor() ([]byte, []int)deprecated
- func (x *GossipMsg) GetOrigin() []byte
- func (x *GossipMsg) GetPayload() []byte
- func (x *GossipMsg) GetSignature() []byte
- func (x *GossipMsg) GetTag() string
- func (x *GossipMsg) GetTimestamp() int64
- func (*GossipMsg) ProtoMessage()
- func (x *GossipMsg) ProtoReflect() protoreflect.Message
- func (x *GossipMsg) Reset()
- func (x *GossipMsg) String() string
- type GossipServer
- type Gossip_StreamClient
- type Gossip_StreamServer
- type Manager
- func (m *Manager) Delete(tag string)
- func (m *Manager) Endpoint(ctx context.Context, msg *GossipMsg) (*Ack, error)
- func (m *Manager) Get(tag string) (*Protocol, bool)
- func (m *Manager) NewGossip(tag string, flags ProtocolFlags, receiver Receiver, ...)
- func (m *Manager) Stream(stream Gossip_StreamServer) error
- type ManagerFlags
- type MessageRecord
- type Protocol
- type ProtocolFlags
- type Receiver
- type SignatureVerification
- type UnimplementedGossipServer
- type UnsafeGossipServer
Constants ¶
const WorkerTimeout = 3 * time.Second
Variables ¶
var File_gossip_proto protoreflect.FileDescriptor
var Gossip_ServiceDesc = grpc.ServiceDesc{ ServiceName: "gossip.Gossip", HandlerType: (*GossipServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Endpoint", Handler: _Gossip_Endpoint_Handler, }, }, Streams: []grpc.StreamDesc{ { StreamName: "Stream", Handler: _Gossip_Stream_Handler, ClientStreams: true, }, }, Metadata: "gossip.proto", }
Gossip_ServiceDesc is the grpc.ServiceDesc for Gossip service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func RegisterGossipServer ¶
func RegisterGossipServer(s grpc.ServiceRegistrar, srv GossipServer)
Types ¶
type Ack ¶
type Ack struct { Error string `protobuf:"bytes,1,opt,name=Error,proto3" json:"Error,omitempty"` // contains filtered or unexported fields }
Generic response message providing an error message from remote servers
func (*Ack) Descriptor
deprecated
func (*Ack) ProtoMessage ¶
func (*Ack) ProtoMessage()
func (*Ack) ProtoReflect ¶
func (x *Ack) ProtoReflect() protoreflect.Message
type Fingerprint ¶
type Fingerprint [16]byte
Defines the type of Gossip message fingerprints hash(tag, origin, payload, signature)
func NewFingerprint ¶
func NewFingerprint(preSum []byte) Fingerprint
NewFingerprint creates a new fingerprint from a byte slice of data
type FingerprintDigest ¶
type FingerprintDigest func(msg *GossipMsg) Fingerprint
Passed into NewGossip to specify how fingerprints will be generated
type GossipClient ¶
type GossipClient interface { Endpoint(ctx context.Context, in *GossipMsg, opts ...grpc.CallOption) (*Ack, error) Stream(ctx context.Context, opts ...grpc.CallOption) (Gossip_StreamClient, error) }
GossipClient is the client API for Gossip service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
func NewGossipClient ¶
func NewGossipClient(cc grpc.ClientConnInterface) GossipClient
type GossipMsg ¶
type GossipMsg struct { Tag string `protobuf:"bytes,1,opt,name=Tag,proto3" json:"Tag,omitempty"` Origin []byte `protobuf:"bytes,2,opt,name=Origin,proto3" json:"Origin,omitempty"` Payload []byte `protobuf:"bytes,3,opt,name=Payload,proto3" json:"Payload,omitempty"` Signature []byte `protobuf:"bytes,4,opt,name=Signature,proto3" json:"Signature,omitempty"` Timestamp int64 `protobuf:"varint,5,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // contains filtered or unexported fields }
Generic message used for a variety of Gossip protocols
func (*GossipMsg) Descriptor
deprecated
func (*GossipMsg) GetPayload ¶
func (*GossipMsg) GetSignature ¶
func (*GossipMsg) GetTimestamp ¶
func (*GossipMsg) ProtoMessage ¶
func (*GossipMsg) ProtoMessage()
func (*GossipMsg) ProtoReflect ¶
func (x *GossipMsg) ProtoReflect() protoreflect.Message
type GossipServer ¶
type GossipServer interface { Endpoint(context.Context, *GossipMsg) (*Ack, error) Stream(Gossip_StreamServer) error // contains filtered or unexported methods }
GossipServer is the server API for Gossip service. All implementations must embed UnimplementedGossipServer for forward compatibility
type Gossip_StreamClient ¶
type Gossip_StreamServer ¶
type Manager ¶
type Manager struct { *UnimplementedGossipServer // contains filtered or unexported fields }
Manager for various GossipProtocols that are accessed by tag
func NewManager ¶
func NewManager(comms *connect.ProtoComms, flags ManagerFlags) *Manager
Creates a new Gossip Manager struct
func (*Manager) NewGossip ¶
func (m *Manager) NewGossip(tag string, flags ProtocolFlags, receiver Receiver, verifier SignatureVerification, peers []*id.ID)
Creates and stores a new Protocol in the Manager
func (*Manager) Stream ¶
func (m *Manager) Stream(stream Gossip_StreamServer) error
Generic streaming endpoint for forwarding GossipMsg to correct Protocol
type ManagerFlags ¶
type ManagerFlags struct { // How long a message record should last in the buffer BufferExpirationTime time.Duration // Frequency with which to check the buffer. // Should be long, since the thread takes a lock each time it checks the buffer MonitorThreadFrequency time.Duration }
func DefaultManagerFlags ¶
func DefaultManagerFlags() ManagerFlags
type MessageRecord ¶
Structure holding messages for a given tag, if the tag does not yet exist If the tag is not created in 5 minutes, the record should be deleted
type Protocol ¶
type Protocol struct { // Marks a Protocol as Defunct such that it will ignore new messages IsDefunct bool // contains filtered or unexported fields }
Generic interface representing various Gossip protocols
func (*Protocol) AddGossipPeer ¶
Adds a peer by ID to the Gossip protocol
func (*Protocol) Defunct ¶
func (p *Protocol) Defunct()
Marks a Protocol as Defunct such that it will ignore new messages
type ProtocolFlags ¶
type ProtocolFlags struct { FanOut uint8 // Default = 0 MaxRecordedFingerprints uint64 // Default = 10000000 MaximumReSends uint64 // Default = 3 NumParallelSends uint32 // Default = 5 MaxGossipAge time.Duration // Default = 10 * time.Second SelfGossip bool // Default = false Fingerprinter FingerprintDigest }
Gossip-related configuration flag
func DefaultProtocolFlags ¶
func DefaultProtocolFlags() ProtocolFlags
Returns a ProtocolFlags object with all flags set to their defaults
type SignatureVerification ¶
Passed into NewGossip to specify how Gossip message signatures will be verified the byte slice will be used to pass in a merkle tree and signature on the trees root for multi-part gossips sent over streaming when streaming is implemented. Ignore it for non streaming implementations.
type UnimplementedGossipServer ¶
type UnimplementedGossipServer struct { }
UnimplementedGossipServer must be embedded to have forward compatible implementations.
func (UnimplementedGossipServer) Stream ¶
func (UnimplementedGossipServer) Stream(Gossip_StreamServer) error
type UnsafeGossipServer ¶
type UnsafeGossipServer interface {
// contains filtered or unexported methods
}
UnsafeGossipServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to GossipServer will result in compilation errors.