pub struct TcpFramedParser;Expand description
Bitcoin P2P framed message parser (TCP path). Pass allowed commands from the node.
Implementations§
Source§impl TcpFramedParser
impl TcpFramedParser
Sourcepub fn parse_message(
data: &[u8],
allowed_commands: &[&str],
) -> Result<ProtocolMessage>
pub fn parse_message( data: &[u8], allowed_commands: &[&str], ) -> Result<ProtocolMessage>
Parse a raw message into a protocol message Orange Paper 10.1.1: ParseMessage, size bounds, checksum rejection
Sourcepub fn serialize_message(message: &ProtocolMessage) -> Result<Vec<u8>>
pub fn serialize_message(message: &ProtocolMessage) -> Result<Vec<u8>>
Serialize a protocol message to bytes
Sourcepub fn calculate_checksum(payload: &[u8]) -> [u8; 4]
pub fn calculate_checksum(payload: &[u8]) -> [u8; 4]
Calculate message checksum
Computes double SHA256 of payload and returns first 4 bytes. Orange Paper 10.1.1: CalculateChecksum, |result| = 4
Auto Trait Implementations§
impl Freeze for TcpFramedParser
impl RefUnwindSafe for TcpFramedParser
impl Send for TcpFramedParser
impl Sync for TcpFramedParser
impl Unpin for TcpFramedParser
impl UnsafeUnpin for TcpFramedParser
impl UnwindSafe for TcpFramedParser
Blanket Implementations§
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> 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