@@ -9,16 +9,16 @@ use mithril_common::entities::{Epoch, ProtocolParameters};
99
1010/// Store and get [protocol parameters][ProtocolParameters] for given epoch.
1111#[ async_trait]
12- pub trait ProtocolParametersStorer : Sync + Send {
12+ pub trait EpochSettingsStorer : Sync + Send {
1313 /// Save the given `ProtocolParameter` for the given [Epoch].
14- async fn save_protocol_parameters (
14+ async fn save_epoch_settings (
1515 & self ,
1616 epoch : Epoch ,
1717 protocol_parameters : ProtocolParameters ,
1818 ) -> StdResult < Option < ProtocolParameters > > ;
1919
2020 /// Get the saved `ProtocolParameter` for the given [Epoch] if any.
21- async fn get_protocol_parameters ( & self , epoch : Epoch ) -> StdResult < Option < ProtocolParameters > > ;
21+ async fn get_epoch_settings ( & self , epoch : Epoch ) -> StdResult < Option < ProtocolParameters > > ;
2222
2323 /// Handle discrepancies at startup in the protocol parameters store.
2424 /// In case an aggregator has been launched after some epochs of not being up or at initial startup,
@@ -31,9 +31,9 @@ pub trait ProtocolParametersStorer: Sync + Send {
3131 ) -> StdResult < ( ) > {
3232 for epoch_offset in 0 ..=2 {
3333 let epoch = current_epoch + epoch_offset;
34- if self . get_protocol_parameters ( epoch) . await ?. is_none ( ) {
34+ if self . get_epoch_settings ( epoch) . await ?. is_none ( ) {
3535 debug ! ( "Handle discrepancies at startup of protocol parameters store, will record protocol parameters from the configuration for epoch {epoch}: {configuration_protocol_parameters:?}" ) ;
36- self . save_protocol_parameters ( epoch, configuration_protocol_parameters. clone ( ) )
36+ self . save_epoch_settings ( epoch, configuration_protocol_parameters. clone ( ) )
3737 . await ?;
3838 }
3939 }
@@ -42,11 +42,11 @@ pub trait ProtocolParametersStorer: Sync + Send {
4242 }
4343}
4444
45- pub struct FakeProtocolParametersStorer {
45+ pub struct FakeEpochSettingsStorer {
4646 pub protocol_parameters : RwLock < HashMap < Epoch , ProtocolParameters > > ,
4747}
4848
49- impl FakeProtocolParametersStorer {
49+ impl FakeEpochSettingsStorer {
5050 #[ cfg( test) ]
5151 pub fn new ( data : Vec < ( Epoch , ProtocolParameters ) > ) -> Self {
5252 let protocol_parameters = RwLock :: new ( data. into_iter ( ) . collect ( ) ) ;
@@ -57,8 +57,8 @@ impl FakeProtocolParametersStorer {
5757}
5858
5959#[ async_trait]
60- impl ProtocolParametersStorer for FakeProtocolParametersStorer {
61- async fn save_protocol_parameters (
60+ impl EpochSettingsStorer for FakeEpochSettingsStorer {
61+ async fn save_epoch_settings (
6262 & self ,
6363 epoch : Epoch ,
6464 protocol_parameters : ProtocolParameters ,
@@ -67,7 +67,7 @@ impl ProtocolParametersStorer for FakeProtocolParametersStorer {
6767 Ok ( protocol_parameters_write. insert ( epoch, protocol_parameters) )
6868 }
6969
70- async fn get_protocol_parameters ( & self , epoch : Epoch ) -> StdResult < Option < ProtocolParameters > > {
70+ async fn get_epoch_settings ( & self , epoch : Epoch ) -> StdResult < Option < ProtocolParameters > > {
7171 let protocol_parameters = self . protocol_parameters . read ( ) . await ;
7272 Ok ( protocol_parameters. get ( & epoch) . cloned ( ) )
7373 }
@@ -84,9 +84,9 @@ mod tests {
8484 async fn test_save_protocol_parameters_do_not_exist_yet ( ) {
8585 let protocol_parameters = fake_data:: protocol_parameters ( ) ;
8686 let epoch = Epoch ( 1 ) ;
87- let store = FakeProtocolParametersStorer :: new ( vec ! [ ] ) ;
87+ let store = FakeEpochSettingsStorer :: new ( vec ! [ ] ) ;
8888 let protocol_parameters_previous = store
89- . save_protocol_parameters ( epoch, protocol_parameters)
89+ . save_epoch_settings ( epoch, protocol_parameters)
9090 . await
9191 . unwrap ( ) ;
9292
@@ -97,13 +97,13 @@ mod tests {
9797 async fn test_save_protocol_parameters_already_exist ( ) {
9898 let protocol_parameters = fake_data:: protocol_parameters ( ) ;
9999 let epoch = Epoch ( 1 ) ;
100- let store = FakeProtocolParametersStorer :: new ( vec ! [ ( epoch, protocol_parameters. clone( ) ) ] ) ;
100+ let store = FakeEpochSettingsStorer :: new ( vec ! [ ( epoch, protocol_parameters. clone( ) ) ] ) ;
101101 let protocol_parameters_new = ProtocolParameters {
102102 k : protocol_parameters. k + 1 ,
103103 ..protocol_parameters
104104 } ;
105105 let protocol_parameters_previous = store
106- . save_protocol_parameters ( epoch, protocol_parameters_new)
106+ . save_epoch_settings ( epoch, protocol_parameters_new)
107107 . await
108108 . unwrap ( ) ;
109109
@@ -114,8 +114,8 @@ mod tests {
114114 async fn test_get_protocol_parameters_exist ( ) {
115115 let protocol_parameters = fake_data:: protocol_parameters ( ) ;
116116 let epoch = Epoch ( 1 ) ;
117- let store = FakeProtocolParametersStorer :: new ( vec ! [ ( epoch, protocol_parameters. clone( ) ) ] ) ;
118- let protocol_parameters_stored = store. get_protocol_parameters ( epoch) . await . unwrap ( ) ;
117+ let store = FakeEpochSettingsStorer :: new ( vec ! [ ( epoch, protocol_parameters. clone( ) ) ] ) ;
118+ let protocol_parameters_stored = store. get_epoch_settings ( epoch) . await . unwrap ( ) ;
119119
120120 assert_eq ! ( Some ( protocol_parameters) , protocol_parameters_stored) ;
121121 }
@@ -124,8 +124,8 @@ mod tests {
124124 async fn test_get_protocol_parameters_do_not_exist ( ) {
125125 let protocol_parameters = fake_data:: protocol_parameters ( ) ;
126126 let epoch = Epoch ( 1 ) ;
127- let store = FakeProtocolParametersStorer :: new ( vec ! [ ( epoch, protocol_parameters. clone( ) ) ] ) ;
128- let protocol_parameters_stored = store. get_protocol_parameters ( epoch + 1 ) . await . unwrap ( ) ;
127+ let store = FakeEpochSettingsStorer :: new ( vec ! [ ( epoch, protocol_parameters. clone( ) ) ] ) ;
128+ let protocol_parameters_stored = store. get_epoch_settings ( epoch + 1 ) . await . unwrap ( ) ;
129129
130130 assert ! ( protocol_parameters_stored. is_none( ) ) ;
131131 }
@@ -138,7 +138,7 @@ mod tests {
138138 ..protocol_parameters
139139 } ;
140140 let epoch = Epoch ( 1 ) ;
141- let store = FakeProtocolParametersStorer :: new ( vec ! [
141+ let store = FakeEpochSettingsStorer :: new ( vec ! [
142142 ( epoch, protocol_parameters. clone( ) ) ,
143143 ( epoch + 1 , protocol_parameters. clone( ) ) ,
144144 ] ) ;
@@ -148,25 +148,25 @@ mod tests {
148148 . await
149149 . unwrap ( ) ;
150150
151- let protocol_parameters_stored = store. get_protocol_parameters ( epoch) . await . unwrap ( ) ;
151+ let protocol_parameters_stored = store. get_epoch_settings ( epoch) . await . unwrap ( ) ;
152152 assert_eq ! (
153153 Some ( protocol_parameters. clone( ) ) ,
154154 protocol_parameters_stored
155155 ) ;
156156
157- let protocol_parameters_stored = store. get_protocol_parameters ( epoch + 1 ) . await . unwrap ( ) ;
157+ let protocol_parameters_stored = store. get_epoch_settings ( epoch + 1 ) . await . unwrap ( ) ;
158158 assert_eq ! (
159159 Some ( protocol_parameters. clone( ) ) ,
160160 protocol_parameters_stored
161161 ) ;
162162
163- let protocol_parameters_stored = store. get_protocol_parameters ( epoch + 2 ) . await . unwrap ( ) ;
163+ let protocol_parameters_stored = store. get_epoch_settings ( epoch + 2 ) . await . unwrap ( ) ;
164164 assert_eq ! (
165165 Some ( protocol_parameters_new. clone( ) ) ,
166166 protocol_parameters_stored
167167 ) ;
168168
169- let protocol_parameters_stored = store. get_protocol_parameters ( epoch + 3 ) . await . unwrap ( ) ;
169+ let protocol_parameters_stored = store. get_epoch_settings ( epoch + 3 ) . await . unwrap ( ) ;
170170 assert ! ( protocol_parameters_stored. is_none( ) ) ;
171171 }
172172}
0 commit comments