#NEWLINE# def recv_promise( self , from_uid , proposal_id , prev_accepted_id , prev_accepted_value ) : #NEWLINE# #INDENT# '\n        Called when a Promise message is received from the network\n        ' #NEWLINE# self . observe_proposal ( from_uid , proposal_id ) #NEWLINE# if ( self . leader or ( proposal_id != self . proposal_id ) or ( from_uid in self . promises_rcvd ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# self . promises_rcvd . add ( from_uid ) #NEWLINE# if ( prev_accepted_id > self . last_accepted_id ) : #NEWLINE# #INDENT# self . last_accepted_id = prev_accepted_id #NEWLINE# if ( prev_accepted_value is not None ) : #NEWLINE# #INDENT# self . proposed_value = prev_accepted_value #NEWLINE# #UNINDENT# #UNINDENT# if ( len ( self . promises_rcvd ) == self . quorum_size ) : #NEWLINE# #INDENT# self . leader = True #NEWLINE# self . messenger . on_leadership_acquired ( ) #NEWLINE# if ( ( self . proposed_value is not None ) and self . active ) : #NEWLINE# #INDENT# self . messenger . send_accept ( self . proposal_id , self . proposed_value )