Commit 356ce278 authored by Kostas Christidis's avatar Kostas Christidis
Browse files

[FAB-2603] Change & export dir containing ledgers

https://jira.hyperledger.org/browse/FAB-2603



1. Ledgers were maintained as directories inside a "blocks" directory.
Semantically speaking, this doesn't quite make sense -- you'd expect to
find blocks under a "blocks" directory.

2. The name of this directory should be an exported constant so that
other packages can access it programmatically. The orderer package for
instance, needs this info in order to construct the proper directories
for its ledger.

This changeset addresses both of these issues.

Change-Id: I3bdf9763e227c29983003bab0769282136a42511
Signed-off-by: default avatarKostas Christidis <kostas@christidis.io>
parent 9ab37a56
...@@ -19,7 +19,11 @@ package fsblkstorage ...@@ -19,7 +19,11 @@ package fsblkstorage
import "path/filepath" import "path/filepath"
const ( const (
defaultMaxBlockfileSize = 64 * 1024 * 1024 // ChainsDir is the name of the directory containing the channel ledgers.
ChainsDir = "chains"
// IndexDir is the name of the directory containing all block indexes across ledgers.
IndexDir = "index"
defaultMaxBlockfileSize = 64 * 1024 * 1024 // bytes
) )
// Conf encapsulates all the configurations for `FsBlockStore` // Conf encapsulates all the configurations for `FsBlockStore`
...@@ -38,13 +42,13 @@ func NewConf(blockStorageDir string, maxBlockfileSize int) *Conf { ...@@ -38,13 +42,13 @@ func NewConf(blockStorageDir string, maxBlockfileSize int) *Conf {
} }
func (conf *Conf) getIndexDir() string { func (conf *Conf) getIndexDir() string {
return filepath.Join(conf.blockStorageDir, "index") return filepath.Join(conf.blockStorageDir, IndexDir)
} }
func (conf *Conf) getBlocksDir() string { func (conf *Conf) getChainsDir() string {
return filepath.Join(conf.blockStorageDir, "blocks") return filepath.Join(conf.blockStorageDir, ChainsDir)
} }
func (conf *Conf) getLedgerBlockDir(ledgerid string) string { func (conf *Conf) getLedgerBlockDir(ledgerid string) string {
return filepath.Join(conf.getBlocksDir(), ledgerid) return filepath.Join(conf.getChainsDir(), ledgerid)
} }
...@@ -56,7 +56,7 @@ func (p *FsBlockstoreProvider) Exists(ledgerid string) (bool, error) { ...@@ -56,7 +56,7 @@ func (p *FsBlockstoreProvider) Exists(ledgerid string) (bool, error) {
// List lists the ids of the existing ledgers // List lists the ids of the existing ledgers
func (p *FsBlockstoreProvider) List() ([]string, error) { func (p *FsBlockstoreProvider) List() ([]string, error) {
return util.ListSubdirs(p.conf.getBlocksDir()) return util.ListSubdirs(p.conf.getChainsDir())
} }
// Close closes the FsBlockstoreProvider // Close closes the FsBlockstoreProvider
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment