Documentation ¶
Overview ¶
Package leader implements leader election between cored processes of a Chain Core.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoLeader = errors.New("no leader process")
ErrNoLeader is returned from Address when no process is currently leader.
Functions ¶
This section is empty.
Types ¶
type Leader ¶
type Leader struct {
// contains filtered or unexported fields
}
Leader provides access to the Core leader process.
func Run ¶
Run starts a goroutine, trying once every five seconds to become the leader for the core. If it succeeds, then it calls the function lead (for generating or fetching blocks, and for expiring reservations) and enters a leadership-keepalive loop.
Function lead is called when the local process becomes the leader. Its context is canceled when the process is deposed as leader.
Run returns a pointer to a Leader struct that can be queried to check the state of the process or find the current leader.
The Chain Core has up to a 1.5-second refractory period after shutdown, during which no process may be leader.
func (*Leader) State ¶
func (l *Leader) State() ProcessState
State returns the current state of this process.
type ProcessState ¶
type ProcessState int
ProcessState is an enum describing the current state of the process. A recovering process has become leader but is still recovering the blockchain state. Some functionality is not available until the process enters the Leading state.
const ( Following ProcessState = iota Recovering Leading )
func (ProcessState) String ¶
func (ps ProcessState) String() string