@@ -3762,31 +3762,31 @@ impl<'a, ChanSigner: ChannelKeys + Readable, M: Deref, T: Deref, K: Deref, F: De
3762
3762
3763
3763
const MAX_ALLOC_SIZE : usize = 1024 * 64 ;
3764
3764
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 ) ) ;
3766
3766
for _ in 0 ..forward_htlcs_count {
3767
3767
let short_channel_id = Readable :: read ( reader) ?;
3768
3768
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 > ( ) ) ) ;
3770
3770
for _ in 0 ..pending_forwards_count {
3771
3771
pending_forwards. push ( Readable :: read ( reader) ?) ;
3772
3772
}
3773
3773
forward_htlcs. insert ( short_channel_id, pending_forwards) ;
3774
3774
}
3775
3775
3776
3776
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 ) ) ;
3778
3778
for _ in 0 ..claimable_htlcs_count {
3779
3779
let payment_hash = Readable :: read ( reader) ?;
3780
3780
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 > ( ) ) ) ;
3782
3782
for _ in 0 ..previous_hops_len {
3783
3783
previous_hops. push ( Readable :: read ( reader) ?) ;
3784
3784
}
3785
3785
claimable_htlcs. insert ( payment_hash, previous_hops) ;
3786
3786
}
3787
3787
3788
3788
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 > > > > ( ) ) ) ;
3790
3790
for _ in 0 ..peer_count {
3791
3791
let peer_pubkey = Readable :: read ( reader) ?;
3792
3792
let peer_state = PeerState {
@@ -3796,7 +3796,7 @@ impl<'a, ChanSigner: ChannelKeys + Readable, M: Deref, T: Deref, K: Deref, F: De
3796
3796
}
3797
3797
3798
3798
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 > ( ) ) ) ;
3800
3800
for _ in 0 ..event_count {
3801
3801
match MaybeReadable :: read ( reader) ? {
3802
3802
Some ( event) => pending_events_read. push ( event) ,
0 commit comments