pub struct BootstrapServerMessageDeserializer {Show 19 fields
message_id_deserializer: U32VarIntDeserializer,
time_deserializer: MassaTimeDeserializer,
version_deserializer: VersionDeserializer,
peers_deserializer: BootstrapPeersDeserializer,
state_new_elements_length_deserializer: U64VarIntDeserializer,
versioning_part_new_elements_length_deserializer: U64VarIntDeserializer,
stream_batch_updates_length_deserializer: U64VarIntDeserializer,
datastore_key_deserializer: VecU8Deserializer,
datastore_val_deserializer: VecU8Deserializer,
opt_vec_u8_deserializer: OptionDeserializer<Vec<u8>, VecU8Deserializer>,
bootstrapable_graph_deserializer: BootstrapableGraphDeserializer,
block_id_set_deserializer: PreHashSetDeserializer<BlockId, BlockIdDeserializer>,
length_bootstrap_error: U64VarIntDeserializer,
slot_deserializer: SlotDeserializer,
opt_last_start_period_deserializer: OptionDeserializer<u64, U64VarIntDeserializer>,
opt_last_slot_before_downtime_deserializer: OptionDeserializer<Option<Slot>, OptionDeserializer<Slot, SlotDeserializer>>,
state_batch_budget: usize,
versioning_batch_budget: usize,
updates_batch_budget: usize,
}Expand description
Deserializer for BootstrapServerMessage
Fields§
§message_id_deserializer: U32VarIntDeserializer§time_deserializer: MassaTimeDeserializer§version_deserializer: VersionDeserializer§peers_deserializer: BootstrapPeersDeserializer§state_new_elements_length_deserializer: U64VarIntDeserializer§versioning_part_new_elements_length_deserializer: U64VarIntDeserializer§stream_batch_updates_length_deserializer: U64VarIntDeserializer§datastore_key_deserializer: VecU8Deserializer§datastore_val_deserializer: VecU8Deserializer§opt_vec_u8_deserializer: OptionDeserializer<Vec<u8>, VecU8Deserializer>§bootstrapable_graph_deserializer: BootstrapableGraphDeserializer§block_id_set_deserializer: PreHashSetDeserializer<BlockId, BlockIdDeserializer>§length_bootstrap_error: U64VarIntDeserializer§slot_deserializer: SlotDeserializer§opt_last_start_period_deserializer: OptionDeserializer<u64, U64VarIntDeserializer>§opt_last_slot_before_downtime_deserializer: OptionDeserializer<Option<Slot>, OptionDeserializer<Slot, SlotDeserializer>>§state_batch_budget: usize§versioning_batch_budget: usize§updates_batch_budget: usizeImplementations§
Source§impl BootstrapServerMessageDeserializer
impl BootstrapServerMessageDeserializer
Sourcepub fn with_last_start_period(
args: BootstrapServerMessageDeserializerArgs,
last_start_period: Option<u64>,
) -> Self
pub fn with_last_start_period( args: BootstrapServerMessageDeserializerArgs, last_start_period: Option<u64>, ) -> Self
Builds a deserializer that applies last_start_period to bootstrap block header
deserialization so genesis vs non-genesis parent-count rules are enforced while
parsing. Pass None for the first part; the server sends restart metadata once on
that part (empty consensus graph), then the client reuses the cached value.
Sourcefn deserialize_kv_map<'a, V, E, F>(
&self,
input: &'a [u8],
parse_entry: F,
budget: usize,
) -> IResult<&'a [u8], BTreeMap<Vec<u8>, V>, E>
fn deserialize_kv_map<'a, V, E, F>( &self, input: &'a [u8], parse_entry: F, budget: usize, ) -> IResult<&'a [u8], BTreeMap<Vec<u8>, V>, E>
Deserialize a map of (key, value) pairs, bounding the in-memory footprint of the result.
Charges every parsed pair the bytes it occupied on the wire plus
BOOTSTRAP_BATCH_ENTRY_OVERHEAD, and fails once budget is spent. Bounding the section
in wire bytes alone is not enough: an entry can cost two bytes on the wire and two orders
of magnitude more as a map node, so a flood of tiny entries amplifies well past the size
the section announced. Pairs are charged as parsed rather than as inserted, so a
duplicate-key flood is charged too.
The map is folded during parsing rather than collected into an intermediate Vec first:
these sections can be large, so skipping the extra full-size allocation roughly halves the
peak memory of parsing one.
Trait Implementations§
Source§impl Deserializer<BootstrapServerMessage> for BootstrapServerMessageDeserializer
impl Deserializer<BootstrapServerMessage> for BootstrapServerMessageDeserializer
Source§fn deserialize<'a, E: ParseError<&'a [u8]> + ContextError<&'a [u8]>>(
&self,
buffer: &'a [u8],
) -> IResult<&'a [u8], BootstrapServerMessage, E>
fn deserialize<'a, E: ParseError<&'a [u8]> + ContextError<&'a [u8]>>( &self, buffer: &'a [u8], ) -> IResult<&'a [u8], BootstrapServerMessage, E>
§Example
use massa_bootstrap::{BootstrapServerMessage, BootstrapServerMessageSerializer, BootstrapServerMessageDeserializer};
use massa_bootstrap::BootstrapServerMessageDeserializerArgs;
use massa_serialization::{Serializer, Deserializer, DeserializeError};
use massa_time::MassaTime;
use massa_models::version::Version;
use std::str::FromStr;
use massa_models::config::CHAINID;
let message_serializer = BootstrapServerMessageSerializer::new();
let args = BootstrapServerMessageDeserializerArgs {
thread_count: 32, endorsement_count: 16,
max_listeners_per_peer: 1000,
max_advertise_length: 1000, max_bootstrap_blocks_length: 1000,
max_operations_per_block: 1000, max_versioning_elements_size: 1000,
max_ledger_changes_count: 1000, max_datastore_key_length: 255,
max_datastore_value_length: 1000,
max_final_state_elements_size: 1000,
max_final_state_batch_allocation: 1_000_000, max_versioning_batch_allocation: 1_000_000,
max_datastore_entry_count: 1000, max_bootstrap_error_length: 1000, max_changes_slot_count: 1000,
max_rolls_length: 1000, max_production_stats_length: 1000, max_credits_length: 1000,
max_executed_ops_length: 1000, max_ops_changes_length: 1000,
mip_store_stats_block_considered: 100,
max_denunciations_per_block_header: 128, max_denunciation_changes_length: 1000,
chain_id: *CHAINID
};
let message_deserializer = BootstrapServerMessageDeserializer::with_last_start_period(args, None);
let bootstrap_server_message = BootstrapServerMessage::BootstrapTime {
server_time: MassaTime::from_millis(0),
version: Version::from_str("TEST.1.10").unwrap(),
};
let mut message_serialized = Vec::new();
message_serializer.serialize(&bootstrap_server_message, &mut message_serialized).unwrap();
let (rest, message_deserialized) = message_deserializer.deserialize::<DeserializeError>(&message_serialized).unwrap();
match message_deserialized {
BootstrapServerMessage::BootstrapTime {
server_time,
version,
} => {
assert_eq!(server_time, MassaTime::from_millis(0));
assert_eq!(version, Version::from_str("TEST.1.10").unwrap());
}
_ => panic!("Unexpected message"),
}
assert_eq!(rest.len(), 0);Auto Trait Implementations§
impl Freeze for BootstrapServerMessageDeserializer
impl RefUnwindSafe for BootstrapServerMessageDeserializer
impl Send for BootstrapServerMessageDeserializer
impl Sync for BootstrapServerMessageDeserializer
impl Unpin for BootstrapServerMessageDeserializer
impl UnwindSafe for BootstrapServerMessageDeserializer
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Conv for T
impl<T> Conv for T
§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
§fn deserialize(
&self,
deserializer: &mut D,
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.