File tree 3 files changed +20
-5
lines changed
3 files changed +20
-5
lines changed Original file line number Diff line number Diff line change 1
1
### Process steps
2
2
- take solo ` Staking::Ledger ` , ` Staking::RingPool ` , ` Staking::KtonPool ` and ` Staking::LivingTime `
3
+ - clean empty ledger
3
4
- adjust decimals and block number, convert ledger, adjust unstaking duration then set ` AccountMigration::Ledgers ` and ` AccountMigration::Deposits `
4
5
- set ` Staking::RingPool ` and ` Staking::KtonPool `
Original file line number Diff line number Diff line change @@ -24,7 +24,16 @@ impl<S> Processor<S> {
24
24
let staking_ik = item_key ( b"AccountMigration" , b"Ledgers" ) ;
25
25
let deposit_ik = item_key ( b"AccountMigration" , b"Deposits" ) ;
26
26
27
- ledgers. into_iter ( ) . for_each ( |( _, mut v) | {
27
+ for ( _, mut v) in ledgers {
28
+ if v. is_empty ( ) {
29
+ log:: info!(
30
+ "clean empty ledger for Account({})" ,
31
+ array_bytes:: bytes2hex( "0x" , v. stash)
32
+ ) ;
33
+
34
+ continue ;
35
+ }
36
+
28
37
v. adjust ( ) ;
29
38
30
39
let hash_k = blake2_128_concat_to_string ( v. stash ) ;
@@ -64,9 +73,6 @@ impl<S> Processor<S> {
64
73
ring_pool += v. active ;
65
74
kton_pool += v. active_kton ;
66
75
67
- // Some accounts were killed.
68
- // But their staking data didn't get deleted.
69
- // TODO: https://github.com/darwinia-network/darwinia-2.0/issues/6
70
76
self . shell_state . inc_consumers_by ( & array_bytes:: bytes2hex ( "" , v. stash ) , consumers) ;
71
77
self . shell_state . insert_raw_key_value (
72
78
staking_k,
@@ -89,7 +95,7 @@ impl<S> Processor<S> {
89
95
unstaking_deposits : Default :: default ( ) ,
90
96
} ,
91
97
) ;
92
- } ) ;
98
+ }
93
99
}
94
100
95
101
ring_pool_storage. adjust ( ) ;
Original file line number Diff line number Diff line change @@ -139,6 +139,14 @@ pub struct StakingLedger {
139
139
pub kton_staking_lock : StakingLock ,
140
140
pub claimed_rewards : Vec < u32 > ,
141
141
}
142
+ impl StakingLedger {
143
+ pub fn is_empty ( & self ) -> bool {
144
+ self . active == 0
145
+ && self . active_deposit_ring == 0
146
+ && self . active_kton == 0
147
+ && self . deposit_items . is_empty ( )
148
+ }
149
+ }
142
150
#[ derive( Default , Debug , Encode , Decode ) ]
143
151
pub struct TimeDepositItem {
144
152
#[ codec( compact) ]
You can’t perform that action at this time.
0 commit comments