Documentation ¶
Index ¶
- Constants
- 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(otherKnown 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) GetAllValidatorSets() (map[int][]*peers.Peer, error)
- func (n *Node) GetBlock(blockIndex int) (*hg.Block, error)
- func (n *Node) GetID() uint32
- func (n *Node) GetLastBlockIndex() int
- func (n *Node) GetLastConsensusRoundIndex() int
- func (n *Node) GetPeers() []*peers.Peer
- func (n *Node) GetStats() map[string]string
- func (n *Node) GetValidatorSet(round int) ([]*peers.Peer, error)
- 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()
- func (n *Node) Suspend()
- type PeerSelector
- type PeerSelectorItem
- type RandomPeerSelector
- type State
- type Validator
Constants ¶
const WGLIMIT = 20
WGLIMIT is the maximum number of goroutines that can be launched through state.goFunc
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 join request // (InternalTransaction) 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 leave request 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 // LastPeerChangeRound is updated whenever a join / leave request is // accepted LastPeerChangeRound 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.Entry) *Core
NewCore is a factory method that returns a new Core object
func (*Core) AddInternalTransaction ¶ added in v0.5.0
func (c *Core) AddInternalTransaction(tx hg.InternalTransaction) *JoinPromise
AddInternalTransaction adds an InternalTransaction to the pool, and creates a corresponding promise.
func (*Core) AddSelfEvent ¶
AddSelfEvent adds a self event
func (*Core) AddTransactions ¶
AddTransactions appends transactions to the transaction pool
func (*Core) Busy ¶ added in v0.5.0
Busy returns a boolean that denotes whether there is incomplete processing
func (*Core) EventDiff ¶
EventDiff returns Events that we are aware of, and that are not known by another. They are returned in topological order. The parameter otherKnown is a map containing the last Event index per participant, as seen by another peer. We compare this to our view of events and return the diff.
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 ¶ added in v0.4.1
InsertEventAndRunConsensus Inserts a hashgraph event and runs consensus
func (*Core) KnownEvents ¶
KnownEvents returns known events from the Hashgraph store
func (*Core) Leave ¶ added in v0.5.0
Leave causes the node to politely leave the network. If the node is not alone, it submits an InternalTransaction to be removed from the validator-set. Otherwise it does nothing.
func (*Core) ProcessAcceptedInternalTransactions ¶ added in v0.5.0
func (c *Core) ProcessAcceptedInternalTransactions(roundReceived int, receipts []hg.InternalTransactionReceipt) error
ProcessAcceptedInternalTransactions processes the accepted internal transactions
func (*Core) ProcessSigPool ¶ added in v0.4.1
ProcessSigPool calls Hashgraph ProcessSigPool
func (*Core) RecordHeads ¶ added in v0.4.1
RecordHeads adds heads as SelfEvents
func (*Core) SetHeadAndSeq ¶
SetHeadAndSeq sets the Head and Seq of a Core object
func (*Core) SetPeers ¶ added in v0.5.0
SetPeers sets the peers property and a New RandomPeerSelector
func (*Core) SignAndInsertSelfEvent ¶
SignAndInsertSelfEvent signs a Hashgraph Event, inserts it and runs consensus
type Graph ¶ added in v0.4.1
type Graph struct {
*Node
}
Graph is a struct containing a node
func (*Graph) GetParticipantEvents ¶ added in v0.4.1
GetParticipantEvents returns Participant Events
type Infos ¶ added in v0.4.1
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 ¶ added in v0.5.0
type JoinPromise struct { Tx hashgraph.InternalTransaction RespCh chan JoinPromiseResponse }
JoinPromise is a struct for an asynchronous response to a Join Request
func NewJoinPromise ¶ added in v0.5.0
func NewJoinPromise(tx hashgraph.InternalTransaction) *JoinPromise
NewJoinPromise is a factory method for a JoinPromise
type JoinPromiseResponse ¶ added in v0.5.0
JoinPromiseResponse is a struct returned by a JoinPromise
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node defines a babble node
func NewNode ¶
func NewNode(conf *config.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) GetAllValidatorSets ¶ added in v0.5.4
GetAllValidatorSets returns the entire history of validator-sets
func (*Node) GetLastBlockIndex ¶ added in v0.5.4
GetLastBlockIndex returns the index of the last known block
func (*Node) GetLastConsensusRoundIndex ¶ added in v0.5.4
GetLastConsensusRoundIndex returns the index of the last consensus round
func (*Node) GetPeers ¶ added in v0.4.1
GetPeers returns the current peers. Not necessarily equal to the current validator-set
func (*Node) GetValidatorSet ¶ added in v0.5.4
GetValidatorSet returns the validator-set associated to a round
func (*Node) Init ¶
Init controls the bootstrap process and sets the node's initial state based on configuration (Babbling, CatchingUp, Joining, or Suspended).
func (*Node) Leave ¶ added in v0.5.0
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 ¶
type PeerSelector interface { Peers() *peers.PeerSet UpdateLast(peer uint32, connected bool) bool Next() *peers.Peer }
PeerSelector defines and interface for Peer Selectors
type PeerSelectorItem ¶ added in v0.5.4
PeerSelectorItem is a wrapper around a Peer that keeps track of the connection status
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 the current set of peers
func (*RandomPeerSelector) UpdateLast ¶
func (ps *RandomPeerSelector) UpdateLast(peer uint32, connected bool) (newConnection bool)
UpdateLast sets the last peer and updates its connection status
type State ¶ added in v0.5.0
type State uint32
State captures the state of a Babble node: Babbling, CatchingUp, Joining, Leaving, Suspended, or Shutdown
type Validator ¶ added in v0.5.0
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 ¶ added in v0.5.0
func NewValidator(key *ecdsa.PrivateKey, moniker string) *Validator
NewValidator is a factory method for a Validator
func (*Validator) PublicKeyBytes ¶ added in v0.5.0
PublicKeyBytes returns the validator's public key as a byte array
func (*Validator) PublicKeyHex ¶ added in v0.5.0
PublicKeyHex returns the validator's public key as a hex string