github.com/celestiaorg/celestia-node@v0.15.0-beta.1/share/eds/store_options.go (about)

     1  package eds
     2  
     3  import (
     4  	"fmt"
     5  	"time"
     6  )
     7  
     8  type Parameters struct {
     9  	// GC performs DAG store garbage collection by reclaiming transient files of
    10  	// shards that are currently available but inactive, or errored.
    11  	// We don't use transient files right now, so GC is turned off by default.
    12  	GCInterval time.Duration
    13  
    14  	// RecentBlocksCacheSize is the size of the cache for recent blocks.
    15  	RecentBlocksCacheSize int
    16  
    17  	// BlockstoreCacheSize is the size of the cache for blockstore requested accessors.
    18  	BlockstoreCacheSize int
    19  }
    20  
    21  // DefaultParameters returns the default configuration values for the EDS store parameters.
    22  func DefaultParameters() *Parameters {
    23  	return &Parameters{
    24  		GCInterval:            0,
    25  		RecentBlocksCacheSize: 10,
    26  		BlockstoreCacheSize:   128,
    27  	}
    28  }
    29  
    30  func (p *Parameters) Validate() error {
    31  	if p.GCInterval < 0 {
    32  		return fmt.Errorf("eds: GC interval cannot be negative")
    33  	}
    34  
    35  	if p.RecentBlocksCacheSize < 1 {
    36  		return fmt.Errorf("eds: recent blocks cache size must be positive")
    37  	}
    38  
    39  	if p.BlockstoreCacheSize < 1 {
    40  		return fmt.Errorf("eds: blockstore cache size must be positive")
    41  	}
    42  	return nil
    43  }