mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-26 00:05:18 +00:00
fix: export synced deposits/borrows (#811)
* fix: export synced deposits/borrows * fix: epxort synced cdps
This commit is contained in:
parent
b620275165
commit
04b65e1d4e
@ -94,7 +94,8 @@ func ExportGenesis(ctx sdk.Context, k Keeper) GenesisState {
|
|||||||
cdps := CDPs{}
|
cdps := CDPs{}
|
||||||
deposits := Deposits{}
|
deposits := Deposits{}
|
||||||
k.IterateAllCdps(ctx, func(cdp CDP) (stop bool) {
|
k.IterateAllCdps(ctx, func(cdp CDP) (stop bool) {
|
||||||
cdps = append(cdps, cdp)
|
syncedCdp := k.SynchronizeInterest(ctx, cdp)
|
||||||
|
cdps = append(cdps, syncedCdp)
|
||||||
k.IterateDeposits(ctx, cdp.ID, func(deposit Deposit) (stop bool) {
|
k.IterateDeposits(ctx, cdp.ID, func(deposit Deposit) (stop bool) {
|
||||||
deposits = append(deposits, deposit)
|
deposits = append(deposits, deposit)
|
||||||
return false
|
return false
|
||||||
|
@ -54,12 +54,20 @@ func ExportGenesis(ctx sdk.Context, k Keeper) GenesisState {
|
|||||||
borrows := types.Borrows{}
|
borrows := types.Borrows{}
|
||||||
|
|
||||||
k.IterateDeposits(ctx, func(d types.Deposit) bool {
|
k.IterateDeposits(ctx, func(d types.Deposit) bool {
|
||||||
deposits = append(deposits, d)
|
syncedDeposit, found := k.GetSyncedDeposit(ctx, d.Depositor)
|
||||||
|
if !found {
|
||||||
|
panic(fmt.Sprintf("syncable deposit not found for %s", d.Depositor))
|
||||||
|
}
|
||||||
|
deposits = append(deposits, syncedDeposit)
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
k.IterateBorrows(ctx, func(b types.Borrow) bool {
|
k.IterateBorrows(ctx, func(b types.Borrow) bool {
|
||||||
borrows = append(borrows, b)
|
syncedBorrow, found := k.GetSyncedBorrow(ctx, b.Borrower)
|
||||||
|
if !found {
|
||||||
|
panic(fmt.Sprintf("syncable borrow not found for %s", b.Borrower))
|
||||||
|
}
|
||||||
|
borrows = append(borrows, syncedBorrow)
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user