-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: compare query height to the previous height (#15)
- Loading branch information
1 parent
ef18f3b
commit fb8f8fd
Showing
7 changed files
with
105 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package constants | ||
|
||
const ( | ||
HeaderBlockHeight = "Grpc-Metadata-X-Cosmos-Block-Height" | ||
) |
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
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,34 @@ | ||
package types | ||
|
||
import ( | ||
"fmt" | ||
"main/pkg/utils" | ||
"net/http" | ||
) | ||
|
||
type HTTPPredicate func(response *http.Response) error | ||
|
||
func HTTPPredicateAlwaysPass() HTTPPredicate { | ||
return func(response *http.Response) error { | ||
return nil | ||
} | ||
} | ||
|
||
func HTTPPredicateCheckHeightAfter(prevHeight int64) HTTPPredicate { | ||
return func(response *http.Response) error { | ||
currentHeight, err := utils.GetBlockHeightFromHeader(response.Header) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if prevHeight > currentHeight { | ||
return fmt.Errorf( | ||
"previous height (%d) is bigger than the current height (%d)", | ||
prevHeight, | ||
currentHeight, | ||
) | ||
} | ||
|
||
return nil | ||
} | ||
} |
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