From 0324be418951bfe098d4a7d112dc23ca9553b363 Mon Sep 17 00:00:00 2001 From: Christopher Goes Date: Thu, 31 May 2018 00:38:20 +0200 Subject: [PATCH] Clarify comment on removePoolShares --- x/stake/validator.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/x/stake/validator.go b/x/stake/validator.go index 1edb8bb836..729a605a96 100644 --- a/x/stake/validator.go +++ b/x/stake/validator.go @@ -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 }