alias work, working on compiling
This commit is contained in:
parent
97f7dbc5e6
commit
76882991a4
|
@ -414,6 +414,14 @@
|
|||
revision = "a8328986c1608950fa5d3d1c0472cccc4f8fc02c"
|
||||
version = "v0.12.0-rc0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:2c971a45c89ca2ccc735af50919cdee05fbdc54d4bf50625073693300e31ead8"
|
||||
name = "github.com/tendermint/go-wire"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "faa6e731944e2b7b6a46ad202902851e8ce85bee"
|
||||
version = "v0.12.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:53397098d6acb7613358683cc84ae59281a60c6033f0bff62fa8d3f279c6c430"
|
||||
name = "github.com/tendermint/iavl"
|
||||
|
@ -645,6 +653,7 @@
|
|||
"github.com/stretchr/testify/assert",
|
||||
"github.com/stretchr/testify/require",
|
||||
"github.com/tendermint/go-amino",
|
||||
"github.com/tendermint/go-wire",
|
||||
"github.com/tendermint/iavl",
|
||||
"github.com/tendermint/tendermint/abci/server",
|
||||
"github.com/tendermint/tendermint/abci/types",
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// nolint
|
||||
package stake
|
||||
package distribution
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/querier"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/tags"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/stake/querier"
|
||||
)
|
||||
|
||||
type (
|
||||
|
|
|
@ -10,12 +10,12 @@ type DelegatorDistInfo struct {
|
|||
}
|
||||
|
||||
// withdraw rewards from delegator
|
||||
func (di DelegatorDistInfo) WithdrawRewards(g Global, vi ValidatorDistInfo,
|
||||
func (di DelegatorDistInfo) WithdrawRewards(fp FeePool, vi ValidatorDistInfo,
|
||||
height int64, totalBonded, vdTokens, totalDelShares, delegatorShares,
|
||||
commissionRate Dec) (di DelegatorDistInfo, g Global, withdrawn DecCoins) {
|
||||
commissionRate sdk.Dec) (DelegatorDistInfo, FeePool, DecCoins) {
|
||||
|
||||
vi.UpdateTotalDelAccum(height, totalDelShares)
|
||||
g = vi.TakeGlobalRewards(g, height, totalBonded, vdTokens, commissionRate)
|
||||
fp = vi.TakeFeePoolRewards(fp, height, totalBonded, vdTokens, commissionRate)
|
||||
|
||||
blocks = height - di.WithdrawalHeight
|
||||
di.WithdrawalHeight = height
|
||||
|
@ -25,7 +25,7 @@ func (di DelegatorDistInfo) WithdrawRewards(g Global, vi ValidatorDistInfo,
|
|||
vi.Pool = vi.Pool.Sub(withdrawalTokens)
|
||||
vi.TotalDelAccum = vi.TotalDelAccum.sub(accum)
|
||||
|
||||
return di, g, withdrawalTokens
|
||||
return di, fp, withdrawalTokens
|
||||
}
|
||||
|
||||
//_____________________________________________________________________
|
||||
|
|
|
@ -14,41 +14,41 @@ type ValidatorDistInfo struct {
|
|||
}
|
||||
|
||||
// update total delegator accumululation
|
||||
func (vi ValidatorDistInfo) UpdateTotalDelAccum(height int64, totalDelShares Dec) ValidatorDistInfo {
|
||||
func (vi ValidatorDistInfo) UpdateTotalDelAccum(height int64, totalDelShares sdk.Dec) ValidatorDistInfo {
|
||||
vi.DelAccum = vi.DelAccum.Update(height, totalDelShares)
|
||||
return vi
|
||||
}
|
||||
|
||||
// XXX TODO Update dec logic
|
||||
// move any available accumulated fees in the Global to the validator's pool
|
||||
func (vi ValidatorDistInfo) TakeGlobalRewards(g Global, height int64, totalBonded, vdTokens, commissionRate Dec) (
|
||||
vi ValidatorDistInfo, g Global) {
|
||||
func (vi ValidatorDistInfo) TakeFeePoolRewards(fp FeePool, height int64, totalBonded, vdTokens,
|
||||
commissionRate sdk.Dec) (ValidatorDistInfo, FeePool) {
|
||||
|
||||
g.UpdateTotalValAccum(height, totalBondedShares)
|
||||
fp.UpdateTotalValAccum(height, totalBondedShares)
|
||||
|
||||
// update the validators pool
|
||||
blocks = height - vi.GlobalWithdrawalHeight
|
||||
vi.GlobalWithdrawalHeight = height
|
||||
accum = blocks * vdTokens
|
||||
withdrawalTokens := g.Pool * accum / g.TotalValAccum
|
||||
commission := withdrawalTokens * commissionRate
|
||||
accum = sdk.NewDec(blocks).Mul(vdTokens)
|
||||
withdrawalTokens := fp.Pool.Mul(accum).Quo(fp.TotalValAccum)
|
||||
commission := withdrawalTokens.Mul(commissionRate)
|
||||
|
||||
g.TotalValAccum -= accumm
|
||||
g.Pool -= withdrawalTokens
|
||||
vi.PoolCommission += commission
|
||||
vi.PoolCommissionFree += withdrawalTokens - commission
|
||||
fp.TotalValAccum = fp.TotalValAccum.Sub(accum)
|
||||
fp.Pool = fp.Pool.Sub(withdrawalTokens)
|
||||
vi.PoolCommission = vi.PoolCommission.Add(commission)
|
||||
vi.PoolCommissionFree = vi.PoolCommissionFree.Add(withdrawalTokens.Sub(commission))
|
||||
|
||||
return vi, g
|
||||
return vi, fp
|
||||
}
|
||||
|
||||
// withdraw commission rewards
|
||||
func (vi ValidatorDistInfo) WithdrawCommission(g Global, height int64,
|
||||
totalBonded, vdTokens, commissionRate Dec) (
|
||||
vi ValidatorDistInfo, g Global, withdrawn DecCoins) {
|
||||
totalBonded, vdTokens, commissionRate Dec) (vio ValidatorDistInfo, fpo FeePool, withdrawn DecCoins) {
|
||||
|
||||
g = vi.TakeGlobalRewards(g, height, totalBonded, vdTokens, commissionRate)
|
||||
fp = vi.TakeFeePoolRewards(fp, height, totalBonded, vdTokens, commissionRate)
|
||||
|
||||
withdrawalTokens := vi.PoolCommission
|
||||
vi.PoolCommission = 0
|
||||
|
||||
return vi, g, withdrawalTokens
|
||||
return vi, fp, withdrawalTokens
|
||||
}
|
||||
|
|
|
@ -736,6 +736,7 @@ func ensureValidatorFound(found bool, ownerAddr []byte) {
|
|||
|
||||
//__________________________________________________________________________
|
||||
|
||||
// XXX remove this code - this is should be superceded by commission work that bez is doing
|
||||
// get a single validator
|
||||
func (k Keeper) UpdateValidatorCommission(ctx sdk.Context, addr sdk.ValAddress, newCommission sdk.Dec) sdk.Error {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
|
@ -753,8 +754,6 @@ func (k Keeper) UpdateValidatorCommission(ctx sdk.Context, addr sdk.ValAddress,
|
|||
return types.ErrNoValidatorFound(k.Codespace())
|
||||
case newCommission.LT(sdk.ZeroDec()):
|
||||
return types.ErrCommissionNegative(k.Codespace())
|
||||
case newCommission.GT(sdk.OnedDec()):
|
||||
return types.ErrCommissionHuge(k.Codespace())
|
||||
case newCommission.GT(validator.CommissionMax):
|
||||
return types.ErrCommissionBeyondMax(k.Codespace())
|
||||
//case rateChange(Commission) > CommissionMaxChange: // XXX XXX XXX TODO implementation
|
||||
|
|
Loading…
Reference in New Issue