-
Notifications
You must be signed in to change notification settings - Fork 101
/
abci.go
48 lines (44 loc) · 1.03 KB
/
abci.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package vault
import (
"runtime/debug"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/dydxprotocol/v4-chain/protocol/lib/abci"
"github.com/dydxprotocol/v4-chain/protocol/lib/log"
"github.com/dydxprotocol/v4-chain/protocol/x/vault/keeper"
)
func BeginBlocker(
ctx sdk.Context,
keeper *keeper.Keeper,
) {
// Panic is not expected in BeginBlocker, but we should recover instead of
// halting the chain.
if err := abci.RunCached(ctx, func(ctx sdk.Context) error {
keeper.DecommissionNonPositiveEquityVaults(ctx)
return nil
}); err != nil {
log.ErrorLog(
ctx,
"panic in vault BeginBlocker",
"stack",
string(debug.Stack()),
)
}
}
func EndBlocker(
ctx sdk.Context,
keeper *keeper.Keeper,
) {
// Panic is not expected in EndBlocker, but we should recover instead of
// halting the chain.
if err := abci.RunCached(ctx, func(ctx sdk.Context) error {
keeper.RefreshAllVaultOrders(ctx)
return nil
}); err != nil {
log.ErrorLog(
ctx,
"panic in vault EndBlocker",
"stack",
string(debug.Stack()),
)
}
}