Skip to content

Commit

Permalink
Merge pull request #447 from GrKamil/dev
Browse files Browse the repository at this point in the history
fix coins state
  • Loading branch information
danil-lashin committed Oct 15, 2020
2 parents 30a58d0 + f470d83 commit 56dd472
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions core/state/coins/coins.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,6 @@ func (c *Coins) Commit() error {
}
}

// clear list
c.symbolsList = make(map[types.CoinSymbol][]types.CoinID)
c.symbolsInfoList = make(map[types.CoinSymbol]*SymbolInfo)

return nil
}

Expand Down Expand Up @@ -238,7 +234,7 @@ func (c *Coins) Create(id types.CoinID, symbol types.CoinSymbol, name string,
func (c *Coins) Recreate(newID types.CoinID, name string, symbol types.CoinSymbol,
volume *big.Int, crr uint32, reserve *big.Int, maxSupply *big.Int,
) {
recreateCoin := c.GetCoinBySymbol(symbol, 0)
recreateCoin := c.GetCoinBySymbol(symbol, BaseVersion)
if recreateCoin == nil {
panic("coin to recreate does not exists")
}
Expand Down Expand Up @@ -267,7 +263,7 @@ func (c *Coins) ChangeOwner(symbol types.CoinSymbol, owner types.Address) {
info := c.getSymbolInfo(symbol)
info.setOwnerAddress(owner)

coin := c.GetCoinBySymbol(symbol, 0)
coin := c.GetCoinBySymbol(symbol, BaseVersion)
coin.symbolInfo = info

c.setSymbolInfoToMap(coin.symbolInfo, coin.Symbol())
Expand Down Expand Up @@ -337,6 +333,8 @@ func (c *Coins) getSymbolInfo(symbol types.CoinSymbol) *SymbolInfo {
panic(fmt.Sprintf("failed to decode coin symbol %s: %s", symbol.String(), err))
}

c.setSymbolInfoToMap(info, symbol)

return info
}

Expand All @@ -356,6 +354,8 @@ func (c *Coins) getBySymbol(symbol types.CoinSymbol) []types.CoinID {
panic(fmt.Sprintf("failed to decode coins by symbol %s: %s", symbol, err))
}

c.setSymbolToMap(coins, symbol)

return coins
}

Expand Down

0 comments on commit 56dd472

Please sign in to comment.