pub struct NetworkMessage {
pub payload: MessagePayload,
pub message_id: String,
pub timestamp: i64,
}Expand description
Network message envelope
Fields§
§payload: MessagePayloadMessage type and payload
message_id: StringMessage ID for deduplication
timestamp: i64Timestamp when message was created
Implementations§
Source§impl NetworkMessage
impl NetworkMessage
Sourcepub fn new(payload: MessagePayload) -> Self
pub fn new(payload: MessagePayload) -> Self
Creates a new network message
Sourcepub fn to_bytes(&self) -> Result<Bytes, Error>
pub fn to_bytes(&self) -> Result<Bytes, Error>
Serializes the message to bytes using bincode.
Wire format: bincode (length-prefixed varint sequences). Bincode is used
rather than serde_json because consensus payloads embed Block and
Transaction types that carry u128 fields (token amounts, gas), and
serde_json does not support u128 without arbitrary_precision.
Mismatched encoders/decoders previously caused honest peers to silently
drop each other’s votes, stalling consensus.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
Deserializes a message from bincode bytes.
Trait Implementations§
Source§impl Clone for NetworkMessage
impl Clone for NetworkMessage
Source§fn clone(&self) -> NetworkMessage
fn clone(&self) -> NetworkMessage
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for NetworkMessage
impl Debug for NetworkMessage
Source§impl<'de> Deserialize<'de> for NetworkMessage
impl<'de> Deserialize<'de> for NetworkMessage
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for NetworkMessage
impl RefUnwindSafe for NetworkMessage
impl Send for NetworkMessage
impl Sync for NetworkMessage
impl Unpin for NetworkMessage
impl UnsafeUnpin for NetworkMessage
impl UnwindSafe for NetworkMessage
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
Converts
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>
Converts
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 more