def deserialize(cls, votes_data: List[Dict], voting_ratio: float): if votes_data: votes = [LeaderVote.deserialize(vote_data) for vote_data in votes_data] reps = [vote.rep for vote in votes] votes_instance = cls(reps, voting_ratio, votes[0].block_height, votes[0].round_, votes[0].old_leader) for vote in votes: index = reps.index(vote.rep) votes_instance.votes[index] = vote return votes_instance else: return cls([], voting_ratio, -1, -1, ExternalAddress.empty())
async def complain_leader(self, vote_dumped: str) -> None: vote_serialized = json.loads(vote_dumped) vote = LeaderVote.deserialize(vote_serialized) self._block_manager.add_complain(vote)