File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 1
1
use std:: sync:: Arc ;
2
2
3
- /// MAX_INLINE is the maximum size of a multiaddr that can be stored inline
4
- const MAX_INLINE : usize = 38 ;
3
+ /// MAX_INLINE is the maximum size of a multiaddr that can be stored inline.
4
+ /// There is an overhead of 2 bytes, 1 for the length and 1 for the enum discriminator.
5
+ /// 30 is chosen so that the overall size is 32. This should still be big enough to fit
6
+ /// a multiaddr containing an ipv4 or ipv6 address and port.
7
+ ///
8
+ /// More complex multiaddrs like those containing peer ids will be stored on the heap.
9
+ const MAX_INLINE : usize = 30 ;
5
10
6
11
#[ derive( Clone ) ]
7
12
pub ( crate ) enum Storage {
@@ -42,7 +47,7 @@ mod tests {
42
47
#[ test]
43
48
fn struct_size ( ) {
44
49
// this should be true for both 32 and 64 bit archs
45
- assert_eq ! ( std:: mem:: size_of:: <Storage >( ) , 40 ) ;
50
+ assert_eq ! ( std:: mem:: size_of:: <Storage >( ) , 32 ) ;
46
51
}
47
52
48
53
#[ test]
You can’t perform that action at this time.
0 commit comments