#NEWLINE# def request( self ) : #NEWLINE# #INDENT# '\n        sync the missing blocks between:\n            head\n            highest height with signing lockset\n\n        we get these locksets by collecting votes on all heights\n        ' #NEWLINE# missing = self . missing #NEWLINE# self . cm . log ( 'sync.request' , missing = len ( missing ) , requested = len ( self . requested ) , received = len ( self . received ) ) #NEWLINE# if self . requested : #NEWLINE# #INDENT# self . cm . log ( 'waiting for requested' ) #NEWLINE# return #NEWLINE# #UNINDENT# if ( ( len ( self . received ) + self . max_getproposals_count ) >= self . max_queued ) : #NEWLINE# #INDENT# self . cm . log ( 'queue is full' ) #NEWLINE# return #NEWLINE# #UNINDENT# if ( not missing ) : #NEWLINE# #INDENT# self . cm . log ( 'insync' ) #NEWLINE# return #NEWLINE# #UNINDENT# if ( self . last_active_protocol is None ) : #NEWLINE# #INDENT# self . cm . log ( 'no active protocol' , last_active_protocol = self . last_active_protocol ) #NEWLINE# return #NEWLINE# #UNINDENT# self . cm . log ( 'collecting' ) #NEWLINE# blocknumbers = [ ] #NEWLINE# for h in missing : #NEWLINE# #INDENT# if ( ( h not in self . received ) and ( h not in self . requested ) ) : #NEWLINE# #INDENT# blocknumbers . append ( h ) #NEWLINE# self . requested . add ( h ) #NEWLINE# if ( len ( blocknumbers ) == self . max_getproposals_count ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . cm . log ( 'collected' , num = len ( blocknumbers ) ) #NEWLINE# if ( not h ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# self . cm . log ( 'requesting' , num = len ( blocknumbers ) , requesting_range = ( blocknumbers [ 0 ] , blocknumbers [ ( - 1 ) ] ) ) #NEWLINE# self . last_active_protocol . send_getblockproposals ( * blocknumbers ) #NEWLINE# self . cm . chainservice . setup_alarm ( self . timeout , self . on_alarm , blocknumbers )