-
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] refactor: query
min_relay_difficulty_bits
param (#655)
- Loading branch information
1 parent
6c3dd65
commit e119984
Showing
9 changed files
with
159 additions
and
28 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,50 @@ | ||
package query | ||
|
||
import ( | ||
"context" | ||
|
||
"cosmossdk.io/depinject" | ||
"github.com/cosmos/gogoproto/grpc" | ||
|
||
"github.com/pokt-network/poktroll/pkg/client" | ||
prooftypes "github.com/pokt-network/poktroll/x/proof/types" | ||
) | ||
|
||
// proofQuerier is a wrapper around the prooftypes.QueryClient that enables the | ||
// querying of on-chain proof module params. | ||
type proofQuerier struct { | ||
clientConn grpc.ClientConn | ||
proofQuerier prooftypes.QueryClient | ||
} | ||
|
||
// NewProofQuerier returns a new instance of a client.ProofQueryClient by | ||
// injecting the dependecies provided by the depinject.Config. | ||
// | ||
// Required dependencies: | ||
// - grpc.ClientConn | ||
func NewProofQuerier(deps depinject.Config) (client.ProofQueryClient, error) { | ||
querier := &proofQuerier{} | ||
|
||
if err := depinject.Inject( | ||
deps, | ||
&querier.clientConn, | ||
); err != nil { | ||
return nil, err | ||
} | ||
|
||
querier.proofQuerier = prooftypes.NewQueryClient(querier.clientConn) | ||
|
||
return querier, nil | ||
} | ||
|
||
// GetParams queries the chain for the current proof module parameters. | ||
func (pq *proofQuerier) GetParams( | ||
ctx context.Context, | ||
) (client.ProofParams, error) { | ||
req := &prooftypes.QueryParamsRequest{} | ||
res, err := pq.proofQuerier.Params(ctx, req) | ||
if err != nil { | ||
return nil, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package testqueryclients | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/golang/mock/gomock" | ||
|
||
"github.com/pokt-network/poktroll/testutil/mockclient" | ||
prooftypes "github.com/pokt-network/poktroll/x/proof/types" | ||
) | ||
|
||
// NewTestProofQueryClient creates a mock of the ProofQueryClient which uses the | ||
// default proof module params for its GetParams() method implementation. | ||
func NewTestProofQueryClient(t *testing.T) *mockclient.MockProofQueryClient { | ||
ctrl := gomock.NewController(t) | ||
defaultProofParams := prooftypes.DefaultParams() | ||
proofQueryClientMock := mockclient.NewMockProofQueryClient(ctrl) | ||
proofQueryClientMock.EXPECT(). | ||
GetParams(gomock.Any()). | ||
Return(&defaultProofParams, nil). | ||
AnyTimes() | ||
|
||
return proofQueryClientMock | ||
} |
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