Print debugging info
This commit is contained in:
parent
1cc74320df
commit
19225fc5d4
@ -1,7 +1,10 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
)
|
||||
|
||||
// total accumulation tracker
|
||||
@ -29,6 +32,27 @@ func (ta TotalAccum) UpdateForNewHeight(height int64, accumCreatedPerBlock sdk.D
|
||||
return ta
|
||||
}
|
||||
|
||||
// update total validator accumulation factor for the new height
|
||||
// CONTRACT: height should be greater than the old height
|
||||
func (ta TotalAccum) UpdateForNewHeight_DEBUG(height int64, accumCreatedPerBlock sdk.Dec) TotalAccum {
|
||||
blocks := height - ta.UpdateHeight
|
||||
if blocks < 0 {
|
||||
panic("reverse updated for new height")
|
||||
}
|
||||
fmt.Println(
|
||||
cmn.Blue(
|
||||
fmt.Sprintf("FP Add %v * %v = %v +=> %v",
|
||||
accumCreatedPerBlock, sdk.NewInt(blocks),
|
||||
accumCreatedPerBlock.MulInt(sdk.NewInt(blocks)),
|
||||
ta.Accum.Add(accumCreatedPerBlock.MulInt(sdk.NewInt(blocks))),
|
||||
),
|
||||
),
|
||||
)
|
||||
ta.Accum = ta.Accum.Add(accumCreatedPerBlock.MulInt(sdk.NewInt(blocks)))
|
||||
ta.UpdateHeight = height
|
||||
return ta
|
||||
}
|
||||
|
||||
//___________________________________________________________________________________________
|
||||
|
||||
// global fee pool for distribution
|
||||
@ -41,7 +65,7 @@ type FeePool struct {
|
||||
// update total validator accumulation factor
|
||||
// NOTE: Do not call this except from ValidatorDistInfo.TakeFeePoolRewards().
|
||||
func (f FeePool) UpdateTotalValAccum(height int64, totalBondedTokens sdk.Dec) FeePool {
|
||||
f.TotalValAccum = f.TotalValAccum.UpdateForNewHeight(height, totalBondedTokens)
|
||||
f.TotalValAccum = f.TotalValAccum.UpdateForNewHeight_DEBUG(height, totalBondedTokens)
|
||||
return f
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
)
|
||||
|
||||
// distribution info for a particular validator
|
||||
@ -62,6 +65,16 @@ func (vi ValidatorDistInfo) TakeFeePoolRewards(fp FeePool, height int64, totalBo
|
||||
commission := withdrawalTokens.MulDec(commissionRate)
|
||||
afterCommission := withdrawalTokens.Minus(commission)
|
||||
|
||||
fmt.Println(
|
||||
cmn.Red(
|
||||
fmt.Sprintf("FP Sub %v * %v = %v -=> %v",
|
||||
vdTokens, sdk.NewInt(blocks),
|
||||
accum,
|
||||
fp.TotalValAccum.Accum.Sub(accum),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
fp.TotalValAccum.Accum = fp.TotalValAccum.Accum.Sub(accum)
|
||||
fp.Pool = remainingTokens
|
||||
vi.PoolCommission = vi.PoolCommission.Plus(commission)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user