Commit 1c159d00 authored by Son of Odin's avatar Son of Odin

tweak

parent 20412f03
Pipeline #129703411 passed with stages
in 33 minutes and 21 seconds
......@@ -117,28 +117,29 @@ func (h ObservedTxOutHandler) handleV1(ctx sdk.Context, msg MsgObservedTxOut) sd
continue
}
vault, err := h.keeper.GetVault(ctx, tx.ObservedPubKey)
if err != nil {
ctx.Logger().Error("fail to get vault", "error", err)
continue
}
// Check if memo is valid, if it isn't and its funds moving from a
// yggdrasil vault, slash the node
// if memo isn't valid and its funds moving from a yggdrasil vault,
// slash the node
_, err = ParseMemo(tx.Tx.Memo)
if err != nil && vault.IsYggdrasil() {
// a yggdrasil vault has apparently stolen funds, slash them
for _, c := range append(tx.Tx.Coins, tx.Tx.Gas.ToCoins()...) {
if err := slashNodeAccount(ctx, h.keeper, tx.ObservedPubKey, c.Asset, c.Amount); err != nil {
ctx.Logger().Error("fail to slash account for sending extra fund", "error", err)
}
if err != nil {
vault, err := h.keeper.GetVault(ctx, tx.ObservedPubKey)
if err != nil {
ctx.Logger().Error("fail to get vault", "error", err)
continue
}
vault.SubFunds(tx.Tx.Coins)
vault.SubFunds(tx.Tx.Gas.ToCoins())
if err := h.keeper.SetVault(ctx, vault); err != nil {
ctx.Logger().Error("fail to save vault", "error", err)
if vault.IsYggdrasil() {
// a yggdrasil vault has apparently stolen funds, slash them
for _, c := range append(tx.Tx.Coins, tx.Tx.Gas.ToCoins()...) {
if err := slashNodeAccount(ctx, h.keeper, tx.ObservedPubKey, c.Asset, c.Amount); err != nil {
ctx.Logger().Error("fail to slash account for sending extra fund", "error", err)
}
}
vault.SubFunds(tx.Tx.Coins)
vault.SubFunds(tx.Tx.Gas.ToCoins())
if err := h.keeper.SetVault(ctx, vault); err != nil {
ctx.Logger().Error("fail to save vault", "error", err)
}
continue
}
continue
}
txOut := voter.GetTx(activeNodeAccounts) // get consensus tx, in case our for loop is incorrect
......@@ -156,6 +157,11 @@ func (h ObservedTxOutHandler) handleV1(ctx sdk.Context, msg MsgObservedTxOut) sd
}
// If sending from one of our vaults, decrement coins
vault, err := h.keeper.GetVault(ctx, tx.ObservedPubKey)
if err != nil {
ctx.Logger().Error("fail to get vault", "error", err)
continue
}
vault.SubFunds(tx.Tx.Coins)
vault.OutboundTxCount += 1
memo, _ := ParseMemo(tx.Tx.Memo) // ignore err
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment