Skip to content

Commit

Permalink
imp: cleanup godoc on router type
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-axner committed Mar 11, 2024
1 parent ccf2adf commit 63ec69c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions modules/core/02-client/types/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ import (
"github.com/cosmos/ibc-go/v8/modules/core/exported"
)

// The router is a map from module name to the LightClientModule
// which contains all the module-defined callbacks required by ICS-26
// Router is a map from a light client module name to a LightClientModule.
// The light client module name must be the same name as the client type.
// The router also has a reference to the client store provided (02-client keeper)
// and will set the store provider on a client module upon route registration.
type Router struct {
routes map[string]exported.LightClientModule
storeProvider exported.ClientStoreProvider
}

// NewRouter returns a instance of the Router.
func NewRouter(key storetypes.StoreKey) *Router {
return &Router{
routes: make(map[string]exported.LightClientModule),
Expand All @@ -24,6 +27,7 @@ func NewRouter(key storetypes.StoreKey) *Router {

// AddRoute adds LightClientModule for a given module name. It returns the Router
// so AddRoute calls can be linked. It will panic if the Router is sealed.
// The store provider will be registered on the light client module.
func (rtr *Router) AddRoute(clientType string, module exported.LightClientModule) *Router {
if rtr.HasRoute(clientType) {
panic(fmt.Errorf("route %s has already been registered", module))
Expand All @@ -36,8 +40,8 @@ func (rtr *Router) AddRoute(clientType string, module exported.LightClientModule
}

// HasRoute returns true if the Router has a module registered or false otherwise.
func (rtr *Router) HasRoute(module string) bool {
_, ok := rtr.routes[module]
func (rtr *Router) HasRoute(clientType string) bool {
_, ok := rtr.routes[clientType]
return ok
}

Expand Down

0 comments on commit 63ec69c

Please sign in to comment.