\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[ruled,vlined,linesnumbered]{algorithm2e}
\usepackage{amssymb}
\begin{document}
{{\DontPrintSemicolon
\SetAlgoNoLine
\LinesNumberedHidden
\SetFuncSty{textbf}
\begin{algorithm}[ht]
\BlankLine
\BlankLine
\BlankLine

\SetKwFunction{FunctionID}{State}
\SetKwProg{Fn}{}{:}{}
\Fn{\FunctionID}{
acceptors
// set of known acceptors
\;promises
// promise messages received
\;n
// proposal number
\;v
// proposal value
}

\;\SetKwFunction{FunctionID}{Init}
\SetKwProg{Fn}{Upon }{ do:}{}
\Fn{\FunctionID}{
// gets set of acceptors
\;acceptors $\longleftarrow$ \FuncSty{getAcceptors(}\ArgSty{}\FuncSty{)}
}

\;\SetKwFunction{FunctionID}{Receive}
\SetKwProg{Fn}{Upon event }{ do:}{}
\Fn{\FunctionID{PROPOSE, v}}{
promises $\longleftarrow$ \{\}
\;// generates a unique number higher than any n seen so far
\;n $\longleftarrow$ \FuncSty{getNextN(}\ArgSty{}\FuncSty{)}
\;v $\longleftarrow$ $\bot$
\;\ForEach{acceptor $\in$ acceptors}{\FuncSty{Trigger} \FuncSty{Send(}\ArgSty{PREPARE, acceptor, n}\FuncSty{)}}
}

\;\SetKwFunction{FunctionID}{Receive}
\SetKwProg{Fn}{Upon event }{ do:}{}
\Fn{\FunctionID{PROMISE, prepared\_n, na, va}}{
\If{prepared\_n $=$ n}{promises $\longleftarrow$ promises $\cup$ \{na, va\}
\;\If{$\neg$ (\#promises $\neq$ \#acceptors / 2)}{v $\longleftarrow$ \FuncSty{getVaWithHighestNa(}\ArgSty{promises}\FuncSty{)}
\;\ForEach{acceptor $\in$ acceptors}{\FuncSty{Trigger} \FuncSty{Send(}\ArgSty{ACCEPT, acceptor, n}\FuncSty{)}}}}
}

\BlankLine
\BlankLine
\BlankLine
\end{algorithm}
\end{document}