@@ -95,14 +95,15 @@ def auto_vote_offers(self):
9595 if not save_offers :
9696 return
9797 current_offers = self .get_offers ()
98+ config34 = self .ton .GetConfig34 ()
9899 for save_offer in list (save_offers .values ()):
99100 offer_hash = save_offer ['hash' ]
100101 if offer_hash not in current_offers :
102+ if save_offer ['ttl' ] > config34 ['endWorkTime' ]: # offer is not expired but not found in current offers, so we assume it has been accepted
103+ save_offers .pop (offer_hash )
104+ self .local .add_log (f'Removing offer { offer_hash } from saved offers' , 'debug' )
101105 continue
102106 offer = current_offers [save_offer ['hash' ]]
103- if offer ['isPassed' ]:
104- save_offers .pop (offer_hash )
105- continue
106107 self .vote_offer_btc_teleport ([offer ['hash' ]])
107108
108109 def get_offers (self ):
@@ -143,6 +144,12 @@ def get_offers(self):
143144 offers [o_hash ] = item
144145 return offers
145146
147+ def add_save_offer (self , offer : dict ):
148+ config15 = self .ton .GetConfig15 ()
149+ offer ['ttl' ] = offer ['created_at' ] + config15 ['validatorsElectedFor' ] * 3 # proposal lives 3 rounds
150+ self .get_save_offers ()[offer ['hash' ]] = offer
151+ self .ton .local .save ()
152+
146153 def vote_offer_btc_teleport (self , args ):
147154 if len (args ) == 0 :
148155 color_print ("{red}Bad args. Usage:{endc} vote_offer_btc_teleport <offer-hash> [offer-hash-2 offer-hash-3 ...]" )
@@ -164,8 +171,7 @@ def vote_offer_btc_teleport(self, args):
164171 if validator_index in offer .get ("votedValidators" ):
165172 self .local .add_log ("Proposal already has been voted" , "debug" )
166173 return
167- self .get_save_offers ()[offer_hash ] = offer
168- self .ton .local .save ()
174+ self .add_save_offer (offer )
169175 request_hash = self .ton .CreateConfigProposalRequest (offer_hash , validator_index )
170176 validator_signature = self .ton .GetValidatorSignature (validator_key , request_hash )
171177 path = self .ton .SignProposalVoteRequestWithValidator (offer_hash , validator_index , validator_pubkey_b64 ,
0 commit comments