Documentation ¶
Index ¶
- Constants
- Variables
- type Config
- type ControlTimer
- type Core
- func (c *Core) AddBlockSignature(bs poset.BlockSignature)
- func (c *Core) AddInternalTransactions(txs []*wire.InternalTransaction)
- func (c *Core) AddSelfEventBlock(otherHead poset.EventHash) error
- func (c *Core) AddTransactions(txs [][]byte) error
- func (c *Core) Bootstrap() error
- func (c *Core) EventDiff(known map[uint64]int64) (events []poset.Event, err error)
- func (c *Core) FastForward(peer string, block poset.Block, frame poset.Frame) error
- func (c *Core) FromWire(wireEvents []poset.WireEvent) ([]poset.Event, error)
- func (c *Core) GetAnchorBlockWithFrame() (poset.Block, poset.Frame, error)
- func (c *Core) GetBlockSignaturePoolCount() int64
- func (c *Core) GetConsensusEvents() poset.EventHashes
- func (c *Core) GetConsensusEventsCount() int64
- func (c *Core) GetConsensusTransactions() ([][]byte, error)
- func (c *Core) GetConsensusTransactionsCount() uint64
- func (c *Core) GetEventBlock(hash poset.EventHash) (poset.Event, error)
- func (c *Core) GetEventBlockTransactions(hash poset.EventHash) ([][]byte, error)
- func (c *Core) GetHead() (poset.Event, error)
- func (c *Core) GetInternalTransactionPoolCount() int64
- func (c *Core) GetLastBlockIndex() int64
- func (c *Core) GetLastCommittedRoundEventsCount() int
- func (c *Core) GetLastConsensusRound() int64
- func (c *Core) GetPendingLoadedEvents() int64
- func (c *Core) GetTransactionPoolCount() int64
- func (c *Core) GetUndeterminedEvents() poset.EventHashes
- func (c *Core) Head() poset.EventHash
- func (c *Core) Heights() map[string]int64
- func (c *Core) HeightsByID() map[uint64]int64
- func (c *Core) HexID() string
- func (c *Core) ID() uint64
- func (c *Core) InDegrees() map[string]int64
- func (c *Core) InsertEvent(event poset.Event, setWireInfo bool) error
- func (c *Core) KnownEvents() map[uint64]int64
- func (c *Core) OverSyncLimit(knownEvents map[uint64]int64, syncLimit int64) bool
- func (c *Core) PubKey() []byte
- func (c *Core) RunConsensus() error
- func (c *Core) SetHeadAndHeight() error
- func (c *Core) SignAndInsertSelfEvent(event poset.Event) error
- func (c *Core) SignBlock(block poset.Block) (poset.BlockSignature, error)
- func (c *Core) Sync(peer *peers.Peer, unknownEvents []poset.WireEvent) error
- func (c *Core) ToWire(events []poset.Event) ([]poset.WireEvent, error)
- type FairPeerSelector
- type FairPeerSelectorCreationFnArgs
- type GetFlagTableFn
- type Graph
- type Infos
- type Node
- func (n *Node) EventDiff(known map[uint64]int64) (events []poset.Event, err error)
- func (n *Node) GetBlock(blockIndex int64) (poset.Block, error)
- func (n *Node) GetConsensusEvents() poset.EventHashes
- func (n *Node) GetConsensusTransactionsCount() uint64
- func (n *Node) GetEventBlock(event poset.EventHash) (poset.Event, error)
- func (n *Node) GetFrame(i int64) (poset.Frame, error)
- func (n *Node) GetKnownEvents() map[uint64]int64
- func (n *Node) GetLastBlockIndex() int64
- func (n *Node) GetLastEventFrom(participant string) (poset.EventHash, bool, error)
- func (n *Node) GetLastRound() int64
- func (n *Node) GetParticipants() (*peers.Peers, error)
- func (n *Node) GetPendingLoadedEvents() int64
- func (n *Node) GetRoot(rootIndex string) (poset.Root, error)
- func (n *Node) GetRound(roundIndex int64) (poset.RoundCreated, error)
- func (n *Node) GetRoundClothos(roundIndex int64) poset.EventHashes
- func (n *Node) GetRoundEvents(roundIndex int64) int
- func (n *Node) GetStats() map[string]string
- func (n *Node) ID() uint64
- func (n *Node) Init() error
- func (n *Node) PushTx(tx []byte) error
- func (n *Node) Register()
- func (n *Node) RoundClothos(i int64) poset.EventHashes
- func (n *Node) Run(gossip bool)
- func (n *Node) RunAsync(gossip bool)
- func (n *Node) Shutdown()
- func (n *Node) Stop()
- func (n *Node) SyncRate() float64
- type NodeList
- type PeerSelector
- type RandomPeerSelector
- type RandomPeerSelectorCreationFnArgs
- type SelectorCreationFn
- type SelectorCreationFnArgs
- type SmartPeerSelector
- type SmartPeerSelectorCreationFnArgs
Constants ¶
const ( // Gossiping is the initial state of a Lachesis node. Gossiping state = iota // CatchingUp is the fast forward state CatchingUp // Shutdown is the shut down state Shutdown // Stop is the stop communicating state Stop )
const ( // MaxEventsPayloadSize is size limitation of txs in bytes. // TODO: collect the similar magic constants in protocol config. MaxEventsPayloadSize = 100 * 1024 * 1024 )
Variables ¶
var ( // ErrTooBigTx is returned when transaction size > MaxEventsPayloadSize ErrTooBigTx = fmt.Errorf("transaction too big") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { HeartbeatTimeout time.Duration `mapstructure:"heartbeat"` TCPTimeout time.Duration `mapstructure:"timeout"` CacheSize int `mapstructure:"cache-size"` SyncLimit int64 `mapstructure:"sync-limit"` Logger *logrus.Logger TestDelay uint64 `mapstructure:"test_delay"` }
Config for node configuration settings
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig sets the default config for a node config
func NewConfig ¶
func NewConfig(heartbeat time.Duration, timeout time.Duration, cacheSize int, syncLimit int64, logger *logrus.Logger) *Config
NewConfig creates a new node config
func TestConfig ¶
TestConfig sets the test config for use with tests
type ControlTimer ¶
ControlTimer struct that controls timing events in the node
func NewControlTimer ¶
func NewControlTimer(timerFactory timerFactory) *ControlTimer
NewControlTimer creates a new control timer struct
func NewRandomControlTimer ¶
func NewRandomControlTimer() *ControlTimer
NewRandomControlTimer creates a random time controller with no defaults set
func (*ControlTimer) Run ¶
func (c *ControlTimer) Run(init time.Duration)
Run handles all the time based events in the background
func (*ControlTimer) SetSet ¶
func (c *ControlTimer) SetSet(v bool)
SetSet sets the set value for the set
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
Core struct that controls the consensus, transaction, and communication
func NewCore ¶
func NewCore(id uint64, key *ecdsa.PrivateKey, participants *peers.Peers, store poset.Store, commitCh chan poset.Block, logger *logrus.Logger) *Core
NewCore creates a new core struct
func (*Core) AddBlockSignature ¶
func (c *Core) AddBlockSignature(bs poset.BlockSignature)
AddBlockSignature add block signatures to the pending pool
func (*Core) AddInternalTransactions ¶
func (c *Core) AddInternalTransactions(txs []*wire.InternalTransaction)
AddInternalTransactions add internal transactions to the pending pool
func (*Core) AddSelfEventBlock ¶
AddSelfEventBlock adds an event block created by this node
func (*Core) AddTransactions ¶
AddTransactions add transactions to the pending pool
func (*Core) FastForward ¶
FastForward catch up to another peer if too far behind
func (*Core) GetAnchorBlockWithFrame ¶
GetAnchorBlockWithFrame returns the current anchor block and their frame
func (*Core) GetBlockSignaturePoolCount ¶
GetBlockSignaturePoolCount returns the count of all pending block signatures
func (*Core) GetConsensusEvents ¶
func (c *Core) GetConsensusEvents() poset.EventHashes
GetConsensusEvents get all known consensus events
func (*Core) GetConsensusEventsCount ¶
GetConsensusEventsCount get the count of all known consensus events
func (*Core) GetConsensusTransactions ¶
GetConsensusTransactions return all transactions that have reached finality
func (*Core) GetConsensusTransactionsCount ¶
GetConsensusTransactionsCount returns the count of transactions that are final
func (*Core) GetEventBlock ¶
GetEventBlock get a specific event block for the hash provided
func (*Core) GetEventBlockTransactions ¶
GetEventBlockTransactions get all transactions in an event block
func (*Core) GetInternalTransactionPoolCount ¶
GetInternalTransactionPoolCount returns the count of all pending internal transactions
func (*Core) GetLastBlockIndex ¶
GetLastBlockIndex returns the latest block index
func (*Core) GetLastCommittedRoundEventsCount ¶
GetLastCommittedRoundEventsCount count of events in last round
func (*Core) GetLastConsensusRound ¶
GetLastConsensusRound returns the last consensus round known
func (*Core) GetPendingLoadedEvents ¶
GetPendingLoadedEvents returns all pending (but already stored) events
func (*Core) GetTransactionPoolCount ¶
GetTransactionPoolCount returns the count of all pending transactions
func (*Core) GetUndeterminedEvents ¶
func (c *Core) GetUndeterminedEvents() poset.EventHashes
GetUndeterminedEvents get all unconfirmed consensus events (pending)
func (*Core) HeightsByID ¶
HeightsByID returns map with heights for each participant ID
func (*Core) InDegrees ¶
InDegrees returns all vertexes from other nodes that reference this top event block
func (*Core) InsertEvent ¶
InsertEvent inserts an unknown event block
func (*Core) KnownEvents ¶
KnownEvents returns map of last known event blocks per participant.ID
func (*Core) OverSyncLimit ¶
OverSyncLimit checks if the unknown events is over the sync limit and if the node should catch up
func (*Core) RunConsensus ¶
RunConsensus is the core consensus mechanism, this checks rounds/frames and creates blocks.
func (*Core) SetHeadAndHeight ¶
SetHeadAndHeight calculates and sets the current head and height for the chain
func (*Core) SignAndInsertSelfEvent ¶
SignAndInsertSelfEvent signs and inserts a self generated event block
type FairPeerSelector ¶
type FairPeerSelector struct {
// contains filtered or unexported fields
}
FairPeerSelector provides selection to prevent lazy node creation
func NewFairPeerSelector ¶
func NewFairPeerSelector(participants *peers.Peers, args FairPeerSelectorCreationFnArgs) *FairPeerSelector
NewFairPeerSelector creates a new fair peer selection struct
func (*FairPeerSelector) Dismiss ¶
func (ps *FairPeerSelector) Dismiss(peer string)
Indicate we are not in communication with a peer so it could be selected as a next peer
func (*FairPeerSelector) Engage ¶
func (ps *FairPeerSelector) Engage(peer string)
Indicate we are in communication with a peer so it would be excluded from next peer selection
func (*FairPeerSelector) Next ¶
func (ps *FairPeerSelector) Next() *peers.Peer
Next returns the next peer based on the work cost function selection
func (*FairPeerSelector) Peers ¶
func (ps *FairPeerSelector) Peers() *peers.Peers
Peers returns all known peers
func (*FairPeerSelector) UpdateLast ¶
func (ps *FairPeerSelector) UpdateLast(peer string)
UpdateLast sets the last peer communicated with (avoid double talk)
type FairPeerSelectorCreationFnArgs ¶
FairPeerSelectorCreationFnArgs specifies which additional arguments are require to create a FairPeerSelector
type GetFlagTableFn ¶
GetFlagTableFn declares flag table function signature
type Graph ¶
type Graph struct {
*Node
}
Graph struct to represent the DAG
func (*Graph) GetParticipantEvents ¶
GetParticipantEvents returns all known events per participant
func (*Graph) GetRounds ¶
func (g *Graph) GetRounds() []poset.RoundCreated
GetRounds returns the created rounds for the DAG
type Infos ¶
type Infos struct { ParticipantEvents map[string]map[poset.EventHash]poset.Event Rounds []poset.RoundCreated Blocks []poset.Block }
Infos struct for graph data (visualizer)
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node struct that keeps all high level node functions
func NewNode ¶
func NewNode(conf *Config, id uint64, key *ecdsa.PrivateKey, participants *peers.Peers, store poset.Store, trans peer.SyncPeer, proxy proxy.AppProxy, selectorInitFunc SelectorCreationFn, selectorInitArgs SelectorCreationFnArgs, localAddr string) *Node
NewNode create a new node struct
func (*Node) GetConsensusEvents ¶
func (n *Node) GetConsensusEvents() poset.EventHashes
GetConsensusEvents returns all consensus events
func (*Node) GetConsensusTransactionsCount ¶
GetConsensusTransactionsCount get the count of finalized transactions
func (*Node) GetEventBlock ¶
GetEventBlock returns a specific event block for the given hash
func (*Node) GetKnownEvents ¶
GetKnownEvents returns all known events
func (*Node) GetLastBlockIndex ¶
GetLastBlockIndex returns the last block index
func (*Node) GetLastEventFrom ¶
GetLastEventFrom returns the last event block for a specific participant
func (*Node) GetParticipants ¶
GetParticipants returns all participants this node knows about
func (*Node) GetPendingLoadedEvents ¶
GetPendingLoadedEvents returns all the pending events
func (*Node) GetRound ¶
func (n *Node) GetRound(roundIndex int64) (poset.RoundCreated, error)
GetRound returns the created round info for a given index
func (*Node) GetRoundClothos ¶
func (n *Node) GetRoundClothos(roundIndex int64) poset.EventHashes
GetRoundClothos returns all clotho for a given round index
func (*Node) GetRoundEvents ¶
GetRoundEvents returns all the round events for a given round index
func (*Node) RoundClothos ¶
func (n *Node) RoundClothos(i int64) poset.EventHashes
RoundClothos returns all clothos in a round
type NodeList ¶
type NodeList map[*ecdsa.PrivateKey]*Node
NodeList is a list of connected nodes for tests purposes
func NewNodeList ¶
NewNodeList makes, fills and runs NodeList instance
func (NodeList) Keys ¶
func (n NodeList) Keys() []*ecdsa.PrivateKey
Keys returns the all PrivateKeys slice
func (NodeList) StartRandTxStream ¶
func (n NodeList) StartRandTxStream() (stop func())
StartRandTxStream sends random txs to nodes until stop() called
func (NodeList) WaitForBlock ¶
WaitForBlock waits until the target block has retrieved a state hash from the app
type PeerSelector ¶
type PeerSelector interface { Peers() *peers.Peers UpdateLast(peer string) Next() *peers.Peer Engage(peer string) // indicate we are in communication with that peer Dismiss(peer string) // indicate we are not in communication with that peer }
PeerSelector provides an interface for the lachesis node to update the last peer it gossiped with and select the next peer to gossip with
func NewFairPeerSelectorWrapper ¶
func NewFairPeerSelectorWrapper(participants *peers.Peers, args interface{}) PeerSelector
NewFairPeerSelectorWrapper implements SelectorCreationFn to allow dynamic creation of FairPeerSelector ie NewNode
func NewRandomPeerSelectorWrapper ¶
func NewRandomPeerSelectorWrapper(participants *peers.Peers, args interface{}) PeerSelector
NewRandomPeerSelectorWrapper implements SelectorCreationFn to allow dynamic creation of RandomPeerSelector ie NewNode
func NewSmartPeerSelectorWrapper ¶
func NewSmartPeerSelectorWrapper(participants *peers.Peers, args interface{}) PeerSelector
NewSmartPeerSelectorWrapper implements SelectorCreationFn to allow dynamic creation of SmartPeerSelector ie NewNode
type RandomPeerSelector ¶
type RandomPeerSelector struct {
// contains filtered or unexported fields
}
RandomPeerSelector is a randomized peer selection struct
func NewRandomPeerSelector ¶
func NewRandomPeerSelector(participants *peers.Peers, args RandomPeerSelectorCreationFnArgs) *RandomPeerSelector
NewRandomPeerSelector creates a new random peer selector
func (*RandomPeerSelector) Dismiss ¶
func (ps *RandomPeerSelector) Dismiss(peer string)
Indicate we are not in communication with a peer so it could be selected as a next peer
func (*RandomPeerSelector) Engage ¶
func (ps *RandomPeerSelector) Engage(peer string)
Indicate we are in communication with a peer so it would be excluded from next peer selection
func (*RandomPeerSelector) Next ¶
func (ps *RandomPeerSelector) Next() *peers.Peer
Next returns the next randomly selected peer(s) to communicate with
func (*RandomPeerSelector) Peers ¶
func (ps *RandomPeerSelector) Peers() *peers.Peers
Peers returns all known peers
func (*RandomPeerSelector) UpdateLast ¶
func (ps *RandomPeerSelector) UpdateLast(peer string)
UpdateLast sets the last peer communicated with (to avoid double talk)
type RandomPeerSelectorCreationFnArgs ¶
type RandomPeerSelectorCreationFnArgs struct {
LocalAddr string
}
RandomPeerSelectorCreationFnArgs arguments for RandomPeerSelector
type SelectorCreationFn ¶
type SelectorCreationFn func(*peers.Peers, interface{}) PeerSelector
SelectorCreationFn declares the function signature to create variants of PeerSelector
type SelectorCreationFnArgs ¶
type SelectorCreationFnArgs interface{}
SelectorCreationFnArgs specifies the union of possible arguments that can be extracted to create a variant of PeerSelector
type SmartPeerSelector ¶
type SmartPeerSelector struct { GetFlagTable GetFlagTableFn // contains filtered or unexported fields }
SmartPeerSelector provides selection based on FlagTable of a randomly chosen undermined event
func NewSmartPeerSelector ¶
func NewSmartPeerSelector(participants *peers.Peers, args SmartPeerSelectorCreationFnArgs) *SmartPeerSelector
NewSmartPeerSelector creates a new smart peer selection struct
func (*SmartPeerSelector) Dismiss ¶
func (ps *SmartPeerSelector) Dismiss(peer string)
Indicate we are not in communication with a peer so it could be selected as a next peer
func (*SmartPeerSelector) Engage ¶
func (ps *SmartPeerSelector) Engage(peer string)
Indicate we are in communication with a peer so it would be excluded from next peer selection
func (*SmartPeerSelector) Next ¶
func (ps *SmartPeerSelector) Next() *peers.Peer
Next returns the next peer based on the flag table cost function selection
func (*SmartPeerSelector) Peers ¶
func (ps *SmartPeerSelector) Peers() *peers.Peers
Peers returns all known peers
func (*SmartPeerSelector) UpdateLast ¶
func (ps *SmartPeerSelector) UpdateLast(peer string)
UpdateLast sets the last peer communicated with (avoid double talk)
type SmartPeerSelectorCreationFnArgs ¶
type SmartPeerSelectorCreationFnArgs struct { GetFlagTable GetFlagTableFn LocalAddr string }
SmartPeerSelectorCreationFnArgs specifies which additional arguments are required to create a SmartPeerSelector