def add_or_update(self, pubkey:str, ip: int, port: int, uid: int, ip_type: int, modality: int, lastemit: int, stake: int, w_uids: List[str], w_vals: List[int]): address_str = net.int_to_ip(ip) neuron = bittensor_pb2.Neuron( version = bittensor.__version__, public_key = pubkey, address = address_str, port = int(port), ip_type = int(ip_type), modality = int(modality), uid = int(uid), ) if pubkey in self.index_for_pubkey: index = self.index_for_pubkey[pubkey] self.neurons[index] = neuron self.stake[index] = float(stake) / 1000000000 self.lastemit[index] = int(lastemit) self.weight_uids[index] = list(w_uids) self.weight_vals[index] = list(w_vals) self.uids[index] = int(uid) else: index = self.n self.n += 1 self.index_for_pubkey[pubkey] = index self.pubkey_for_index[index] = pubkey self.neurons.append(neuron) self.stake.append(float(stake) / 1000000000) self.lastemit.append(int(lastemit)) self.weight_uids.append(list(w_uids)) self.weight_vals.append(list(w_vals)) self.uids.append( uid ) self.index_for_uid[uid] = index
def __init__(self, uid, hotkey, ip, ip_type, modality, coldkey): self.uid = uid self.hotkey = hotkey self.ip = net.int_to_ip(ip) self.ip_type = ip_type self.coldkey = coldkey self.modality = modality self.stake = int
def __init__(self, version: int, uid: int, hotkey: str, ip: str, ip_type: int, port: int, modality: int, coldkey: str): self.version = version self.uid = uid self.hotkey = hotkey self.ip = net.int_to_ip(ip) self.ip_type = ip_type self.port = port self.coldkey = coldkey self.modality = modality if self.check_format(): # possibly throw a warning here. pass
def add_or_update(self, pubkey: str, ip: int, port: int, uid: int, ip_type: int, modality: int, lastemit: int, stake: int, w_uids: List[int], w_vals: List[int]): address_str = net.int_to_ip(ip) neuron = bittensor.proto.Neuron( version=bittensor.__version__, public_key=pubkey, address=address_str, port=int(port), ip_type=int(ip_type), modality=int(modality), uid=int(uid), ) if pubkey in self.index_for_pubkey: index = self.index_for_pubkey[pubkey] if self.uids[index] == uid: self.neurons[index] = neuron self.stake[index] = float(stake) / 1000000000 self.lastemit[index] = int(lastemit) self.weight_uids[index] = list(w_uids) self.weight_vals[index] = list(w_vals) self.uids[index] = int(uid) else: raise ValueError( 'received inconsistent uid - pubey pairing with uid{}, pubkey{} and expected uid {}' .format(uid, pubkey, self.uids[index])) else: index = self.n self.n += 1 self.index_for_pubkey[pubkey] = index self.pubkey_for_index[index] = pubkey self.neurons.append(neuron) self.stake.append(float(stake) / 1000000000) self.lastemit.append(int(lastemit)) self.weight_uids.append(list(w_uids)) self.weight_vals.append(list(w_vals)) self.uids.append(uid) self.index_for_uid[uid] = index