github.com/osdi23p228/fabric@v0.0.0-20221218062954-77808885f5db/common/ledger/blkstorage/config.go (about)

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package blkstorage
     8  
     9  import "path/filepath"
    10  
    11  const (
    12  	// ChainsDir is the name of the directory containing the channel ledgers.
    13  	ChainsDir = "chains"
    14  	// IndexDir is the name of the directory containing all block indexes across ledgers.
    15  	IndexDir                = "index"
    16  	defaultMaxBlockfileSize = 64 * 1024 * 1024 // bytes
    17  )
    18  
    19  // Conf encapsulates all the configurations for `BlockStore`
    20  type Conf struct {
    21  	blockStorageDir  string
    22  	maxBlockfileSize int
    23  }
    24  
    25  // NewConf constructs new `Conf`.
    26  // blockStorageDir is the top level folder under which `BlockStore` manages its data
    27  func NewConf(blockStorageDir string, maxBlockfileSize int) *Conf {
    28  	if maxBlockfileSize <= 0 {
    29  		maxBlockfileSize = defaultMaxBlockfileSize
    30  	}
    31  	return &Conf{blockStorageDir, maxBlockfileSize}
    32  }
    33  
    34  func (conf *Conf) getIndexDir() string {
    35  	return filepath.Join(conf.blockStorageDir, IndexDir)
    36  }
    37  
    38  func (conf *Conf) getChainsDir() string {
    39  	return filepath.Join(conf.blockStorageDir, ChainsDir)
    40  }
    41  
    42  func (conf *Conf) getLedgerBlockDir(ledgerid string) string {
    43  	return filepath.Join(conf.getChainsDir(), ledgerid)
    44  }