Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/messages.py
Show All 22 Lines | |||||
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 test_framework.siphash import siphash256 | from test_framework.siphash import siphash256 | ||||
from test_framework.util import hex_str_to_bytes | 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/" | ||||
# from version 70001 onwards, fRelay should be appended to version | # from version 70001 onwards, fRelay should be appended to version | ||||
# messages (BIP37) | # messages (BIP37) | ||||
MY_RELAY = 1 | MY_RELAY = 1 | ||||
▲ Show 20 Lines • Show All 462 Lines • ▼ Show 20 Lines | def rehash(self): | ||||
return self.sha256 | return self.sha256 | ||||
def __repr__(self): | def __repr__(self): | ||||
return "CBlockHeader(nVersion={} hashPrevBlock={:064x} hashMerkleRoot={:064x} nTime={} nBits={:08x} nNonce={:08x})".format( | return "CBlockHeader(nVersion={} hashPrevBlock={:064x} hashMerkleRoot={:064x} nTime={} nBits={:08x} nNonce={:08x})".format( | ||||
self.nVersion, self.hashPrevBlock, self.hashMerkleRoot, | self.nVersion, self.hashPrevBlock, self.hashMerkleRoot, | ||||
self.nTime, self.nBits, self.nNonce) | self.nTime, self.nBits, self.nNonce) | ||||
BLOCK_HEADER_SIZE = len(CBlockHeader().serialize()) | |||||
assert_equal(BLOCK_HEADER_SIZE, 80) | |||||
class CBlock(CBlockHeader): | class CBlock(CBlockHeader): | ||||
__slots__ = ("vtx",) | __slots__ = ("vtx",) | ||||
def __init__(self, header=None): | def __init__(self, header=None): | ||||
super(CBlock, self).__init__(header) | super(CBlock, self).__init__(header) | ||||
self.vtx = [] | self.vtx = [] | ||||
def deserialize(self, f): | def deserialize(self, f): | ||||
▲ Show 20 Lines • Show All 1,046 Lines • Show Last 20 Lines |