File tree 1 file changed +3
-12
lines changed
1 file changed +3
-12
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,6 @@ use crate::sign::{NodeSigner, Recipient};
41
41
#[ allow( unused_imports) ]
42
42
use crate :: prelude:: * ;
43
43
44
- use core:: cmp;
45
44
use core:: fmt;
46
45
use core:: fmt:: Debug ;
47
46
use core:: ops:: Deref ;
@@ -1859,23 +1858,15 @@ impl Writeable for TrampolineOnionPacket {
1859
1858
1860
1859
impl LengthReadable for TrampolineOnionPacket {
1861
1860
fn read < R : LengthRead > ( r : & mut R ) -> Result < Self , DecodeError > {
1862
- const READ_BUFFER_SIZE : usize = 4096 ;
1863
-
1864
1861
let version = Readable :: read ( r) ?;
1865
1862
let public_key = Readable :: read ( r) ?;
1866
1863
1867
- let mut hop_data = Vec :: new ( ) ;
1868
1864
let hop_data_len = r. total_bytes ( ) . saturating_sub ( 66 ) as usize ; // 1 (version) + 33 (pubkey) + 32 (HMAC) = 66
1869
- let mut read_idx = 0 ;
1870
- while read_idx < hop_data_len {
1871
- let mut read_buffer = [ 0 ; READ_BUFFER_SIZE ] ;
1872
- let read_amt = cmp:: min ( hop_data_len - read_idx, READ_BUFFER_SIZE ) ;
1873
- r. read_exact ( & mut read_buffer[ ..read_amt] ) ?;
1874
- hop_data. extend_from_slice ( & read_buffer[ ..read_amt] ) ;
1875
- read_idx += read_amt;
1876
- }
1865
+ let mut rd = FixedLengthReader :: new ( r, hop_data_len as u64 ) ;
1866
+ let hop_data = WithoutLength :: < Vec < u8 > > :: read ( & mut rd) ?. 0 ;
1877
1867
1878
1868
let hmac = Readable :: read ( r) ?;
1869
+
1879
1870
Ok ( TrampolineOnionPacket {
1880
1871
version,
1881
1872
public_key,
You can’t perform that action at this time.
0 commit comments