github.com/unicornultrafoundation/go-u2u@v1.0.0-rc1.0.20240205080301-e74a83d3fadc/gossip/protocols/blockrecords/brstream/brstreamleecher/config.go (about)

     1  package brstreamleecher
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/unicornultrafoundation/go-helios/gossip/basestream/basestreamleecher/basepeerleecher"
     7  )
     8  
     9  type Config struct {
    10  	Session              basepeerleecher.EpochDownloaderConfig
    11  	RecheckInterval      time.Duration
    12  	BaseProgressWatchdog time.Duration
    13  	BaseSessionWatchdog  time.Duration
    14  	MinSessionRestart    time.Duration
    15  	MaxSessionRestart    time.Duration
    16  }
    17  
    18  // DefaultConfig returns default leecher config
    19  func DefaultConfig() Config {
    20  	return Config{
    21  		Session: basepeerleecher.EpochDownloaderConfig{
    22  			DefaultChunkItemsNum:   500,
    23  			DefaultChunkItemsSize:  512 * 1024,
    24  			ParallelChunksDownload: 6,
    25  			RecheckInterval:        10 * time.Millisecond,
    26  		},
    27  		RecheckInterval:      time.Second,
    28  		BaseProgressWatchdog: time.Second * 5,
    29  		BaseSessionWatchdog:  time.Second * 30 * 5,
    30  		MinSessionRestart:    time.Second * 5,
    31  		MaxSessionRestart:    time.Minute * 5,
    32  	}
    33  }
    34  
    35  // LiteConfig returns default leecher config for tests
    36  func LiteConfig() Config {
    37  	cfg := DefaultConfig()
    38  	cfg.Session.DefaultChunkItemsSize /= 10
    39  	cfg.Session.DefaultChunkItemsNum /= 10
    40  	cfg.Session.ParallelChunksDownload = cfg.Session.ParallelChunksDownload/2 + 1
    41  	return cfg
    42  }