message
— P2P network packets¶
This chapter describes the network packet format as well as the protocol for communicating with nodes.
The following section describes the purpose of each message type as well as the expected responses to such messages. See the classes section for the description of the message format.
Usage¶
-
FILTERADD
¶ Update a configured bloomfilter.
See also
Payload:
FilterAddPayload
Response type: None
Response payload: None
-
FILTERCLEAR
¶ Clear a configured bloomfilter.
Payload: None
Response type: None
Response payload: None
-
FILTERLOAD
¶ Configure a bloomfilter on the remote node.
See also
Payload:
FilterLoadPayload
Response type: None
Response payload: None
-
GETADDR
¶ Request a list of known network addresses.
Payload:
AddrPayload
Response type:
ADDR
Response payload:
AddrPayload
-
GETDATA
¶ Request inventory types based on a list of hashes.
Payload:
InventoryPayload
Response type: Depending on the type indicated in the request payload the response will be one of
BLOCK
,CONSENSUS
,TRANSACTION
orMERKLEBLOCK
.Note
A
MERKLEBLOCK
response is given when the inventory type is set toBLOCK
while a bloomfilter is configured on the remote node.Response payload: Depending on the type indicated in the request payload one of
Block
,InventoryType
,Transaction
orMerkleBlockPayload
.
-
GETHEADERS
¶ Request Header objects (can be used for syncing).
Payload:
GetBlockByIndexPayload
Response type:
HEADERS
Response payload:
HeadersPayload
-
GETBLOCKS
¶ Request block hashes (can be used for syncing).
Payload:
GetBlocksPayload
Response type:
INV
Response payload:
InventoryPayload
with type set toBLOCK
-
GETBLOCKBYINDEX
¶ Request block objects.
Payload:
GetBlockByIndexPayload
Response type:
BLOCK
orMERKLEBLOCK
.Note
A
MERKLEBLOCK
response is given when a bloomfilter is configured on the remote node.Response payload:
Block
orMerkleBlockPayload
-
MEMPOOL
¶ Request a list of hashes currently in the mempool.
Payload: None
Response type:
INV
Response payload:
InventoryPayload
with type set toTX
-
PING
¶ Request node chain height update, send own chain height.
Payload:
PingPayload
Response type:
PONG
Response payload:
PingPayload
-
REJECT
¶ Inform a remote node why its connection is rejected.
Note
Is expected to return a new RejectPayload once this PR is merged.
Payload: None
Response type: None
Response payload: None
-
NOTFOUND
¶ Not used.
Classes¶
The Message class encapsulates network payloads for sending and receiving over the TCP/IP network.
There are various types of messages supported as indicated by the type
attribute of the Message class.
-
class
neo3.network.message.
Message
(msg_type, payload=None)¶ Bases:
neo3.core.serialization.ISerializable
- Parameters
msg_type (
MessageType
) – message object configuration.payload (
Optional
[~ISerializable_T]) – an identifier specifying the purpose of the message.
-
deserialize
(reader)¶ Deserialize the object from a binary stream.
- Parameters
reader (
BinaryReader
) – instance.- Return type
-
classmethod
deserialize_from_bytes
(data)¶ Parse data into an object instance.
-
serialize
(writer)¶ Serialize the object into a binary stream.
- Parameters
writer (
BinaryWriter
) – instance.- Return type
-
COMPRESSION_MIN_SIZE
= 128¶
-
COMPRESSION_THRESHOLD
= 64¶
-
PAYLOAD_MAX_SIZE
= 33554432¶
-
config
¶ message object configuration.
- Type
-
type
: neo3.network.message.MessageType¶ an identifier specifying the purpose of the message.
- Type
-
class
neo3.network.message.
MessageType
(value)¶ Bases:
enum.IntEnum
An enumeration.
-
ADDR
= 17¶
-
ALERT
= 64¶
-
BLOCK
= 44¶
-
CONSENSUS
= 45¶
-
DEFAULT
= 255¶
-
EXTENSIBLE
= 46¶
-
FILTERADD
= 49¶
-
FILTERCLEAR
= 50¶
-
FILTERLOAD
= 48¶
-
GETADDR
= 16¶
-
GETBLOCKBYINDEX
= 41¶
-
GETBLOCKS
= 36¶
-
GETDATA
= 40¶
-
GETHEADERS
= 32¶
-
HEADERS
= 33¶
-
INV
= 39¶
-
MEMPOOL
= 37¶
-
MERKLEBLOCK
= 56¶
-
NOTFOUND
= 42¶
-
PING
= 24¶
-
PONG
= 25¶
-
REJECT
= 47¶
-
TRANSACTION
= 43¶
-
VERACK
= 1¶
-
VERSION
= 0¶
-
-
class
neo3.network.message.
MessageConfig
(value)¶ Bases:
enum.IntFlag
An enumeration.
-
COMPRESSED
= 1¶ Indicates that the payload data is compressed using LZ4
-
NONE
= 0¶ Indicates that the payload data is not compressed
-