forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(server/v2): simplify servers (cosmos#20796)
- Loading branch information
1 parent
be0e2ee
commit afddef3
Showing
25 changed files
with
269 additions
and
256 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 |
---|---|---|
@@ -1,6 +1,11 @@ | ||
package context | ||
|
||
type ( | ||
LoggerContextKey struct{} | ||
ViperContextKey struct{} | ||
loggerContextKey struct{} | ||
viperContextKey struct{} | ||
) | ||
|
||
var ( | ||
LoggerContextKey loggerContextKey | ||
ViperContextKey viperContextKey | ||
) |
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,52 @@ | ||
package cometbft | ||
|
||
import "github.com/spf13/cobra" | ||
|
||
const ( | ||
FlagQuery = "query" | ||
FlagType = "type" | ||
FlagOrderBy = "order_by" | ||
) | ||
|
||
const ( | ||
FlagWithComet = "with-comet" | ||
FlagAddress = "address" | ||
FlagTransport = "transport" | ||
FlagTraceStore = "trace-store" | ||
FlagCPUProfile = "cpu-profile" | ||
FlagMinGasPrices = "minimum-gas-prices" | ||
FlagQueryGasLimit = "query-gas-limit" | ||
FlagHaltHeight = "halt-height" | ||
FlagHaltTime = "halt-time" | ||
FlagTrace = "trace" | ||
) | ||
|
||
const ( | ||
FlagChainID = "chain-id" | ||
FlagNode = "node" | ||
FlagGRPC = "grpc-addr" | ||
FlagGRPCInsecure = "grpc-insecure" | ||
FlagHeight = "height" | ||
FlagPage = "page" | ||
FlagLimit = "limit" | ||
FlagOutput = "output" | ||
) | ||
|
||
// List of supported output formats | ||
const ( | ||
OutputFormatJSON = "json" | ||
OutputFormatText = "text" | ||
) | ||
|
||
// AddQueryFlagsToCmd adds common flags to a module query command. | ||
func AddQueryFlagsToCmd(cmd *cobra.Command) { | ||
cmd.Flags().String(FlagNode, "tcp://localhost:26657", "<host>:<port> to CometBFT RPC interface for this chain") | ||
cmd.Flags().String(FlagGRPC, "", "the gRPC endpoint to use for this chain") | ||
cmd.Flags().Bool(FlagGRPCInsecure, false, "allow gRPC over insecure channels, if not the server must use TLS") | ||
cmd.Flags().Int64(FlagHeight, 0, "Use a specific height to query state at (this can error if the node is pruning state)") | ||
cmd.Flags().StringP(FlagOutput, "o", OutputFormatText, "Output format (text|json)") | ||
|
||
// some base commands does not require chainID e.g `simd testnet` while subcommands do | ||
// hence the flag should not be required for those commands | ||
_ = cmd.MarkFlagRequired(FlagChainID) | ||
} |
This file was deleted.
Oops, something went wrong.
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,32 @@ | ||
package cometbft | ||
|
||
import ( | ||
"cosmossdk.io/core/transaction" | ||
"cosmossdk.io/server/v2/cometbft/handlers" | ||
"cosmossdk.io/server/v2/cometbft/mempool" | ||
"cosmossdk.io/store/v2/snapshots" | ||
) | ||
|
||
// ServerOptions defines the options for the CometBFT server. | ||
type ServerOptions[T transaction.Tx] struct { | ||
Mempool mempool.Mempool[T] | ||
PrepareProposalHandler handlers.PrepareHandler[T] | ||
ProcessProposalHandler handlers.ProcessHandler[T] | ||
VerifyVoteExtensionHandler handlers.VerifyVoteExtensionhandler | ||
ExtendVoteHandler handlers.ExtendVoteHandler | ||
|
||
SnapshotOptions snapshots.SnapshotOptions | ||
} | ||
|
||
// DefaultServerOptions returns the default server options. | ||
// It defaults to a NoOpMempool and NoOp handlers. | ||
func DefaultServerOptions[T transaction.Tx]() ServerOptions[T] { | ||
return ServerOptions[T]{ | ||
Mempool: mempool.NoOpMempool[T]{}, | ||
PrepareProposalHandler: handlers.NoOpPrepareProposal[T](), | ||
ProcessProposalHandler: handlers.NoOpProcessProposal[T](), | ||
VerifyVoteExtensionHandler: handlers.NoOpVerifyVoteExtensionHandler(), | ||
ExtendVoteHandler: handlers.NoOpExtendVote(), | ||
SnapshotOptions: snapshots.NewSnapshotOptions(0, 0), | ||
} | ||
} |
Oops, something went wrong.