@@ -17,12 +17,13 @@ use commonware_cryptography::{
1717 Signer ,
1818} ;
1919use commonware_p2p:: { Blocker , Receiver , Sender } ;
20- use commonware_runtime:: { Clock , Handle , Metrics , Spawner , Storage } ;
20+ use commonware_runtime:: { buffer:: PoolRef , Clock , Handle , Metrics , Spawner , Storage } ;
21+ use commonware_utils:: { NZUsize , NZU64 } ;
2122use futures:: future:: try_join_all;
2223use governor:: clock:: Clock as GClock ;
2324use governor:: Quota ;
2425use rand:: { CryptoRng , Rng } ;
25- use std:: time:: Duration ;
26+ use std:: { num :: NonZero , time:: Duration } ;
2627use tracing:: { error, warn} ;
2728
2829/// Reporter type for [threshold_simplex::Engine].
@@ -32,14 +33,16 @@ type Reporter<E, I> =
3233/// To better support peers near tip during network instability, we multiply
3334/// the consensus activity timeout by this factor.
3435const SYNCER_ACTIVITY_TIMEOUT_MULTIPLIER : u64 = 10 ;
35- const PRUNABLE_ITEMS_PER_SECTION : u64 = 4_096 ;
36- const IMMUTABLE_ITEMS_PER_SECTION : u64 = 262_144 ;
36+ const PRUNABLE_ITEMS_PER_SECTION : NonZero < u64 > = NZU64 ! ( 4_096 ) ;
37+ const IMMUTABLE_ITEMS_PER_SECTION : NonZero < u64 > = NZU64 ! ( 262_144 ) ;
3738const FREEZER_TABLE_RESIZE_FREQUENCY : u8 = 4 ;
3839const FREEZER_TABLE_RESIZE_CHUNK_SIZE : u32 = 2u32 . pow ( 16 ) ; // 3MB
3940const FREEZER_JOURNAL_TARGET_SIZE : u64 = 1024 * 1024 * 1024 ; // 1GB
4041const FREEZER_JOURNAL_COMPRESSION : Option < u8 > = Some ( 3 ) ;
41- const REPLAY_BUFFER : usize = 8 * 1024 * 1024 ; // 8MB
42- const WRITE_BUFFER : usize = 1024 * 1024 ; // 1MB
42+ const REPLAY_BUFFER : NonZero < usize > = NZUsize ! ( 8 * 1024 * 1024 ) ; // 8MB
43+ const WRITE_BUFFER : NonZero < usize > = NZUsize ! ( 1024 * 1024 ) ; // 1MB
44+ const BUFFER_POOL_PAGE_SIZE : NonZero < usize > = NZUsize ! ( 4_096 ) ; // 4KB
45+ const BUFFER_POOL_CAPACITY : NonZero < usize > = NZUsize ! ( 8_192 ) ; // 32MB
4346const MAX_REPAIR : u64 = 20 ;
4447
4548/// Configuration for the [Engine].
@@ -130,6 +133,9 @@ impl<
130133 } ,
131134 ) ;
132135
136+ // Create the buffer pool
137+ let buffer_pool = PoolRef :: new ( BUFFER_POOL_PAGE_SIZE , BUFFER_POOL_CAPACITY ) ;
138+
133139 // Create marshal
134140 let ( marshal, marshal_mailbox) : ( _ , marshal:: Mailbox < MinSig , Block > ) =
135141 marshal:: Actor :: init (
@@ -152,6 +158,7 @@ impl<
152158 freezer_table_resize_chunk_size : FREEZER_TABLE_RESIZE_CHUNK_SIZE ,
153159 freezer_journal_target_size : FREEZER_JOURNAL_TARGET_SIZE ,
154160 freezer_journal_compression : FREEZER_JOURNAL_COMPRESSION ,
161+ freezer_journal_buffer_pool : buffer_pool. clone ( ) ,
155162 replay_buffer : REPLAY_BUFFER ,
156163 write_buffer : WRITE_BUFFER ,
157164 codec_config : ( ) ,
@@ -198,6 +205,7 @@ impl<
198205 replay_buffer : REPLAY_BUFFER ,
199206 write_buffer : WRITE_BUFFER ,
200207 blocker : cfg. blocker ,
208+ buffer_pool,
201209 } ,
202210 ) ;
203211
0 commit comments