Skip to content

Commit

Permalink
[FAB-2603] Change & export dir containing ledgers
Browse files Browse the repository at this point in the history
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: Kostas Christidis <kostas@christidis.io>
  • Loading branch information
kchristidis committed Mar 2, 2017
1 parent 9ab37a5 commit 356ce27
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions common/ledger/blkstorage/fsblkstorage/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ package fsblkstorage
import "path/filepath"

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`
Expand All @@ -38,13 +42,13 @@ func NewConf(blockStorageDir string, maxBlockfileSize int) *Conf {
}

func (conf *Conf) getIndexDir() string {
return filepath.Join(conf.blockStorageDir, "index")
return filepath.Join(conf.blockStorageDir, IndexDir)
}

func (conf *Conf) getBlocksDir() string {
return filepath.Join(conf.blockStorageDir, "blocks")
func (conf *Conf) getChainsDir() string {
return filepath.Join(conf.blockStorageDir, ChainsDir)
}

func (conf *Conf) getLedgerBlockDir(ledgerid string) string {
return filepath.Join(conf.getBlocksDir(), ledgerid)
return filepath.Join(conf.getChainsDir(), ledgerid)
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (p *FsBlockstoreProvider) Exists(ledgerid string) (bool, error) {

// List lists the ids of the existing ledgers
func (p *FsBlockstoreProvider) List() ([]string, error) {
return util.ListSubdirs(p.conf.getBlocksDir())
return util.ListSubdirs(p.conf.getChainsDir())
}

// Close closes the FsBlockstoreProvider
Expand Down

0 comments on commit 356ce27

Please sign in to comment.