@@ -3762,31 +3762,31 @@ impl<'a, ChanSigner: ChannelKeys + Readable, M: Deref, T: Deref, K: Deref, F: De
37623762
37633763 const MAX_ALLOC_SIZE : usize = 1024 * 64 ;
37643764 let forward_htlcs_count: u64 = Readable :: read ( reader) ?;
3765- let mut forward_htlcs = HashMap :: with_capacity ( cmp:: min ( forward_htlcs_count as usize , ( MAX_ALLOC_SIZE as usize ) /mem :: size_of :: < HTLCForwardInfo > ( ) ) ) ;
3765+ let mut forward_htlcs = HashMap :: with_capacity ( cmp:: min ( forward_htlcs_count as usize , 128 ) ) ;
37663766 for _ in 0 ..forward_htlcs_count {
37673767 let short_channel_id = Readable :: read ( reader) ?;
37683768 let pending_forwards_count: u64 = Readable :: read ( reader) ?;
3769- let mut pending_forwards = Vec :: with_capacity ( cmp:: min ( pending_forwards_count as usize , 128 ) ) ;
3769+ let mut pending_forwards = Vec :: with_capacity ( cmp:: min ( pending_forwards_count as usize , MAX_ALLOC_SIZE /mem :: size_of :: < HTLCForwardInfo > ( ) ) ) ;
37703770 for _ in 0 ..pending_forwards_count {
37713771 pending_forwards. push ( Readable :: read ( reader) ?) ;
37723772 }
37733773 forward_htlcs. insert ( short_channel_id, pending_forwards) ;
37743774 }
37753775
37763776 let claimable_htlcs_count: u64 = Readable :: read ( reader) ?;
3777- let mut claimable_htlcs = HashMap :: with_capacity ( cmp:: min ( claimable_htlcs_count as usize , ( MAX_ALLOC_SIZE as usize ) /mem :: size_of :: < ClaimableHTLC > ( ) ) ) ;
3777+ let mut claimable_htlcs = HashMap :: with_capacity ( cmp:: min ( claimable_htlcs_count as usize , 128 ) ) ;
37783778 for _ in 0 ..claimable_htlcs_count {
37793779 let payment_hash = Readable :: read ( reader) ?;
37803780 let previous_hops_len: u64 = Readable :: read ( reader) ?;
3781- let mut previous_hops = Vec :: with_capacity ( cmp:: min ( previous_hops_len as usize , 2 ) ) ;
3781+ let mut previous_hops = Vec :: with_capacity ( cmp:: min ( previous_hops_len as usize , MAX_ALLOC_SIZE /mem :: size_of :: < ClaimableHTLC > ( ) ) ) ;
37823782 for _ in 0 ..previous_hops_len {
37833783 previous_hops. push ( Readable :: read ( reader) ?) ;
37843784 }
37853785 claimable_htlcs. insert ( payment_hash, previous_hops) ;
37863786 }
37873787
37883788 let peer_count: u64 = Readable :: read ( reader) ?;
3789- let mut per_peer_state = HashMap :: with_capacity ( cmp:: min ( peer_count as usize , ( MAX_ALLOC_SIZE as usize ) /mem:: size_of :: < PeerState > ( ) ) ) ;
3789+ let mut per_peer_state = HashMap :: with_capacity ( cmp:: min ( peer_count as usize , MAX_ALLOC_SIZE /mem:: size_of :: < RwLock < HashMap < PublicKey , Mutex < PeerState > > > > ( ) ) ) ;
37903790 for _ in 0 ..peer_count {
37913791 let peer_pubkey = Readable :: read ( reader) ?;
37923792 let peer_state = PeerState {
@@ -3796,7 +3796,7 @@ impl<'a, ChanSigner: ChannelKeys + Readable, M: Deref, T: Deref, K: Deref, F: De
37963796 }
37973797
37983798 let event_count: u64 = Readable :: read ( reader) ?;
3799- let mut pending_events_read: Vec < events:: Event > = Vec :: with_capacity ( cmp:: min ( event_count as usize , ( MAX_ALLOC_SIZE as usize ) /mem:: size_of :: < events:: Event > ( ) ) ) ;
3799+ let mut pending_events_read: Vec < events:: Event > = Vec :: with_capacity ( cmp:: min ( event_count as usize , MAX_ALLOC_SIZE /mem:: size_of :: < events:: Event > ( ) ) ) ;
38003800 for _ in 0 ..event_count {
38013801 match MaybeReadable :: read ( reader) ? {
38023802 Some ( event) => pending_events_read. push ( event) ,
0 commit comments