@@ -26,7 +26,9 @@ pub struct Sv1ServerData {
2626 pub downstreams : HashMap < DownstreamId , Arc < Downstream > > ,
2727 pub request_id_to_downstream_id : HashMap < RequestId , DownstreamId > ,
2828 pub vardiff : HashMap < DownstreamId , Arc < RwLock < VardiffState > > > ,
29- pub prevhash : Option < SetNewPrevHash < ' static > > ,
29+ /// HashMap to store the SetNewPrevHash for each channel
30+ /// Used in both aggregated and non-aggregated mode
31+ pub prevhashes : HashMap < ChannelId , SetNewPrevHash < ' static > > ,
3032 pub downstream_id_factory : AtomicUsize ,
3133 pub request_id_factory : AtomicU32 ,
3234 /// Job storage for aggregated mode - all Sv1 downstreams share the same jobs
@@ -52,7 +54,7 @@ impl Sv1ServerData {
5254 downstreams : HashMap :: new ( ) ,
5355 request_id_to_downstream_id : HashMap :: new ( ) ,
5456 vardiff : HashMap :: new ( ) ,
55- prevhash : None ,
57+ prevhashes : HashMap :: new ( ) ,
5658 downstream_id_factory : AtomicUsize :: new ( 1 ) ,
5759 request_id_factory : AtomicU32 :: new ( 1 ) ,
5860 aggregated_valid_jobs : aggregate_channels. then ( Vec :: new) ,
@@ -87,6 +89,16 @@ impl Sv1ServerData {
8789 job_id. contains ( KEEPALIVE_JOB_ID_DELIMITER )
8890 }
8991
92+ /// Gets the prevhash for a given channel.
93+ pub fn get_prevhash ( & self , channel_id : u32 ) -> Option < SetNewPrevHash < ' static > > {
94+ self . prevhashes . get ( & channel_id) . cloned ( )
95+ }
96+
97+ /// Sets the prevhash for a given channel.
98+ pub fn set_prevhash ( & mut self , channel_id : u32 , prevhash : SetNewPrevHash < ' static > ) {
99+ self . prevhashes . insert ( channel_id, prevhash) ;
100+ }
101+
90102 /// Gets the last job from the jobs storage.
91103 /// In aggregated mode, returns the last job from the shared job list.
92104 /// In non-aggregated mode, returns the last job for the specified channel.
0 commit comments