docs: update docs (#19676)
Co-authored-by: son trinh <son@decentrio.ventures> Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
co-authored by
son trinh
Julien Robert
parent
2bf7e9f846
commit
2bfc037a07
+27
-29
@@ -1,30 +1,28 @@
|
||||
/*
|
||||
The commands from the SDK are defined with `cobra` and configured with the
|
||||
`viper` package.
|
||||
|
||||
This takes place in the `InterceptConfigsPreRunHandler` function.
|
||||
Since the `viper` package is used for configuration the precedence is dictated
|
||||
by that package. That is
|
||||
|
||||
1. Command line switches
|
||||
2. Environment variables
|
||||
3. Files from configuration values
|
||||
4. Default values
|
||||
|
||||
The global configuration instance exposed by the `viper` package is not
|
||||
used by Cosmos SDK in this function. A new instance of `viper.Viper` is created
|
||||
and the following is performed. The environmental variable prefix is set
|
||||
to the current program name. Environmental variables consider the underscore
|
||||
to be equivalent to the `.` or `-` character. This means that an configuration
|
||||
value called `rpc.laddr` would be read from an environmental variable called
|
||||
`MYTOOL_RPC_LADDR` if the current program name is `mytool`.
|
||||
|
||||
Running the `InterceptConfigsPreRunHandler` also reads `app.toml`
|
||||
and `config.toml` from the home directory under the `config` directory.
|
||||
If `config.toml` or `app.toml` do not exist then those files are created
|
||||
and populated with default values. `InterceptConfigsPreRunHandler` takes
|
||||
two parameters to set/update a custom template to create custom `app.toml`.
|
||||
If these parameters are empty, the server then creates a default template
|
||||
provided by the SDK.
|
||||
*/
|
||||
// Package server The commands from the SDK are defined with `cobra` and configured with the
|
||||
// `viper` package.
|
||||
//
|
||||
// This takes place in the `InterceptConfigsPreRunHandler` function.
|
||||
// Since the `viper` package is used for configuration the precedence is dictated
|
||||
// by that package. That is
|
||||
//
|
||||
// 1. Command line switches
|
||||
// 2. Environment variables
|
||||
// 3. Files from configuration values
|
||||
// 4. Default values
|
||||
//
|
||||
// The global configuration instance exposed by the `viper` package is not
|
||||
// used by Cosmos SDK in this function. A new instance of `viper.Viper` is created
|
||||
// and the following is performed. The environmental variable prefix is set
|
||||
// to the current program name. Environmental variables consider the underscore
|
||||
// to be equivalent to the `.` or `-` character. This means that an configuration
|
||||
// value called `rpc.laddr` would be read from an environmental variable called
|
||||
// `MYTOOL_RPC_LADDR` if the current program name is `mytool`.
|
||||
//
|
||||
// Running the `InterceptConfigsPreRunHandler` also reads `app.toml`
|
||||
// and `config.toml` from the home directory under the `config` directory.
|
||||
// If `config.toml` or `app.toml` do not exist then those files are created
|
||||
// and populated with default values. `InterceptConfigsPreRunHandler` takes
|
||||
// two parameters to set/update a custom template to create custom `app.toml`.
|
||||
// If these parameters are empty, the server then creates a default template
|
||||
// provided by the SDK.
|
||||
package server
|
||||
|
||||
@@ -1,40 +1,35 @@
|
||||
/*
|
||||
*
|
||||
* Copyright 2016 gRPC authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
// Copyright 2016 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/*
|
||||
Package reflection implements server reflection service.
|
||||
// Package gogoreflection implements server reflection service.
|
||||
//
|
||||
// The service implemented is defined in:
|
||||
// https://github.com/grpc/grpc/blob/master/src/proto/grpc/reflection/v1alpha/reflection.proto.
|
||||
//
|
||||
// To register server reflection on a gRPC server:
|
||||
//
|
||||
// import "google.golang.org/grpc/reflection"
|
||||
//
|
||||
// s := grpc.NewServer()
|
||||
// pb.RegisterYourOwnServer(s, &server{})
|
||||
//
|
||||
// // Register reflection service on gRPC server.
|
||||
// reflection.Register(s)
|
||||
//
|
||||
// s.Serve(lis)
|
||||
|
||||
The service implemented is defined in:
|
||||
https://github.com/grpc/grpc/blob/master/src/proto/grpc/reflection/v1alpha/reflection.proto.
|
||||
|
||||
To register server reflection on a gRPC server:
|
||||
|
||||
import "google.golang.org/grpc/reflection"
|
||||
|
||||
s := grpc.NewServer()
|
||||
pb.RegisterYourOwnServer(s, &server{})
|
||||
|
||||
// Register reflection service on gRPC server.
|
||||
reflection.Register(s)
|
||||
|
||||
s.Serve(lis)
|
||||
*/
|
||||
package gogoreflection // import "google.golang.org/grpc/reflection"
|
||||
package gogoreflection
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
+3
-3
@@ -89,13 +89,13 @@ func KVStoreHandler(storeKey storetypes.StoreKey) bam.MsgServiceHandler {
|
||||
}
|
||||
}
|
||||
|
||||
// basic KV structure
|
||||
// KV is a basic kv structure
|
||||
type KV struct {
|
||||
Key string `json:"key"`
|
||||
Value string `json:"value"`
|
||||
}
|
||||
|
||||
// What Genesis JSON is formatted as
|
||||
// GenesisJSON what genesis JSON is formatted as
|
||||
type GenesisJSON struct {
|
||||
Values []KV `json:"values"`
|
||||
}
|
||||
@@ -144,7 +144,7 @@ func AppGenStateEmpty(_ *codec.LegacyAmino, _ genutiltypes.AppGenesis, _ []json.
|
||||
return
|
||||
}
|
||||
|
||||
// Manually write the handlers for this custom message
|
||||
// MsgServer manually write the handlers for this custom message
|
||||
type MsgServer interface {
|
||||
Test(ctx context.Context, msg *KVStoreTx) (*sdk.Result, error)
|
||||
}
|
||||
|
||||
+3
-2
@@ -16,7 +16,7 @@ import (
|
||||
txsigning "github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||
)
|
||||
|
||||
// An sdk.Tx which is its own sdk.Msg.
|
||||
// KVStoreTx is an sdk.Tx which is its own sdk.Msg.
|
||||
type KVStoreTx struct {
|
||||
key []byte
|
||||
value []byte
|
||||
@@ -72,6 +72,7 @@ func (msg *KVStoreTx) Equals(key cryptotypes.PubKey) bool {
|
||||
}
|
||||
|
||||
// dummy implementation of proto.Message
|
||||
|
||||
func (msg *KVStoreTx) Reset() {}
|
||||
func (msg *KVStoreTx) String() string { return "TODO" }
|
||||
func (msg *KVStoreTx) ProtoMessage() {}
|
||||
@@ -110,7 +111,7 @@ func (msg *KVStoreTx) GetSignBytes() []byte {
|
||||
return msg.bytes
|
||||
}
|
||||
|
||||
// Should the app be calling this? Or only handlers?
|
||||
// ValidateBasic should the app be calling this? or only handlers?
|
||||
func (msg *KVStoreTx) ValidateBasic() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -76,10 +76,12 @@ const (
|
||||
FlagShutdownGrace = "shutdown-grace"
|
||||
|
||||
// state sync-related flags
|
||||
|
||||
FlagStateSyncSnapshotInterval = "state-sync.snapshot-interval"
|
||||
FlagStateSyncSnapshotKeepRecent = "state-sync.snapshot-keep-recent"
|
||||
|
||||
// api-related flags
|
||||
|
||||
FlagAPIEnable = "api.enable"
|
||||
FlagAPISwagger = "api.swagger"
|
||||
FlagAPIAddress = "api.address"
|
||||
@@ -90,15 +92,18 @@ const (
|
||||
FlagAPIEnableUnsafeCORS = "api.enabled-unsafe-cors"
|
||||
|
||||
// gRPC-related flags
|
||||
|
||||
flagGRPCOnly = "grpc-only"
|
||||
flagGRPCEnable = "grpc.enable"
|
||||
flagGRPCAddress = "grpc.address"
|
||||
flagGRPCWebEnable = "grpc-web.enable"
|
||||
|
||||
// mempool flags
|
||||
|
||||
FlagMempoolMaxTxs = "mempool.max-txs"
|
||||
|
||||
// testnet keys
|
||||
|
||||
KeyIsTestnet = "is-testnet"
|
||||
KeyNewChainID = "new-chain-ID"
|
||||
KeyNewOpAddr = "new-operator-addr"
|
||||
|
||||
+23
-11
@@ -10,28 +10,40 @@ import (
|
||||
// to be driven by a blockchain-based replication engine via the ABCI.
|
||||
type ABCI interface {
|
||||
// Info/Query Connection
|
||||
Info(*abci.RequestInfo) (*abci.ResponseInfo, error) // Return application info
|
||||
Query(context.Context, *abci.RequestQuery) (*abci.ResponseQuery, error) // Query for state
|
||||
|
||||
// Info returns application info
|
||||
Info(*abci.RequestInfo) (*abci.ResponseInfo, error)
|
||||
// Query returns application state
|
||||
Query(context.Context, *abci.RequestQuery) (*abci.ResponseQuery, error)
|
||||
|
||||
// Mempool Connection
|
||||
CheckTx(*abci.RequestCheckTx) (*abci.ResponseCheckTx, error) // Validate a tx for the mempool
|
||||
|
||||
// CheckTx validate a tx for the mempool
|
||||
CheckTx(*abci.RequestCheckTx) (*abci.ResponseCheckTx, error)
|
||||
|
||||
// Consensus Connection
|
||||
InitChain(*abci.RequestInitChain) (*abci.ResponseInitChain, error) // Initialize blockchain w validators/other info from CometBFT
|
||||
|
||||
// InitChain Initialize blockchain w validators/other info from CometBFT
|
||||
InitChain(*abci.RequestInitChain) (*abci.ResponseInitChain, error)
|
||||
PrepareProposal(*abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error)
|
||||
ProcessProposal(*abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error)
|
||||
// Deliver the decided block with its txs to the Application
|
||||
// FinalizeBlock deliver the decided block with its txs to the Application
|
||||
FinalizeBlock(*abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error)
|
||||
// Create application specific vote extension
|
||||
// ExtendVote create application specific vote extension
|
||||
ExtendVote(context.Context, *abci.RequestExtendVote) (*abci.ResponseExtendVote, error)
|
||||
// Verify application's vote extension data
|
||||
// VerifyVoteExtension verify application's vote extension data
|
||||
VerifyVoteExtension(*abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error)
|
||||
// Commit the state and return the application Merkle root hash
|
||||
Commit() (*abci.ResponseCommit, error)
|
||||
|
||||
// State Sync Connection
|
||||
ListSnapshots(*abci.RequestListSnapshots) (*abci.ResponseListSnapshots, error) // List available snapshots
|
||||
OfferSnapshot(*abci.RequestOfferSnapshot) (*abci.ResponseOfferSnapshot, error) // Offer a snapshot to the application
|
||||
LoadSnapshotChunk(*abci.RequestLoadSnapshotChunk) (*abci.ResponseLoadSnapshotChunk, error) // Load a snapshot chunk
|
||||
ApplySnapshotChunk(*abci.RequestApplySnapshotChunk) (*abci.ResponseApplySnapshotChunk, error) // Apply a snapshot chunk
|
||||
|
||||
// ListSnapshots list available snapshots
|
||||
ListSnapshots(*abci.RequestListSnapshots) (*abci.ResponseListSnapshots, error)
|
||||
// OfferSnapshot offer a snapshot to the application
|
||||
OfferSnapshot(*abci.RequestOfferSnapshot) (*abci.ResponseOfferSnapshot, error)
|
||||
// LoadSnapshotChunk load a snapshot chunk
|
||||
LoadSnapshotChunk(*abci.RequestLoadSnapshotChunk) (*abci.ResponseLoadSnapshotChunk, error)
|
||||
// ApplySnapshotChunk apply a snapshot chunk
|
||||
ApplySnapshotChunk(*abci.RequestApplySnapshotChunk) (*abci.ResponseApplySnapshotChunk, error)
|
||||
}
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ type (
|
||||
// CommitMultiStore return the multistore instance
|
||||
CommitMultiStore() storetypes.CommitMultiStore
|
||||
|
||||
// Return the snapshot manager
|
||||
// SnapshotManager return the snapshot manager
|
||||
SnapshotManager() *snapshots.Manager
|
||||
|
||||
// Close is called in start cmd to gracefully cleanup resources.
|
||||
|
||||
+3
-3
@@ -44,7 +44,7 @@ import (
|
||||
// a command's Context.
|
||||
const ServerContextKey = sdk.ContextKey("server.context")
|
||||
|
||||
// server context
|
||||
// Context server context
|
||||
type Context struct {
|
||||
Viper *viper.Viper
|
||||
Config *cmtcfg.Config
|
||||
@@ -323,7 +323,7 @@ func interceptConfigs(rootViper *viper.Viper, customAppTemplate string, customCo
|
||||
return conf, nil
|
||||
}
|
||||
|
||||
// add server commands
|
||||
// AddCommands add server commands
|
||||
func AddCommands[T types.Application](rootCmd *cobra.Command, appCreator types.AppCreator[T], addStartFlags types.ModuleInitFlags) {
|
||||
cometCmd := &cobra.Command{
|
||||
Use: "comet",
|
||||
@@ -361,7 +361,7 @@ func AddTestnetCreatorCommand[T types.Application](rootCmd *cobra.Command, appCr
|
||||
rootCmd.AddCommand(testnetCreateCmd)
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/23558425/how-do-i-get-the-local-ip-address-in-go
|
||||
// ExternalIP https://stackoverflow.com/questions/23558425/how-do-i-get-the-local-ip-address-in-go
|
||||
// TODO there must be a better way to get external IP
|
||||
func ExternalIP() (string, error) {
|
||||
ifaces, err := net.Interfaces()
|
||||
|
||||
Reference in New Issue
Block a user