-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add btclightclient events and hooks (#53)
- Loading branch information
Showing
17 changed files
with
940 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
syntax = "proto3"; | ||
package babylon.btclightclient.v1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "babylon/btclightclient/btclightclient.proto"; | ||
|
||
option go_package = "github.com/babylonchain/babylon/x/btclightclient/types"; | ||
|
||
// The header included in the event is the block in the history | ||
// of the current mainchain to which we are rolling back to. | ||
// In other words, there is one rollback event emitted per re-org, to the | ||
// greatest common ancestor of the old and the new fork. | ||
message EventBTCRollBack { | ||
BTCHeaderInfo header = 1; | ||
} | ||
|
||
// EventBTCRollForward is emitted on Msg/InsertHeader | ||
// The header included in the event is the one the main chain is extended with. | ||
// In the event of a reorg, each block on the new fork that comes after | ||
// the greatest common ancestor will have a corresponding roll forward event. | ||
message EventBTCRollForward { | ||
BTCHeaderInfo header = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package keeper | ||
|
||
import ( | ||
"github.com/babylonchain/babylon/x/btclightclient/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
// Implements BTCLightClientHooks interface | ||
var _ types.BTCLightClientHooks = Keeper{} | ||
|
||
// AfterBTCRollBack - call hook if registered | ||
func (k Keeper) AfterBTCRollBack(ctx sdk.Context, headerInfo *types.BTCHeaderInfo) { | ||
if k.hooks != nil { | ||
k.hooks.AfterBTCRollBack(ctx, headerInfo) | ||
} | ||
} | ||
|
||
// AfterBTCRollForward - call hook if registered | ||
func (k Keeper) AfterBTCRollForward(ctx sdk.Context, headerInfo *types.BTCHeaderInfo) { | ||
if k.hooks != nil { | ||
k.hooks.AfterBTCRollBack(ctx, headerInfo) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.