Documentation ¶
Index ¶
- type Config
- type ControlTimer
- type Core
- func (c *Core) AddInternalTransaction(tx hg.InternalTransaction) *JoinPromise
- func (c *Core) AddSelfEvent(otherHead string) error
- func (c *Core) AddTransactions(txs [][]byte)
- func (c *Core) Bootstrap() error
- func (c *Core) Busy() bool
- func (c *Core) Commit(block *hg.Block) error
- func (c *Core) EventDiff(known map[uint32]int) (events []*hg.Event, err error)
- func (c *Core) FastForward(block *hg.Block, frame *hg.Frame) error
- func (c *Core) FromWire(wireEvents []hg.WireEvent) ([]hg.Event, error)
- func (c *Core) GetAnchorBlockWithFrame() (*hg.Block, *hg.Frame, error)
- func (c *Core) GetConsensusEvents() []string
- func (c *Core) GetConsensusEventsCount() int
- func (c *Core) GetConsensusTransactions() ([][]byte, error)
- func (c *Core) GetConsensusTransactionsCount() int
- func (c *Core) GetEvent(hash string) (*hg.Event, error)
- func (c *Core) GetEventTransactions(hash string) ([][]byte, error)
- func (c *Core) GetHead() (*hg.Event, error)
- func (c *Core) GetLastBlockIndex() int
- func (c *Core) GetLastCommitedRoundEventsCount() int
- func (c *Core) GetLastConsensusRoundIndex() *int
- func (c *Core) GetPendingLoadedEvents() int
- func (c *Core) GetUndeterminedEvents() []string
- func (c *Core) InsertEventAndRunConsensus(event *hg.Event, setWireInfo bool) error
- func (c *Core) KnownEvents() map[uint32]int
- func (c *Core) Leave(leaveTimeout time.Duration) error
- func (c *Core) ProcessAcceptedInternalTransactions(roundReceived int, receipts []hg.InternalTransactionReceipt) error
- func (c *Core) ProcessSigPool() error
- func (c *Core) RecordHeads() error
- func (c *Core) SetHeadAndSeq() error
- func (c *Core) SetPeers(ps *peers.PeerSet)
- func (c *Core) SignAndInsertSelfEvent(event *hg.Event) error
- func (c *Core) SignBlock(block *hg.Block) (hg.BlockSignature, error)
- func (c *Core) Sync(fromID uint32, unknownEvents []hg.WireEvent) error
- func (c *Core) ToWire(events []*hg.Event) ([]hg.WireEvent, error)
- type Graph
- type Infos
- type JoinPromise
- type JoinPromiseResponse
- type Node
- func (n *Node) GetBlock(blockIndex int) (*hg.Block, error)
- func (n *Node) GetGenesisPeers() []*peers.Peer
- func (n *Node) GetID() uint32
- func (n *Node) GetPeers() []*peers.Peer
- func (n *Node) GetStats() map[string]string
- func (n *Node) Init() error
- func (n *Node) Leave() error
- func (n *Node) Run(gossip bool)
- func (n *Node) RunAsync(gossip bool)
- func (n *Node) Shutdown()
- type PeerSelector
- type RandomPeerSelector
- type State
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { HeartbeatTimeout time.Duration `mapstructure:"heartbeat"` TCPTimeout time.Duration `mapstructure:"timeout"` JoinTimeout time.Duration `mapstructure:"join_timeout"` CacheSize int `mapstructure:"cache-size"` SyncLimit int `mapstructure:"sync-limit"` EnableFastSync bool `mapstructure:"fast-sync"` Bootstrap bool `mapstructure:"bootstrap"` Logger *logrus.Logger }
Config is a Configuration Object Definition
func NewConfig ¶
func NewConfig(heartbeat time.Duration, timeout time.Duration, joinTimeout time.Duration, cacheSize int, syncLimit int, enableFastSync bool, logger *logrus.Logger) *Config
NewConfig eturns a new Config Object
func TestConfig ¶
TestConfig returns a Preset Test Configuration
type ControlTimer ¶
type ControlTimer struct {
// contains filtered or unexported fields
}
ControlTimer struct
func NewControlTimer ¶
func NewControlTimer(timerFactory timerFactory) *ControlTimer
NewControlTimer is a ControlTimer factory method
func NewRandomControlTimer ¶
func NewRandomControlTimer() *ControlTimer
NewRandomControlTimer is a ControlTimer factory method that produces a ControlTimer with a random timeout
func (*ControlTimer) Run ¶
func (c *ControlTimer) Run(init time.Duration)
Run starts the Control Timer
func (*ControlTimer) Shutdown ¶
func (c *ControlTimer) Shutdown()
Shutdown shuts down the ControlTimer
type Core ¶
type Core struct { // Hash and Index of this instance's head Event Head string Seq int // AcceptedRound is the first round at which the node's last JoinRequest // takes effect. A node will not create SelfEvents before reaching // AcceptedRound.Default -1. AcceptedRound int // RemovedRound is the round at which the node's last LeaveRequest takes // effect (if there is one). Default -1. RemovedRound int // TargetRound is the minimum Consensus Round that the node needs to reach. // It is useful to set this value to a joining peer's accepted-round to // prevent them from having to wait. TargetRound int // contains filtered or unexported fields }
Core is the core Node object
func NewCore ¶
func NewCore( validator *Validator, peers *peers.PeerSet, genesisPeers *peers.PeerSet, store hg.Store, proxyCommitCallback proxy.CommitCallback, logger *logrus.Logger) *Core
NewCore is a factory method that returns a new Core object
func (*Core) AddInternalTransaction ¶
func (c *Core) AddInternalTransaction(tx hg.InternalTransaction) *JoinPromise
AddInternalTransaction adds an internal transaction
func (*Core) AddSelfEvent ¶
AddSelfEvent adds a self event
func (*Core) AddTransactions ¶
AddTransactions appends transactions to the transaction pool
func (*Core) FastForward ¶
FastForward is used whilst in catchingUp state to apply past blocks and frames
func (*Core) GetAnchorBlockWithFrame ¶
GetAnchorBlockWithFrame returns GetAnchorBlockWithFrame from the hashgraph
func (*Core) GetConsensusEvents ¶
GetConsensusEvents returns consensus events from the hashgragh store
func (*Core) GetConsensusEventsCount ¶
GetConsensusEventsCount returns the count of consensus events from the hashgragh store
func (*Core) GetConsensusTransactions ¶
GetConsensusTransactions returns the transaction from the events returned by GetConsensusEvents()
func (*Core) GetConsensusTransactionsCount ¶
GetConsensusTransactionsCount return ConsensusTransacions from the hashgraph
func (*Core) GetEventTransactions ¶
GetEventTransactions returns the transactions for an event
func (*Core) GetLastBlockIndex ¶
GetLastBlockIndex returns last block index from the hashgraph store
func (*Core) GetLastCommitedRoundEventsCount ¶
GetLastCommitedRoundEventsCount returns LastCommitedRoundEvents from the hashgraph
func (*Core) GetLastConsensusRoundIndex ¶
GetLastConsensusRoundIndex returns the Last Consensus Round from the hashgraph
func (*Core) GetPendingLoadedEvents ¶
GetPendingLoadedEvents returns pendign loading events from the hashgraph
func (*Core) GetUndeterminedEvents ¶
GetUndeterminedEvents returns undetermined events from the hashgraph
func (*Core) InsertEventAndRunConsensus ¶
InsertEventAndRunConsensus Inserts a hashgraph event and runs consensus
func (*Core) KnownEvents ¶
KnownEvents returns known events from the Hashgraph store
func (*Core) ProcessAcceptedInternalTransactions ¶
func (c *Core) ProcessAcceptedInternalTransactions(roundReceived int, receipts []hg.InternalTransactionReceipt) error
ProcessAcceptedInternalTransactions processes the accepted internal transactions
func (*Core) ProcessSigPool ¶
ProcessSigPool calls Hashgraph ProcessSigPool
func (*Core) SetHeadAndSeq ¶
SetHeadAndSeq sets the Head and Seq of a Core object
func (*Core) SignAndInsertSelfEvent ¶
SignAndInsertSelfEvent signs a Hashgraph Event, inserts it and runs consensus
type Graph ¶
type Graph struct {
*Node
}
Graph is a struct containing a node
func (*Graph) GetParticipantEvents ¶
GetParticipantEvents returns Participant Events
type Infos ¶
type Infos struct { ParticipantEvents map[string]map[string]*hg.Event Rounds []*hg.RoundInfo Blocks []*hg.Block }
Infos is a struct providing Hashgraph information
type JoinPromise ¶
type JoinPromise struct { Tx hashgraph.InternalTransaction RespCh chan JoinPromiseResponse }
JoinPromise is a struct for an asynchronous response to a Join Request
func NewJoinPromise ¶
func NewJoinPromise(tx hashgraph.InternalTransaction) *JoinPromise
NewJoinPromise is a factory method for a JoinPromise
type JoinPromiseResponse ¶
JoinPromiseResponse is a struct returned by a Join Promise
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node defines a babble node
func NewNode ¶
func NewNode(conf *Config, validator *Validator, peers *peers.PeerSet, genesisPeers *peers.PeerSet, store hg.Store, trans net.Transport, proxy proxy.AppProxy, ) *Node
NewNode is a factory method that returns a Node instance
func (*Node) GetGenesisPeers ¶
GetGenesisPeers returns the genesis peers
func (*Node) Init ¶
Init initialises the node based on its configuration. It controls the boostrap process which loads the hashgraph from an existing database (if bootstrap option is set in config). It also decides what state the node will start in (Babbling, CatchingUp, or Joining) based on the current validator-set and the value of the fast-sync option.
func (*Node) Leave ¶
Leave causes the node to politely leave the network via a LeaveRequest and wait for the node to be removed from the validator-list via consensus.
func (*Node) Run ¶
Run invokes the main loop of the node. The gossip parameter controls whether to actively participate in gossip or not.
type PeerSelector ¶
PeerSelector defines and interface for Peer Selectors
type RandomPeerSelector ¶
type RandomPeerSelector struct {
// contains filtered or unexported fields
}
RandomPeerSelector defines a struct which controls the random selection of peers
func NewRandomPeerSelector ¶
func NewRandomPeerSelector(peerSet *peers.PeerSet, selfID uint32) *RandomPeerSelector
NewRandomPeerSelector is a factory method that returns a new instance of RandomPeerSelector
func (*RandomPeerSelector) Next ¶
func (ps *RandomPeerSelector) Next() *peers.Peer
Next returns the next peer
func (*RandomPeerSelector) Peers ¶
func (ps *RandomPeerSelector) Peers() *peers.PeerSet
Peers returns a set of peers
func (*RandomPeerSelector) UpdateLast ¶
func (ps *RandomPeerSelector) UpdateLast(peer uint32)
UpdateLast sets the last peer
type State ¶
type State uint32
State captures the state of a Babble node: Babbling, CatchingUp, Joining, or Shutdown
type Validator ¶
type Validator struct { Key *ecdsa.PrivateKey Moniker string // contains filtered or unexported fields }
Validator struct holds information about the validator for a node
func NewValidator ¶
func NewValidator(key *ecdsa.PrivateKey, moniker string) *Validator
NewValidator is a factory method for a Validator
func (*Validator) PublicKeyBytes ¶
PublicKeyBytes returns the validator's public key as a byte array
func (*Validator) PublicKeyHex ¶
PublicKeyHex returns the validator's public key as a hex string