github.com/celestiaorg/celestia-node@v0.15.0-beta.1/nodebuilder/das/config.go (about) 1 package das 2 3 import ( 4 "fmt" 5 "time" 6 7 "github.com/celestiaorg/celestia-node/das" 8 "github.com/celestiaorg/celestia-node/nodebuilder/node" 9 modp2p "github.com/celestiaorg/celestia-node/nodebuilder/p2p" 10 ) 11 12 // Config contains configuration parameters for the DASer (or DASing process) 13 type Config das.Parameters 14 15 // TODO(@derrandz): parameters needs performance testing on real network to define optimal values 16 // DefaultConfig provide the optimal default configuration per node type. 17 // For the moment, there is only one default configuration for all node types 18 // but this function will provide more once #1261 is addressed. 19 // 20 // TODO(@derrandz): Address #1261 21 func DefaultConfig(tp node.Type) Config { 22 cfg := das.DefaultParameters() 23 switch tp { 24 case node.Light: 25 cfg.SampleTimeout = modp2p.BlockTime * time.Duration(cfg.ConcurrencyLimit) 26 case node.Full: 27 // Default value for DASer concurrency limit is based on dasing using ipld getter. 28 // Full node will primarily use shrex protocol for sampling, that is much more efficient and can 29 // fully utilize nodes bandwidth with lower amount of parallel sampling workers 30 cfg.ConcurrencyLimit = 6 31 // Full node uses shrex with fallback to ipld to sample, so need 2x amount of time in worst case 32 // scenario 33 cfg.SampleTimeout = 2 * modp2p.BlockTime * time.Duration(cfg.ConcurrencyLimit) 34 } 35 return Config(cfg) 36 } 37 38 // Validate performs basic validation of the config. 39 // Upon encountering an invalid value, Validate returns an error of type: ErrMisConfig 40 func (cfg *Config) Validate() error { 41 err := (*das.Parameters)(cfg).Validate() 42 if err != nil { 43 return fmt.Errorf("moddas misconfiguration: %w", err) 44 } 45 46 return nil 47 }