@@ -27,7 +27,6 @@ pub enum MaskImpl {
2727 Attached {
2828 parent : Mask ,
2929 owning_account : HashMap < AccountIndex , Account > ,
30- token_to_account : HashMap < TokenId , AccountId > ,
3130 id_to_addr : HashMap < AccountId , Address > ,
3231 last_location : Option < Address > ,
3332 depth : u8 ,
@@ -39,7 +38,6 @@ pub enum MaskImpl {
3938 depth : u8 ,
4039 childs : HashMap < Uuid , Mask > ,
4140 owning_account : HashMap < AccountIndex , Account > ,
42- token_to_account : HashMap < TokenId , AccountId > ,
4341 id_to_addr : HashMap < AccountId , Address > ,
4442 last_location : Option < Address > ,
4543 hashes : HashesMatrix ,
@@ -68,7 +66,6 @@ impl Clone for MaskImpl {
6866 Self :: Attached {
6967 parent,
7068 owning_account,
71- token_to_account,
7269 id_to_addr,
7370 last_location,
7471 depth,
@@ -78,7 +75,6 @@ impl Clone for MaskImpl {
7875 } => Self :: Attached {
7976 parent : parent. clone ( ) ,
8077 owning_account : owning_account. clone ( ) ,
81- token_to_account : token_to_account. clone ( ) ,
8278 id_to_addr : id_to_addr. clone ( ) ,
8379 last_location : last_location. clone ( ) ,
8480 depth : * depth,
@@ -90,7 +86,6 @@ impl Clone for MaskImpl {
9086 depth,
9187 childs,
9288 owning_account,
93- token_to_account,
9489 id_to_addr,
9590 last_location,
9691 hashes,
@@ -99,7 +94,6 @@ impl Clone for MaskImpl {
9994 depth : * depth,
10095 childs : childs. clone ( ) ,
10196 owning_account : owning_account. clone ( ) ,
102- token_to_account : token_to_account. clone ( ) ,
10397 id_to_addr : id_to_addr. clone ( ) ,
10498 last_location : last_location. clone ( ) ,
10599 hashes : hashes. clone ( ) ,
@@ -121,7 +115,6 @@ impl std::fmt::Debug for MaskImpl {
121115 Self :: Attached {
122116 parent,
123117 owning_account,
124- token_to_account,
125118 id_to_addr,
126119 last_location,
127120 depth,
@@ -133,7 +126,6 @@ impl std::fmt::Debug for MaskImpl {
133126 . field ( "uuid" , uuid)
134127 . field ( "parent" , & parent. get_uuid ( ) )
135128 . field ( "owning_account" , & owning_account. len ( ) )
136- . field ( "token_to_account" , & token_to_account. len ( ) )
137129 . field ( "id_to_addr" , & id_to_addr. len ( ) )
138130 . field ( "last_location" , last_location)
139131 . field ( "depth" , depth)
@@ -145,7 +137,6 @@ impl std::fmt::Debug for MaskImpl {
145137 depth,
146138 childs,
147139 owning_account,
148- token_to_account,
149140 id_to_addr,
150141 last_location,
151142 hashes,
@@ -155,7 +146,6 @@ impl std::fmt::Debug for MaskImpl {
155146 . field ( "depth" , depth)
156147 . field ( "childs" , & childs. len ( ) )
157148 . field ( "owning_account" , & owning_account. len ( ) )
158- . field ( "token_to_account" , & token_to_account. len ( ) )
159149 . field ( "id_to_addr" , & id_to_addr. len ( ) )
160150 . field ( "last_location" , last_location)
161151 . field ( "uuid" , uuid)
@@ -298,7 +288,6 @@ impl MaskImpl {
298288 childs,
299289 uuid,
300290 owning_account,
301- token_to_account,
302291 id_to_addr,
303292 last_location,
304293 hashes,
@@ -308,7 +297,6 @@ impl MaskImpl {
308297 * self = Attached {
309298 parent,
310299 owning_account : take ( owning_account) ,
311- token_to_account : take ( token_to_account) ,
312300 id_to_addr : take ( id_to_addr) ,
313301 last_location : take ( last_location) ,
314302 depth : * depth,
@@ -378,15 +366,13 @@ impl MaskImpl {
378366 Attached {
379367 parent,
380368 owning_account,
381- token_to_account,
382369 id_to_addr,
383370 hashes,
384371 ..
385372 } => {
386373 assert_ne ! ( parent. get_uuid( ) , self_uuid) ;
387374
388375 let ( accounts, hashes) = {
389- token_to_account. clear ( ) ;
390376 id_to_addr. clear ( ) ;
391377 ( std:: mem:: take ( owning_account) , hashes. take ( ) )
392378 } ;
@@ -485,7 +471,6 @@ impl MaskImpl {
485471 let Self :: Attached {
486472 parent,
487473 owning_account,
488- token_to_account,
489474 id_to_addr,
490475 last_location,
491476 depth,
@@ -502,15 +487,13 @@ impl MaskImpl {
502487 let owning_account = std:: mem:: take ( owning_account) ;
503488 let depth = std:: mem:: take ( depth) ;
504489 let childs = std:: mem:: take ( childs) ;
505- let token_to_account = std:: mem:: take ( token_to_account) ;
506490 let id_to_addr = std:: mem:: take ( id_to_addr) ;
507491 let last_location = std:: mem:: take ( last_location) ;
508492 let hashes = std:: mem:: replace ( hashes, HashesMatrix :: new ( depth as usize ) ) ;
509493 let uuid = std:: mem:: replace ( uuid, "temporary" . to_string ( ) ) ;
510494
511495 * self = Self :: Unattached {
512496 owning_account,
513- token_to_account,
514497 id_to_addr,
515498 last_location,
516499 depth,
@@ -790,15 +773,13 @@ impl MaskImpl {
790773 Root { .. } => todo ! ( ) ,
791774 Unattached {
792775 owning_account,
793- token_to_account,
794776 id_to_addr,
795777 last_location,
796778 hashes,
797779 ..
798780 }
799781 | Attached {
800782 owning_account,
801- token_to_account,
802783 id_to_addr,
803784 last_location,
804785 hashes,
@@ -814,8 +795,7 @@ impl MaskImpl {
814795 let account_index = addr. to_index ( ) ;
815796 hashes. invalidate_hashes ( account_index) ;
816797
817- let account = owning_account. remove ( & account_index) . unwrap ( ) ;
818- token_to_account. remove ( & account. token_id ) . unwrap ( ) ;
798+ let _account = owning_account. remove ( & account_index) . unwrap ( ) ;
819799
820800 if last_location
821801 . as_ref ( )
@@ -852,24 +832,20 @@ impl MaskImpl {
852832 Root { database, .. } => database. set ( addr, account) ,
853833 Unattached {
854834 owning_account,
855- token_to_account,
856835 id_to_addr,
857836 last_location,
858837 ..
859838 }
860839 | Attached {
861840 owning_account,
862- token_to_account,
863841 id_to_addr,
864842 last_location,
865843 ..
866844 } => {
867845 let account_id = account. id ( ) ;
868- let token_id = account. token_id . clone ( ) ;
869846
870847 owning_account. insert ( account_index, * account) ;
871848 id_to_addr. insert ( account_id. clone ( ) , addr. clone ( ) ) ;
872- token_to_account. insert ( token_id, account_id) ;
873849
874850 if last_location
875851 . as_ref ( )
@@ -1111,34 +1087,6 @@ impl BaseLedger for MaskImpl {
11111087 set
11121088 }
11131089
1114- fn token_owner ( & self , token_id : TokenId ) -> Option < AccountId > {
1115- let ( parent, token_to_account) = match self {
1116- Root { database, .. } => return database. token_owner ( token_id) ,
1117- Attached {
1118- parent,
1119- token_to_account,
1120- ..
1121- } => ( Some ( parent) , token_to_account) ,
1122- Unattached {
1123- token_to_account, ..
1124- } => ( None , token_to_account) ,
1125- } ;
1126-
1127- if let Some ( account_id) = token_to_account. get ( & token_id) . cloned ( ) {
1128- return Some ( account_id) ;
1129- } ;
1130-
1131- parent. as_ref ( ) ?. token_owner ( token_id)
1132- }
1133-
1134- fn token_owners ( & self ) -> HashSet < AccountId > {
1135- // TODO: Not sure if it's the correct impl
1136- self . to_list ( )
1137- . into_iter ( )
1138- . map ( |account| account. id ( ) )
1139- . collect ( )
1140- }
1141-
11421090 fn tokens ( & self , public_key : CompressedPubKey ) -> HashSet < TokenId > {
11431091 let mut set = HashSet :: with_capacity ( 1024 ) ;
11441092
@@ -1195,15 +1143,13 @@ impl BaseLedger for MaskImpl {
11951143 Root { database, .. } => database. get_or_create_account ( account_id, account) ?,
11961144 Unattached {
11971145 owning_account,
1198- token_to_account,
11991146 id_to_addr,
12001147 last_location,
12011148 depth,
12021149 ..
12031150 }
12041151 | Attached {
12051152 owning_account,
1206- token_to_account,
12071153 id_to_addr,
12081154 last_location,
12091155 depth,
@@ -1215,11 +1161,9 @@ impl BaseLedger for MaskImpl {
12151161 } ;
12161162
12171163 let account_index: AccountIndex = location. to_index ( ) ;
1218- let token_id = account. token_id . clone ( ) ;
12191164
12201165 id_to_addr. insert ( account_id. clone ( ) , location. clone ( ) ) ;
12211166 * last_location = Some ( location. clone ( ) ) ;
1222- token_to_account. insert ( token_id, account_id) ;
12231167 owning_account. insert ( account_index, account) ;
12241168
12251169 self . invalidate_hashes ( account_index) ;
0 commit comments