Corrected Algorithm 3.2

Initially waiting is empty and status = asleep

 1. let R be the set of message received in this computation event
 2. S := empty set  // holds messages to be sent

 3. if status = asleep then
 4.    if R is empty then
 5.       status = participating
 6.       min := id
 7.       add <id,1> to S  // first phase message
 8.    else                
 9.       status = relay
10.      min := infinity
11.    endif
12. endif

13. for each <m,h> in R do
14.    if m < min then
15.       become not elected
16.       min := m
17.       if (status = relay) & (h = 1) then
18.          add (m,h) to S
19.       else 
20.          add (m,2) to waiting tagged with current round number
21.       endif
22.    elseif m = id then become elected endif
23. // if m > min then it is swallowed
24. endfor

25. for each <m,2> in waiting do
26.    if <m,2> was received 2^m - 1 rounds ago then
27.       remove <m,2> from waiting and add it to S
28.    endif
29. endfor