Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/messages.py
Show All 20 Lines | |||||
import copy | import copy | ||||
import hashlib | import hashlib | ||||
import random | import random | ||||
import socket | import socket | ||||
import struct | import struct | ||||
import time | import time | ||||
import unittest | import unittest | ||||
from codecs import encode | from codecs import encode | ||||
from enum import IntEnum | |||||
from io import BytesIO | from io import BytesIO | ||||
from typing import List | from typing import List | ||||
from test_framework.siphash import siphash256 | from test_framework.siphash import siphash256 | ||||
from test_framework.util import assert_equal, hex_str_to_bytes | from test_framework.util import assert_equal, hex_str_to_bytes | ||||
MIN_VERSION_SUPPORTED = 60001 | MIN_VERSION_SUPPORTED = 60001 | ||||
# past bip-31 for ping/pong | # past bip-31 for ping/pong | ||||
▲ Show 20 Lines • Show All 935 Lines • ▼ Show 20 Lines | def serialize(self): | ||||
r += ser_vector(self.invs) | r += ser_vector(self.invs) | ||||
return r | return r | ||||
def __repr__(self): | def __repr__(self): | ||||
return "AvalanchePoll(round={}, invs={})".format( | return "AvalanchePoll(round={}, invs={})".format( | ||||
self.round, repr(self.invs)) | self.round, repr(self.invs)) | ||||
class AvalancheVoteError(IntEnum): | |||||
ACCEPTED = 0 | |||||
INVALID = 1 | |||||
PARKED = 2 | |||||
FORK = 3 | |||||
UNKNOWN = -1 | |||||
MISSING = -2 | |||||
PENDING = -3 | |||||
class AvalancheVote(): | class AvalancheVote(): | ||||
__slots__ = ("error", "hash") | __slots__ = ("error", "hash") | ||||
def __init__(self, e=0, h=0): | def __init__(self, e=0, h=0): | ||||
self.error = e | self.error = e | ||||
self.hash = h | self.hash = h | ||||
def deserialize(self, f): | def deserialize(self, f): | ||||
▲ Show 20 Lines • Show All 1,100 Lines • Show Last 20 Lines |