Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:MinterTeam/minter-go-node into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
danil-lashin committed Oct 8, 2020
2 parents e558b8d + cadbe54 commit 96dbf89
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ func (cs *CheckState) Export11To12(height uint64) types.AppState {
frozenFundsState.Export(state, height, coinsMap)
accountsState.Export(state, coinsMap)
checksState.Export(state)
coinsState.Export(state)

return *state
}
Expand Down
39 changes: 39 additions & 0 deletions legacy/coins/coins.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/MinterTeam/minter-go-node/helpers"
"github.com/MinterTeam/minter-go-node/rlp"
"github.com/MinterTeam/minter-go-node/tree"
"math/big"
"sort"
"sync"
)
Expand Down Expand Up @@ -104,6 +105,44 @@ func (c *Coins) getOrderedDirtyCoins() []types.CoinSymbol {
func (c *Coins) Export(state *types.AppState) map[types.CoinSymbol]types.Coin {
var coins []types.Coin

if len(state.Coins) != 0 {
for k, coin := range state.Coins {
// check coins' volume
volume := big.NewInt(0)
for _, ff := range state.FrozenFunds {
if ff.Coin == coin.ID {
volume.Add(volume, helpers.StringToBigInt(ff.Value))
}
}

for _, candidate := range state.Candidates {
for _, stake := range candidate.Stakes {
if stake.Coin == coin.ID {
volume.Add(volume, helpers.StringToBigInt(stake.Value))
}
}

for _, stake := range candidate.Updates {
if stake.Coin == coin.ID {
volume.Add(volume, helpers.StringToBigInt(stake.Value))
}
}
}

for _, account := range state.Accounts {
for _, bal := range account.Balance {
if bal.Coin == coin.ID {
volume.Add(volume, helpers.StringToBigInt(bal.Value))
}
}
}

state.Coins[k].Volume = volume.String()
}

return nil
}

c.iavl.Iterate(func(key []byte, value []byte) bool {
if key[0] == mainPrefix {
if len(key[1:]) > types.CoinSymbolLength {
Expand Down

0 comments on commit 96dbf89

Please sign in to comment.