module

package
v0.0.0-...-607fb14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2020 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package module contains application module patterns and associated "manager" functionality. The module pattern has been broken down by:

  • independent module functionality (AppModuleBasic)
  • inter-dependent module genesis functionality (AppModuleGenesis)
  • inter-dependent module full functionality (AppModule)

inter-dependent module functionality is module functionality which somehow depends on other modules, typically through the module keeper. Many of the module keepers are dependent on each other, thus in order to access the full set of module functionality we need to define all the keepers/params-store/keys etc. This full set of advanced functionality is defined by the AppModule interface.

Independent module functions are separated to allow for the construction of the basic application structures required early on in the application definition and used to enable the definition of full module functionality later in the process. This separation is necessary, however we still want to allow for a high level pattern for modules to follow - for instance, such that we don't have to manually register all of the codecs for all the modules. This basic procedure as well as other basic patterns are handled through the use of BasicManager.

Lastly the interface for genesis functionality (AppModuleGenesis) has been separated out from full module functionality (AppModule) so that modules which are only used for genesis can take advantage of the Module patterns without needlessly defining many placeholder functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppModule

type AppModule interface {
	AppModuleGenesis

	// registers
	RegisterInvariants(sdk.InvariantRegistry)

	// routes
	Route() string
	NewHandler() sdk.Handler
	QuerierRoute() string
	NewQuerierHandler() sdk.Querier

	BeginBlock(sdk.Context, abci.RequestBeginBlock)
	EndBlock(sdk.Context, abci.RequestEndBlock) []abci.ValidatorUpdate
}

AppModule is the standard form for an application module

func NewGenesisOnlyAppModule

func NewGenesisOnlyAppModule(amg AppModuleGenesis) AppModule

NewGenesisOnlyAppModule creates a new GenesisOnlyAppModule object

type AppModuleBasic

type AppModuleBasic interface {
	Name() string
	RegisterCodec(*codec.Codec)

	// genesis
	DefaultGenesis() json.RawMessage
	ValidateGenesis(json.RawMessage) error

	// client functionality
	RegisterRESTRoutes(context.CLIContext, *mux.Router)
	GetTxCmd(*codec.Codec) *cobra.Command
	GetQueryCmd(*codec.Codec) *cobra.Command
}

__________________________________________________________________________________________ AppModuleBasic is the standard form for basic non-dependant elements of an application module.

type AppModuleGenesis

type AppModuleGenesis interface {
	AppModuleBasic
	InitGenesis(sdk.Context, json.RawMessage) []abci.ValidatorUpdate
	ExportGenesis(sdk.Context) json.RawMessage
}

_________________________________________________________ AppModuleGenesis is the standard form for an application module genesis functions

type BasicManager

type BasicManager map[string]AppModuleBasic

collections of AppModuleBasic

func NewBasicManager

func NewBasicManager(modules ...AppModuleBasic) BasicManager

func (BasicManager) AddQueryCommands

func (bm BasicManager) AddQueryCommands(rootQueryCmd *cobra.Command, cdc *codec.Codec)

add all query commands to the rootQueryCmd

func (BasicManager) AddTxCommands

func (bm BasicManager) AddTxCommands(rootTxCmd *cobra.Command, cdc *codec.Codec)

add all tx commands to the rootTxCmd

func (BasicManager) DefaultGenesis

func (bm BasicManager) DefaultGenesis() map[string]json.RawMessage

Provided default genesis information for all modules

func (BasicManager) RegisterCodec

func (bm BasicManager) RegisterCodec(cdc *codec.Codec)

RegisterCodecs registers all module codecs

func (BasicManager) RegisterRESTRoutes

func (bm BasicManager) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router)

RegisterRestRoutes registers all module rest routes

func (BasicManager) ValidateGenesis

func (bm BasicManager) ValidateGenesis(genesis map[string]json.RawMessage) error

Provided default genesis information for all modules

type GenesisOnlyAppModule

type GenesisOnlyAppModule struct {
	AppModuleGenesis
}

___________________________ app module

func (GenesisOnlyAppModule) BeginBlock

func (gam GenesisOnlyAppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock)

module begin-block

func (GenesisOnlyAppModule) EndBlock

module end-block

func (GenesisOnlyAppModule) NewHandler

func (GenesisOnlyAppModule) NewHandler() sdk.Handler

module handler

func (GenesisOnlyAppModule) NewQuerierHandler

func (gam GenesisOnlyAppModule) NewQuerierHandler() sdk.Querier

module querier

func (GenesisOnlyAppModule) QuerierRoute

func (GenesisOnlyAppModule) QuerierRoute() string

module querier route ngame

func (GenesisOnlyAppModule) RegisterInvariants

func (GenesisOnlyAppModule) RegisterInvariants(_ sdk.InvariantRegistry)

register invariants

func (GenesisOnlyAppModule) Route

func (GenesisOnlyAppModule) Route() string

module message route ngame

type Manager

type Manager struct {
	Modules            map[string]AppModule
	OrderInitGenesis   []string
	OrderExportGenesis []string
	OrderBeginBlockers []string
	OrderEndBlockers   []string
}

____________________________________________________________________________ module manager provides the high level utility for managing and executing operations for a group of modules

func NewManager

func NewManager(modules ...AppModule) *Manager

NewModuleManager creates a new Manager object

func (*Manager) BeginBlock

BeginBlock performs begin block functionality for all modules. It creates a child context with an event manager to aggregate events emitted from all modules.

func (*Manager) EndBlock

EndBlock performs end block functionality for all modules. It creates a child context with an event manager to aggregate events emitted from all modules.

func (*Manager) ExportGenesis

func (m *Manager) ExportGenesis(ctx sdk.Context) map[string]json.RawMessage

perform export genesis functionality for modules

func (*Manager) InitGenesis

func (m *Manager) InitGenesis(ctx sdk.Context, genesisData map[string]json.RawMessage) abci.ResponseInitChain

perform init genesis functionality for modules

func (*Manager) RegisterInvariants

func (m *Manager) RegisterInvariants(ir sdk.InvariantRegistry)

register all module routes and module querier routes

func (*Manager) RegisterRoutes

func (m *Manager) RegisterRoutes(router sdk.Router, queryRouter sdk.QueryRouter)

register all module routes and module querier routes

func (*Manager) SetOrderBeginBlockers

func (m *Manager) SetOrderBeginBlockers(moduleNames ...string)

set the order of set begin-blocker calls

func (*Manager) SetOrderEndBlockers

func (m *Manager) SetOrderEndBlockers(moduleNames ...string)

set the order of set end-blocker calls

func (*Manager) SetOrderExportGenesis

func (m *Manager) SetOrderExportGenesis(moduleNames ...string)

set the order of export genesis calls

func (*Manager) SetOrderInitGenesis

func (m *Manager) SetOrderInitGenesis(moduleNames ...string)

set the order of init genesis calls

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL