@@ -3769,8 +3769,9 @@ impl<'a, ChanSigner: ChannelKeys + Readable, M: Deref, T: Deref, K: Deref, F: De
3769
3769
}
3770
3770
}
3771
3771
3772
+ const MAX_ALLOC_SIZE : u64 = 1024 * 64 ;
3772
3773
let forward_htlcs_count: u64 = Readable :: read ( reader) ?;
3773
- let mut forward_htlcs = HashMap :: with_capacity ( cmp:: min ( forward_htlcs_count as usize , 128 ) ) ;
3774
+ let mut forward_htlcs = HashMap :: with_capacity ( cmp:: min ( forward_htlcs_count as usize , ( MAX_ALLOC_SIZE as usize ) /mem :: size_of :: < HTLCForwardInfo > ( ) ) ) ;
3774
3775
for _ in 0 ..forward_htlcs_count {
3775
3776
let short_channel_id = Readable :: read ( reader) ?;
3776
3777
let pending_forwards_count: u64 = Readable :: read ( reader) ?;
@@ -3782,7 +3783,7 @@ impl<'a, ChanSigner: ChannelKeys + Readable, M: Deref, T: Deref, K: Deref, F: De
3782
3783
}
3783
3784
3784
3785
let claimable_htlcs_count: u64 = Readable :: read ( reader) ?;
3785
- let mut claimable_htlcs = HashMap :: with_capacity ( cmp:: min ( claimable_htlcs_count as usize , 128 ) ) ;
3786
+ let mut claimable_htlcs = HashMap :: with_capacity ( cmp:: min ( claimable_htlcs_count as usize , ( MAX_ALLOC_SIZE as usize ) /mem :: size_of :: < ClaimableHTLC > ( ) ) ) ;
3786
3787
for _ in 0 ..claimable_htlcs_count {
3787
3788
let payment_hash = Readable :: read ( reader) ?;
3788
3789
let previous_hops_len: u64 = Readable :: read ( reader) ?;
@@ -3794,7 +3795,7 @@ impl<'a, ChanSigner: ChannelKeys + Readable, M: Deref, T: Deref, K: Deref, F: De
3794
3795
}
3795
3796
3796
3797
let peer_count: u64 = Readable :: read ( reader) ?;
3797
- let mut per_peer_state = HashMap :: with_capacity ( cmp:: min ( peer_count as usize , 128 ) ) ;
3798
+ let mut per_peer_state = HashMap :: with_capacity ( cmp:: min ( peer_count as usize , ( MAX_ALLOC_SIZE as usize ) /mem :: size_of :: < PeerState > ( ) ) ) ;
3798
3799
for _ in 0 ..peer_count {
3799
3800
let peer_pubkey = Readable :: read ( reader) ?;
3800
3801
let peer_state = PeerState {
@@ -3803,7 +3804,6 @@ impl<'a, ChanSigner: ChannelKeys + Readable, M: Deref, T: Deref, K: Deref, F: De
3803
3804
per_peer_state. insert ( peer_pubkey, Mutex :: new ( peer_state) ) ;
3804
3805
}
3805
3806
3806
- const MAX_ALLOC_SIZE : u64 = 1024 * 64 ;
3807
3807
let event_count: u64 = Readable :: read ( reader) ?;
3808
3808
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 > ( ) ) ) ;
3809
3809
for _ in 0 ..event_count {
0 commit comments