github.com/Finschia/finschia-sdk@v0.48.1/server/types/app.go (about)

     1  package types
     2  
     3  import (
     4  	"encoding/json"
     5  	"io"
     6  	"time"
     7  
     8  	"github.com/gogo/protobuf/grpc"
     9  	"github.com/spf13/cobra"
    10  	dbm "github.com/tendermint/tm-db"
    11  
    12  	ocabci "github.com/Finschia/ostracon/abci/types"
    13  	"github.com/Finschia/ostracon/libs/log"
    14  	octypes "github.com/Finschia/ostracon/types"
    15  	abci "github.com/tendermint/tendermint/abci/types"
    16  
    17  	"github.com/Finschia/finschia-sdk/client"
    18  	"github.com/Finschia/finschia-sdk/server/api"
    19  	"github.com/Finschia/finschia-sdk/server/config"
    20  	sdk "github.com/Finschia/finschia-sdk/types"
    21  )
    22  
    23  // ServerStartTime defines the time duration that the server need to stay running after startup
    24  // for the startup be considered successful
    25  const ServerStartTime = 5 * time.Second
    26  
    27  type (
    28  	// AppOptions defines an interface that is passed into an application
    29  	// constructor, typically used to set BaseApp options that are either supplied
    30  	// via config file or through CLI arguments/flags. The underlying implementation
    31  	// is defined by the server package and is typically implemented via a Viper
    32  	// literal defined on the server Context. Note, casting Get calls may not yield
    33  	// the expected types and could result in type assertion errors. It is recommend
    34  	// to either use the cast package or perform manual conversion for safety.
    35  	AppOptions interface {
    36  		Get(string) interface{}
    37  	}
    38  
    39  	// Application defines an application interface that wraps abci.Application.
    40  	// The interface defines the necessary contracts to be implemented in order
    41  	// to fully bootstrap and start an application.
    42  	Application interface {
    43  		ocabci.Application
    44  
    45  		RegisterAPIRoutes(*api.Server, config.APIConfig)
    46  
    47  		// RegisterGRPCServer registers gRPC services directly with the gRPC
    48  		// server.
    49  		RegisterGRPCServer(grpc.Server)
    50  
    51  		// RegisterTxService registers the gRPC Query service for tx (such as tx
    52  		// simulation, fetching txs by hash...).
    53  		RegisterTxService(client.Context)
    54  
    55  		// RegisterTendermintService registers the gRPC Query service for ostracon queries.
    56  		RegisterTendermintService(client.Context)
    57  
    58  		// CommitMultiStore Returns the multistore instance
    59  		CommitMultiStore() sdk.CommitMultiStore
    60  	}
    61  
    62  	// ApplicationQueryService defines an extension of the Application interface
    63  	// that facilitates gRPC query Services.
    64  	//
    65  	// NOTE: This interfaces exists only in the v0.45.x line to ensure the existing
    66  	// Application interface does not introduce API breaking changes.
    67  	ApplicationQueryService interface {
    68  		// RegisterNodeService registers the node gRPC Query service.
    69  		RegisterNodeService(client.Context)
    70  	}
    71  
    72  	// AppCreator is a function that allows us to lazily initialize an
    73  	// application using various configurations.
    74  	AppCreator func(log.Logger, dbm.DB, io.Writer, AppOptions) Application
    75  
    76  	// ModuleInitFlags takes a start command and adds modules specific init flags.
    77  	ModuleInitFlags func(startCmd *cobra.Command)
    78  
    79  	// ExportedApp represents an exported app state, along with
    80  	// validators, consensus params and latest app height.
    81  	ExportedApp struct {
    82  		// AppState is the application state as JSON.
    83  		AppState json.RawMessage
    84  		// Validators is the exported validator set.
    85  		Validators []octypes.GenesisValidator
    86  		// Height is the app's latest block height.
    87  		Height int64
    88  		// ConsensusParams are the exported consensus params for ABCI.
    89  		ConsensusParams *abci.ConsensusParams
    90  	}
    91  
    92  	// AppExporter is a function that dumps all app state to
    93  	// JSON-serializable structure and returns the current validator set.
    94  	AppExporter func(log.Logger, dbm.DB, io.Writer, int64, bool, []string, AppOptions) (ExportedApp, error)
    95  )