Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AcceptedValue ¶
type AcceptedValue struct { Value Value Origin ProposalID }
An AcceptedValue is a Value plus the proposal which originated that Value. The origin is not essential, but makes comparing AcceptedValues easy even if comparing Values is not.
type GossipState ¶
type GossipState map[NodeID]NodeClaims
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
func (*Node) Consensus ¶
func (node *Node) Consensus() (bool, AcceptedValue)
Has a consensus been reached, based on the known claims of other nodes?
func (*Node) GossipState ¶
func (node *Node) GossipState() GossipState
func (*Node) Propose ¶
func (node *Node) Propose()
Initiate a new proposal, i.e. the Paxos "Prepare" step. This is simply a matter of gossipping a new proposal that supersedes all others.
func (*Node) Think ¶
The heart of the consensus algorithm. Return true if we have changed our claims.
func (*Node) Update ¶
func (node *Node) Update(from GossipState) bool
Update this node's information about what other nodes know. Returns true if we learned something new.
type NodeClaims ¶
type NodeClaims struct { // The node promises not to accept a proposal with id less // than this. Promise ProposalID // The accepted proposal, if valid Accepted ProposalID AcceptedVal AcceptedValue }
type NodeID ¶
The node identifier. The use of the UID here is important: Paxos acceptors must not forget their promises, so it's important that a node does not restart and lose its Paxos state but claim to have the same ID.
type ProposalID ¶
type ProposalID struct { // round numbers begin at 1. round 0 indicates an // uninitialized ProposalID, and precedes all other ProposalIDs Round uint Proposer NodeID }
note all fields exported in structs so we can Gob them