Skip to content

Instantly share code, notes, and snippets.

@SamvitJ
Created Oct 23, 2016
Embed
What would you like to do?
Paxos Pseudocode
--- Paxos Proposer ---
proposer(v):
choose n > n_p
send prepare(n) to all servers including self
if prepare_ok(n, n_a, v_a) from majority:
v’ = v_a with highest n_a; choose own v otherwise
send accept(n, v’) to all
if accept_ok(n) from majority:
send decided(v’) to all
--- Paxos Acceptor ---
acceptor state on each node (persistent):
n_p --- highest prepare seen
n_a, v_a --- highest accept seen
acceptor’s prepare(n) handler:
if n > n_p
n_p = n
reply prepare_ok(n, n_a, v_a)
acceptor’s accept(n, v) handler:
if n >= n_p
n_p = n
n_a = n
v_a = v
reply accept_ok(n)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment