Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/messages.py
Show All 21 Lines | |||||
import copy | import copy | ||||
import hashlib | import hashlib | ||||
from io import BytesIO | from io import BytesIO | ||||
import random | import random | ||||
import socket | import socket | ||||
import struct | import struct | ||||
import time | import time | ||||
from typing import List | |||||
from test_framework.siphash import siphash256 | from test_framework.siphash import siphash256 | ||||
from test_framework.util import hex_str_to_bytes, assert_equal | from test_framework.util import hex_str_to_bytes, assert_equal | ||||
MIN_VERSION_SUPPORTED = 60001 | MIN_VERSION_SUPPORTED = 60001 | ||||
# past bip-31 for ping/pong | # past bip-31 for ping/pong | ||||
MY_VERSION = 70014 | MY_VERSION = 70014 | ||||
MY_SUBVERSION = b"/python-mininode-tester:0.0.3/" | MY_SUBVERSION = b"/python-mininode-tester:0.0.3/" | ||||
▲ Show 20 Lines • Show All 905 Lines • ▼ Show 20 Lines | def __repr__(self): | ||||
return "AvalancheDelegationLevel(pubkey={}, sig={})".format( | return "AvalancheDelegationLevel(pubkey={}, sig={})".format( | ||||
self.pubkey.hex(), self.sig) | self.pubkey.hex(), self.sig) | ||||
class AvalancheDelegation: | class AvalancheDelegation: | ||||
__slots__ = ("proofid", "levels") | __slots__ = ("proofid", "levels") | ||||
def __init__(self, proofid=0, levels=None): | def __init__(self, proofid=0, levels=None): | ||||
self.proofid = proofid | self.proofid: int = proofid | ||||
self.levels = levels | self.levels: List[AvalancheDelegationLevel] = levels or [] | ||||
def deserialize(self, f): | def deserialize(self, f): | ||||
self.proofid = deser_uint256(f) | self.proofid = deser_uint256(f) | ||||
self.levels = deser_vector(f, AvalancheDelegationLevel) | self.levels = deser_vector(f, AvalancheDelegationLevel) | ||||
def serialize(self): | def serialize(self): | ||||
r = b"" | r = b"" | ||||
r += ser_uint256(self.proofid) | r += ser_uint256(self.proofid) | ||||
▲ Show 20 Lines • Show All 914 Lines • Show Last 20 Lines |