raft

package
v1.5.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSecretTCPTransport

func NewSecretTCPTransport(
	bindAddr string,
	advertise net.Addr,
	maxPool int,
	timeout time.Duration,
	logOutput io.Writer,
	privKey crypto.PrivKey,
) (*raft.NetworkTransport, error)

NewTCPTransport returns a NetworkTransport that is built on top of a Secret TCP streaming transport layer.

Types

type AddPeerResult

type AddPeerResult struct{}

type BlockChainFSM

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

func (*BlockChainFSM) AppliedCh

func (b *BlockChainFSM) AppliedCh() <-chan *types.Block

func (*BlockChainFSM) Apply

func (b *BlockChainFSM) Apply(l *raft.Log) interface{}

func (*BlockChainFSM) Restore

func (b *BlockChainFSM) Restore(r io.ReadCloser) error

func (*BlockChainFSM) SetEventSwitch

func (b *BlockChainFSM) SetEventSwitch(evsw types.EventSwitch)

func (*BlockChainFSM) Snapshot

func (b *BlockChainFSM) Snapshot() (raft.FSMSnapshot, error)

type BlockChainSnapshot

type BlockChainSnapshot struct {
	Height int64
	Hash   []byte
}

func (*BlockChainSnapshot) Persist

func (s *BlockChainSnapshot) Persist(sink raft.SnapshotSink) error

func (*BlockChainSnapshot) Release

func (s *BlockChainSnapshot) Release()

type ClusterConfig

type ClusterConfig struct {
	Local     Peer   `json:"local"`
	Advertise string `json:"advertise"`
	Peers     []Peer `json:"peers"`
	// contains filtered or unexported fields
}

func NewClusterConfig

func NewClusterConfig(filename string) (*ClusterConfig, error)

func (*ClusterConfig) AddPeer

func (c *ClusterConfig) AddPeer(peer Peer) bool

func (*ClusterConfig) FindByBindAddress

func (c *ClusterConfig) FindByBindAddress(bind string) *Peer

func (*ClusterConfig) LocalServer

func (c *ClusterConfig) LocalServer() raft.Server

func (*ClusterConfig) Remove

func (c *ClusterConfig) Remove(pubKey crypto.PubKey) bool

func (*ClusterConfig) Save

func (c *ClusterConfig) Save() error

func (*ClusterConfig) Server

func (c *ClusterConfig) Server() ([]raft.Server, error)

func (*ClusterConfig) String

func (c *ClusterConfig) String() string

type ConsensusState

type ConsensusState struct {
	*common.BaseService
	// contains filtered or unexported fields
}

func NewConsensusState

func NewConsensusState(vconf *viper.Viper, evsw types.EventSwitch, blockStore *blockchain.BlockStore, state *state.State, mempool types.TxPool, privValidator *types.PrivValidator) (*ConsensusState, error)

func (*ConsensusState) GetValidators

func (cs *ConsensusState) GetValidators() (int64, []*types.Validator)

func (*ConsensusState) NewPublicAPI

func (cs *ConsensusState) NewPublicAPI() *PublicAPI

func (*ConsensusState) OnStart

func (cs *ConsensusState) OnStart() error

func (*ConsensusState) OnStop

func (cs *ConsensusState) OnStop()

func (*ConsensusState) SetEventSwitch

func (cs *ConsensusState) SetEventSwitch(evsw types.EventSwitch)

func (*ConsensusState) SetOnUpdateStatus added in v1.4.2

func (cs *ConsensusState) SetOnUpdateStatus(onUpdateState func(s *state.State))

func (*ConsensusState) ValidateBlock

func (cs *ConsensusState) ValidateBlock(b *types.Block) error

type LeaderResult

type LeaderResult struct {
	ID      string
	Address string
	RPC     string
}

type Peer

type Peer struct {
	PubKey crypto.PubKey `json:"pub_key"`
	RPC    string        `json:"rpc"`
	Bind   string        `json:"bind"`
}

type PublicAPI

type PublicAPI struct {
	*ConsensusState
}

func (*PublicAPI) API

func (p *PublicAPI) API() map[string]*rpcserver.RPCFunc

func (*PublicAPI) AddPeer

func (p *PublicAPI) AddPeer(addr, rpc string, pubKey string) (*AddPeerResult, error)

func (*PublicAPI) Leader

func (p *PublicAPI) Leader() (*LeaderResult, error)

func (*PublicAPI) RemovePeer

func (p *PublicAPI) RemovePeer(pubKey string) (*RemovePeerResult, error)

func (*PublicAPI) Role

func (p *PublicAPI) Role() (string, error)

func (*PublicAPI) Stats

func (p *PublicAPI) Stats() (string, error)

type RemovePeerResult

type RemovePeerResult struct{}

type SecretTCPStreamLayer

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

func (*SecretTCPStreamLayer) Accept

func (t *SecretTCPStreamLayer) Accept() (net.Conn, error)

func (*SecretTCPStreamLayer) Addr

func (t *SecretTCPStreamLayer) Addr() net.Addr

func (*SecretTCPStreamLayer) Close

func (t *SecretTCPStreamLayer) Close() error

func (*SecretTCPStreamLayer) Dial

func (t *SecretTCPStreamLayer) Dial(address raft.ServerAddress, timeout time.Duration) (conn net.Conn, err error)

Jump to

Keyboard shortcuts

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