Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
renaynay committed May 8, 2024
1 parent ae5cd2b commit e276af8
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 33 deletions.
64 changes: 34 additions & 30 deletions nodebuilder/pruner/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,7 @@ func ConstructModule(tp node.Type, cfg *Config) fx.Option {
)

if !cfg.EnableService {
switch tp {
case node.Light:
// light nodes are still subject to sampling within window
// even if pruning is not enabled.
return fx.Options(
baseComponents,
fx.Provide(func() pruner.AvailabilityWindow {
return light.Window
}),
)
case node.Full:
return fx.Options(
baseComponents,
fx.Provide(func() pruner.AvailabilityWindow {
return archival.Window
}),
)
case node.Bridge:
return fx.Options(
baseComponents,
fx.Provide(func() pruner.AvailabilityWindow {
return archival.Window
}),
fx.Provide(func() []core.Option {
return []core.Option{}
}),
)
default:
panic("unknown node type")
}
return disabledPrunerComponents(tp, baseComponents)
}

baseComponents = fx.Options(
Expand Down Expand Up @@ -104,3 +75,36 @@ func ConstructModule(tp node.Type, cfg *Config) fx.Option {
panic("unknown node type")
}
}

func disabledPrunerComponents(tp node.Type, baseComponents fx.Option) fx.Option {
switch tp {
case node.Light:
// light nodes are still subject to sampling within window
// even if pruning is not enabled.
return fx.Options(
baseComponents,
fx.Provide(func() pruner.AvailabilityWindow {
return light.Window
}),
)
case node.Full:
return fx.Options(
baseComponents,
fx.Provide(func() pruner.AvailabilityWindow {
return archival.Window
}),
)
case node.Bridge:
return fx.Options(
baseComponents,
fx.Provide(func() pruner.AvailabilityWindow {
return archival.Window
}),
fx.Provide(func() []core.Option {
return []core.Option{}
}),
)
default:
panic("unknown node type")
}
}
3 changes: 0 additions & 3 deletions nodebuilder/share/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package share
import (
"context"
"fmt"
"time"

"github.com/ipfs/go-datastore"
"github.com/libp2p/go-libp2p/core/host"
Expand Down Expand Up @@ -188,15 +187,13 @@ func shrexGetterComponents(cfg *Config) fx.Option {
// shrex-getter
fx.Provide(fx.Annotate(
func(
tp node.Type,
edsClient *shrexeds.Client,
ndClient *shrexnd.Client,
man *peers.Manager,
window pruner.AvailabilityWindow,
opts []getters.Option,
) *getters.ShrexGetter {
opts = append(opts, getters.WithAvailabilityWindow(window))
fmt.Println("\n\n CONSTRUCTING SHREX GETTER WITH WINDOW: ", time.Duration(window).String(), "TYPE: ", tp.String())
return getters.NewShrexGetter(edsClient, ndClient, man, opts...)
},
fx.OnStart(func(ctx context.Context, getter *getters.ShrexGetter) error {
Expand Down
4 changes: 4 additions & 0 deletions nodebuilder/tests/swamp/swamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/celestiaorg/celestia-node/core"
"github.com/celestiaorg/celestia-node/header"
"github.com/celestiaorg/celestia-node/libs/keystore"
"github.com/celestiaorg/celestia-node/logs"
"github.com/celestiaorg/celestia-node/nodebuilder"
coremodule "github.com/celestiaorg/celestia-node/nodebuilder/core"
"github.com/celestiaorg/celestia-node/nodebuilder/node"
Expand Down Expand Up @@ -64,6 +65,9 @@ type Swamp struct {

// NewSwamp creates a new instance of Swamp.
func NewSwamp(t *testing.T, options ...Option) *Swamp {
if testing.Verbose() {
logs.SetDebugLogging()
}

ic := DefaultConfig()
for _, option := range options {
Expand Down

0 comments on commit e276af8

Please sign in to comment.