gossip

package
v0.0.0-...-a56bd7b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func (*GossipMessage) GetPullMsgType

func (m *GossipMessage) GetPullMsgType() PullMsgType

GetPullMsgType returns the phase of the pull mechanism this GossipMessage belongs to for example: Hello, Digest, etc. If this isn't a pull message, PullMsgType_UNDEFINED is returned.

func (*GossipMessage) IsAliveMsg

func (m *GossipMessage) IsAliveMsg() bool

IsAliveMsg returns whether this GossipMessage is an AliveMessage

func (*GossipMessage) IsChannelRestricted

func (m *GossipMessage) IsChannelRestricted() bool

IsChannelRestricted returns whether this GossipMessage should be routed only in its channel

func (*GossipMessage) IsDataMsg

func (m *GossipMessage) IsDataMsg() bool

IsDataMsg returns whether this GossipMessage is a data message

func (*GossipMessage) IsDataReq

func (m *GossipMessage) IsDataReq() bool

IsDataReq returns whether this GossipMessage is a data request message

func (*GossipMessage) IsDataUpdate

func (m *GossipMessage) IsDataUpdate() bool

IsDataUpdate returns whether this GossipMessage is a data update message

func (*GossipMessage) IsDigestMsg

func (m *GossipMessage) IsDigestMsg() bool

IsDigestMsg returns whether this GossipMessage is a digest message

func (*GossipMessage) IsHelloMsg

func (m *GossipMessage) IsHelloMsg() bool

IsHelloMsg returns whether this GossipMessage is a hello message

func (*GossipMessage) IsIdentityMsg

func (m *GossipMessage) IsIdentityMsg() bool

IsIdentityMsg returns whether this GossipMessage is an identity message

func (*GossipMessage) IsLeadershipMsg

func (m *GossipMessage) IsLeadershipMsg() bool

IsLeadershipMsg returns whether this GossipMessage is a leadership (leader election) message

func (*GossipMessage) IsOrgRestricted

func (m *GossipMessage) IsOrgRestricted() bool

IsOrgRestricted returns whether this GossipMessage should be routed only inside the organization

func (*GossipMessage) IsPullMsg

func (m *GossipMessage) IsPullMsg() bool

IsPullMsg returns whether this GossipMessage is a message that belongs to the pull mechanism

func (*GossipMessage) IsRemoteStateMessage

func (m *GossipMessage) IsRemoteStateMessage() bool

IsRemoteStateMessage returns whether this GossipMessage is related to state synchronization

func (*GossipMessage) IsStateInfoMsg

func (m *GossipMessage) IsStateInfoMsg() bool

IsStateInfoMsg returns whether this GossipMessage is a stateInfo message

func (*GossipMessage) IsStateInfoPullRequestMsg

func (m *GossipMessage) IsStateInfoPullRequestMsg() bool

IsStateInfoPullRequestMsg returns whether this GossipMessage is a stateInfoPullRequest

func (*GossipMessage) IsStateInfoSnapshot

func (m *GossipMessage) IsStateInfoSnapshot() bool

IsStateInfoSnapshot returns whether this GossipMessage is a stateInfo snapshot

func (*GossipMessage) IsTagLegal

func (m *GossipMessage) IsTagLegal() error

IsTagLegal checks the GossipMessage tags and inner type and returns an error if the tag doesn't match the type.

func NewGossipMessageComparator

func NewGossipMessageComparator(dataBlockStorageSize int) common.MessageReplacingPolicy

NewGossipMessageComparator creates a MessageReplacingPolicy given a maximum number of blocks to hold

func (*GossipMessage) NoopSign

func (m *GossipMessage) NoopSign() (*SignedGossipMessage, error)

NoopSign creates a SignedGossipMessage with a nil signature

func (*Envelope) SignSecret

func (e *Envelope) SignSecret(signer Signer, secret *Secret) error

SignSecret signs the secret payload and creates a secret envelope out of it.

func (*Envelope) ToGossipMessage

func (e *Envelope) ToGossipMessage() (*SignedGossipMessage, error)

ToGossipMessage un-marshals a given envelope and creates a SignedGossipMessage out of it. Returns an error if un-marshaling fails.

Types

type AuthInfo

type AuthInfo struct {
	SignedData []byte
	Signature  []byte
}

AuthInfo represents the authentication data that was provided by the remote peer at the connection time

type ConnectionInfo

type ConnectionInfo struct {
	ID       common.PKIidType
	Auth     *AuthInfo
	Identity api.PeerIdentityType
	Endpoint string
}

ConnectionInfo represents information about the remote peer that sent a certain ReceivedMessage

func (*ConnectionInfo) IsAuthenticated

func (c *ConnectionInfo) IsAuthenticated() bool

IsAuthenticated returns whether the connection to the remote peer was authenticated when the handshake took place

func (*ConnectionInfo) String

func (c *ConnectionInfo) String() string

String returns a string representation of this ConnectionInfo

type IdentifierExtractor

type IdentifierExtractor func(*SignedGossipMessage) string

IdentifierExtractor extracts from a SignedGossipMessage an identifier

type MsgConsumer

type MsgConsumer func(message *SignedGossipMessage)

MsgConsumer invokes code given a SignedGossipMessage

type ReceivedMessage

type ReceivedMessage interface {

	// Respond sends a GossipMessage to the origin from which this ReceivedMessage was sent from
	Respond(msg *GossipMessage)

	// GetGossipMessage returns the underlying GossipMessage
	GetGossipMessage() *SignedGossipMessage

	// GetSourceMessage Returns the Envelope the ReceivedMessage was
	// constructed with
	GetSourceEnvelope() *Envelope

	// GetConnectionInfo returns information about the remote peer
	// that sent the message
	GetConnectionInfo() *ConnectionInfo
}

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 SignedGossipMessage

type SignedGossipMessage struct {
	*Envelope
	*GossipMessage
}

SignedGossipMessage contains a GossipMessage and the Envelope from which it came from

func (*SignedGossipMessage) IsSigned

func (m *SignedGossipMessage) IsSigned() bool

IsSigned returns whether the message has a signature in the envelope.

func (*SignedGossipMessage) Sign

func (m *SignedGossipMessage) Sign(signer Signer) (*Envelope, error)

Sign signs a GossipMessage with given Signer. Returns an Envelope on success, panics on failure.

func (*SignedGossipMessage) String

func (m *SignedGossipMessage) String() string

String returns a string representation of a SignedGossipMessage

func (*SignedGossipMessage) Verify

func (m *SignedGossipMessage) Verify(peerIdentity []byte, verify Verifier) error

Verify verifies a signed GossipMessage with a given Verifier. Returns nil on success, error on failure.

type Signer

type Signer func(msg []byte) ([]byte, error)

Signer signs a message, and returns (signature, nil) on success, and nil and an error on failure.

type Verifier

type Verifier func(peerIdentity []byte, signature, message []byte) error

Verifier receives a peer identity, a signature and a message and returns nil if the signature on the message could be verified using the given identity.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL