Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/p2p.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2010 ArtForz -- public domain half-a-node | # Copyright (c) 2010 ArtForz -- public domain half-a-node | ||||
# Copyright (c) 2012 Jeff Garzik | # Copyright (c) 2012 Jeff Garzik | ||||
# Copyright (c) 2010-2019 The Bitcoin Core developers | # Copyright (c) 2010-2019 The Bitcoin Core developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
"""Bitcoin P2P network half-a-node. | """Test objects for interacting with a bitcoind node over the p2p protocol. | ||||
This python code was modified from ArtForz' public domain half-a-node, as | The P2PInterface objects interact with the bitcoind nodes under test using the | ||||
found in the mini-node branch of http://github.com/jgarzik/pynode. | node's p2p interface. They can be used to send messages to the node, and | ||||
callbacks can be registered that execute when messages are received from the | |||||
node. Messages are sent to/received from the node on an asyncio event loop. | |||||
State held inside the objects must be guarded by the p2p_lock to avoid data | |||||
races between the main testing thread and the event loop. | |||||
P2PConnection: A low-level connection object to a node's P2P interface | P2PConnection: A low-level connection object to a node's P2P interface | ||||
P2PInterface: A high-level interface object for communicating to a node over P2P | P2PInterface: A high-level interface object for communicating to a node over P2P | ||||
P2PDataStore: A p2p interface class that keeps a store of transactions and blocks | P2PDataStore: A p2p interface class that keeps a store of transactions and blocks | ||||
and can respond correctly to getdata and getheaders messages | and can respond correctly to getdata and getheaders messages | ||||
P2PTxInvStore: A p2p interface class that inherits from P2PDataStore, and keeps | P2PTxInvStore: A p2p interface class that inherits from P2PDataStore, and keeps | ||||
a count of how many times each txid has been announced.""" | a count of how many times each txid has been announced.""" | ||||
▲ Show 20 Lines • Show All 774 Lines • Show Last 20 Lines |