github.com/adnan-c/fabric_e2e_couchdb@v0.6.1-preview.0.20170228180935-21ce6b23cf91/common/ledger/blkstorage/fsblkstorage/config.go (about)

     1  /*
     2  Copyright IBM Corp. 2016 All Rights Reserved.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8  		 http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package fsblkstorage
    18  
    19  import "path/filepath"
    20  
    21  const (
    22  	defaultMaxBlockfileSize = 64 * 1024 * 1024
    23  )
    24  
    25  // Conf encapsulates all the configurations for `FsBlockStore`
    26  type Conf struct {
    27  	blockStorageDir  string
    28  	maxBlockfileSize int
    29  }
    30  
    31  // NewConf constructs new `Conf`.
    32  // blockStorageDir is the top level folder under which `FsBlockStore` manages its data
    33  func NewConf(blockStorageDir string, maxBlockfileSize int) *Conf {
    34  	if maxBlockfileSize <= 0 {
    35  		maxBlockfileSize = defaultMaxBlockfileSize
    36  	}
    37  	return &Conf{blockStorageDir, maxBlockfileSize}
    38  }
    39  
    40  func (conf *Conf) getIndexDir() string {
    41  	return filepath.Join(conf.blockStorageDir, "index")
    42  }
    43  
    44  func (conf *Conf) getBlocksDir() string {
    45  	return filepath.Join(conf.blockStorageDir, "blocks")
    46  }
    47  
    48  func (conf *Conf) getLedgerBlockDir(ledgerid string) string {
    49  	return filepath.Join(conf.getBlocksDir(), ledgerid)
    50  }