pulsar

package
v0.5.0 Latest Latest
Warning

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

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

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 EntropyGenerator

type EntropyGenerator interface {
	GenerateEntropy() core.Entropy
}

EntropyGenerator is the base interface for generation of entropy for pulses

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
	PublicKeyRaw      string
}

Neighbour is a helper struct, which contains info about pulsar-neighbour

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
	PublicKeyRaw string

	Config configuration.Pulsar

	Storage          pulsarstorage.PulsarStorage
	EntropyGenerator EntropyGenerator

	StartProcessLock     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
	// contains filtered or unexported fields
}

Pulsar is a base struct for pulsar's node It contains all the stuff, which is needed for working of a pulsar

func NewPulsar

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

NewPulsar creates a new pulse with using of custom GeneratedEntropy Generator

func (*Pulsar) CheckConnectionsToPulsars added in v0.5.0

func (pulsar *Pulsar) CheckConnectionsToPulsars()

CheckConnectionsToPulsars is a method refreshing connections between pulsars

func (*Pulsar) EstablishConnectionToPulsar added in v0.5.0

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

EstablishConnectionToPulsar is a method for creating connection to another pulsar

func (*Pulsar) StartConsensusProcess added in v0.4.0

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

StartConsensusProcess starts process of calculating consensus between pulsars

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

type RPCClientWrapper added in v0.4.0

type RPCClientWrapper interface {
	// Lock takes current neighbour's lock
	Lock()
	// Unlock releases current neighbour's lock
	Unlock()

	// IsInitialised compares underhood rpc-client with nil
	IsInitialised() bool
	// CreateConnection creates connection to an another pulsar
	CreateConnection(connectionType configuration.ConnectionType, connectionAddress string) error
	// Close closes connection
	Close() error

	// Go makes rpc-call to an another pulsar
	Go(serviceMethod string, args interface{}, reply interface{}, done chan *rpc.Call) *rpc.Call

	// ResetClient clears rpc-client
	ResetClient()
}

RPCClientWrapper describes interface of the wrapper around rpc-client

type RPCClientWrapperFactory added in v0.4.0

type RPCClientWrapperFactory interface {
	CreateWrapper() RPCClientWrapper
}

RPCClientWrapperFactory describes interface for the wrappers factory

type RPCClientWrapperFactoryImpl added in v0.4.0

type RPCClientWrapperFactoryImpl struct {
}

RPCClientWrapperFactoryImpl is a base impl of the RPCClientWrapperFactory

func (RPCClientWrapperFactoryImpl) CreateWrapper added in v0.4.0

CreateWrapper return new RPCClientWrapper

type RPCClientWrapperImpl added in v0.4.0

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

RPCClientWrapperImpl is a standard impl of RPCClientWrapper

func (*RPCClientWrapperImpl) Close added in v0.4.0

func (impl *RPCClientWrapperImpl) Close() error

Close closes connection

func (*RPCClientWrapperImpl) CreateConnection added in v0.4.0

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

CreateConnection creates connection to an another pulsar

func (*RPCClientWrapperImpl) Go added in v0.4.0

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

Go makes rpc-call to an another pulsar

func (*RPCClientWrapperImpl) IsInitialised added in v0.4.0

func (impl *RPCClientWrapperImpl) IsInitialised() bool

IsInitialised compares underhood rpc-client with nil

func (*RPCClientWrapperImpl) Lock added in v0.4.0

func (impl *RPCClientWrapperImpl) Lock()

Lock takes current neighbour's lock

func (*RPCClientWrapperImpl) ResetClient added in v0.5.0

func (impl *RPCClientWrapperImpl) ResetClient()

ResetClient clears rpc-client

func (*RPCClientWrapperImpl) Unlock added in v0.4.0

func (impl *RPCClientWrapperImpl) Unlock()

Unlock releases 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 {
}

StandardEntropyGenerator is the base impl of EntropyGenerator with using of crypto/rand

func (*StandardEntropyGenerator) GenerateEntropy

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

GenerateEntropy generate entropy with using of EntropyGenerator

type State added in v0.4.0

type State int

func (State) String added in v0.5.0

func (i State) String() string

type StateSwitcher added in v0.5.0

type StateSwitcher interface {
	SetPulsar(pulsar *Pulsar)
	// contains filtered or unexported methods
}

StateSwitcher is a base for pulsar's state machine

type StateSwitcherImpl added in v0.5.0

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

StateSwitcherImpl is a base implementation of the pulsar's state machine

func (*StateSwitcherImpl) SetPulsar added in v0.5.0

func (switcher *StateSwitcherImpl) SetPulsar(pulsar *Pulsar)

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