@@ -142,10 +142,7 @@ pub enum AccountAddressFilter {
142
142
143
143
impl Accounts {
144
144
pub fn default_for_tests ( ) -> Self {
145
- Self {
146
- accounts_db : Arc :: new ( AccountsDb :: default_for_tests ( ) ) ,
147
- account_locks : Mutex :: default ( ) ,
148
- }
145
+ Self :: new_empty ( AccountsDb :: default_for_tests ( ) )
149
146
}
150
147
151
148
pub fn new_with_config_for_tests (
@@ -191,32 +188,30 @@ impl Accounts {
191
188
accounts_update_notifier : Option < AccountsUpdateNotifier > ,
192
189
exit : & Arc < AtomicBool > ,
193
190
) -> Self {
194
- Self {
195
- accounts_db : Arc :: new ( AccountsDb :: new_with_config (
196
- paths,
197
- cluster_type,
198
- account_indexes,
199
- shrink_ratio,
200
- accounts_db_config,
201
- accounts_update_notifier,
202
- exit,
203
- ) ) ,
204
- account_locks : Mutex :: new ( AccountLocks :: default ( ) ) ,
205
- }
191
+ Self :: new_empty ( AccountsDb :: new_with_config (
192
+ paths,
193
+ cluster_type,
194
+ account_indexes,
195
+ shrink_ratio,
196
+ accounts_db_config,
197
+ accounts_update_notifier,
198
+ exit,
199
+ ) )
206
200
}
207
201
208
202
pub fn new_from_parent ( parent : & Accounts , slot : Slot , parent_slot : Slot ) -> Self {
209
203
let accounts_db = parent. accounts_db . clone ( ) ;
210
204
accounts_db. insert_default_bank_hash_stats ( slot, parent_slot) ;
211
- Self {
212
- accounts_db,
213
- account_locks : Mutex :: new ( AccountLocks :: default ( ) ) ,
214
- }
205
+ Self :: new ( accounts_db)
215
206
}
216
207
217
208
pub ( crate ) fn new_empty ( accounts_db : AccountsDb ) -> Self {
209
+ Self :: new ( Arc :: new ( accounts_db) )
210
+ }
211
+
212
+ fn new ( accounts_db : Arc < AccountsDb > ) -> Self {
218
213
Self {
219
- accounts_db : Arc :: new ( accounts_db ) ,
214
+ accounts_db,
220
215
account_locks : Mutex :: new ( AccountLocks :: default ( ) ) ,
221
216
}
222
217
}
0 commit comments