@@ -6,6 +6,7 @@ use std::{
66
77use mina_hasher:: Fp ;
88use mina_signer:: CompressedPubKey ;
9+ use openmina_core:: IS_ARCHIVE ;
910
1011use crate :: {
1112 next_uuid, Account , AccountId , AccountIndex , AccountLegacy , Address , AddressIterator ,
@@ -34,7 +35,7 @@ impl<T: TreeVersion> std::fmt::Debug for DatabaseImpl<T> {
3435 // .field("accounts", &self.accounts)
3536 . field ( "hashes_matrix" , & self . hashes_matrix )
3637 // .field("id_to_addr", &self.id_to_addr)
37- // .field("token_to_account ", &self.token_to_account )
38+ // .field("token_owners ", &self.token_owners )
3839 // .field("depth", &self.depth)
3940 // .field("last_location", &self.last_location)
4041 . field ( "naccounts" , & self . naccounts )
@@ -106,8 +107,8 @@ impl DatabaseImpl<V2> {
106107 self . naccounts += 1 ;
107108
108109 if !token_id. is_default ( ) {
109- if let Some ( token_to_account ) = self . token_owners . as_mut ( ) {
110- token_to_account . insert ( account_id. derive_token_id ( ) , account_id. clone ( ) ) ;
110+ if let Some ( token_owners ) = self . token_owners . as_mut ( ) {
111+ token_owners . insert ( account_id. derive_token_id ( ) , account_id. clone ( ) ) ;
111112 }
112113 }
113114 self . id_to_addr . insert ( account_id, location. clone ( ) ) ;
@@ -310,7 +311,7 @@ impl DatabaseImpl<V1> {
310311}
311312
312313impl DatabaseImpl < V2 > {
313- pub fn create_with_dir ( depth : u8 , dir_name : Option < PathBuf > , is_archive : bool ) -> Self {
314+ pub fn create_with_dir ( depth : u8 , dir_name : Option < PathBuf > ) -> Self {
314315 assert ! ( ( 1 ..0xfe ) . contains( & depth) ) ;
315316
316317 const NACCOUNTS : usize = 10_000 ;
@@ -338,7 +339,7 @@ impl DatabaseImpl<V2> {
338339
339340 // std::fs::create_dir_all(&path).ok();
340341
341- let token_to_account = if is_archive {
342+ let token_owners = if IS_ARCHIVE . get ( ) . cloned ( ) . unwrap_or_default ( ) {
342343 Some ( HashMap :: with_capacity ( NACCOUNTS ) )
343344 } else {
344345 None
@@ -350,16 +351,16 @@ impl DatabaseImpl<V2> {
350351 last_location : None ,
351352 naccounts : 0 ,
352353 id_to_addr : HashMap :: with_capacity ( NACCOUNTS ) ,
353- token_owners : token_to_account ,
354+ token_owners,
354355 uuid,
355356 directory : path,
356357 hashes_matrix : HashesMatrix :: new ( depth as usize ) ,
357358 // root_hash: Default::default(),
358359 }
359360 }
360361
361- pub fn create ( depth : u8 , is_archive : bool ) -> Self {
362- Self :: create_with_dir ( depth, None , is_archive )
362+ pub fn create ( depth : u8 ) -> Self {
363+ Self :: create_with_dir ( depth, None )
363364 }
364365
365366 pub fn root_hash ( & mut self ) -> Fp {
@@ -534,7 +535,7 @@ impl BaseLedger for DatabaseImpl<V2> {
534535 fn token_owner ( & self , token_id : TokenId ) -> Option < AccountId > {
535536 self . token_owners
536537 . as_ref ( )
537- . and_then ( |token_to_account| token_to_account . get ( & token_id) . cloned ( ) )
538+ . and_then ( |token_owners| token_owners . get ( & token_id) . cloned ( ) )
538539 }
539540
540541 fn tokens ( & self , public_key : CompressedPubKey ) -> HashSet < TokenId > {
@@ -695,17 +696,17 @@ impl BaseLedger for DatabaseImpl<V2> {
695696 let id = account. id ( ) ;
696697 self . id_to_addr . remove ( & id) ;
697698 if !id. token_id . is_default ( ) {
698- if let Some ( token_to_account ) = self . token_owners . as_mut ( ) {
699- token_to_account . remove ( & id. derive_token_id ( ) ) ;
699+ if let Some ( token_owners ) = self . token_owners . as_mut ( ) {
700+ token_owners . remove ( & id. derive_token_id ( ) ) ;
700701 }
701702 }
702703 } else {
703704 self . naccounts += 1 ;
704705 }
705706
706707 if !account. token_id . is_default ( ) {
707- if let Some ( token_to_account ) = self . token_owners . as_mut ( ) {
708- token_to_account . insert ( account. id ( ) . derive_token_id ( ) , id. clone ( ) ) ;
708+ if let Some ( token_owners ) = self . token_owners . as_mut ( ) {
709+ token_owners . insert ( account. id ( ) . derive_token_id ( ) , id. clone ( ) ) ;
709710 }
710711 }
711712 self . id_to_addr . insert ( id, addr. clone ( ) ) ;
@@ -838,8 +839,8 @@ impl BaseLedger for DatabaseImpl<V2> {
838839 let id = account. id ( ) ;
839840 self . id_to_addr . remove ( & id) ;
840841 if !id. token_id . is_default ( ) {
841- if let Some ( token_to_account ) = self . token_owners . as_mut ( ) {
842- token_to_account . remove ( & id. derive_token_id ( ) ) ;
842+ if let Some ( token_owners ) = self . token_owners . as_mut ( ) {
843+ token_owners . remove ( & id. derive_token_id ( ) ) ;
843844 }
844845 }
845846
0 commit comments