Clarify comment on removePoolShares

This commit is contained in:
Christopher Goes 2018-05-31 00:38:20 +02:00
parent 004e10ebcd
commit 0324be4189
No known key found for this signature in database
GPG Key ID: E828D98232D328D3
1 changed files with 8 additions and 6 deletions

View File

@ -155,18 +155,20 @@ func (v Validator) UpdateStatus(pool Pool, NewStatus sdk.BondStatus) (Validator,
return v, pool
}
// Remove & burn pool shares, e.g. when slashing a validator
func (v Validator) removePoolShares(pool Pool, amt sdk.Rat) (Validator, Pool, int64) {
// Remove pool shares
// Returns corresponding tokens, which could be burned (e.g. when slashing
// a validator) or redistributed elsewhere
func (v Validator) removePoolShares(pool Pool, poolShares sdk.Rat) (Validator, Pool, int64) {
var tokens int64
switch v.Status() {
case sdk.Unbonded:
pool, tokens = pool.removeSharesUnbonded(amt)
pool, tokens = pool.removeSharesUnbonded(poolShares)
case sdk.Unbonding:
pool, tokens = pool.removeSharesUnbonding(amt)
pool, tokens = pool.removeSharesUnbonding(poolShares)
case sdk.Bonded:
pool, tokens = pool.removeSharesBonded(amt)
pool, tokens = pool.removeSharesBonded(poolShares)
}
v.PoolShares.Amount = v.PoolShares.Amount.Sub(amt)
v.PoolShares.Amount = v.PoolShares.Amount.Sub(poolShares)
return v, pool, tokens
}