From: Matt Corallo Date: Mon, 3 Feb 2020 02:25:33 +0000 (-0500) Subject: Expose VecWriter outside of util::ser since peer_handler uses it X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=ebb55ff2aae55146239ff8fecd79c02ea4c3580f;p=rust-lightning Expose VecWriter outside of util::ser since peer_handler uses it --- diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs index 5838b782f..4809cecc4 100644 --- a/lightning/src/ln/peer_handler.rs +++ b/lightning/src/ln/peer_handler.rs @@ -12,7 +12,7 @@ use ln::features::InitFeatures; use ln::msgs; use ln::msgs::ChannelMessageHandler; use ln::channelmanager::{SimpleArcChannelManager, SimpleRefChannelManager}; -use util::ser::{Writeable, Writer, Readable}; +use util::ser::{Writeable, Readable, VecWriter}; use ln::peer_channel_encryptor::{PeerChannelEncryptor,NextNoiseStep}; use util::byte_utils; use util::events::{MessageSendEvent, MessageSendEventsProvider}; @@ -191,17 +191,6 @@ pub struct PeerManager where CM::Target logger: Arc, } -struct VecWriter(Vec); -impl Writer for VecWriter { - fn write_all(&mut self, buf: &[u8]) -> Result<(), ::std::io::Error> { - self.0.extend_from_slice(buf); - Ok(()) - } - fn size_hint(&mut self, size: usize) { - self.0.reserve_exact(size); - } -} - macro_rules! encode_msg { ($msg: expr, $msg_code: expr) => {{ let mut msg = VecWriter(Vec::new()); diff --git a/lightning/src/util/ser.rs b/lightning/src/util/ser.rs index 96f8cea04..e773c4f2d 100644 --- a/lightning/src/util/ser.rs +++ b/lightning/src/util/ser.rs @@ -57,7 +57,7 @@ impl<'a, W: Writer + 'a> Write for WriterWriteAdaptor<'a, W> { } } -struct VecWriter(Vec); +pub(crate) struct VecWriter(pub Vec); impl Writer for VecWriter { fn write_all(&mut self, buf: &[u8]) -> Result<(), ::std::io::Error> { self.0.extend_from_slice(buf);