Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

cdb: Add delegation row in create validator handler #2219

Merged
merged 3 commits into from
Jul 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG_UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

### Emitter & Flusher

- (bugs) [\#2219](https://github.com/bandprotocol/bandchain/pull/2219) Add delegation row in create validator handler.
- (bugs) [\#2222](https://github.com/bandprotocol/bandchain/pull/2222) Fix account_transactions table name
- (impv) [\#2196](https://github.com/bandprotocol/bandchain/pull/2196) Fix create view table command
- (impv) [\#2186](https://github.com/bandprotocol/bandchain/pull/2186) Add temporary view tables.
Expand Down
4 changes: 2 additions & 2 deletions chain/emitter/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ func (app *App) InitChain(req abci.RequestInitChain) abci.ResponseInitChain {
var tx auth.StdTx
app.Codec().MustUnmarshalJSON(genTx, &tx)
for _, msg := range tx.Msgs {
if createMsg, ok := msg.(staking.MsgCreateValidator); ok {
app.emitSetValidator(createMsg.ValidatorAddress)
if msg, ok := msg.(staking.MsgCreateValidator); ok {
app.handleMsgCreateValidator(nil, msg, nil, nil)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions chain/emitter/staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,12 @@ func (app *App) emitUpdateValidatorStatus(addr sdk.ValAddress) {
func (app *App) emitDelegation(operatorAddress sdk.ValAddress, delegatorAddress sdk.AccAddress) {
delegation, found := app.StakingKeeper.GetDelegation(app.DeliverContext, delegatorAddress, operatorAddress)
if found {
info := app.DistrKeeper.GetDelegatorStartingInfo(app.DeliverContext, operatorAddress, delegatorAddress)
latestReward := app.DistrKeeper.GetValidatorHistoricalRewards(app.DeliverContext, operatorAddress, info.PreviousPeriod)
_, ratio := app.getCurrentRewardAndCurrentRatio(operatorAddress)
app.Write("SET_DELEGATION", JsDict{
"delegator_address": delegatorAddress,
"operator_address": operatorAddress,
"shares": delegation.Shares.String(),
"last_ratio": latestReward.CumulativeRewardRatio[0].Amount.String(),
"last_ratio": ratio,
})
} else {
app.Write("REMOVE_DELEGATION", JsDict{
Expand All @@ -80,6 +79,7 @@ func (app *App) handleMsgCreateValidator(
txHash []byte, msg staking.MsgCreateValidator, evMap EvMap, extra JsDict,
) {
app.emitSetValidator(msg.ValidatorAddress)
app.emitDelegation(msg.ValidatorAddress, msg.DelegatorAddress)
}

// handleMsgEditValidator implements emitter handler for MsgEditValidator.
Expand Down