def get_dpos_votes(self): list_producers = rpc.list_producers(0, 200) if list_producers is False: return 0 total_votes = float(list_producers["totalvotes"]) # candidates = rpc.get_arbiters_info()["candidates"] dpos_votes = dict() producers = list_producers["producers"] for producer in producers: node_pubkey = producer["nodepublickey"] dpos_votes[ self.node_manager.node_pubkey_name_dict[node_pubkey]] = float( producer["votes"]) # if after_h2_transactions is not None: # for tx_income in after_h2_transactions: # if tx_income.node_pubkey != "" and tx_income.node_pubkey in candidates: # total_votes -= tx_income.votes # node_name = self.node_manager.node_pubkey_name_dict[tx_income.node_pubkey] # origin_votes = dpos_votes[node_name] # origin_votes -= tx_income.votes # dpos_votes[node_name] = origin_votes Logger.debug("{} total votes: {}".format(self.tag, total_votes)) dpos_votes["total"] = total_votes self.dpos_votes_dict = dpos_votes return dpos_votes
def get_list_producers_names(self): producers_names = list() list_producers = rpc.list_producers(0, 100) for producer in list_producers["producers"]: node_public_key = producer["nodepublickey"] name = self.node_manager.node_pubkey_name_dict[node_public_key] producers_names.append(name) return producers_names
def ready_for_dpos(self): producers = rpc.list_producers(0, 100, state="active") if producers is None: Logger.info('{} list producers is null'.format(self.tag)) return Logger.debug('{} list producers:{}'.format(self.tag, producers)) self.producers_list = producers["producers"] ret = self.vote_producers_candidates() self.check_result("vote producers", ret) Logger.info("{} vote producer on success!".format(self.tag))
def get_producer_state(index: int): list_producers = rpc.list_producers(0, 100) producers = list_producers["producers"] return producers[index]["state"]