node

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2018 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	HeartbeatTimeout time.Duration
	TCPTimeout       time.Duration
	CacheSize        int
	SyncLimit        int
	StoreType        string
	StorePath        string
	Logger           *logrus.Logger
}

func DefaultConfig

func DefaultConfig() *Config

func NewConfig

func NewConfig(heartbeat time.Duration,
	timeout time.Duration,
	cacheSize int,
	syncLimit int,
	storeType string,
	storePath string,
	logger *logrus.Logger) *Config

func TestConfig

func TestConfig(t *testing.T) *Config

type ControlTimer

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

func NewControlTimer

func NewControlTimer(timerFactory timerFactory) *ControlTimer

func NewRandomControlTimer

func NewRandomControlTimer(base time.Duration) *ControlTimer

func (*ControlTimer) Run

func (c *ControlTimer) Run()

func (*ControlTimer) Shutdown

func (c *ControlTimer) Shutdown()

type Core

type Core struct {
	Head string
	Seq  int
	// contains filtered or unexported fields
}

func NewCore

func NewCore(
	id int,
	key *ecdsa.PrivateKey,
	participants map[string]int,
	store hg.Store,
	commitCh chan hg.Block,
	logger *logrus.Logger) Core

func (*Core) AddBlockSignature

func (c *Core) AddBlockSignature(bs hg.BlockSignature)

func (*Core) AddSelfEvent

func (c *Core) AddSelfEvent(otherHead string) error

func (*Core) AddTransactions

func (c *Core) AddTransactions(txs [][]byte)

func (*Core) Bootstrap

func (c *Core) Bootstrap() error

func (*Core) EventDiff

func (c *Core) EventDiff(known map[int]int) (events []hg.Event, err error)

returns events that c knowns about and are not in 'known'

func (*Core) FastForward

func (c *Core) FastForward(peer string, block hg.Block, frame hg.Frame) error

func (*Core) FromWire

func (c *Core) FromWire(wireEvents []hg.WireEvent) ([]hg.Event, error)

func (*Core) GetAnchorBlockWithFrame

func (c *Core) GetAnchorBlockWithFrame() (hg.Block, hg.Frame, error)

func (*Core) GetConsensusEvents

func (c *Core) GetConsensusEvents() []string

func (*Core) GetConsensusEventsCount

func (c *Core) GetConsensusEventsCount() int

func (*Core) GetConsensusTransactions

func (c *Core) GetConsensusTransactions() ([][]byte, error)

func (*Core) GetConsensusTransactionsCount

func (c *Core) GetConsensusTransactionsCount() int

func (*Core) GetEvent

func (c *Core) GetEvent(hash string) (hg.Event, error)

func (*Core) GetEventTransactions

func (c *Core) GetEventTransactions(hash string) ([][]byte, error)

func (*Core) GetHead

func (c *Core) GetHead() (hg.Event, error)

func (*Core) GetLastBlockIndex

func (c *Core) GetLastBlockIndex() int

func (*Core) GetLastCommitedRoundEventsCount

func (c *Core) GetLastCommitedRoundEventsCount() int

func (*Core) GetLastConsensusRoundIndex

func (c *Core) GetLastConsensusRoundIndex() *int

func (*Core) GetPendingLoadedEvents

func (c *Core) GetPendingLoadedEvents() int

func (*Core) GetUndeterminedEvents

func (c *Core) GetUndeterminedEvents() []string

func (*Core) HexID

func (c *Core) HexID() string

func (*Core) ID

func (c *Core) ID() int

func (*Core) InsertEvent

func (c *Core) InsertEvent(event hg.Event, setWireInfo bool) error

func (*Core) KnownEvents

func (c *Core) KnownEvents() map[int]int

func (*Core) NeedGossip

func (c *Core) NeedGossip() bool

func (*Core) OverSyncLimit

func (c *Core) OverSyncLimit(knownEvents map[int]int, syncLimit int) bool

func (*Core) PubKey

func (c *Core) PubKey() []byte

func (*Core) RunConsensus

func (c *Core) RunConsensus() error

func (*Core) SetHeadAndSeq

func (c *Core) SetHeadAndSeq() error

func (*Core) SignAndInsertSelfEvent

func (c *Core) SignAndInsertSelfEvent(event hg.Event) error

func (*Core) SignBlock

func (c *Core) SignBlock(block hg.Block) (hg.BlockSignature, error)

func (*Core) Sync

func (c *Core) Sync(unknownEvents []hg.WireEvent) error

func (*Core) ToWire

func (c *Core) ToWire(events []hg.Event) ([]hg.WireEvent, error)

type Node

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

func NewNode

func NewNode(conf *Config,
	id int,
	key *ecdsa.PrivateKey,
	participants []net.Peer,
	store hg.Store,
	trans net.Transport,
	proxy proxy.AppProxy) *Node

func (*Node) GetBlock

func (n *Node) GetBlock(blockIndex int) (hg.Block, error)

func (*Node) GetStats

func (n *Node) GetStats() map[string]string

func (*Node) Init

func (n *Node) Init(bootstrap bool) error

func (*Node) Run

func (n *Node) Run(gossip bool)

func (*Node) RunAsync

func (n *Node) RunAsync(gossip bool)

func (*Node) Shutdown

func (n *Node) Shutdown()

func (*Node) SyncRate

func (n *Node) SyncRate() float64

type NodeState

type NodeState uint32

NodeState captures the state of a Babble node: Babbling, CatchingUp or Shutdown

const (
	// Babbling is the initial state of a Babble node.
	Babbling NodeState = iota

	CatchingUp

	Shutdown
)

func (NodeState) String

func (s NodeState) String() string

type PeerSelector

type PeerSelector interface {
	Peers() []net.Peer
	UpdateLast(peer string)
	Next() net.Peer
}

type RandomPeerSelector

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

func NewRandomPeerSelector

func NewRandomPeerSelector(participants []net.Peer, localAddr string) *RandomPeerSelector

func (*RandomPeerSelector) Next

func (ps *RandomPeerSelector) Next() net.Peer

func (*RandomPeerSelector) Peers

func (ps *RandomPeerSelector) Peers() []net.Peer

func (*RandomPeerSelector) UpdateLast

func (ps *RandomPeerSelector) UpdateLast(peer string)

Jump to

Keyboard shortcuts

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