Skip to content

Commit 356ce27

Browse files
committed
[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: Kostas Christidis <[email protected]>
1 parent 9ab37a5 commit 356ce27

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

common/ledger/blkstorage/fsblkstorage/config.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ package fsblkstorage
1919
import "path/filepath"
2020

2121
const (
22-
defaultMaxBlockfileSize = 64 * 1024 * 1024
22+
// ChainsDir is the name of the directory containing the channel ledgers.
23+
ChainsDir = "chains"
24+
// IndexDir is the name of the directory containing all block indexes across ledgers.
25+
IndexDir = "index"
26+
defaultMaxBlockfileSize = 64 * 1024 * 1024 // bytes
2327
)
2428

2529
// Conf encapsulates all the configurations for `FsBlockStore`
@@ -38,13 +42,13 @@ func NewConf(blockStorageDir string, maxBlockfileSize int) *Conf {
3842
}
3943

4044
func (conf *Conf) getIndexDir() string {
41-
return filepath.Join(conf.blockStorageDir, "index")
45+
return filepath.Join(conf.blockStorageDir, IndexDir)
4246
}
4347

44-
func (conf *Conf) getBlocksDir() string {
45-
return filepath.Join(conf.blockStorageDir, "blocks")
48+
func (conf *Conf) getChainsDir() string {
49+
return filepath.Join(conf.blockStorageDir, ChainsDir)
4650
}
4751

4852
func (conf *Conf) getLedgerBlockDir(ledgerid string) string {
49-
return filepath.Join(conf.getBlocksDir(), ledgerid)
53+
return filepath.Join(conf.getChainsDir(), ledgerid)
5054
}

common/ledger/blkstorage/fsblkstorage/fs_blockstore_provider.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (p *FsBlockstoreProvider) Exists(ledgerid string) (bool, error) {
5656

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

6262
// Close closes the FsBlockstoreProvider

0 commit comments

Comments
 (0)