neo3.network.node
P2P node. Connects over TCP. Handles network messages.
NeoNode— P2P network actor.
encode_base62(num)— Encode number in base62, returns a string.
neo3.network.node.NeoNode(reader, writer)
P2P network actor.
connection_made()— Event called by the NeoNode.connect_to.disconnect(reason)— Close the connection to remote endpoint.handler_addr(msg)— Handler for a message with theADDRtype.handler_block(msg)— Handler for a message with theBLOCKtype.handler_consensus(msg)— Handler for a message with theCONSENSUStype.handler_extensible(msg)— Handler for a message with theEXTENSIBLEtype.handler_filteradd(msg)— Handler for a message with theFILTERADDtype.handler_filterclear(msg)— Handler for a message with theFILTERCLEARtype.handler_filterload(msg)— Handler for a message with theFILTERLOADtype.handler_getaddr(msg)— Handler for a message with theGETADDRtype.handler_getblockdata(msg)— Handler for a message with theGETBLOCKBYINDEXtype.handler_getblocks(msg)— Handler for a message with theGETBLOCKStype.handler_getdata(msg)— Handler for a message with theGETDATAtype.handler_getheaders(msg)— Handler for a message with theGETHEADERStype.handler_headers(msg)— Handler for a message with theHEADERStype.handler_inv(msg)— Handler for a message with theINVtype.handler_mempool(msg)— Handler for a message with theMEMPOOLtype.handler_merkleblock(msg)— Handler for a message with theMERKLEBLOCKtype.handler_ping(msg)— Handler for a message with thePINGtype.handler_pong(msg)— Handler for a message with thePONGtype.handler_transaction(msg)— Handler for a message with theTRANSACTIONtype.read_message(timeout)(Optional) — Read a message from the network.relay(inv)(bool) — Relay the inventory to the network.request_address_list()— Send a request for receiving known network addresses.request_block_data(index_start,count)— Send a request forcountblocks starting fromindex_start.request_blocks(hash_start,count)— Send a request for retrieving block hashes fromhash_starttohash_start+count.request_data(type,hashes)— Send a request for receiving the specified inventory data.request_headers(index_start,count)— Send a request for headers fromindex_starttoindex_start+count.send_address_list(network_addresses)— Send network addresses.send_headers(headers)— Send a list of Header objects.send_inventory(inv_type,inv_hash)— Send an inventory to the network.send_message(msg)— Broadcast a message to the network.send_ping()— Send a Ping message and expecting a Pong response.start_message_handler()— A convenience function to start a message reading loop and forward the messages to their respective handlers asconfigured in :attr:~neo3.network.node.NeoNode.dispatch_table.get_address_new()(Optional) — Utility function to return the first address with the state NEW.connect_to(host,port,timeout,socket,_test_data)(tuple[NeoNode, None]) — Connect to another node.
connect_to(host=None, port=None, timeout=3, socket=None, _test_data=None)
Connect to another node.
host(Optional, optional) — node ip.port(Optional, optional) — node port.timeout(optional) — max time to wait before aborting.socket(optional) — use an existing socket.
if connection was established succesfully.tuple[None, tuple[host:port, failure_reason]]: if connection is not established successfully.
connection_made()
Event called by the NeoNode.connect_to.
disconnect(reason)
Close the connection to remote endpoint.
reason(DisconnectReason) — reason for disconnecting.
get_address_new() → Optional
Utility function to return the first address with the state NEW.
handler_addr(msg)
Handler for a message with the ADDR type.
handler_block(msg)
Handler for a message with the BLOCK type.
handler_consensus(msg)
Handler for a message with the CONSENSUS type.
handler_extensible(msg)
Handler for a message with the EXTENSIBLE type.
handler_filteradd(msg)
Handler for a message with the FILTERADD type.
handler_filterclear(msg)
Handler for a message with the FILTERCLEAR type.
handler_filterload(msg)
Handler for a message with the FILTERLOAD type.
handler_getaddr(msg)
Handler for a message with the GETADDR type.
handler_getblockdata(msg)
Handler for a message with the GETBLOCKBYINDEX type.
handler_getblocks(msg)
Handler for a message with the GETBLOCKS type.
handler_getdata(msg)
Handler for a message with the GETDATA type.
handler_getheaders(msg)
Handler for a message with the GETHEADERS type.
handler_headers(msg)
Handler for a message with the HEADERS type.
handler_inv(msg)
Handler for a message with the INV type.
handler_mempool(msg)
Handler for a message with the MEMPOOL type.
handler_merkleblock(msg)
Handler for a message with the MERKLEBLOCK type.
handler_ping(msg)
Handler for a message with the PING type.
handler_pong(msg)
Handler for a message with the PONG type.
handler_transaction(msg)
Handler for a message with the TRANSACTION type.
read_message(timeout=30) → Optional
Read a message from the network.
timeout(Optional, optional) — maximum time to wait for a message to arrive over the network.
relay(inv) → bool
Relay the inventory to the network.
inv(IInventory) — should be of type Block, Transaction or Consensus.
request_address_list()
Send a request for receiving known network addresses.
request_block_data(index_start, count)
Send a request for count blocks starting from index_start.
Count cannot exceed :attr:~neo3.network.payloads.block.GetBlockByIndexPayload.MAX_BLOCKS_COUNT.
See also:
:meth:~neo3.network.node.NeoNode.request_blocks() to only request block hashes.
index_start— block index to start from.count— number of blocks to return.
request_blocks(hash_start, count=None)
Send a request for retrieving block hashes from hash_start to hash_start+count.
Not specifying a count results in requesting at most 500 blocks.
Note
The remote node is expected to reply with a Message with the :const:~neo3.network.message.MessageType.INV
type containing the hashes of the requested blocks. Use :meth:~neo3.network.node.NeoNode.request_data in
combination with these hashes to return the actual :class:~neo3.network.payloads.block.Block objects.
See also: NeoNode.request_block_data() to immediately retrieve
neo3.network.payloads.block.Block objects.
hash_start(UInt256) — block hash to start from.count(Optional, optional) — number of blocks to return.
request_data(type, hashes)
Send a request for receiving the specified inventory data.
type(InventoryType) — the inventory type to request.hashes(Sequence) — the hashes oftypeto request.
request_headers(index_start, count=2000)
Send a request for headers from index_start to index_start+count.
Not specifying a count results in requesting at most 2000 headers.
index_start(int) — block height to start from.count(int, optional) — number of headers to request.
send_address_list(network_addresses)
Send network addresses.
network_addresses(Sequence) — list of addresses of other network actors.
send_headers(headers)
Send a list of Header objects.
send_inventory(inv_type, inv_hash)
Send an inventory to the network.
send_message(msg)
Broadcast a message to the network.
send_ping()
Send a Ping message and expecting a Pong response.
start_message_handler()
A convenience function to start a message reading loop and forward the messages to their respective handlers asconfigured in :attr:~neo3.network.node.NeoNode.dispatch_table.
neo3.network.node.encode_base62(num)
Encode number in base62, returns a string.