Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc_p2p_avalanche.py
Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | class TestNode(P2PInterface): | ||||
def on_version(self, message): | def on_version(self, message): | ||||
super().on_version(message) | super().on_version(message) | ||||
# Save the nonce and extra entropy so they can be reused later. | # Save the nonce and extra entropy so they can be reused later. | ||||
self.remote_nonce = message.nNonce | self.remote_nonce = message.nNonce | ||||
self.remote_extra_entropy = message.nExtraEntropy | self.remote_extra_entropy = message.nExtraEntropy | ||||
def on_avaresponse(self, message): | def on_avaresponse(self, message): | ||||
with mininode_lock: | |||||
self.avaresponses.append(message.response) | self.avaresponses.append(message.response) | ||||
def on_avapoll(self, message): | def on_avapoll(self, message): | ||||
with mininode_lock: | |||||
self.avapolls.append(message.poll) | self.avapolls.append(message.poll) | ||||
def on_avahello(self, message): | def on_avahello(self, message): | ||||
with mininode_lock: | |||||
assert(self.avahello is None) | assert(self.avahello is None) | ||||
self.avahello = message | self.avahello = message | ||||
def send_avaresponse(self, round, votes, privkey): | def send_avaresponse(self, round, votes, privkey): | ||||
response = AvalancheResponse(round, 0, votes) | response = AvalancheResponse(round, 0, votes) | ||||
sig = privkey.sign_schnorr(response.get_hash()) | sig = privkey.sign_schnorr(response.get_hash()) | ||||
msg = msg_tcpavaresponse() | msg = msg_tcpavaresponse() | ||||
msg.response = TCPAvalancheResponse(response, sig) | msg.response = TCPAvalancheResponse(response, sig) | ||||
self.send_message(msg) | self.send_message(msg) | ||||
▲ Show 20 Lines • Show All 284 Lines • Show Last 20 Lines |