heartbeat

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2019 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyPublicKeyList = errors.New("nil or empty public key list")

ErrEmptyPublicKeyList signals that a nil or empty public key list has been provided

View Source
var ErrInvalidMaxDurationPeerUnresponsive = errors.New("invalid max duration to declare the peer unresponsive")

ErrInvalidMaxDurationPeerUnresponsive signals that the duration provided is invalid

View Source
var ErrNilDataToProcess = errors.New("nil data to process")

ErrNilDataToProcess signals that nil data was provided

View Source
var ErrNilKeyGenerator = errors.New("key generator is nil")

ErrNilKeyGenerator is raised when a valid key generator is expected but nil used

View Source
var ErrNilMarshalizer = errors.New("nil marshalizer")

ErrNilMarshalizer signals that a nil marshalizer has been provided

View Source
var ErrNilMessage = errors.New("nil message")

ErrNilMessage signals that a nil message has been received

View Source
var ErrNilMessenger = errors.New("nil P2P Messenger")

ErrNilMessenger signals that a nil p2p messenger has been provided

View Source
var ErrNilPrivateKey = errors.New("nil private key")

ErrNilPrivateKey signals that a nil private key has been provided

View Source
var ErrNilSingleSigner = errors.New("nil single signer")

ErrNilSingleSigner signals that a nil single signer has been provided

Functions

This section is empty.

Types

type Duration

type Duration struct {
	time.Duration
}

Duration is a wrapper of the original Duration struct that has JSON marshal and unmarshal capabilities golang issue: https://github.com/golang/go/issues/10275

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

MarshalJSON is called when a json marshal is triggered on this field

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(b []byte) error

UnmarshalJSON is called when a json unmarshal is triggered on this field

type Heartbeat

type Heartbeat struct {
	Payload   []byte
	Pubkey    []byte
	Signature []byte
}

Heartbeat represents the heartbeat message that is sent between peers

type Monitor

type Monitor struct {
	// contains filtered or unexported fields
}

Monitor represents the heartbeat component that processes received heartbeat messages

func NewMonitor

func NewMonitor(
	peerMessenger PeerMessenger,
	singleSigner crypto.SingleSigner,
	keygen crypto.KeyGenerator,
	marshalizer marshal.Marshalizer,
	maxDurationPeerUnresponsive time.Duration,
	pubKeyList []string,
) (*Monitor, error)

NewMonitor returns a new monitor instance

func (*Monitor) GetHeartbeats

func (m *Monitor) GetHeartbeats() []PubKeyHeartbeat

GetHeartbeats returns the heartbeat status

func (*Monitor) ProcessReceivedMessage

func (m *Monitor) ProcessReceivedMessage(message p2p.MessageP2P) error

ProcessReceivedMessage satisfies the p2p.MessageProcessor interface so it can be called by the p2p subsystem each time a new heartbeat message arrives

type PeerHeartbeat added in v1.0.3

type PeerHeartbeat struct {
	P2PAddress      string
	TimeStamp       time.Time
	MaxInactiveTime Duration
	IsActive        bool
}

PeerHeartbeat represents the status of a received message from a p2p address

type PeerMessenger

type PeerMessenger interface {
	Broadcast(topic string, buff []byte)
	PeerAddress(pid p2p.PeerID) string
}

PeerMessenger defines a subset of the p2p.Messenger interface

type PubKeyHeartbeat

type PubKeyHeartbeat struct {
	HexPublicKey   string
	PeerHeartBeats []PeerHeartbeat
}

PubKeyHeartbeat returns the heartbeat status for the public key

type Sender

type Sender struct {
	// contains filtered or unexported fields
}

Sender periodically sends heartbeat messages on a pubsub topic

func NewSender

func NewSender(
	peerMessenger PeerMessenger,
	singleSigner crypto.SingleSigner,
	privKey crypto.PrivateKey,
	marshalizer marshal.Marshalizer,
	topic string,
) (*Sender, error)

NewSender will create a new sender instance

func (*Sender) SendHeartbeat

func (s *Sender) SendHeartbeat() error

SendHeartbeat broadcasts a new heartbeat message

Jump to

Keyboard shortcuts

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