@@ -810,42 +810,48 @@ def GetShardsNumber(self, block=None):
810810
811811 def GetValidatorStatus (self ):
812812 # Get buffer
813- bname = "validatorStatus "
813+ bname = "validator_status "
814814 buff = self .GetFunctionBuffer (bname )
815815 if buff :
816816 return buff
817817 #end if
818818
819819 self .local .add_log ("start GetValidatorStatus function" , "debug" )
820- validatorStatus = dict ()
820+ status = Dict ()
821821 try :
822- validatorStatus ["isWorking" ] = True
822+ # Parse
823+ status .is_working = True
823824 result = self .validatorConsole .Run ("getstats" )
824- validatorStatus [ " unixtime" ] = int (parse (result , "unixtime" , '\n ' ))
825- validatorStatus [ " masterchainblocktime" ] = int (parse (result , "masterchainblocktime" , '\n ' ))
826- validatorStatus [ " stateserializermasterchainseqno" ] = int (parse (result , "stateserializermasterchainseqno" , '\n ' ))
827- validatorStatus [ " shardclientmasterchainseqno" ] = int (parse (result , "shardclientmasterchainseqno" , '\n ' ))
825+ status . unixtime = int (parse (result , "unixtime" , '\n ' ))
826+ status . masterchainblocktime = int (parse (result , "masterchainblocktime" , '\n ' ))
827+ status . stateserializermasterchainseqno = int (parse (result , "stateserializermasterchainseqno" , '\n ' ))
828+ status . shardclientmasterchainseqno = int (parse (result , "shardclientmasterchainseqno" , '\n ' ))
828829 buff = parse (result , "masterchainblock" , '\n ' )
829- validatorStatus [ " masterchainblock" ] = self .GVS_GetItemFromBuff (buff )
830+ status . masterchainblock = self .GVS_GetItemFromBuff (buff )
830831 buff = parse (result , "gcmasterchainblock" , '\n ' )
831- validatorStatus [ " gcmasterchainblock" ] = self .GVS_GetItemFromBuff (buff )
832+ status . gcmasterchainblock = self .GVS_GetItemFromBuff (buff )
832833 buff = parse (result , "keymasterchainblock" , '\n ' )
833- validatorStatus [ " keymasterchainblock" ] = self .GVS_GetItemFromBuff (buff )
834+ status . keymasterchainblock = self .GVS_GetItemFromBuff (buff )
834835 buff = parse (result , "rotatemasterchainblock" , '\n ' )
835- validatorStatus ["rotatemasterchainblock" ] = self .GVS_GetItemFromBuff (buff )
836- validatorStatus ["transNum" ] = self .local .buffer .get ("transNum" , - 1 )
837- validatorStatus ["blocksNum" ] = self .local .buffer .get ("blocksNum" , - 1 )
838- validatorStatus ["masterBlocksNum" ] = self .local .buffer .get ("masterBlocksNum" , - 1 )
836+ status .rotatemasterchainblock = self .GVS_GetItemFromBuff (buff )
837+ # Calculate
838+ status .masterchain_out_of_sync = status .unixtime - status .masterchainblocktime
839+ status .shardchain_out_of_sync = status .masterchainblock - status .shardclientmasterchainseqno
840+ status .masterchain_out_of_ser = status .masterchainblock - status .stateserializermasterchainseqno
841+ status .out_of_sync = status .masterchain_out_of_sync if status .masterchain_out_of_sync > status .shardchain_out_of_sync else status .shardchain_out_of_sync
842+ status .out_of_ser = status .masterchain_out_of_ser
839843 except Exception as ex :
840844 self .local .add_log (f"GetValidatorStatus warning: { ex } " , "warning" )
841- validatorStatus ["isWorking" ] = False
842- validatorStatus ["unixtime" ] = get_timestamp ()
843- validatorStatus ["masterchainblocktime" ] = 0
844- validatorStatus ["outOfSync" ] = validatorStatus ["unixtime" ] - validatorStatus ["masterchainblocktime" ]
845+ status .is_working = False
846+ #end try
847+
848+ # old vars
849+ status .outOfSync = status .out_of_sync
850+ status .isWorking = status .is_working
845851
846852 # Set buffer
847- self .SetFunctionBuffer (bname , validatorStatus )
848- return validatorStatus
853+ self .SetFunctionBuffer (bname , status )
854+ return status
849855 #end define
850856
851857 def GVS_GetItemFromBuff (self , buff ):
@@ -2349,12 +2355,12 @@ def VoteOffer(self, offerHash):
23492355 if validatorIndex in offer .get ("votedValidators" ):
23502356 self .local .add_log ("Proposal already has been voted" , "debug" )
23512357 return
2358+ self .add_save_offer (offer )
23522359 var1 = self .CreateConfigProposalRequest (offerHash , validatorIndex )
23532360 validatorSignature = self .GetValidatorSignature (validatorKey , var1 )
23542361 resultFilePath = self .SignProposalVoteRequestWithValidator (offerHash , validatorIndex , validatorPubkey_b64 , validatorSignature )
23552362 resultFilePath = self .SignBocWithWallet (wallet , resultFilePath , fullConfigAddr , 1.5 )
23562363 self .SendFile (resultFilePath , wallet )
2357- self .add_save_offer (offer )
23582364 #end define
23592365
23602366 def VoteComplaint (self , electionId , complaintHash ):
0 commit comments