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-Tag: v0.0.12~138^2~5 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=85c8410f897d21268da7242d420c292a41c1a6ba;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 6576da806..44d080300 100644 --- a/lightning/src/ln/peer_handler.rs +++ b/lightning/src/ln/peer_handler.rs @@ -12,13 +12,13 @@ use ln::features::InitFeatures; use ln::msgs; use ln::msgs::ChannelMessageHandler; use ln::channelmanager::{SimpleArcChannelManager, SimpleRefChannelManager}; +use util::ser::VecWriter; use ln::peer_channel_encryptor::{PeerChannelEncryptor,NextNoiseStep}; use ln::wire; use ln::wire::Encode; use util::byte_utils; use util::events::{MessageSendEvent, MessageSendEventsProvider}; use util::logger::Logger; -use util::ser::Writer; use std::collections::{HashMap,hash_map,HashSet,LinkedList}; use std::sync::{Arc, Mutex}; @@ -192,17 +192,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) => {{ let mut buffer = VecWriter(Vec::new()); diff --git a/lightning/src/util/ser.rs b/lightning/src/util/ser.rs index 223e2aba8..1b98e341f 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);