@@ -1428,17 +1428,30 @@ def ElectionEntry(self, args=None):
14281428 #end if
14291429
14301430 # Get ADNL address
1431- adnlAddr = self .GetAdnlAddr ()
1431+ adnl_addr = self .GetAdnlAddr ()
1432+ adnl_addr_bytes = bytes .fromhex (adnl_addr )
14321433
14331434 # Check wether it is too early to participate
14341435 if "participateBeforeEnd" in self .local .db :
14351436 now = time .time ()
14361437 if (startWorkTime - now ) > self .local .db ["participateBeforeEnd" ] and \
14371438 (now + self .local .db ["periods" ]["elections" ]) < startWorkTime :
14381439 return
1440+
1441+ vconfig = self .GetValidatorConfig ()
1442+
1443+ have_adnl = False
1444+ # Check if ADNL address is in the list
1445+ for a in vconfig .adnl :
1446+ if base64 .b64decode (a .id ) == adnl_addr_bytes :
1447+ have_adnl = True
1448+ break
1449+ if not have_adnl :
1450+ raise Exception ('ADNL address is not found' )
1451+
14391452 # Check if election entry already completed
14401453 entries = self .GetElectionEntries ()
1441- if adnlAddr in entries :
1454+ if adnl_addr in entries :
14421455 self .local .add_log ("Elections entry already completed" , "info" )
14431456 return
14441457 #end if
@@ -1456,32 +1469,32 @@ def ElectionEntry(self, args=None):
14561469 validatorPubkey_b64 = self .GetPubKeyBase64 (validatorKey )
14571470
14581471 # Attach ADNL addr to validator
1459- self .AttachAdnlAddrToValidator (adnlAddr , validatorKey , endWorkTime )
1472+ self .AttachAdnlAddrToValidator (adnl_addr , validatorKey , endWorkTime )
14601473
14611474 # Get max factor
14621475 maxFactor = self .GetMaxFactor ()
14631476
14641477 # Create fift's. Continue with pool or walet
14651478 if usePool :
1466- var1 = self .CreateElectionRequest (pool , startWorkTime , adnlAddr , maxFactor )
1479+ var1 = self .CreateElectionRequest (pool , startWorkTime , adnl_addr , maxFactor )
14671480 validatorSignature = self .GetValidatorSignature (validatorKey , var1 )
1468- validatorPubkey , resultFilePath = self .SignElectionRequestWithPoolWithValidator (pool , startWorkTime , adnlAddr , validatorPubkey_b64 , validatorSignature , maxFactor , stake )
1481+ validatorPubkey , resultFilePath = self .SignElectionRequestWithPoolWithValidator (pool , startWorkTime , adnl_addr , validatorPubkey_b64 , validatorSignature , maxFactor , stake )
14691482
14701483 # Send boc file to TON
14711484 resultFilePath = self .SignBocWithWallet (wallet , resultFilePath , pool .addrB64 , 1.3 )
14721485 self .SendFile (resultFilePath , wallet )
14731486 else :
1474- var1 = self .CreateElectionRequest (wallet , startWorkTime , adnlAddr , maxFactor )
1487+ var1 = self .CreateElectionRequest (wallet , startWorkTime , adnl_addr , maxFactor )
14751488 validatorSignature = self .GetValidatorSignature (validatorKey , var1 )
1476- validatorPubkey , resultFilePath = self .SignElectionRequestWithValidator (wallet , startWorkTime , adnlAddr , validatorPubkey_b64 , validatorSignature , maxFactor )
1489+ validatorPubkey , resultFilePath = self .SignElectionRequestWithValidator (wallet , startWorkTime , adnl_addr , validatorPubkey_b64 , validatorSignature , maxFactor )
14771490
14781491 # Send boc file to TON
14791492 resultFilePath = self .SignBocWithWallet (wallet , resultFilePath , fullElectorAddr , stake )
14801493 self .SendFile (resultFilePath , wallet )
14811494 #end if
14821495
14831496 # Save vars to json file
1484- self .SaveElectionVarsToJsonFile (wallet = wallet , account = account , stake = stake , maxFactor = maxFactor , fullElectorAddr = fullElectorAddr , startWorkTime = startWorkTime , validatorsElectedFor = validatorsElectedFor , endWorkTime = endWorkTime , validatorKey = validatorKey , validatorPubkey_b64 = validatorPubkey_b64 , adnlAddr = adnlAddr , var1 = var1 , validatorSignature = validatorSignature , validatorPubkey = validatorPubkey )
1497+ self .SaveElectionVarsToJsonFile (wallet = wallet , account = account , stake = stake , maxFactor = maxFactor , fullElectorAddr = fullElectorAddr , startWorkTime = startWorkTime , validatorsElectedFor = validatorsElectedFor , endWorkTime = endWorkTime , validatorKey = validatorKey , validatorPubkey_b64 = validatorPubkey_b64 , adnlAddr = adnl_addr , var1 = var1 , validatorSignature = validatorSignature , validatorPubkey = validatorPubkey )
14851498
14861499 self .local .add_log ("ElectionEntry completed. Start work time: " + str (startWorkTime ))
14871500 #end define
0 commit comments