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 bd73a9c commit 1684a62
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 1684a62

Please sign in to comment.