def __init__(self, remote=False): super().__init__() # Track number of messages of each type received and the most recent # message of each type self.message_count = defaultdict(int) self.protocol_message_count = defaultdict(int) self.last_message = {} self.last_protocol_message = {} # Default protocol version self.protocol = b'cfx' self.protocol_version = 1 self.genesis = make_genesis() self.best_block_hash = self.genesis.block_header.hash self.blocks = {self.genesis.block_header.hash: self.genesis} self.peer_pubkey = None self.priv_key, self.pub_key = ec_random_keys() x, y = self.pub_key self.key = "0x" + encode_hex(bytes(int_to_32bytearray(x)))[2:] + encode_hex(bytes(int_to_32bytearray(y)))[2:] self.had_status = False self.on_packet_func = {} self.remote = remote
import rlp import sys, os from eth_utils import decode_hex sys.path.insert(1, os.path.join(sys.path[0], '..')) from conflux.utils import ec_random_keys, encode_hex, priv_to_pub NUM_NODES = 2 for _ in range(NUM_NODES): pri_key_raw, _ = ec_random_keys() pri_key = encode_hex(pri_key_raw) pub_key = encode_hex(priv_to_pub(pri_key_raw)) # print(f""" {host}: # index: {i} print(f""" net_pri_key: \"{pri_key}\" net_pub_key: \"{pub_key}\"""") # i += 1