pulsar

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2018 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPulse

func NewPulse(numberDelta uint32, previousPulseNumber core.PulseNumber, entropyGenerator EntropyGenerator) *core.Pulse

NewPulse creates a new pulse with using of custom GeneratedEntropy Generator

Types

type BftCell added in v0.4.0

type BftCell struct {
	Sign              []byte
	Entropy           core.Entropy
	IsEntropyReceived bool
}

type EntropyGenerator

type EntropyGenerator interface {
	GenerateEntropy() core.Entropy
}

type EntropyPayload added in v0.4.0

type EntropyPayload struct {
	PulseNumber core.PulseNumber
	Entropy     core.Entropy
}

type EntropySignaturePayload added in v0.4.0

type EntropySignaturePayload struct {
	PulseNumber core.PulseNumber
	Signature   []byte
}

type GetLastPulsePayload added in v0.4.0

type GetLastPulsePayload struct {
	core.Pulse
}

type Handler added in v0.3.0

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

func (*Handler) GetLastPulseNumber added in v0.4.0

func (handler *Handler) GetLastPulseNumber(request *Payload, response *Payload) error

func (*Handler) HealthCheck added in v0.4.0

func (handler *Handler) HealthCheck(request *Payload, response *Payload) error

func (*Handler) MakeHandshake added in v0.3.0

func (handler *Handler) MakeHandshake(request *Payload, response *Payload) error

func (*Handler) ReceiveChosenSignature added in v0.4.0

func (handler *Handler) ReceiveChosenSignature(request *Payload, response *Payload) error

func (*Handler) ReceiveEntropy added in v0.4.0

func (handler *Handler) ReceiveEntropy(request *Payload, response *Payload) error

func (*Handler) ReceiveSignatureForEntropy added in v0.4.0

func (handler *Handler) ReceiveSignatureForEntropy(request *Payload, response *Payload) error

func (*Handler) ReceiveVector added in v0.4.0

func (handler *Handler) ReceiveVector(request *Payload, response *Payload) error

type HandshakePayload added in v0.3.0

type HandshakePayload struct {
	Entropy core.Entropy
}

type Neighbour added in v0.3.0

type Neighbour struct {
	ConnectionType    configuration.ConnectionType
	ConnectionAddress string
	OutgoingClient    RPCClientWrapper
	PublicKey         *ecdsa.PublicKey
}

Helper for functionality of connection to another pulsar

func (*Neighbour) CheckAndRefreshConnection added in v0.4.0

func (neighbour *Neighbour) CheckAndRefreshConnection(rpcErr error) error

Check connection error, write it to the log and try to refresh connection

type Payload added in v0.3.0

type Payload struct {
	PublicKey string
	Signature []byte
	Body      interface{}
}

type Pulsar

type Pulsar struct {
	Sock               net.Listener
	SockConnectionType configuration.ConnectionType
	RPCServer          *rpc.Server

	Neighbours map[string]*Neighbour
	PrivateKey *ecdsa.PrivateKey

	Config configuration.Pulsar

	Storage          pulsarstorage.PulsarStorage
	EntropyGenerator EntropyGenerator

	State                 State
	EntropyGenerationLock sync.Mutex
	GeneratedEntropy      core.Entropy
	GeneratedEntropySign  []byte

	EntropyForNodes       core.Entropy
	PulseSenderToNodes    string
	SignsConfirmedSending map[string]core.PulseSenderConfirmation

	ProcessingPulseNumber core.PulseNumber
	LastPulse             *core.Pulse

	OwnedBftRow map[string]*BftCell
	BftGrid     map[string]map[string]*BftCell
}

Base pulsar's struct

func NewPulsar

func NewPulsar(
	configuration configuration.Pulsar,
	storage pulsarstorage.PulsarStorage,
	rpcWrapperFactory RPCClientWrapperFactory,
	entropyGenerator EntropyGenerator,
	listener func(string, string) (net.Listener, error)) (*Pulsar, error)

NewPulse creates a new pulse with using of custom GeneratedEntropy Generator

func (*Pulsar) BroadcastEntropy added in v0.4.0

func (pulsar *Pulsar) BroadcastEntropy()

func (*Pulsar) BroadcastSignatureOfEntropy added in v0.4.0

func (pulsar *Pulsar) BroadcastSignatureOfEntropy()

func (*Pulsar) BroadcastVector added in v0.4.0

func (pulsar *Pulsar) BroadcastVector()

func (*Pulsar) EstablishConnection added in v0.3.0

func (pulsar *Pulsar) EstablishConnection(pubKey string) error

func (*Pulsar) RefreshConnections added in v0.4.0

func (pulsar *Pulsar) RefreshConnections()

func (*Pulsar) StartConsensusProcess added in v0.4.0

func (pulsar *Pulsar) StartConsensusProcess(pulseNumber core.PulseNumber) error

