]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Expose VecWriter outside of util::ser since peer_handler uses it
authorMatt Corallo <git@bluematt.me>
Mon, 3 Feb 2020 02:25:33 +0000 (21:25 -0500)
committerMatt Corallo <git@bluematt.me>
Tue, 11 Feb 2020 18:48:56 +0000 (13:48 -0500)
lightning/src/ln/peer_handler.rs
lightning/src/util/ser.rs

index 6576da806afb48c938791f47c0fee55880b5452a..44d08030062fb47b337b879901b6967a73776d58 100644 (file)
@@ -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<Descriptor: SocketDescriptor, CM: Deref> where CM::Target
        logger: Arc<Logger>,
 }
 
-struct VecWriter(Vec<u8>);
-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());
index 223e2aba8666f1edc4e2267648121eec18d0757d..1b98e341fad6f35e94e555528865ed1cee508b5a 100644 (file)
@@ -57,7 +57,7 @@ impl<'a, W: Writer + 'a> Write for WriterWriteAdaptor<'a, W> {
        }
 }
 
-struct VecWriter(Vec<u8>);
+pub(crate) struct VecWriter(pub Vec<u8>);
 impl Writer for VecWriter {
        fn write_all(&mut self, buf: &[u8]) -> Result<(), ::std::io::Error> {
                self.0.extend_from_slice(buf);