-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Relayminer] Query for on-chain session param
num_blocks_per_session
(
#538) Co-authored-by: Daniel Olshansky <[email protected]>
- Loading branch information
1 parent
6f2fe5b
commit 7507dc5
Showing
34 changed files
with
313 additions
and
162 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
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,55 @@ | ||
package query | ||
|
||
import ( | ||
"context" | ||
|
||
"cosmossdk.io/depinject" | ||
"github.com/cosmos/gogoproto/grpc" | ||
|
||
"github.com/pokt-network/poktroll/pkg/client" | ||
sharedtypes "github.com/pokt-network/poktroll/x/shared/types" | ||
) | ||
|
||
var _ client.SharedQueryClient = (*sharedQuerier)(nil) | ||
|
||
// sharedQuerier is a wrapper around the sharedtypes.QueryClient that enables the | ||
// querying of on-chain shared information through a single exposed method | ||
// which returns an sharedtypes.Session struct | ||
type sharedQuerier struct { | ||
clientConn grpc.ClientConn | ||
sharedQuerier sharedtypes.QueryClient | ||
} | ||
|
||
// NewSharedQuerier returns a new instance of a client.SharedQueryClient by | ||
// injecting the dependecies provided by the depinject.Config. | ||
// | ||
// Required dependencies: | ||
// - clientCtx | ||
func NewSharedQuerier(deps depinject.Config) (client.SharedQueryClient, error) { | ||
querier := &sharedQuerier{} | ||
|
||
if err := depinject.Inject( | ||
deps, | ||
&querier.clientConn, | ||
); err != nil { | ||
return nil, err | ||
} | ||
|
||
querier.sharedQuerier = sharedtypes.NewQueryClient(querier.clientConn) | ||
|
||
return querier, nil | ||
} | ||
|
||
// GetParams queries & returns the shared module on-chain parameters. | ||
// | ||
// TODO_TECHDEBT(#543): We don't really want to have to query the params for every method call. | ||
// Once `ModuleParamsClient` is implemented, use its replay observable's `#Last()` method | ||
// to get the most recently (asynchronously) observed (and cached) value. | ||
func (sq *sharedQuerier) GetParams(ctx context.Context) (*sharedtypes.Params, error) { | ||
req := &sharedtypes.QueryParamsRequest{} | ||
res, err := sq.sharedQuerier.Params(ctx, req) | ||
if err != nil { | ||
return nil, ErrQuerySessionParams.Wrapf("[%v]", err) | ||
} | ||
return &res.Params, 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
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
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
Oops, something went wrong.