func (*Pulsar) StartServer added in v0.4.0

func (pulsar *Pulsar) StartServer()

StartServer starts listening of the rpc-server

func (*Pulsar) StopServer added in v0.4.0

func (pulsar *Pulsar) StopServer()

StopServer stops listening of the rpc-server

func (*Pulsar) SyncLastPulseWithNeighbour added in v0.4.0

func (pulsar *Pulsar) SyncLastPulseWithNeighbour(neighbour *Neighbour) (*core.Pulse, error)

type RPCClientWrapper added in v0.4.0

type RPCClientWrapper interface {
	// Take current neighbour's lock
	Lock()
	// Release current neighbour's lock
	Unlock()

	// Check if client initialised
	IsInitialised() bool
	// Set wrapper's undercover rpc client
	SetRPCClient(client *rpc.Client)
	// Create connection and reinit client
	CreateConnection(connectionType configuration.ConnectionType, connectionAddress string) error
	// Close wrapped client
	Close() error

	// Make rpc call in async-style
	Go(serviceMethod string, args interface{}, reply interface{}, done chan *rpc.Call) *rpc.Call
}

Interface for wrappers around rpc clients

type RPCClientWrapperFactory added in v0.4.0

type RPCClientWrapperFactory interface {
	CreateWrapper() RPCClientWrapper
}

Interface for factory of rpc wrappers Needed for creation wrappers objects

type RPCClientWrapperFactoryImpl added in v0.4.0

type RPCClientWrapperFactoryImpl struct {
}

Standard factory implementation Returns RPCClientWrapperImpl

func (RPCClientWrapperFactoryImpl) CreateWrapper added in v0.4.0

Standard factory implementation Returns RPCClientWrapperImpl

type RPCClientWrapperImpl added in v0.4.0

type RPCClientWrapperImpl struct {
	*sync.Mutex
	*rpc.Client
}

Base RPCClientWrapper impl for rpc.Client

func (*RPCClientWrapperImpl) Close added in v0.4.0

func (impl *RPCClientWrapperImpl) Close() error

Close wrapped client

func (*RPCClientWrapperImpl) CreateConnection added in v0.4.0

func (impl *RPCClientWrapperImpl) CreateConnection(connectionType configuration.ConnectionType, connectionAddress string) error

Create base rpc connection

func (*RPCClientWrapperImpl) Go added in v0.4.0

func (impl *RPCClientWrapperImpl) Go(serviceMethod string, args interface{}, reply interface{}, done chan *rpc.Call) *rpc.Call

Make a call in async style, with done channel as async-marker

func (*RPCClientWrapperImpl) IsInitialised added in v0.4.0

func (impl *RPCClientWrapperImpl) IsInitialised() bool

func (*RPCClientWrapperImpl) Lock added in v0.4.0

func (impl *RPCClientWrapperImpl) Lock()

Take current neighbour's lock

func (*RPCClientWrapperImpl) SetRPCClient added in v0.4.0

func (impl *RPCClientWrapperImpl) SetRPCClient(client *rpc.Client)

Set wrapper's undercover rpc client

func (*RPCClientWrapperImpl) Unlock added in v0.4.0

func (impl *RPCClientWrapperImpl) Unlock()

Release current neighbour's lock

type RequestType added in v0.3.0

type RequestType string
const (
	HealthCheck                RequestType = "Pulsar.HealthCheck"
	Handshake                  RequestType = "Pulsar.MakeHandshake"
	GetLastPulseNumber         RequestType = "Pulsar.SyncLastPulseWithNeighbour"
	ReceiveSignatureForEntropy RequestType = "Pulsar.ReceiveSignatureForEntropy"
	ReceiveEntropy             RequestType = "Pulsar.ReceiveEntropy"
	ReceiveVector              RequestType = "Pulsar.ReceiveVector"
	ReceiveChosenSignature     RequestType = "Pulsar.ReceiveChosenSignature"
)

func (RequestType) String added in v0.3.0

func (state RequestType) String() string

type SenderConfirmationPayload added in v0.4.0

type SenderConfirmationPayload struct {
	PulseNumber     core.PulseNumber
	Signature       []byte
	ChosenPublicKey string
}

type StandardEntropyGenerator

type StandardEntropyGenerator struct {
}

func (*StandardEntropyGenerator) GenerateEntropy

func (generator *StandardEntropyGenerator) GenerateEntropy() core.Entropy

type State added in v0.4.0

type State int
const (
	WaitingForTheStart State = iota + 1
	WaitingForTheSigns
	SendingEntropy
	WaitingForTheEntropy
	SendingVector
	WaitingForTheVectors
	Verifying
	SendingSignForChosen
	WaitingForChosenSigns
	SendingEntropyToNodes
	Failed
)

type VectorPayload added in v0.4.0

type VectorPayload struct {
	PulseNumber core.PulseNumber
	Vector      map[string]*BftCell
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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