Skip to content

Commit

Permalink
chore: simplify base router config
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanchriswhite committed Jul 11, 2023
1 parent 3839c98 commit e11a55a
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions p2p/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/libp2p/go-libp2p/core/protocol"
"go.uber.org/multierr"

"github.com/pokt-network/pocket/p2p/providers"
typesP2P "github.com/pokt-network/pocket/p2p/types"
"github.com/pokt-network/pocket/shared/crypto"
"github.com/pokt-network/pocket/shared/modules"
Expand All @@ -20,18 +19,16 @@ var (
_ typesP2P.RouterConfig = &RainTreeConfig{}
)

// baseConfig implements `RouterConfig` using the given libp2p host and current
// height and peerstore providers. Intended for internal use by other `RouterConfig`
// baseConfig implements `RouterConfig` using the given libp2p host, pokt address
// and handler function. Intended for internal use by other `RouterConfig`
// implementations with common config parameters.
//
// NB: intentionally *not* embedding `baseConfig` to improve readability of usages
// of would-be embedders (e.g. `BackgroundConfig`).
type baseConfig struct {
Host host.Host
Addr crypto.Address
CurrentHeightProvider providers.CurrentHeightProvider
PeerstoreProvider providers.PeerstoreProvider
Handler func(data []byte) error
Host host.Host
Addr crypto.Address
Handler func(data []byte) error
}

type UnicastRouterConfig struct {
Expand Down Expand Up @@ -62,20 +59,10 @@ func (cfg *baseConfig) IsValid() (err error) {
err = multierr.Append(err, fmt.Errorf("pokt address not configured"))
}

// TODO_THIS_COMMIT: ...
//if cfg.CurrentHeightProvider == nil {
// err = multierr.Append(err, fmt.Errorf("current height provider not configured"))
//}

if cfg.Host == nil {
err = multierr.Append(err, fmt.Errorf("host not configured"))
}

// TODO_THIS_COMMIT: ...
//if cfg.PeerstoreProvider == nil {
// err = multierr.Append(err, fmt.Errorf("peerstore provider not configured"))
//}

if cfg.Handler == nil {
err = multierr.Append(err, fmt.Errorf("handler not configured"))
}
Expand Down

0 comments on commit e11a55a

Please sign in to comment.