neo3.network.payloads.block
Block payload and related classes.
Block
— The famous Block. I transfer chain state.GetBlockByIndexPayload
— Used to request full Block or Header objects via a message with themessage.MessageType.GETBLOCKBYINDEX
ormessage.MessageType.GETHEADERS
type respectively.GetBlocksPayload
— Used to request an array of block hashes that can be retrieved via a message with themessage.MessageType.GETDATA
type.Header
— ABlock
header only object.HeadersPayload
— Payload for sending or receivingBlock
headers.MerkleBlockPayload
— Payload for transfering merkletree hashes of a block.TrimmedBlock
— A size reducedBlock
instance.
neo3.network.payloads.block.
Block
(
header
, transactions=None
, *args
, **kwargs
)
The famous Block. I transfer chain state.
index
(int) — The height of the block.inventory_type
(InventoryType) — Inventory type identifier.merkle_root
(UInt256) — The merkle root of the transactions in the block.next_consensus
(UInt160) — The hash of the consensus node that will generate the next block.nonce
(int) — Random number.prev_hash
(UInt256) — The hash of the previous block.primary_index
(int) — The index into the consensus node list that was used to generate this block.timestamp
(int) — UTC timestamp in milliseconds.version
(int) — Block data structure version - for internal use.witness
(Witness) — The witness of this block.
__len__
(
)
— Return the length of the object in number of bytes.deserialize
(
reader
)
— Deserialize the object from a binary stream.deserialize_unsigned
(
reader
)
— Not supported.get_hash_data
(
protocol_magic
)
(bytes) — Get the unsigned data.get_script_hashes_for_verifying
(
snapshot
)
(list) — Helper method to get the data used in verifying the object.hash
(
)
(UInt256) — A unique identifier based on the unsigned data portion of the object.rebuild_merkle_root
(
)
— Recalculates the Merkle root.serialize
(
writer
)
— Serialize the object into a binary stream.serialize_unsigned
(
writer
)
— Serialize the unsigned part of the object into a binary stream.to_array
(
)
(bytes) — Serialize the object into a bytearray.trim
(
)
(TrimmedBlock) — Reduce a block in size by replacing the transaction objects with their identifying hashes.deserialize_from_bytes
(
data
)
(ISerializable_T) — Parse data into an object instance.
deserialize_from_bytes
(
data
)
Parse data into an object instance.
data
(bytes | bytearray) — hex escaped bytes.
a deserialized instance of the class.
to_array
(
)
→ bytes
Serialize the object into a bytearray.
__len__
(
)
Return the length of the object in number of bytes.
deserialize
(
reader
)
Deserialize the object from a binary stream.
reader
(BinaryReader) — instance.
ValueError
— if the content count of the block is zero, or if there is a duplicate transaction in the list,or if the merkle root does not include the calculated root.
deserialize_unsigned
(
reader
)
Not supported.
get_script_hashes_for_verifying
(
snapshot
)
→ list
Helper method to get the data used in verifying the object.
hash
(
)
→ UInt256
A unique identifier based on the unsigned data portion of the object.
rebuild_merkle_root
(
)
Recalculates the Merkle root.
serialize
(
writer
)
Serialize the object into a binary stream.
writer
(BinaryWriter) — instance.
serialize_unsigned
(
writer
)
Serialize the unsigned part of the object into a binary stream.
writer
(BinaryWriter) — instance.
trim
(
)
→ TrimmedBlock
Reduce a block in size by replacing the transaction objects with their identifying hashes.
get_hash_data
(
protocol_magic
)
→ bytes
Get the unsigned data.
protocol_magic
(int) — network protocol number (NEO MainNet = 860833102, Testnet (T5) = 894710606, private net = ?)
neo3.network.payloads.block.
GetBlockByIndexPayload
(
index_start
, count=2000
)
Used to request full Block or Header objects via a message with the message.MessageType.GETBLOCKBYINDEX
or message.MessageType.GETHEADERS
type respectively.
__len__
(
)
— Return the length of the object in number of bytes.deserialize
(
reader
)
— Deserialize the object from a binary stream.serialize
(
writer
)
— Serialize the object into a binary stream.to_array
(
)
(bytes) — Serialize the object into a bytearray.deserialize_from_bytes
(
data
)
(ISerializable_T) — Parse data into an object instance.
deserialize_from_bytes
(
data
)
Parse data into an object instance.
data
(bytes | bytearray) — hex escaped bytes.
a deserialized instance of the class.
to_array
(
)
→ bytes
Serialize the object into a bytearray.
__len__
(
)
Return the length of the object in number of bytes.
deserialize
(
reader
)
Deserialize the object from a binary stream.
reader
(BinaryReader) — instance.
ValueError
— ifcount
is zero or exceedsGetBlockByIndexPayload.MAX_BLOCKS_COUNT
.
serialize
(
writer
)
Serialize the object into a binary stream.
writer
(BinaryWriter) — instance.
neo3.network.payloads.block.
GetBlocksPayload
(
hash_start
, count=-1
)
Used to request an array of block hashes that can be retrieved via a message with themessage.MessageType.GETDATA
type.
__len__
(
)
— Return the length of the object in number of bytes.deserialize
(
reader
)
— Deserialize the object from a binary stream.serialize
(
writer
)
— Serialize the object into a binary stream.to_array
(
)
(bytes) — Serialize the object into a bytearray.deserialize_from_bytes
(
data
)
(ISerializable_T) — Parse data into an object instance.
deserialize_from_bytes
(
data
)
Parse data into an object instance.
data
(bytes | bytearray) — hex escaped bytes.
a deserialized instance of the class.
to_array
(
)
→ bytes
Serialize the object into a bytearray.
__len__
(
)
Return the length of the object in number of bytes.
deserialize
(
reader
)
Deserialize the object from a binary stream.
reader
(BinaryReader) — instance.
serialize
(
writer
)
Serialize the object into a binary stream.
writer
(BinaryWriter) — instance.
neo3.network.payloads.block.
Header
(
version
, prev_hash
, timestamp
, nonce
, index
, primary_index
, next_consensus
, witness
, merkle_root=None
, *args
, **kwargs
)
A Block
header only object.
Does not contain any consensus data or transactions.
See also:
:class:~neo3.network.payloads.block.TrimmedBlock
__len__
(
)
— Return the length of the object in number of bytes.deserialize
(
reader
)
— Deserialize the object from a binary stream.deserialize_unsigned
(
reader
)
— Deserialize the unsigned data part of the object from a binary stream.get_hash_data
(
protocol_magic
)
(bytes) — Get the unsigned data.get_script_hashes_for_verifying
(
snapshot
)
(list) — Helper method to get the data used in verifying the object.hash
(
)
(UInt256) — Get a unique identifier based on the unsigned data portion of the object.serialize
(
writer
)
— Serialize the object into a binary stream.serialize_unsigned
(
writer
)
— Serialize the unsigned data portion.to_array
(
)
(bytes) — Serialize the object into a bytearray.deserialize_from_bytes
(
data
)
(ISerializable_T) — Parse data into an object instance.
deserialize_from_bytes
(
data
)
Parse data into an object instance.
data
(bytes | bytearray) — hex escaped bytes.
a deserialized instance of the class.
to_array
(
)
→ bytes
Serialize the object into a bytearray.
__len__
(
)
Return the length of the object in number of bytes.
deserialize
(
reader
)
Deserialize the object from a binary stream.
reader
(BinaryReader) — instance.
ValueError
— if the check byte does not equal.
deserialize_unsigned
(
reader
)
Deserialize the unsigned data part of the object from a binary stream.
reader
(BinaryReader) — instance.
ValueError
— if the primary_index field is greater than the configured consensus validator count.
get_script_hashes_for_verifying
(
snapshot
)
→ list
Helper method to get the data used in verifying the object.
hash
(
)
→ UInt256
Get a unique identifier based on the unsigned data portion of the object.
serialize
(
writer
)
Serialize the object into a binary stream.
writer
(BinaryWriter) — instance.
serialize_unsigned
(
writer
)
Serialize the unsigned data portion.
writer
(BinaryWriter) — instance.
get_hash_data
(
protocol_magic
)
→ bytes
Get the unsigned data.
protocol_magic
(int) — network protocol number (NEO MainNet = 860833102, Testnet (T5) = 894710606, private net = ?)
neo3.network.payloads.block.
HeadersPayload
(
headers=None
)
Payload for sending or receiving Block
headers.
__len__
(
)
— Return the length of the object in number of bytes.deserialize
(
reader
)
— Deserialize the object from a binary stream.serialize
(
writer
)
— Serialize the object into a binary stream.to_array
(
)
(bytes) — Serialize the object into a bytearray.deserialize_from_bytes
(
data
)
(ISerializable_T) — Parse data into an object instance.
deserialize_from_bytes
(
data
)
Parse data into an object instance.
data
(bytes | bytearray) — hex escaped bytes.
a deserialized instance of the class.
to_array
(
)
→ bytes
Serialize the object into a bytearray.
__len__
(
)
Return the length of the object in number of bytes.
deserialize
(
reader
)
Deserialize the object from a binary stream.
reader
(BinaryReader) — instance.
serialize
(
writer
)
Serialize the object into a binary stream.
writer
(BinaryWriter) — instance.
neo3.network.payloads.block.
MerkleBlockPayload
(
block
, flags
)
Payload for transfering merkletree hashes of a block.
__len__
(
)
— Return the length of the object in number of bytes.deserialize
(
reader
)
— Deserialize the object from a binary stream.serialize
(
writer
)
— Serialize the object into a binary stream.to_array
(
)
(bytes) — Serialize the object into a bytearray.deserialize_from_bytes
(
data
)
(ISerializable_T) — Parse data into an object instance.
deserialize_from_bytes
(
data
)
Parse data into an object instance.
data
(bytes | bytearray) — hex escaped bytes.
a deserialized instance of the class.
to_array
(
)
→ bytes
Serialize the object into a bytearray.
__len__
(
)
Return the length of the object in number of bytes.
deserialize
(
reader
)
Deserialize the object from a binary stream.
reader
(BinaryReader) — instance.
serialize
(
writer
)
Serialize the object into a binary stream.
writer
(BinaryWriter) — instance.
neo3.network.payloads.block.
TrimmedBlock
(
header
, hashes
)
A size reduced Block
instance.
Contains consensus data and transactions hashes instead of their full objects.
index
— The height of the block.
__len__
(
)
— Return the length of the object in number of bytes.deserialize
(
reader
)
— Deserialize the object from a binary stream.hash
(
)
— A unique identifier based on the unsigned data portion of the object.serialize
(
writer
)
— Serialize the object into a binary stream.to_array
(
)
(bytes) — Serialize the object into a bytearray.deserialize_from_bytes
(
data
)
(ISerializable_T) — Parse data into an object instance.
deserialize_from_bytes
(
data
)
Parse data into an object instance.
data
(bytes | bytearray) — hex escaped bytes.
a deserialized instance of the class.
to_array
(
)
→ bytes
Serialize the object into a bytearray.
__len__
(
)
Return the length of the object in number of bytes.
deserialize
(
reader
)
Deserialize the object from a binary stream.
reader
(BinaryReader) — instance.
hash
(
)
A unique identifier based on the unsigned data portion of the object.
serialize
(
writer
)
Serialize the object into a binary stream.
writer
(BinaryWriter) — instance.