Skip to content

Commit

Permalink
feat: added block interval in the oracle params
Browse files Browse the repository at this point in the history
  • Loading branch information
ironman0x7b2 committed Nov 20, 2024
1 parent 16afc18 commit 347bf01
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 31 deletions.
7 changes: 4 additions & 3 deletions proto/sentinel/oracle/v1/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ option (gogoproto.equal_all) = false;
option (gogoproto.goproto_getters_all) = false;

message Params {
string channel_id = 1 [(gogoproto.customname) = "ChannelID"];
string port_id = 2 [(gogoproto.customname) = "PortID"];
google.protobuf.Duration timeout = 3 [
int64 block_interval = 1;
string channel_id = 2 [(gogoproto.customname) = "ChannelID"];
string port_id = 3 [(gogoproto.customname) = "PortID"];
google.protobuf.Duration timeout = 4 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true
];
Expand Down
5 changes: 5 additions & 0 deletions x/oracle/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import (

// BeginBlock is called at the beginning of each block to trigger IBC query packets for relevant assets.
func (k *Keeper) BeginBlock(ctx sdk.Context) {
interval := k.GetBlockInterval(ctx)
if ctx.BlockHeight()%interval != 0 {
return
}

portID := k.GetPortID(ctx)
if portID == "" {
ctx.Logger().Info("PortID is empty, skipping BeginBlock execution")
Expand Down
5 changes: 5 additions & 0 deletions x/oracle/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ func (k *Keeper) GetParams(ctx sdk.Context) (v v1.Params) {
return v
}

// GetBlockInterval retrieves the BlockInterval parameter from the module's parameters.
func (k *Keeper) GetBlockInterval(ctx sdk.Context) int64 {
return k.GetParams(ctx).BlockInterval
}

// GetChannelID retrieves the ChannelID parameter from the module's parameters.
func (k *Keeper) GetChannelID(ctx sdk.Context) string {
return k.GetParams(ctx).ChannelID
Expand Down
86 changes: 58 additions & 28 deletions x/oracle/types/v1/params.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 347bf01

Please sign in to comment.