inventory — Chain inventory

There are three types of inventory in the NEO chain being Block, Consensus and Transaction, as indicated by InventoryType.

Inventory types are shared over the network in a variety of scenarios. Consensus inventory types are relayed between NEO’s consensus nodes as the data to use to come to an agreement on the next Block to produce.

Next, the Block inventory type is send as a reponse to a network request. Additionally, the reference C# neo-cli client regularly broadcasts its latest block hash through this mechanism.

Finally, the Transaction inventory type is commonly used when a new transaction needs to be relayed or is requested from the mempool.

class neo3.network.payloads.inventory.InventoryType(value)

Bases: enum.IntEnum

An enumeration.

BLOCK = 44
CONSENSUS = 45
EXTENSIBLE = 46
TX = 43
class neo3.network.payloads.inventory.InventoryPayload(type, hashes)

Bases: neo3.core.serialization.ISerializable

A payload used to share inventory hashes.

Create payload.

Parameters
  • type (InventoryType) – indicator to what type of object the the hashes of this payload relate to.

  • hashes (List[UInt256]) – hashes of “type” objects.

deserialize(reader)

Deserialize the object from a binary stream.

Parameters

reader (BinaryReader) – instance.

Return type

None

classmethod deserialize_from_bytes(data)

Parse data into an object instance.

Parameters

data (Union[bytes, bytearray]) – hex escaped bytes.

Return type

~ISerializable_T

Returns

a deserialized instance of the class.

serialize(writer)

Serialize the object into a binary stream.

Parameters

writer (BinaryWriter) – instance.

Return type

None

to_array()

Serialize the object into a bytearray.

Return type

bytes

class neo3.network.payloads.inventory.IInventory(*args, **kwargs)

Bases: neo3.network.payloads.verification.IVerifiable

abstract deserialize(reader)

Deserialize the object from a binary stream.

Parameters

reader (BinaryReader) – instance.

Return type

None

classmethod deserialize_from_bytes(data)

Parse data into an object instance.

Parameters

data (Union[bytes, bytearray]) – hex escaped bytes.

Return type

~ISerializable_T

Returns

a deserialized instance of the class.

abstract deserialize_unsigned(reader)
Return type

None

get_hash_data(protocol_magic)

Get the unsigned data

Parameters

protocol_magic (int) – network protocol number (NEO MainNet = 5195086, Testnet = 1951352142, private net = ??)

Return type

bytes

abstract get_script_hashes_for_verifying(snapshot)

Helper method to get the data used in verifying the object.

Return type

List[UInt160]

abstract hash()
Return type

UInt256

abstract serialize(writer)

Serialize the object into a binary stream.

Parameters

writer (BinaryWriter) – instance.

Return type

None

abstract serialize_unsigned(writer)
Return type

None

to_array()

Serialize the object into a bytearray.

Return type

bytes

abstract property inventory_type
Return type

InventoryType