#NEWLINE# def recv_accepted( self , from_uid , proposal_id , accepted_value ) : #NEWLINE# #INDENT# '\n        Called when an Accepted message is received from an acceptor\n        ' #NEWLINE# if ( self . final_value is not None ) : #NEWLINE# #INDENT# if ( accepted_value == self . final_value ) : #NEWLINE# #INDENT# self . final_acceptors . add ( from_uid ) #NEWLINE# #UNINDENT# return #NEWLINE# #UNINDENT# if ( self . proposals is None ) : #NEWLINE# #INDENT# self . proposals = dict ( ) #NEWLINE# self . acceptors = dict ( ) #NEWLINE# #UNINDENT# last_pn = self . acceptors . get ( from_uid ) #NEWLINE# if ( not ( proposal_id > last_pn ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# self . acceptors [ from_uid ] = proposal_id #NEWLINE# if ( last_pn is not None ) : #NEWLINE# #INDENT# oldp = self . proposals [ last_pn ] #NEWLINE# oldp [ 1 ] . remove ( from_uid ) #NEWLINE# if ( len ( oldp [ 1 ] ) == 0 ) : #NEWLINE# #INDENT# del self . proposals [ last_pn ] #NEWLINE# #UNINDENT# #UNINDENT# if ( not ( proposal_id in self . proposals ) ) : #NEWLINE# #INDENT# self . proposals [ proposal_id ] = [ set ( ) , set ( ) , accepted_value ] #NEWLINE# #UNINDENT# t = self . proposals [ proposal_id ] #NEWLINE# assert ( accepted_value == t [ 2 ] ) , 'Value mismatch for single proposal!' #NEWLINE# t [ 0 ] . add ( from_uid ) #NEWLINE# t [ 1 ] . add ( from_uid ) #NEWLINE# if ( len ( t [ 0 ] ) == self . quorum_size ) : #NEWLINE# #INDENT# self . final_value = accepted_value #NEWLINE# self . final_proposal_id = proposal_id #NEWLINE# self . final_acceptors = t [ 0 ] #NEWLINE# self . proposals = None #NEWLINE# self . acceptors = None #NEWLINE# self . messenger . on_resolution ( proposal_id , accepted_value )